29 #define MIN_PACKET_SIZE 16
30 #define MAX_PACKET_SIZE 0x104000
34 static const uint8_t dca2wav_norm[28] = {
35 2, 0, 1, 9, 10, 3, 8, 4, 5, 9, 10, 6, 7, 12,
36 13, 14, 3, 6, 7, 11, 12, 14, 16, 15, 17, 8, 4, 5,
39 static const uint8_t dca2wav_wide[28] = {
40 2, 0, 1, 4, 5, 3, 8, 4, 5, 9, 10, 6, 7, 12,
41 13, 14, 3, 9, 10, 11, 12, 14, 16, 15, 17, 8, 4, 5,
44 int dca_ch, wav_ch, nchannels = 0;
48 if (dca_mask & (1U << dca_ch))
49 ch_remap[nchannels++] = dca_ch;
57 dca2wav = dca2wav_wide;
59 dca2wav = dca2wav_norm;
60 for (dca_ch = 0; dca_ch < 28; dca_ch++) {
61 if (dca_mask & (1 << dca_ch)) {
62 wav_ch = dca2wav[dca_ch];
63 if (!(wav_mask & (1 << wav_ch))) {
64 wav_map[wav_ch] = dca_ch;
65 wav_mask |= 1 << wav_ch;
69 for (wav_ch = 0; wav_ch < 18; wav_ch++)
70 if (wav_mask & (1 << wav_ch))
71 ch_remap[nchannels++] = wav_map[wav_ch];
80 int *coeff_l,
int nsamples,
int ch_mask)
93 for (spkr = 0; spkr <= max_spkr; spkr++) {
94 if (!(ch_mask & (1U << spkr)))
111 int *coeff_l,
int nsamples,
int ch_mask)
115 const float scale = 1.0f / (1 << 15);
122 coeff_l[
pos ] * scale, nsamples);
124 coeff_r[
pos + 1] * scale, nsamples);
127 for (spkr = 0; spkr <= max_spkr; spkr++) {
128 if (!(ch_mask & (1U << spkr)))
133 *coeff_l * scale, nsamples);
137 *coeff_r * scale, nsamples);
145 int *got_frame_ptr,
AVPacket *avpkt)
150 int input_size = avpkt->
size;
151 int i, ret, prev_packet =
s->packet;
207 asset = &
s->exss.assets[0];
251 if (
s->xll.chset[0].freq == 96000 &&
s->core.sample_rate == 48000)
261 &&
s->xll.nchsets > 1) {
326 s->core.avctx = avctx;
327 s->exss.avctx = avctx;
328 s->xll.avctx = avctx;
329 s->lbr.avctx = avctx;
340 s->core.dcadsp = &
s->dcadsp;
341 s->xll.dcadsp = &
s->dcadsp;
342 s->lbr.dcadsp = &
s->dcadsp;
348 s->request_channel_layout = 0;
368 #define OFFSET(x) offsetof(DCAContext, x)
369 #define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
static void flush(AVCodecContext *avctx)
static enum AVSampleFormat sample_fmts[]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static av_cold int init(AVCodecContext *avctx)
audio channel layout utility functions
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.
#define DCA_SPEAKER_LAYOUT_5POINT0
#define DCA_SPEAKER_LAYOUT_7POINT0_WIDE
#define DCA_SPEAKER_LAYOUT_STEREO
#define DCA_HAS_STEREO(mask)
#define DCA_SPEAKER_LAYOUT_5POINT1
#define DCA_SPEAKER_LAYOUT_7POINT1_WIDE
int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth)
int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset)
av_cold int ff_dca_core_init(DCACoreDecoder *s)
av_cold void ff_dca_core_flush(DCACoreDecoder *s)
av_cold void ff_dca_core_close(DCACoreDecoder *s)
int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame)
#define DCA_FILTER_MODE_FIXED
int ff_dca_exss_parse(DCAExssParser *s, const uint8_t *data, int size)
int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
av_cold void ff_dca_lbr_close(DCALbrDecoder *s)
av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
#define DCA_SYNCWORD_SUBSTREAM
#define DCA_SYNCWORD_CORE_BE
int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
av_cold void ff_dca_xll_flush(DCAXllDecoder *s)
int ff_dca_xll_parse(DCAXllDecoder *s, uint8_t *data, DCAExssAsset *asset)
av_cold void ff_dca_xll_close(DCAXllDecoder *s)
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
static const AVClass dcadec_class
static av_cold int dcadec_close(AVCodecContext *avctx)
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static av_cold void dcadec_flush(AVCodecContext *avctx)
static av_cold int dcadec_init(AVCodecContext *avctx)
static const AVOption dcadec_options[]
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
#define DCA_PACKET_RESIDUAL
Core valid for residual decoding.
#define DCA_PACKET_RECOVERY
Sync error recovery flag.
av_cold void ff_dcadsp_init(DCADSPContext *s)
av_cold void ff_dca_init_vlcs(void)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define AV_CH_LAYOUT_5POINT0
#define AV_CH_LAYOUT_STEREO_DOWNMIX
#define AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_5POINT1
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
#define LIBAVUTIL_VERSION_INT
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_CLASS_CATEGORY_DECODER
const AVProfile ff_dca_profiles[]
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
int channels
number of audio channels
uint64_t channel_layout
Audio channel layout.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
const char * name
Name of the codec implementation.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
void(* dmix_scale)(int32_t *dst, int scale, ptrdiff_t len)
void(* dmix_add)(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
int extension_mask
Coding components used in asset.