[FFmpeg-devel,2/6] avcodec/extract_extradata: move the reference in the bsf internal buffer

Submitted by James Almer on March 11, 2018, 5:58 p.m.

Details

Message ID 20180311175854.10096-2-jamrial@gmail.com
State Accepted
Headers show

Commit Message

James Almer March 11, 2018, 5:58 p.m.
There's no need to allocate a new packet for it.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/extract_extradata_bsf.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/extract_extradata_bsf.c b/libavcodec/extract_extradata_bsf.c
index 64017b6fb7..711814576c 100644
--- a/libavcodec/extract_extradata_bsf.c
+++ b/libavcodec/extract_extradata_bsf.c
@@ -280,21 +280,20 @@  static int extract_extradata_init(AVBSFContext *ctx)
 static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out)
 {
     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, out);
     if (ret < 0)
         return ret;
 
-    ret = s->extract(ctx, in, &extradata, &extradata_size);
+    ret = s->extract(ctx, out, &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(out, AV_PKT_DATA_NEW_EXTRADATA,
                                       extradata, extradata_size);
         if (ret < 0) {
             av_freep(&extradata);
@@ -302,10 +301,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(out);
     return ret;
 }