[FFmpeg-cvslog] cbs_vp9: Use table-based alloc/free

Mark Thompson git at videolan.org
Wed Sep 2 02:07:09 EEST 2020


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Mon Jul 27 17:32:25 2020 +0100| [f643f9bd6d6c954717cd8e607034b0dd25156244] | committer: Mark Thompson

cbs_vp9: Use table-based alloc/free

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f643f9bd6d6c954717cd8e607034b0dd25156244
---

 libavcodec/cbs_vp9.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/libavcodec/cbs_vp9.c b/libavcodec/cbs_vp9.c
index 6e0a7dcbea..6a480b4ce3 100644
--- a/libavcodec/cbs_vp9.c
+++ b/libavcodec/cbs_vp9.c
@@ -479,13 +479,6 @@ static int cbs_vp9_split_fragment(CodedBitstreamContext *ctx,
     return 0;
 }
 
-static void cbs_vp9_free_frame(void *opaque, uint8_t *content)
-{
-    VP9RawFrame *frame = (VP9RawFrame*)content;
-    av_buffer_unref(&frame->data_ref);
-    av_freep(&frame);
-}
-
 static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
                              CodedBitstreamUnit *unit)
 {
@@ -497,8 +490,7 @@ static int cbs_vp9_read_unit(CodedBitstreamContext *ctx,
     if (err < 0)
         return err;
 
-    err = ff_cbs_alloc_unit_content(unit, sizeof(*frame),
-                                    &cbs_vp9_free_frame);
+    err = ff_cbs_alloc_unit_content2(ctx, unit);
     if (err < 0)
         return err;
     frame = unit->content;
@@ -642,11 +634,18 @@ static int cbs_vp9_assemble_fragment(CodedBitstreamContext *ctx,
     return 0;
 }
 
+static const CodedBitstreamUnitTypeDescriptor cbs_vp9_unit_types[] = {
+    CBS_UNIT_TYPE_INTERNAL_REF(0, VP9RawFrame, data),
+    CBS_UNIT_TYPE_END_OF_LIST
+};
+
 const CodedBitstreamType ff_cbs_type_vp9 = {
     .codec_id          = AV_CODEC_ID_VP9,
 
     .priv_data_size    = sizeof(CodedBitstreamVP9Context),
 
+    .unit_types        = cbs_vp9_unit_types,
+
     .split_fragment    = &cbs_vp9_split_fragment,
     .read_unit         = &cbs_vp9_read_unit,
     .write_unit        = &cbs_vp9_write_unit,



More information about the ffmpeg-cvslog mailing list