[FFmpeg-devel] [PATCH]lavf/flacdec: Return maximum score if a valid streaminfo header was found

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Mar 1 10:38:58 EET 2017


Hi!

I implemented this patch to fix ticket #6208 but it turned out the flac probe 
function wasn't the issue. Still looks like a good idea to me.

Please comment, Carl Eugen
-------------- next part --------------
From acc7558a3585d99776523ed670747597c4de99fb Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Wed, 1 Mar 2017 09:34:37 +0100
Subject: [PATCH 1/2] lavf/flacdec: Return maximum score if the streaminfo
 header is valid.

---
 libavformat/flacdec.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 66baba5..c75eba8 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -233,7 +233,14 @@ static int flac_probe(AVProbeData *p)
         return raw_flac_probe(p);
     if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4))
         return 0;
-    return AVPROBE_SCORE_EXTENSION;
+    if (   p->buf[4] & 0x7f != FLAC_METADATA_TYPE_STREAMINFO
+        || AV_RB24(p->buf + 5) != FLAC_STREAMINFO_SIZE
+        || AV_RB16(p->buf + 8) < 16
+        || AV_RB16(p->buf + 8) > AV_RB16(p->buf + 10)
+        || !(AV_RB24(p->buf + 18) >> 4)
+        || AV_RB24(p->buf + 18) >> 4 > 655350)
+        return AVPROBE_SCORE_EXTENSION / 8;
+    return AVPROBE_SCORE_MAX;
 }
 
 static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_index,
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list