diff mbox series

[FFmpeg-devel] Check codec whitelist in av_find_best_stream

Message ID CY4PR0501MB37305E8D8E7C943D397FBFB1AA219@CY4PR0501MB3730.namprd05.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel] Check codec whitelist in av_find_best_stream | expand

Checks

Context Check Description
andriy/commit_msg_armv7_RPi4 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/commit_msg_x86 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/commit_msg_ppc warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/commit_msg_aarch64_jetson warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Eric Juteau Jan. 27, 2022, 2:12 a.m. UTC
Modified the function av_find_best_stream() such that, when a list of
allowed codecs is supplied in the format context, and when the caller is
requesting a decoder be returned, the function will select the best
stream that has a decoder in the allowed decoders list.

Signed-off-by: Eric Juteau <ericjut@outlook.com>
---
 libavformat/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index e643821fc9..5a96f16c0f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -529,7 +529,8 @@  int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
             continue;
         if (decoder_ret) {
             decoder = ff_find_decoder(ic, st, par->codec_id);
-            if (!decoder) {
+            if ((!decoder) ||
+                (ic->codec_whitelist && av_match_list(decoder->name, ic->codec_whitelist, ',') <= 0)) {
                 if (ret < 0)
                     ret = AVERROR_DECODER_NOT_FOUND;
                 continue;