summaryrefslogtreecommitdiff
path: root/libavformat/flacdec.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2015-04-10 12:35:02 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2015-04-10 12:35:02 +0200
commit7b39d853b88e4be03f2cfb346df3ad55ccae3377 (patch)
tree8919d7aad2e1ba4107babac7f162ed3361331e0c /libavformat/flacdec.c
parent3553b815f66cb42f79706d6be5c11c0b13d9ac2e (diff)
downloadffmpeg-7b39d853b88e4be03f2cfb346df3ad55ccae3377.tar.gz
lavf/flac: Autodetect raw flac files.
Diffstat (limited to 'libavformat/flacdec.c')
-rw-r--r--libavformat/flacdec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 1a8dc19af3..4207fd2bf6 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -176,8 +176,26 @@ fail:
return ret;
}
+static int raw_flac_probe(AVProbeData *p)
+{
+ if ((p->buf[2] & 0xF0) == 0) // blocksize code invalid
+ return 0;
+ if ((p->buf[2] & 0x0F) == 0x0F) // sample rate code invalid
+ return 0;
+ if ((p->buf[3] & 0xF0) >= FLAC_MAX_CHANNELS + FLAC_CHMODE_MID_SIDE << 4)
+ // channel mode invalid
+ return 0;
+ if ((p->buf[3] & 0x06) == 0x06) // bits per sample code invalid
+ return 0;
+ if ((p->buf[3] & 0x01) == 0x01) // reserved bit set
+ return 0;
+ return AVPROBE_SCORE_EXTENSION / 4 + 1;
+}
+
static int flac_probe(AVProbeData *p)
{
+ if ((AV_RB16(p->buf) & 0xFFFE) == 0xFFF8)
+ return raw_flac_probe(p);
if (p->buf_size < 4 || memcmp(p->buf, "fLaC", 4))
return 0;
return AVPROBE_SCORE_EXTENSION;