34#define MIN_PACKET_SIZE 16
35#define MAX_PACKET_SIZE 0x104000
39 2, 0, 1, 9, 10, 3, 8, 4, 5, 9, 10, 6, 7, 12,
40 13, 14, 3, 6, 7, 11, 12, 14, 16, 15, 17, 8, 4, 5,
44 2, 0, 1, 4, 5, 3, 8, 4, 5, 9, 10, 6, 7, 12,
45 13, 14, 3, 6, 7, 11, 12, 14, 16, 15, 17, 8, 4, 5,
52 int dca_ch, wav_ch, nchannels = 0;
53 const uint8_t *dca2wav;
65 if (dca_mask & (1U << dca_ch))
66 ch_remap[nchannels++] = dca_ch;
73 if (dca_mask & (1U << dca_ch))
78 for (dca_ch = 0; dca_ch < 28; dca_ch++) {
79 if (dca_mask & (1 << dca_ch)) {
80 wav_ch = dca2wav[dca_ch];
81 if (!(wav_mask & (1 << wav_ch))) {
82 wav_map[wav_ch] = dca_ch;
83 wav_mask |= 1 << wav_ch;
87 for (wav_ch = 0; wav_ch < 18; wav_ch++)
88 if (wav_mask & (1 << wav_ch))
89 ch_remap[nchannels++] = wav_map[wav_ch];
98 int *coeff_l,
int nsamples,
int ch_mask)
111 for (spkr = 0; spkr <= max_spkr; spkr++) {
112 if (!(ch_mask & (1U << spkr)))
129 int *coeff_l,
int nsamples,
int ch_mask)
133 const float scale = 1.0f / (1 << 15);
142 coeff_r[
pos + 1] *
scale, nsamples);
145 for (spkr = 0; spkr <= max_spkr; spkr++) {
146 if (!(ch_mask & (1U << spkr)))
151 *coeff_l *
scale, nsamples);
155 *coeff_r *
scale, nsamples);
164 int output_mask,
const int *coeff_l)
170 const int *coeff_r = coeff_l +
av_popcount(output_mask);
171 const double scale = 1.0 / (1 << 15);
173 const uint8_t *dca2wav;
187 for (
int i = 0;
i <=
av_log2(output_mask);
i++) {
188 if (!(output_mask & (1U <<
i)))
195 matrix_l[idx] = *coeff_l *
scale;
198 matrix_r[idx] = *coeff_r *
scale;
219 int *got_frame_ptr,
AVPacket *avpkt)
222 const uint8_t *input = avpkt->
data;
223 int input_size = avpkt->
size;
224 int i, ret, prev_packet =
s->packet;
280 asset = &
s->exss.assets[0];
323 if (
s->xll.chset[0].freq == 96000 &&
s->core.sample_rate == 48000)
333 &&
s->xll.nchsets > 1) {
405 s->core.avctx = avctx;
406 s->exss.avctx = avctx;
407 s->xll.avctx = avctx;
408 s->lbr.avctx = avctx;
417 s->core.dcadsp = &
s->dcadsp;
418 s->xll.dcadsp = &
s->dcadsp;
419 s->lbr.dcadsp = &
s->dcadsp;
423 if (
s->downmix_layout.nb_channels) {
447#define OFFSET(x) offsetof(DCAContext, x)
448#define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
453 {
"channel_order",
"Order in which the channels are to be exported",
458 {
"coded",
"order in which the channels are coded in the bitstream",
461 {
"downmix",
"Request a specific channel layout from the decoder",
OFFSET(downmix_layout),
468 .class_name =
"DCA decoder",
const FFCodec ff_dca_decoder
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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_exss(DCACoreDecoder *s, const 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_parse(DCACoreDecoder *s, const uint8_t *data, int size)
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)
av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
int ff_dca_lbr_parse(DCALbrDecoder *s, const uint8_t *data, DCAExssAsset *asset)
av_cold void ff_dca_lbr_close(DCALbrDecoder *s)
av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
av_cold void ff_dca_lbr_init_tables(void)
#define DCA_SYNCWORD_SUBSTREAM
#define DCA_SYNCWORD_CORE_BE
int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
int ff_dca_xll_parse(DCAXllDecoder *s, const uint8_t *data, DCAExssAsset *asset)
av_cold void ff_dca_xll_flush(DCAXllDecoder *s)
av_cold void ff_dca_xll_close(DCAXllDecoder *s)
static int dcadec_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
static av_cold void dcadec_init_static(void)
static const uint8_t dca2wav_wide[28]
static const AVClass dcadec_class
int ff_dca_export_downmix_matrix(AVCodecContext *avctx, AVFrame *frame, enum DCADownMixType downmix_type, int output_mask, const int *coeff_l)
static av_cold int dcadec_close(AVCodecContext *avctx)
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
static const uint8_t dca2wav_norm[28]
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_dca_init_vlcs(void)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int(* init)(AVBSFContext *ctx)
static const uint8_t frame_size[4]
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
AVDownmixMatrix * av_downmix_matrix_alloc(enum AVDownmixType type, int in_ch_count, size_t *out_size)
Allocates memory for AVDownmixMatrix of the given type, plus an array of in_ch_count times the implic...
double AVDownmixCoeff
Data type for storing coefficients, which are allocated as a part of AVDownmixMatrix and should be re...
AVDownmixType
Possible downmix types.
static av_always_inline AVDownmixCoeff * av_downmix_matrix_coeff(AVDownmixMatrix *dm, unsigned int out, unsigned int in)
Get a pointer to the coeff that represents the weight of input channel in in output channel out.
@ AV_DOWNMIX_TYPE_LTRT
Lt/Rt 2-channel downmix, Dolby Surround compatible.
@ AV_DOWNMIX_TYPE_LORO
Lo/Ro 2-channel downmix (Stereo).
#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...
int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, enum AVChannel channel)
Get the index of a given channel in a channel layout.
#define AV_CHANNEL_LAYOUT_5POINT0
#define AV_CHANNEL_LAYOUT_STEREO
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_CHANNEL_LAYOUT_5POINT1
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
@ AV_FRAME_DATA_DOWNMIX_MATRIX
Metadata relevant to a downmix procedure in the form of a remixig matrix.
#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.
#define LIBAVUTIL_VERSION_INT
static void scale(int *out, const int *in, const int w, const int h, const int shift)
av_cold void ff_dcadsp_init(DCADSPContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int ff_thread_once(char *control, void(*routine)(void))
@ AV_CLASS_CATEGORY_DECODER
Memory handling functions.
const AVProfile ff_dca_profiles[]
A reference to a data buffer.
An AVChannelLayout holds information about the channel layout of audio data.
union AVChannelLayout::@162063043056170047076125117143030261346263330336 u
Details about which channels are present in this layout.
AVChannelCustom * map
This member must be used when the channel order is AV_CHANNEL_ORDER_CUSTOM.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
This structure describes optional metadata relevant to a downmix procedure in the form of a remixing ...
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.