[FFmpeg-cvslog] avcodec/cbs: create reference counted fragments in ff_cbs_read_extradata()

James Almer git at videolan.org
Fri Apr 27 02:06:00 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Apr 25 19:27:04 2018 -0300| [dff1fb27aaf076da1912366191e593834cecf841] | committer: James Almer

avcodec/cbs: create reference counted fragments in ff_cbs_read_extradata()

This way, every CodedBitstreamType->split_fragment() function can
safely assume the fragment passed to them will be reference counted,
potentially simplifying code.

Reviewed-by: Mark Thompson <sw at jkqxz.net>
Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/cbs.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 897e0bb28e..d81b4e03f7 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -167,27 +167,6 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
     return 0;
 }
 
-int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
-                          CodedBitstreamFragment *frag,
-                          const AVCodecParameters *par)
-{
-    int err;
-
-    memset(frag, 0, sizeof(*frag));
-
-    frag->data      = par->extradata;
-    frag->data_size = par->extradata_size;
-
-    err = ctx->codec->split_fragment(ctx, frag, 1);
-    if (err < 0)
-        return err;
-
-    frag->data      = NULL;
-    frag->data_size = 0;
-
-    return cbs_read_fragment_content(ctx, frag);
-}
-
 static int cbs_fill_fragment_data(CodedBitstreamContext *ctx,
                                   CodedBitstreamFragment *frag,
                                   const uint8_t *data, size_t size)
@@ -209,6 +188,26 @@ static int cbs_fill_fragment_data(CodedBitstreamContext *ctx,
     return 0;
 }
 
+int ff_cbs_read_extradata(CodedBitstreamContext *ctx,
+                          CodedBitstreamFragment *frag,
+                          const AVCodecParameters *par)
+{
+    int err;
+
+    memset(frag, 0, sizeof(*frag));
+
+    err = cbs_fill_fragment_data(ctx, frag, par->extradata,
+                                 par->extradata_size);
+    if (err < 0)
+        return err;
+
+    err = ctx->codec->split_fragment(ctx, frag, 1);
+    if (err < 0)
+        return err;
+
+    return cbs_read_fragment_content(ctx, frag);
+}
+
 int ff_cbs_read_packet(CodedBitstreamContext *ctx,
                        CodedBitstreamFragment *frag,
                        const AVPacket *pkt)



More information about the ffmpeg-cvslog mailing list