[FFmpeg-cvslog] avcodec/extract_extradata: move the reference in the bsf internal buffer

James Almer git at videolan.org
Sun Mar 11 20:47:24 EET 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Mar 11 13:45:05 2018 -0300| [9c6dd9d6248897a2d8dd4ede948c166e5a579a4b] | committer: James Almer

avcodec/extract_extradata: move the reference in the bsf internal buffer

There's no need to allocate a new packet for it.

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=9c6dd9d6248897a2d8dd4ede948c166e5a579a4b
---

 libavcodec/extract_extradata_bsf.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 4e2d601742..1c386becd7 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -279,24 +279,23 @@ static int extract_extradata_init(AVBSFContext *ctx)
     return 0;
 }
 
-static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out)
+static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *pkt)
 {
     ExtractExtradataContext *s = ctx->priv_data;
-    AVPacket *in;
     uint8_t *extradata = NULL;
     int extradata_size;
     int ret = 0;
 
-    ret = ff_bsf_get_packet(ctx, &in);
+    ret = ff_bsf_get_packet_ref(ctx, pkt);
     if (ret < 0)
         return ret;
 
-    ret = s->extract(ctx, in, &extradata, &extradata_size);
+    ret = s->extract(ctx, pkt, &extradata, &extradata_size);
     if (ret < 0)
         goto fail;
 
     if (extradata) {
-        ret = av_packet_add_side_data(in, AV_PKT_DATA_NEW_EXTRADATA,
+        ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
                                       extradata, extradata_size);
         if (ret < 0) {
             av_freep(&extradata);
@@ -304,10 +303,10 @@ static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out)
         }
     }
 
-    av_packet_move_ref(out, in);
+    return 0;
 
 fail:
-    av_packet_free(&in);
+    av_packet_unref(pkt);
     return ret;
 }
 



More information about the ffmpeg-cvslog mailing list