[FFmpeg-cvslog] avcodec/dump_extradata_bsf: don't allocate a new AVPacket per filtered packet

James Almer git at videolan.org
Thu Aug 2 21:02:39 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Jul 23 19:16:30 2018 -0300| [b98bd60bfa2605fd874d42f96804d1c999278a7e] | committer: James Almer

avcodec/dump_extradata_bsf: don't allocate a new AVPacket per filtered packet

~4x speedup in dump_extradata()

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/dump_extradata_bsf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
index 98703749f7..188a1c619b 100644
--- a/libavcodec/dump_extradata_bsf.c
+++ b/libavcodec/dump_extradata_bsf.c
@@ -34,16 +34,17 @@ enum DumpFreq {
 
 typedef struct DumpExtradataContext {
     const AVClass *class;
+    AVPacket pkt;
     int freq;
 } DumpExtradataContext;
 
 static int dump_extradata(AVBSFContext *ctx, AVPacket *out)
 {
     DumpExtradataContext *s = ctx->priv_data;
-    AVPacket *in;
+    AVPacket *in = &s->pkt;
     int ret = 0;
 
-    ret = ff_bsf_get_packet(ctx, &in);
+    ret = ff_bsf_get_packet_ref(ctx, in);
     if (ret < 0)
         return ret;
 
@@ -72,7 +73,7 @@ static int dump_extradata(AVBSFContext *ctx, AVPacket *out)
     }
 
 fail:
-    av_packet_free(&in);
+    av_packet_unref(in);
 
     return ret;
 }



More information about the ffmpeg-cvslog mailing list