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:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-06 23:21:53 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-08-07 00:28:46 +0400
commit6a44699746501332207d967e27297cc6cfa987dd (patch)
treea4ba05d45f369a5dc18f75d0cc01525d0f51273a /libavformat/dtsdec.c
parent7a34b7d80f35f3c6862b1dc30628658a6e60b599 (diff)
avformat/dtsdec: check more of the dca headers in dts_probe()
Fixes misdetection of 664461_flac_16_44100_2.wav Fixes Ticket3830 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/dtsdec.c')
-rw-r--r--libavformat/dtsdec.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 0ebf8472c5..f6a939a1d8 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -20,6 +20,8 @@
*/
#include "libavcodec/bytestream.h"
+#include "libavcodec/get_bits.h"
+#include "libavcodec/dca.h"
#include "avformat.h"
#include "rawdec.h"
@@ -35,31 +37,59 @@ static int dts_probe(AVProbeData *p)
int markers[4] = {0};
int sum, max, i;
int64_t diff = 0;
+ uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
buf = p->buf + FFMIN(4096, p->buf_size);
for(; buf < (p->buf+p->buf_size)-2; buf+=2) {
+ int marker, sample_blocks, sample_rate, sr_code, framesize;
+ GetBitContext gb;
+
bufp = buf;
state = (state << 16) | bytestream_get_be16(&bufp);
+ if (buf - p->buf >= 4)
+ diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
+
/* regular bitstream */
if (state == DCA_MARKER_RAW_BE)
- markers[0]++;
- if (state == DCA_MARKER_RAW_LE)
- markers[1]++;
+ marker = 0;
+ else if (state == DCA_MARKER_RAW_LE)
+ marker = 1;
/* 14 bits big-endian bitstream */
- if (state == DCA_MARKER_14B_BE)
- if ((bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
- markers[2]++;
+ else if (state == DCA_MARKER_14B_BE &&
+ (bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
+ marker = 2;
/* 14 bits little-endian bitstream */
- if (state == DCA_MARKER_14B_LE)
- if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
- markers[3]++;
+ else if (state == DCA_MARKER_14B_LE &&
+ (bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
+ marker = 3;
+ else
+ continue;
- if (buf - p->buf >= 4)
- diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
+ if (avpriv_dca_convert_bitstream(buf-2, 12, hdr, 12) < 0)
+ continue;
+
+ init_get_bits(&gb, hdr, 96);
+ skip_bits_long(&gb, 39);
+
+ sample_blocks = get_bits(&gb, 7) + 1;
+ if (sample_blocks < 8)
+ continue;
+
+ framesize = get_bits(&gb, 14) + 1;
+ if (framesize < 95)
+ continue;
+
+ skip_bits(&gb, 6);
+ sr_code = get_bits(&gb, 4);
+ sample_rate = avpriv_dca_sample_rates[sr_code];
+ if (sample_rate == 0)
+ continue;
+
+ markers[marker] ++;
}
sum = markers[0] + markers[1] + markers[2] + markers[3];
max = 0;