39 #define IS_MARKER(state, i, buf, buf_size) \
40 ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \
41 || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \
42 || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)
60 for (i = 0; i < buf_size; i++) {
61 state = (state << 8) | buf[i];
75 for (; i < buf_size; i++) {
77 state = (state << 8) | buf[i];
111 const uint16_t *ssrc = (
const uint16_t *) src;
112 uint16_t *sdst = (uint16_t *) dst;
115 if ((
unsigned) src_size > (unsigned) max_size)
121 memcpy(dst, src, src_size);
124 for (i = 0; i < (src_size + 1) >> 1; i++)
130 for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
146 int ret, sample_blocks, sr_code;
157 sample_blocks =
get_bits(&gb, 7) + 1;
158 if (sample_blocks < 8)
160 *duration = 256 * (sample_blocks / 8);
165 if (*sample_rate == 0)
173 const uint8_t ** poutbuf,
int *poutbuf_size,
174 const uint8_t * buf,
int buf_size)
200 *poutbuf_size = buf_size;
static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration, int *sample_rate)
static av_cold int dca_parse_init(AVCodecParserContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int ff_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.
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.
#define DCA_HD_MARKER
DCA-HD specific block starts with this marker.
bitstream reader API header.
AVCodecParser ff_dca_parser
int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
Combine the (truncated) bitstream to a complete frame.
#define IS_MARKER(state, i, buf, buf_size)
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
static int put_bits_count(PutBitContext *s)
void ff_parse_close(AVCodecParserContext *s)
#define DCA_MARKER_14B_LE
struct DCAParseContext DCAParseContext
const uint32_t avpriv_dca_sample_rates[16]
#define PARSER_FLAG_COMPLETE_FRAMES
static int dca_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
#define DCA_MARKER_RAW_LE
int sample_rate
samples per second
main external API structure.
uint32_t state
contains the last few bytes in MSB order
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define FF_INPUT_BUFFER_PADDING_SIZE
#define DCA_MARKER_14B_BE
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define AVERROR_INVALIDDATA
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define DCA_MARKER_RAW_BE
DCA syncwords, also used for bitstream type detection.