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 & (1
U << 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)
82 int pos, spkr, max_spkr =
av_log2(ch_mask);
83 int *coeff_r = coeff_l + av_popcount(ch_mask);
93 for (spkr = 0; spkr <= max_spkr; spkr++) {
94 if (!(ch_mask & (1
U << spkr)))
97 if (*coeff_l && spkr != DCA_SPEAKER_L)
98 dcadsp->
dmix_add(samples[DCA_SPEAKER_L], samples[spkr],
101 if (*coeff_r && spkr != DCA_SPEAKER_R)
102 dcadsp->
dmix_add(samples[DCA_SPEAKER_R], samples[spkr],
111 int *coeff_l,
int nsamples,
int ch_mask)
113 int pos, spkr, max_spkr =
av_log2(ch_mask);
114 int *coeff_r = coeff_l + av_popcount(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 & (1
U << spkr)))
131 if (*coeff_l && spkr != DCA_SPEAKER_L)
133 *coeff_l * scale, nsamples);
135 if (*coeff_r && spkr != DCA_SPEAKER_R)
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;
191 if (input_size - 4 > frame_size) {
368 #define OFFSET(x) offsetof(DCAContext, x)
369 #define PARAM AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth)
DCACoreDecoder core
Core decoder context.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static const AVClass dcadec_class
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
static av_cold int dcadec_init(AVCodecContext *avctx)
#define DCA_PACKET_RECOVERY
Sync error recovery flag.
int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset)
int frame_size
Primary frame byte size.
const char * av_default_item_name(void *ptr)
Return the context name.
av_cold void ff_dca_core_close(DCACoreDecoder *s)
static av_cold int dcadec_close(AVCodecContext *avctx)
int core_only
Core only decoding flag.
#define DCA_FILTER_MODE_FIXED
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...
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
uint8_t * buffer
Packet buffer.
#define AV_CH_LAYOUT_STEREO
int freq
Original sampling frequency (max. 96000 Hz)
#define AV_CH_LAYOUT_5POINT0
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
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.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static av_cold void dcadec_flush(AVCodecContext *avctx)
int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
static int dcadec_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
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 filter_mode
Previous filtering mode for detecting changes.
int extension_mask
Coding components used in asset.
void(* dmix_add)(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
av_cold void ff_dcadsp_init(DCADSPContext *s)
#define AV_LOG_VERBOSE
Detailed information.
DCALbrDecoder lbr
LBR decoder context.
DCAExssParser exss
EXSS parser context.
#define DCA_SYNCWORD_CORE_BE
#define AV_CH_LAYOUT_5POINT1
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
static const AVOption dcadec_options[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
#define DCA_SPEAKER_LAYOUT_STEREO
uint64_t channel_layout
Audio channel layout.
int sample_rate
Core audio sampling frequency.
audio channel layout utility functions
#define AV_CH_LAYOUT_STEREO_DOWNMIX
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void(* dmix_scale)(int32_t *dst, int scale, ptrdiff_t len)
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_HAS_STEREO(mask)
DCAXllDecoder xll
XLL decoder context.
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
av_cold void ff_dca_lbr_close(DCALbrDecoder *s)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
av_cold void ff_dca_core_flush(DCACoreDecoder *s)
#define AV_EF_EXPLODE
abort decoding on minor error detection
DCAExssAsset assets[1]
Audio asset descriptors.
int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
AVSampleFormat
Audio sample formats.
av_cold void ff_dca_init_vlcs(void)
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
main external API structure.
#define DCA_SPEAKER_LAYOUT_7POINT0_WIDE
Describe the class of an AVClass context structure.
av_cold int ff_dca_core_init(DCACoreDecoder *s)
int nreschsets
Number of channel sets that have residual encoded channels.
#define DCA_SPEAKER_LAYOUT_5POINT1
#define DCA_SPEAKER_LAYOUT_5POINT0
const AVProfile ff_dca_profiles[]
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame)
av_cold void ff_dca_xll_flush(DCAXllDecoder *s)
DCAXllChSet chset[DCA_XLL_CHSETS_MAX]
Channel sets.
int request_channel_layout
Converted from avctx.request_channel_layout.
av_cold void ff_dca_xll_close(DCAXllDecoder *s)
#define DCA_PACKET_RESIDUAL
Core valid for residual decoding.
int channels
number of audio channels
#define DCA_SYNCWORD_SUBSTREAM
int ff_dca_xll_parse(DCAXllDecoder *s, uint8_t *data, DCAExssAsset *asset)
static enum AVSampleFormat sample_fmts[]
int ff_dca_exss_parse(DCAExssParser *s, const uint8_t *data, int size)
av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
int nchsets
Number of channels sets per frame.
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
This structure stores compressed data.
#define DCA_SPEAKER_LAYOUT_7POINT1_WIDE
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.