[FFmpeg-devel,1/3] Consistently use av_match_name() for whitelists

Submitted by Michael Niedermayer on June 1, 2017, 11:44 a.m.

Details

Message ID 20170601114446.11358-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer June 1, 2017, 11:44 a.m.
Also make docs consistent

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 doc/codecs.texi     | 3 ++-
 doc/formats.texi    | 3 ++-
 libavcodec/utils.c  | 2 +-
 libavformat/avio.c  | 2 +-
 libavformat/utils.c | 4 ++--
 5 files changed, 8 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/doc/codecs.texi b/doc/codecs.texi
index 40f64fe4c8..48c5e11050 100644
--- a/doc/codecs.texi
+++ b/doc/codecs.texi
@@ -1264,7 +1264,8 @@  Set to 1 to disable processing alpha (transparency). This works like the
 instead of alpha. Default is 0.
 
 @item codec_whitelist @var{list} (@emph{input})
-"," separated list of allowed decoders. By default all are allowed.
+Set a ","-separated list of allowed decoders. "ALL" matches all decoders. Decoders
+prefixed by "-" are disabled. By default all are allowed.
 
 @item dump_separator @var{string} (@emph{input})
 Separator used to separate the fields printed on the command line about the
diff --git a/doc/formats.texi b/doc/formats.texi
index c51d4086db..cce103149e 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -199,7 +199,8 @@  delayed bt the time duration specified in @var{offset}. Default value
 is @code{0} (meaning that no offset is applied).
 
 @item format_whitelist @var{list} (@emph{input})
-"," separated list of allowed demuxers. By default all are allowed.
+Set a ","-separated list of allowed demuxers. "ALL" matches all demuxers. Demuxers
+prefixed by "-" are disabled. By default all are allowed.
 
 @item dump_separator @var{string} (@emph{input})
 Separator used to separate the fields printed on the command line about the
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1336e921c9..2de6521b34 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -725,7 +725,7 @@  int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
     if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
         goto free_and_end;
 
-    if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) {
+    if (avctx->codec_whitelist && av_match_name(codec->name, avctx->codec_whitelist) <= 0) {
         av_log(avctx, AV_LOG_ERROR, "Codec (%s) not on whitelist \'%s\'\n", codec->name, avctx->codec_whitelist);
         ret = AVERROR(EINVAL);
         goto free_and_end;
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 1e79c9dd5c..6b6d7c8e57 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -178,7 +178,7 @@  int ffurl_connect(URLContext *uc, AVDictionary **options)
     av_assert0(!(e=av_dict_get(*options, "protocol_blacklist", NULL, 0)) ||
                (uc->protocol_blacklist && !strcmp(uc->protocol_blacklist, e->value)));
 
-    if (uc->protocol_whitelist && av_match_list(uc->prot->name, uc->protocol_whitelist, ',') <= 0) {
+    if (uc->protocol_whitelist && av_match_name(uc->prot->name, uc->protocol_whitelist) <= 0) {
         av_log(uc, AV_LOG_ERROR, "Protocol '%s' not on whitelist '%s'!\n", uc->prot->name, uc->protocol_whitelist);
         return AVERROR(EINVAL);
     }
diff --git a/libavformat/utils.c b/libavformat/utils.c
index fbd8b58ac2..7dd6084f27 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -373,7 +373,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
 int av_demuxer_open(AVFormatContext *ic) {
     int err;
 
-    if (ic->format_whitelist && av_match_list(ic->iformat->name, ic->format_whitelist, ',') <= 0) {
+    if (ic->format_whitelist && av_match_name(ic->iformat->name, ic->format_whitelist) <= 0) {
         av_log(ic, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", ic->format_whitelist);
         return AVERROR(EINVAL);
     }
@@ -553,7 +553,7 @@  int avformat_open_input(AVFormatContext **ps, const char *filename,
         }
     }
 
-    if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) {
+    if (s->format_whitelist && av_match_name(s->iformat->name, s->format_whitelist) <= 0) {
         av_log(s, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", s->format_whitelist);
         ret = AVERROR(EINVAL);
         goto fail;