36 int markers[4*16] = {0};
37 int exss_markers = 0, exss_nextpos = 0;
38 int sum, max, pos, ret, i;
42 for (pos =
FFMIN(4096, p->
buf_size); pos < p->buf_size - 2; pos += 2) {
43 int marker, wide_hdr, hdr_size, framesize;
47 bufp = buf = p->
buf + pos;
48 state = (state << 16) | bytestream_get_be16(&bufp);
55 if (pos < exss_nextpos)
62 hdr_size =
get_bits(&gb, 8 + 4 * wide_hdr) + 1;
63 framesize =
get_bits(&gb, 16 + 4 * wide_hdr) + 1;
64 if (hdr_size & 3 || framesize & 3)
66 if (hdr_size < 16 || framesize < hdr_size)
68 if (pos - 2 + hdr_size > p->
buf_size)
73 if (pos == exss_nextpos)
76 exss_markers =
FFMAX(1, exss_markers - 1);
77 exss_nextpos = pos + framesize;
83 (bytestream_get_be16(&bufp) & 0xFC00) == 0xFC00)
86 (bytestream_get_be16(&bufp) & 0x00FC) == 0x00FC)
91 (bytestream_get_be16(&bufp) & 0xFFF0) == 0x07F0)
96 (bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
112 if (exss_markers > 3)
118 if (markers[max] < markers[i])
122 if (markers[max] > 3 && p->
buf_size / markers[max] < 32*1024 &&
123 markers[max] * 4 > sum * 3 &&
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int dts_probe(AVProbeData *p)
#define DCA_SYNCWORD_CORE_14B_BE
Public header for CRC hash function implementation.
bitstream reader API header.
#define DCA_SYNCWORD_CORE_BE
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avpriv_dca_parse_core_frame_header(DCACoreFrameHeader *h, const uint8_t *buf, int size)
Parse and validate core frame header.
#define DCA_SYNCWORD_CORE_14B_LE
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size)
Convert bitstream to one representation based on sync marker.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define FF_ARRAY_ELEMS(a)
#define DCA_CORE_FRAME_HEADER_SIZE
#define DCA_SYNCWORD_CORE_LE
AVInputFormat ff_dts_demuxer
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
This structure contains the data a format has to probe a file.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define DCA_SYNCWORD_SUBSTREAM