diff mbox

[FFmpeg-devel] avformat/utils: avoid using marked decoders for probing

Message ID 20160922164409.5860-1-timo@rothenpieler.org
State Accepted
Commit 9777ba33f52c54cc982f977ce28e5d4b55927b72
Headers show

Commit Message

Timo Rothenpieler Sept. 22, 2016, 4:44 p.m. UTC
---
 libavformat/utils.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Sept. 23, 2016, 1:42 a.m. UTC | #1
On Thu, Sep 22, 2016 at 06:44:09PM +0200, Timo Rothenpieler wrote:
> ---
>  libavformat/utils.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

should be ok

thx

[...]
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 05d2315..93ea6ff 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -188,6 +188,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
 
 static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
 {
+    const AVCodec *codec;
+
 #if CONFIG_H264_DECODER
     /* Other parts of the code assume this decoder to be used for h264,
      * so force it if possible. */
@@ -195,7 +197,22 @@  static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
         return avcodec_find_decoder_by_name("h264");
 #endif
 
-    return find_decoder(s, st, codec_id);
+    codec = find_decoder(s, st, codec_id);
+    if (!codec)
+        return NULL;
+
+    if (codec->capabilities & AV_CODEC_CAP_AVOID_PROBING) {
+        const AVCodec *probe_codec = NULL;
+        while (probe_codec = av_codec_next(probe_codec)) {
+            if (probe_codec->id == codec_id &&
+                    av_codec_is_decoder(probe_codec) &&
+                    !(probe_codec->capabilities & (AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_EXPERIMENTAL))) {
+                return probe_codec;
+            }
+        }
+    }
+
+    return codec;
 }
 
 int av_format_get_probe_score(const AVFormatContext *s)