41 #define IS_CORE_MARKER(state) \
42 (((state & 0xFFFFFFFFF0FF) == (((uint64_t)DCA_SYNCWORD_CORE_14B_LE << 16) | 0xF007)) || \
43 ((state & 0xFFFFFFFFFFF0) == (((uint64_t)DCA_SYNCWORD_CORE_14B_BE << 16) | 0x07F0)) || \
44 ((state & 0xFFFFFFFF00FC) == (((uint64_t)DCA_SYNCWORD_CORE_LE << 16) | 0x00FC)) || \
45 ((state & 0xFFFFFFFFFC00) == (((uint64_t)DCA_SYNCWORD_CORE_BE << 16) | 0xFC00)))
47 #define IS_EXSS_MARKER(state) ((state & 0xFFFFFFFF) == DCA_SYNCWORD_SUBSTREAM)
49 #define IS_MARKER(state) (IS_CORE_MARKER(state) || IS_EXSS_MARKER(state))
51 #define CORE_MARKER(state) ((state >> 16) & 0xFFFFFFFF)
52 #define EXSS_MARKER(state) (state & 0xFFFFFFFF)
54 #define STATE_LE(state) (((state & 0xFF00FF00) >> 8) | ((state & 0x00FF00FF) << 8))
55 #define STATE_14(state) (((state & 0x3FFF0000) >> 8) | ((state & 0x00003FFF) >> 6))
57 #define CORE_FRAMESIZE(state) (((state >> 4) & 0x3FFF) + 1)
58 #define EXSS_FRAMESIZE(state) ((state & 0x2000000000) ? \
59 ((state >> 5) & 0xFFFFF) + 1 : \
60 ((state >> 13) & 0x0FFFF) + 1)
69 int start_found,
size, i;
79 for (; i < buf_size; i++) {
81 state = (state << 8) | buf[i];
105 for (; i < buf_size; i++) {
107 state = (state << 8) | buf[i];
109 if (start_found == 1) {
154 if (start_found == 3) {
196 int ret, sample_blocks;
247 if (nsamples_log2 > 24)
251 *duration = (1 + (*sample_rate > 96000)) << nsamples_log2;
264 sample_blocks =
get_bits(&gb, 7) + 1;
265 if (sample_blocks < 8)
267 *duration = 256 * (sample_blocks / 8);
271 if (*sample_rate == 0)
278 const uint8_t **poutbuf,
int *poutbuf_size,
313 *poutbuf_size = buf_size;
static av_cold int dca_parse_init(AVCodecParserContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_bits_long(GetBitContext *s, int n)
static int dca_find_frame_end(DCAParseContext *pc1, const uint8_t *buf, int buf_size)
Find the end of the current frame in the bitstream.
int duration
Duration of the current frame.
const uint8_t ff_dca_freq_ranges[16]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define IS_EXSS_MARKER(state)
#define DCA_SYNCWORD_CORE_14B_BE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int extension_mask
Coding components used in asset.
bitstream reader API header.
AVCodecParser ff_dca_parser
#define DCA_SYNCWORD_CORE_BE
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
const uint32_t ff_dca_sampling_freqs[16]
int lbr_offset
Offset to LBR component from start of substream.
#define DCA_SYNCWORD_CORE_14B_LE
void ff_parse_close(AVCodecParserContext *s)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int xll_offset
Offset to XLL data from start of substream.
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.
const uint32_t avpriv_dca_sample_rates[16]
DCAExssAsset assets[1]
Audio asset descriptors.
int xll_size
Size of XLL data in extension substream.
#define FF_ARRAY_ELEMS(a)
#define EXSS_MARKER(state)
int max_sample_rate
Maximum sample rate.
static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
int sample_rate
samples per second
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define DCA_SYNCWORD_CORE_LE
main external API structure.
#define CORE_FRAMESIZE(state)
int lbr_size
Size of LBR component in extension substream.
static void skip_bits(GetBitContext *s, int n)
uint64_t state64
contains the last 8 bytes in MSB order
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define CORE_MARKER(state)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
#define EXSS_FRAMESIZE(state)
#define PARSER_FLAG_COMPLETE_FRAMES
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define DCA_SYNCWORD_SUBSTREAM
static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf, int buf_size, int *duration, int *sample_rate)
int ff_dca_exss_parse(DCAExssParser *s, const uint8_t *data, int size)