summaryrefslogtreecommitdiff
path: root/libavformat/bit.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-09-29 19:10:46 +0200
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-09-30 20:41:52 +0200
commite9f9175db60ac67e906f8ad0709129843ab41d14 (patch)
treeac1824713ed88f7358425059ffe76f77a04c218f /libavformat/bit.c
parent67057aaeb23d84144b2b371547fd46e915be238f (diff)
downloadffmpeg-e9f9175db60ac67e906f8ad0709129843ab41d14.tar.gz
lavf/bit: Fix the G.729 bit auto-detection.
Diffstat (limited to 'libavformat/bit.c')
-rw-r--r--libavformat/bit.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/libavformat/bit.c b/libavformat/bit.c
index d742a5b363..76aae2d4a1 100644
--- a/libavformat/bit.c
+++ b/libavformat/bit.c
@@ -32,20 +32,23 @@
#if CONFIG_BIT_DEMUXER
static int probe(AVProbeData *p)
{
- int i, j;
+ int i = 0, j, valid = 0;
- if(p->buf_size < 0x40)
- return 0;
-
- for(i=0; i+3<p->buf_size && i< 10*0x50; ){
- if(AV_RL16(&p->buf[0]) != SYNC_WORD)
+ while (2 * i + 3 < p->buf_size){
+ if (AV_RL16(&p->buf[2 * i++]) != SYNC_WORD)
return 0;
- j=AV_RL16(&p->buf[2]);
- if(j!=0x40 && j!=0x50)
+ j = AV_RL16(&p->buf[2 * i++]);
+ if (j != 0 && j != 0x10 && j != 0x40 && j != 0x50 && j != 0x76)
return 0;
- i+=j;
+ if (j)
+ valid++;
+ i += j;
}
- return AVPROBE_SCORE_EXTENSION;
+ if (valid > 10)
+ return AVPROBE_SCORE_MAX;
+ if (valid > 2)
+ return AVPROBE_SCORE_EXTENSION - 1;
+ return 0;
}
static int read_header(AVFormatContext *s)