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

Nicolas George george at nsup.org
Thu May 19 09:47:10 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 |  3 +++
 libavcodec/bsf.c               | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)


Updated to the new list format.

Name unchanged, already explained.


diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 6d58233..b7e786c 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -24,6 +24,8 @@
 #include "avcodec.h"
 #include "bsf.h"
 
+extern const AVBitStreamFilter /* hardcoded, hidden from configure */ ff_null_bsf;
+
 extern const AVBitStreamFilter ff_aac_adtstoasc_bsf;
 extern const AVBitStreamFilter ff_chomp_bsf;
 extern const AVBitStreamFilter ff_dump_extradata_bsf;
@@ -42,6 +44,7 @@ extern const AVBitStreamFilter ff_text2movsub_bsf;
 extern const AVBitStreamFilter ff_vp9_superframe_bsf;
 
 static const AVBitStreamFilter *bitstream_filters[] = {
+    &ff_null_bsf,
 #include "libavcodec/bsf_list.c"
     NULL
 };
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.1



More information about the ffmpeg-devel mailing list