[FFmpeg-devel,3/6] avcodec/remove_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-3-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/remove_extradata_bsf.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/remove_extradata_bsf.c b/libavcodec/remove_extradata_bsf.c
index a54bbdbacf..d44cc8be92 100644
--- a/libavcodec/remove_extradata_bsf.c
+++ b/libavcodec/remove_extradata_bsf.c
@@ -42,26 +42,22 @@  static int remove_extradata(AVBSFContext *ctx, AVPacket *out)
 {
     RemoveExtradataContext *s = ctx->priv_data;
 
-    AVPacket *in;
     int ret;
 
-    ret = ff_bsf_get_packet(ctx, &in);
+    ret = ff_bsf_get_packet_ref(ctx, out);
     if (ret < 0)
         return ret;
 
     if (s->parser && s->parser->parser->split) {
         if (s->freq == REMOVE_FREQ_ALL ||
-            (s->freq == REMOVE_FREQ_NONKEYFRAME && !(in->flags & AV_PKT_FLAG_KEY)) ||
-            (s->freq == REMOVE_FREQ_KEYFRAME && in->flags & AV_PKT_FLAG_KEY)) {
-            int i = s->parser->parser->split(s->avctx, in->data, in->size);
-            in->data += i;
-            in->size -= i;
+            (s->freq == REMOVE_FREQ_NONKEYFRAME && !(out->flags & AV_PKT_FLAG_KEY)) ||
+            (s->freq == REMOVE_FREQ_KEYFRAME && out->flags & AV_PKT_FLAG_KEY)) {
+            int i = s->parser->parser->split(s->avctx, out->data, out->size);
+            out->data += i;
+            out->size -= i;
         }
     }
 
-    av_packet_move_ref(out, in);
-    av_packet_free(&in);
-
     return 0;
 }