Le primidi 11 messidor, an CCXXIV, Nicolas George a écrit : > Well, looking at the code, I am thinking that the current design is flawed: > the extra alloc in ff_bsf_get_packet() seems completely useless, and could > be removed as is without any other change in the current code, because all > current filters are 1:1, it would be different for future 1:N filters. Maybe > implementing ff_bsf_peek_packet() and using it to replace > ff_bsf_get_packet() in 1:1 cases would do the trick.
I have checked that the following quick-and-dirty changes pass FATE. Making it in shape (testing filters not covered by FATE, making future-proof) would take time that I would like to spend on lavfi right now. But it proves the overhead can be reduced easily. Regards, -- Nicolas George diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 88b7f29..05fa1e3 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -208,12 +208,7 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) !ctx->internal->buffer_pkt->side_data_elems) return AVERROR(EAGAIN); - tmp_pkt = av_packet_alloc(); - if (!tmp_pkt) - return AVERROR(ENOMEM); - *pkt = ctx->internal->buffer_pkt; - ctx->internal->buffer_pkt = tmp_pkt; return 0; } diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 163d0f5..26e26c0 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -274,7 +274,7 @@ next_nal: fail: if (ret < 0) av_packet_unref(out); - av_packet_free(&in); + av_packet_unref(in); return ret; } diff --git a/libavcodec/mpeg4_unpack_bframes_bsf.c b/libavcodec/mpeg4_unpack_bframes_bsf.c index 0615621..257efaf 100644 --- a/libavcodec/mpeg4_unpack_bframes_bsf.c +++ b/libavcodec/mpeg4_unpack_bframes_bsf.c @@ -151,7 +151,7 @@ static int mpeg4_unpack_bframes_filter(AVBSFContext *ctx, AVPacket *out) av_packet_move_ref(out, in); } - av_packet_free(&in); + av_packet_unref(in); return 0; } diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c index b686adb..9391fcb 100644 --- a/libavcodec/vp9_superframe_bsf.c +++ b/libavcodec/vp9_superframe_bsf.c @@ -178,7 +178,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *out) done: if (res < 0) av_packet_unref(out); - av_packet_free(&in); + av_packet_unref(in); return res; }
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel