summaryrefslogtreecommitdiff
path: root/libavformat/dtsdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-20 00:09:36 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-20 00:21:09 +0100
commit0dba982bb4f711447fcbb62d381d24f820c35084 (patch)
tree1ffb7dab840f63abec83213b51947a211fea4fbd /libavformat/dtsdec.c
parentfbb6de2ad774880b5db08df476050e84fe3446bc (diff)
avformat/dtsdec: dts_probe: check reserved bit, check lfe, check sr_code similarity
Fixes misdetection of s16le Fixes Ticket4109 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/dtsdec.c')
-rw-r--r--libavformat/dtsdec.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index f6a939a1d8..d054f43537 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -34,7 +34,7 @@ static int dts_probe(AVProbeData *p)
{
const uint8_t *buf, *bufp;
uint32_t state = -1;
- int markers[4] = {0};
+ int markers[4*16] = {0};
int sum, max, i;
int64_t diff = 0;
uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
@@ -43,6 +43,7 @@ static int dts_probe(AVProbeData *p)
for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
int marker, sample_blocks, sample_rate, sr_code, framesize;
+ int lfe;
GetBitContext gb;
bufp = buf;
@@ -89,13 +90,27 @@ static int dts_probe(AVProbeData *p)
if (sample_rate == 0)
continue;
+ get_bits(&gb, 5);
+ if (get_bits(&gb, 1))
+ continue;
+
+ skip_bits_long(&gb, 9);
+ lfe = get_bits(&gb, 2);
+ if (lfe > 2)
+ continue;
+
+ marker += 4* sr_code;
+
markers[marker] ++;
}
- sum = markers[0] + markers[1] + markers[2] + markers[3];
- max = 0;
- for (i=1; i<4; i++)
+
+ sum = max = 0;
+ for (i=0; i<FF_ARRAY_ELEMS(markers); i++) {
+ sum += markers[i];
if (markers[max] < markers[i])
max = i;
+ }
+
if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
markers[max] * 4 > sum * 3 &&
diff / p->buf_size > 200)