aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vp9.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-03-05 00:39:12 -0300
committerJames Almer <jamrial@gmail.com>2020-03-26 11:45:12 -0300
commite4dd8ee3233634a7656d53f64bdfec37a501f38e (patch)
treec18c1756fe53e1430b3680726d91fe0f8847866f /libavcodec/vp9.c
parent840e92da17b12ea34df5757e57eb1d33231bc6b7 (diff)
downloadffmpeg-e4dd8ee3233634a7656d53f64bdfec37a501f38e.tar.gz
avcodec/vp9: use a buffer pool to allocate VP9Frame extradata
Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/vp9.c')
-rw-r--r--libavcodec/vp9.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 7aaae9b792..7ee375d4d0 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -112,10 +112,20 @@ static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
return ret;
sz = 64 * s->sb_cols * s->sb_rows;
- f->extradata = av_buffer_allocz(sz * (1 + sizeof(VP9mvrefPair)));
+ if (sz != s->frame_extradata_pool_size) {
+ av_buffer_pool_uninit(&s->frame_extradata_pool);
+ s->frame_extradata_pool = av_buffer_pool_init(sz * (1 + sizeof(VP9mvrefPair)), NULL);
+ if (!s->frame_extradata_pool) {
+ s->frame_extradata_pool_size = 0;
+ goto fail;
+ }
+ s->frame_extradata_pool_size = sz;
+ }
+ f->extradata = av_buffer_pool_get(s->frame_extradata_pool);
if (!f->extradata) {
goto fail;
}
+ memset(f->extradata->data, 0, f->extradata->size);
f->segmentation_map = f->extradata->data;
f->mv = (VP9mvrefPair *) (f->extradata->data + sz);
@@ -1210,6 +1220,7 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
vp9_frame_unref(avctx, &s->s.frames[i]);
av_frame_free(&s->s.frames[i].tf.f);
}
+ av_buffer_pool_uninit(&s->frame_extradata_pool);
for (i = 0; i < 8; i++) {
if (s->s.refs[i].f->buf[0])
ff_thread_release_buffer(avctx, &s->s.refs[i]);