MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / dts_probe

Function dts_probe

libavformat/dtsdec.c:33–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include "rawdec.h"
32
33static int dts_probe(const AVProbeData *p)
34{
35 const uint8_t *buf, *bufp;
36 uint32_t state = -1;
37 int markers[4*16] = {0};
38 int exss_markers = 0, exss_nextpos = 0;
39 int sum, max, pos, ret, i;
40 int64_t diff = 0;
41 int diffcount = 1;
42 uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
43
44 for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
45 int marker, wide_hdr, hdr_size, framesize;
46 DCACoreFrameHeader h;
47 GetBitContext gb;
48
49 bufp = buf = p->buf + pos;
50 state = (state << 16) | bytestream_get_be16(&bufp);
51
52 if (pos >= 4) {
53 if (AV_RL16(buf) || AV_RL16(buf-4)) {
54 diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
55 diffcount ++;
56 }
57 }
58
59 /* extension substream (EXSS) */
60 if (state == DCA_SYNCWORD_SUBSTREAM) {
61 if (pos < exss_nextpos)
62 continue;
63
64 init_get_bits(&gb, buf - 2, 96);
65 skip_bits_long(&gb, 42);
66
67 wide_hdr = get_bits1(&gb);
68 hdr_size = get_bits(&gb, 8 + 4 * wide_hdr) + 1;
69 framesize = get_bits(&gb, 16 + 4 * wide_hdr) + 1;
70 if (hdr_size & 3 || framesize & 3)
71 continue;
72 if (hdr_size < 16 || framesize < hdr_size)
73 continue;
74 if (pos - 2 + hdr_size > p->buf_size)
75 continue;
76 if (av_crc(av_crc_get_table(AV_CRC_16_CCITT), 0xffff, buf + 3, hdr_size - 5))
77 continue;
78
79 if (pos == exss_nextpos)
80 exss_markers++;
81 else
82 exss_markers = FFMAX(1, exss_markers - 1);
83 exss_nextpos = pos + framesize;
84 continue;
85 }
86
87 /* regular bitstream */
88 if (state == DCA_SYNCWORD_CORE_BE &&
89 (bytestream_get_be16(&bufp) & 0xFC00) == 0xFC00)
90 marker = 0;

Callers

nothing calls this directly

Calls 8

init_get_bitsFunction · 0.85
skip_bits_longFunction · 0.85
get_bits1Function · 0.85
av_crcFunction · 0.85
av_crc_get_tableFunction · 0.85
get_bitsFunction · 0.50

Tested by

no test coverage detected