[FFmpeg-devel] [PATCH 1/3] lavc/bsf: add a null bitstream filter.

Nicolas George george at nsup.org
Thu Apr 28 11:06:43 CEST 2016


It passes packets unchanged with a very low overhead.
Using it allows to have the same code path when bitstream filtering
is not used, making the code simpler and avoiding bitroting.
The filter can not be disabled so that applications can rely on it.
It is added out of alphabetical order to keep the regularity.

TODO: minor bump.
Signed-off-by: Nicolas George <george at nsup.org>
---
 libavcodec/bitstream_filters.c |  2 ++
 libavcodec/bsf.c               | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 51f3cd9..1b262fa 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -37,11 +37,13 @@ extern const AVBitStreamFilter ff_mp3_header_decompress_bsf;
 extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf;
 extern const AVBitStreamFilter ff_mov2textsub_bsf;
 extern const AVBitStreamFilter ff_noise_bsf;
+extern const AVBitStreamFilter ff_null_bsf;
 extern const AVBitStreamFilter ff_remove_extradata_bsf;
 extern const AVBitStreamFilter ff_text2movsub_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_bsf;
 
 static const AVBitStreamFilter *bitstream_filters[] = {
+    &ff_null_bsf,
 #if CONFIG_AAC_ADTSTOASC_BSF
     &ff_aac_adtstoasc_bsf,
 #endif
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 88b7f29..cd82f5e 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -217,3 +217,19 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
 
     return 0;
 }
+
+static int null_filter(AVBSFContext *ctx, AVPacket *out)
+{
+    AVPacket *in;
+    int ret = ff_bsf_get_packet(ctx, &in);
+    if (ret < 0)
+        return ret;
+    av_packet_move_ref(out, in);
+    av_packet_free(&in);
+    return 0;
+}
+
+const AVBitStreamFilter ff_null_bsf = {
+    .name           = "null",
+    .filter         = null_filter,
+};
-- 
2.8.0.rc3



More information about the ffmpeg-devel mailing list