Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-03-16 01:16:23 +0300
committerClément Bœsch <u@pkh.me>2017-03-16 01:17:32 +0300
commite887d685f74197cda153c0ec57f9cb719a33932b (patch)
tree7cd6b72200d887eb3a56930e54c6c4d844cf7840 /libavformat/flacdec.c
parentdd0abace3ec73d253486a0dd19f43dd9263f8a2f (diff)
parented1cd81076434b76f37576d4d806973476a8e96c (diff)
Merge commit 'ed1cd81076434b76f37576d4d806973476a8e96c'
* commit 'ed1cd81076434b76f37576d4d806973476a8e96c': flac demuxer: improve probing Suggested commit very closely matches our code, except with regards to AVPROBE_SCORE_EXTENSION. The code layout is mostly merged but preserves our behaviour. Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'libavformat/flacdec.c')
-rw-r--r--libavformat/flacdec.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index fee46fcfe6..a032378045 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -231,16 +231,27 @@ 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;
- 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)
+
+ /* file header + metadata header + checked bytes of streaminfo */
+ if (p->buf_size >= 4 + 4 + 13) {
+ int type = p->buf[4] & 0x7f;
+ int size = AV_RB24(p->buf + 5);
+ int min_block_size = AV_RB16(p->buf + 8);
+ int max_block_size = AV_RB16(p->buf + 10);
+ int sample_rate = AV_RB24(p->buf + 18) >> 4;
+
+ if (memcmp(p->buf, "fLaC", 4))
+ return 0;
+ if (type == FLAC_METADATA_TYPE_STREAMINFO &&
+ size == FLAC_STREAMINFO_SIZE &&
+ min_block_size >= 16 &&
+ max_block_size >= min_block_size &&
+ sample_rate && sample_rate <= 655350)
+ return AVPROBE_SCORE_MAX;
return AVPROBE_SCORE_EXTENSION;
- return AVPROBE_SCORE_MAX;
+ }
+
+ return 0;
}
static av_unused int64_t flac_read_timestamp(AVFormatContext *s, int stream_index,