diff mbox series

[FFmpeg-devel,3/5] avcodec/bsf: Use null-bsf for passthrough when available

Message ID AM7PR03MB6660BB26B3EB790C2176CC498FD29@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,1/5] configure: Remove null_bsf dependency | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 6, 2021, 8:29 p.m. UTC
When an empty list bsf is used for passthrough, there is a check
for every packet in bsf_list_filter() before ff_bsf_get_packet_ref()
is called. Directly using the null bsf avoids that.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/bsf.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 57034ce646..3420885e5f 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -18,6 +18,8 @@ 
 
 #include <string.h>
 
+#include "config.h"
+
 #include "libavutil/avassert.h"
 #include "libavutil/log.h"
 #include "libavutil/mem.h"
@@ -544,5 +546,10 @@  end:
 
 int av_bsf_get_null_filter(AVBSFContext **bsf)
 {
+#if CONFIG_NULL_BSF
+    extern const AVBitStreamFilter ff_null_bsf;
+    return av_bsf_alloc(&ff_null_bsf, bsf);
+#else
     return av_bsf_alloc(&ff_list_bsf, bsf);
+#endif
 }