[FFmpeg-devel] [PATCH] img2dec: make probing score zero for known file extensions.

Benoit Fouet benoit.fouet at free.fr
Thu Sep 11 15:48:21 CEST 2014


When a known extension has its own probing function, make img_read_probe
return 0, so that the probing functions are actually called instead of
relying only on the file extensions.

Fixes issue #3901
---
 libavformat/img2dec.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 8bbcddc..0be31c8 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -155,6 +155,26 @@ fail:
     return -1;
 }
 
+/* Add entry here when/if a known extension has its own probing function */
+static int ext_has_probe(const char *filename)
+{
+    const char extensions[] = "jpg,jpeg,jps,mpo"                     /* AV_CODEC_ID_MJPEG */
+                              ",jls"                                 /* AV_CODEC_ID_MJPEG */
+                              ",png,pns,mng"                         /* AV_CODEC_ID_PNG */
+                              ",bmp"                                 /* AV_CODEC_ID_BMP */
+                              ",tiff,tif"                            /* AV_CODEC_ID_TIFF */
+                              ",sgi"                                 /* AV_CODEC_ID_SGI */
+                              ",sun,ras,rs,im1,im8,im24,im32,sunras" /* AV_CODEC_ID_SUNRAST */
+                              ",j2c,jp2,jpc,j2k"                     /* AV_CODEC_ID_JPEG2000 */
+                              ",dpx"                                 /* AV_CODEC_ID_DPX */
+                              ",exr"                                 /* AV_CODEC_ID_EXR */
+                              ",pic"                                 /* AV_CODEC_ID_PICTOR */
+                              ",webp"                                /* AV_CODEC_ID_WEBP */
+                              ",gif"                                 /* AV_CODEC_ID_GIF */
+                              ;
+    return av_match_ext(filename, extensions);
+}
+
 static int img_read_probe(AVProbeData *p)
 {
     if (p->filename && ff_guess_image2_codec(p->filename)) {
@@ -162,8 +182,10 @@ static int img_read_probe(AVProbeData *p)
             return AVPROBE_SCORE_MAX;
         else if (is_glob(p->filename))
             return AVPROBE_SCORE_MAX;
-        else if (av_match_ext(p->filename, "raw") || av_match_ext(p->filename, "gif"))
+        else if (av_match_ext(p->filename, "raw"))
             return 5;
+        else if (ext_has_probe(p->filename))
+            return 0;
         else
             return AVPROBE_SCORE_EXTENSION;
     }
-- 
2.1.0.127.g0c72b98



More information about the ffmpeg-devel mailing list