summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorfoo86 <foobaz86@gmail.com>2017-07-10 17:11:36 +0300
committerJames Almer <jamrial@gmail.com>2017-07-18 21:04:57 -0300
commit3b7ec920af42f1dc3676b72db9e617227c220436 (patch)
tree2bc04b2d03caf37a851c63b3928c1c8d6e633878 /libavformat
parente54b9be1ffd669c76458324206935c8927a7c705 (diff)
avformat/dtsdec: switch to common frame header parsing function
This makes probing for regular DTS more strict because more header fields are checked and values not supported by decoder are now rejected. Also fixes an issue original code had with 14-bit streams: 96 bits of header were expected, however only 84 bits were converted, which was not enough to parse LFE flag. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/dtsdec.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index 8c985b8877..6e0048f9bc 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -35,13 +35,13 @@ static int dts_probe(AVProbeData *p)
uint32_t state = -1;
int markers[4*16] = {0};
int exss_markers = 0, exss_nextpos = 0;
- int sum, max, pos, i;
+ int sum, max, pos, ret, i;
int64_t diff = 0;
- uint8_t hdr[12 + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
+ uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
- int marker, sample_blocks, sample_rate, sr_code, framesize;
- int lfe, wide_hdr, hdr_size;
+ int marker, wide_hdr, hdr_size, framesize;
+ DCACoreFrameHeader h;
GetBitContext gb;
bufp = buf = p->buf + pos;
@@ -98,36 +98,15 @@ static int dts_probe(AVProbeData *p)
else
continue;
- if (avpriv_dca_convert_bitstream(buf-2, 12, hdr, 12) < 0)
+ if ((ret = avpriv_dca_convert_bitstream(buf - 2, DCA_CORE_FRAME_HEADER_SIZE,
+ hdr, DCA_CORE_FRAME_HEADER_SIZE)) < 0)
continue;
-
- init_get_bits(&gb, hdr, 96);
- skip_bits_long(&gb, 39);
-
- sample_blocks = get_bits(&gb, 7) + 1;
- if (sample_blocks < 8)
+ if (init_get_bits8(&gb, hdr, ret) < 0)
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;
-
- get_bits(&gb, 5);
- if (get_bits(&gb, 1))
- continue;
-
- skip_bits_long(&gb, 9);
- lfe = get_bits(&gb, 2);
- if (lfe > 2)
+ if (avpriv_dca_parse_core_frame_header(&gb, &h) < 0)
continue;
- marker += 4* sr_code;
+ marker += 4 * h.sr_code;
markers[marker] ++;
}