65 7, 10, 12, 13, 15, 17, 19
77 for (i = 0; i <
size; i++)
238 for (ch = 0; ch < nchannels; ch++) {
248 for (ch = 0; ch < nchannels; ch++) {
252 int sign = (code >> 6) - 1;
254 index = code * 4 - 3;
274 for (ch = xch_base; ch < s->
nchannels; ch++) {
283 for (ch = xch_base; ch < s->
nchannels; ch++)
287 for (ch = xch_base; ch < s->
nchannels; ch++) {
298 for (ch = xch_base; ch < s->
nchannels; ch++)
302 for (ch = xch_base; ch < s->
nchannels; ch++) {
311 for (ch = xch_base; ch < s->
nchannels; ch++) {
321 for (ch = xch_base; ch < s->
nchannels; ch++)
326 for (ch = xch_base; ch < s->
nchannels; ch++)
349 const uint32_t *scale_table;
350 unsigned int scale_size;
368 if ((
unsigned int)*scale_index >= scale_size) {
373 return scale_table[*scale_index];
416 for (ch = xch_base; ch < s->
nchannels; ch++)
421 for (ch = xch_base; ch < s->
nchannels; ch++)
427 for (ch = xch_base; ch < s->
nchannels; ch++) {
448 for (ch = xch_base; ch < s->
nchannels; ch++) {
462 for (ch = xch_base; ch < s->
nchannels; ch++) {
491 for (ch = xch_base; ch < s->
nchannels; ch++) {
502 for (ch = xch_base; ch < s->
nchannels; ch++) {
506 for (band = s->
nsubbands[ch]; band < s->nsubbands[src_ch]; band++) {
525 #ifndef decode_blockcodes
528 int offset = (levels - 1) / 2;
533 audio[
n] = code1 - div * levels -
offset;
538 audio[
n] = code2 - div * levels -
offset;
542 return code1 | code2;
601 const int16_t *vq_index,
602 const int8_t *prediction_mode,
603 int sb_start,
int sb_end,
608 for (i = sb_start; i < sb_end; i++) {
609 if (prediction_mode[i]) {
610 const int pred_id = vq_index[i];
611 int32_t *ptr = subband_samples[i] + ofs;
612 for (j = 0; j <
len; j++) {
614 ptr[j] =
clip23(ptr[j] + x);
622 int xch_base,
int *sub_pos,
int *lfe_pos)
625 int n, ssf, ofs,
ch, band;
638 for (ch = xch_base; ch < s->
nchannels; ch++) {
675 scale =
mul23(4697620 , scale);
678 for (n = 0, ofs = *lfe_pos; n < nlfesamples; n++, ofs++)
686 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
687 for (ch = xch_base; ch < s->
nchannels; ch++) {
711 if (trans_ssf == 0 || ssf < trans_ssf)
719 scale =
clip23(adj * scale >> 22);
737 for (ch = xch_base; ch < s->
nchannels; ch++) {
744 for (ch = xch_base; ch < s->
nchannels; ch++) {
749 s->
nsubbands[src_ch], *sub_pos, nsamples);
781 (nframesamples + nlfesamples) *
sizeof(
int32_t));
801 int sf,
ch, ret, band, sub_pos, lfe_pos;
813 for (ch = xch_base; ch < s->
nchannels; ch++) {
820 for (band = 0; band < nsubbands; band++) {
860 int xxch_nchsets, xxch_frame_size;
890 if (xxch_nchsets > 1) {
936 int *xbr_nsubbands,
int xbr_transition_mode,
int sf,
int *sub_pos)
942 int ssf,
ch, band, ofs;
954 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++)
958 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
959 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
960 xbr_bit_allocation[
ch][band] =
get_bits(&s->
gb, xbr_nabits[ch]);
969 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
971 if (!xbr_scale_nbits[ch]) {
978 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
979 const uint32_t *scale_table;
993 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
994 if (xbr_bit_allocation[ch][band]) {
995 int scale_index =
get_bits(&s->
gb, xbr_scale_nbits[ch]);
996 if (scale_index >= scale_size) {
1000 xbr_scale_factors[
ch][band][0] = scale_table[scale_index];
1002 scale_index =
get_bits(&s->
gb, xbr_scale_nbits[ch]);
1003 if (scale_index >= scale_size) {
1007 xbr_scale_factors[
ch][band][1] = scale_table[scale_index];
1014 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
1015 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
1019 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
1020 int ret, trans_ssf, abits = xbr_bit_allocation[
ch][band];
1027 }
else if (abits > 0) {
1040 if (xbr_transition_mode)
1046 if (trans_ssf == 0 || ssf < trans_ssf)
1047 scale = xbr_scale_factors[
ch][band][0];
1049 scale = xbr_scale_factors[
ch][band][1];
1075 int xbr_nchsets, xbr_transition_mode, xbr_band_nbits, xbr_base_ch;
1097 for (i = 0; i < xbr_nchsets; i++)
1098 xbr_frame_size[i] =
get_bits(&s->
gb, 14) + 1;
1104 for (i = 0, ch2 = 0; i < xbr_nchsets; i++) {
1107 for (ch1 = 0; ch1 < xbr_nchannels[i]; ch1++, ch2++) {
1108 xbr_nsubbands[ch2] =
get_bits(&s->
gb, xbr_band_nbits) + 1;
1125 for (i = 0, xbr_base_ch = 0; i < xbr_nchsets; i++) {
1128 if (xbr_base_ch + xbr_nchannels[i] <= s->
nchannels) {
1131 for (sf = 0, sub_pos = 0; sf < s->
nsubframes; sf++) {
1133 xbr_base_ch + xbr_nchannels[i],
1134 xbr_nsubbands, xbr_transition_mode,
1140 xbr_base_ch += xbr_nchannels[i];
1156 return (s->
x96_rand & 0x7fffffff) - 0x40000000;
1161 int n, ssf,
ch, band, ofs;
1183 memset(samples, 0, nsamples *
sizeof(
int32_t));
1184 else for (n = 0; n < nsamples; n++)
1190 for (ssf = 0; ssf < (s->
nsubsubframes[sf] + 1) / 2; ssf++) {
1195 for (n = 0; n <
FFMIN(nsamples - ssf * 16, 16); n++)
1196 *samples++ =
clip23(vq_samples[n] * scale + (1 << 3) >> 4);
1204 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
1249 *sub_pos, nsamples);
1258 s->
nsubbands[src_ch], *sub_pos, nsamples);
1289 nframesamples *
sizeof(
int32_t));
1348 int scale_index = 0;
1353 if ((ret =
parse_scale(s, &scale_index, sel)) < 0)
1375 for (band = s->
nsubbands[ch]; band < s->nsubbands[src_ch]; band++) {
1479 int sf,
ch, ret, band, sub_pos;
1484 for (sf = 0, sub_pos = 0; sf < s->
nsubframes; sf++) {
1545 int x96_nchsets, x96_base_ch;
1577 for (i = 0; i < x96_nchsets; i++)
1578 x96_frame_size[i] =
get_bits(&s->
gb, 12) + 1;
1581 for (i = 0; i < x96_nchsets; i++)
1597 for (i = 0, x96_base_ch = 0; i < x96_nchsets; i++) {
1600 if (x96_base_ch + x96_nchannels[i] <= s->
nchannels) {
1606 x96_base_ch += x96_nchannels[i];
1658 for (i = 0; i < m *
n; i++) {
1660 int sign = (code >> 8) - 1;
1661 unsigned int index = code & 0xff;
1707 uint32_t w1, w2 = 0;
1722 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1725 size = (w2 >> 22) + 1;
1728 && (size == dist || size - 1 == dist)
1729 && (w2 >> 15 & 0x7f) == 0x08) {
1730 s->
xch_pos = sync_pos * 32 + 49;
1747 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1750 size = (w2 >> 20) + 1;
1752 if (size >= 96 && size == dist) {
1753 s->
x96_pos = sync_pos * 32 + 44;
1772 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1775 size = (w2 >> 26) + 1;
1777 if (size >= 11 && size <= dist &&
1779 (sync_pos + 1) * 4, size - 4)) {
1836 int ret = 0, ext = 0;
1961 int n,
ch, spkr, nsamples, x96_nchannels = 0;
2040 samples += nsamples / 2;
2067 int i,
n,
ch, ret, spkr, nsamples;
2103 scale_inv, nsamples);
2108 for (ch = xch_base; ch < s->
nchannels; ch++) {
2150 for (i = 0; i < avctx->
channels; i++) {
2153 for (n = 0; n < nsamples; n++)
2154 plane[n] =
clip23(samples[n]) * (1 << 8);
2163 int x96_nchannels = 0, x96_synth = 0;
2164 int i,
n,
ch, ret, spkr, nsamples, nchannels;
2166 const float *filter_coeff;
2182 for (i = 0; i < avctx->
channels; i++)
2187 if (nchannels > 0) {
2189 nsamples * nchannels *
sizeof(
float));
2197 if (output_samples[spkr])
2199 output_samples[spkr] = ptr;
2225 &s->
imdct[x96_synth],
2226 output_samples[spkr],
2234 1.0f / (1 << (17 - x96_synth)));
2241 int nlfesamples = s->
npcmblocks >> (dec_select + 1);
2245 samples += nsamples / 2;
2278 output_samples[DCA_SPEAKER_Cs],
2291 for (ch = xch_base; ch < s->
nchannels; ch++) {
2297 int coeff = *coeff_ptr++;
2300 output_samples[src_spkr],
2301 coeff * (-1.0f / (1 << 15)),
2312 output_samples[spkr],
2313 scale_inv, nsamples);
int audio_mode
Audio channel arrangement.
int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth)
static int decode_blockcodes(int code1, int code2, int levels, int32_t *audio)
int16_t prediction_vq_index[DCA_CHANNELS][DCA_SUBBANDS_X96]
Prediction coefficients VQ address.
struct DCADSPData::@51::@53 fix
void(* lfe_fir_fixed)(int32_t *pcm_samples, int32_t *lfe_samples, const int32_t *filter_coeff, ptrdiff_t npcmblocks)
int xxch_mask_nbits
Number of bits for loudspeaker mask.
static int ff_dca_seek_bits(GetBitContext *s, int p)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
DCAVLC ff_dca_vlc_bit_allocation
int prim_dmix_coeff[DCA_DMIX_CHANNELS_MAX *DCA_CORE_CHANNELS_MAX]
Dynamic downmix code coefficients.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
void(* sub_qmf_float[2])(SynthFilterContext *synth, FFTContext *imdct, float *pcm_samples, int32_t **subband_samples_lo, int32_t **subband_samples_hi, float *hist1, int *offset, float *hist2, const float *filter_coeff, ptrdiff_t npcmblocks, float scale)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const uint32_t ff_dca_lossy_quant[32]
int64_t bit_rate
the average bitrate
int xxch_dmix_embedded
Downmix already performed by encoder.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
int ext_audio_type
Extension audio descriptor flag.
#define FF_PROFILE_DTS_HD_HRA
int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset)
#define DCA_SPEAKER_LAYOUT_3_0
int frame_size
Primary frame byte size.
static int parse_frame_header(DCACoreDecoder *s)
static int alloc_x96_sample_buffer(DCACoreDecoder *s)
int8_t joint_scale_sel[DCA_CHANNELS]
Joint subband codebook select.
static void set_filter_mode(DCACoreDecoder *s, int mode)
static int filter_frame_float(DCACoreDecoder *s, AVFrame *frame)
av_cold void ff_dca_core_close(DCACoreDecoder *s)
int8_t joint_intensity_index[DCA_CHANNELS]
Joint intensity coding index.
static const uint8_t audio_mode_ch_mask[DCA_AMODE_COUNT]
static int parse_coding_header(DCACoreDecoder *s, enum HeaderType header, int xch_base)
int core_only
Core only decoding flag.
#define DCA_FILTER_MODE_FIXED
int filter_perfect
Multirate interpolator switch.
void(* dmix_scale_inv)(int32_t *dst, int scale_inv, ptrdiff_t len)
float output_history_lfe_float
LFE PCM history for X96 filter.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int map_prm_ch_to_spkr(DCACoreDecoder *s, int ch)
static int64_t ff_dcaadpcm_predict(int pred_vq_index, const int32_t *input)
unsigned int x96_subband_size
int nsubframes
Number of subframes.
static int get_sbits(GetBitContext *s, int n)
av_cold void ff_synth_filter_init(SynthFilterContext *c)
static int parse_xch_frame(DCACoreDecoder *s)
const float ff_dca_fir_32bands_nonperfect[512]
const int8_t ff_dca_high_freq_vq[1024][32]
#define DCA_EXSS_CHANNELS_MAX
static int parse_xbr_frame(DCACoreDecoder *s)
const float ff_dca_fir_64bands[1024]
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.
static int parse_frame_data(DCACoreDecoder *s, enum HeaderType header, int xch_base)
static int parse_subframe_header(DCACoreDecoder *s, int sf, enum HeaderType header, int xch_base)
DCADSPData dcadsp_data[DCA_CHANNELS]
FIR history buffers.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int32_t scale_factor_adj[DCA_CHANNELS][DCA_CODE_BOOKS]
Scale factor adjustment.
static int32_t clip23(int32_t a)
static int32_t mul23(int32_t a, int32_t b)
int x96_rand
Random seed for generating samples for unallocated X96 subbands.
const uint32_t ff_dca_bit_rates[32]
enum AVSampleFormat sample_fmt
audio sample format
int8_t prediction_mode[DCA_CHANNELS][DCA_SUBBANDS_X96]
Prediction mode.
static int32_t mul16(int32_t a, int32_t b)
int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
int source_pcm_res
Source PCM resolution.
#define FF_DCA_DMIXTABLE_OFFSET
int xxch_dmix_scale_inv
Downmix scale factor.
int32_t * subband_samples[DCA_CHANNELS][DCA_SUBBANDS]
Subband samples.
static int extract_audio(DCACoreDecoder *s, int32_t *audio, int abits, int ch)
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.
const int32_t ff_dca_lfe_fir_64_fixed[256]
int extension_mask
Coding components used in asset.
void * output_buffer
PCM output buffer base.
static int alloc_sample_buffer(DCACoreDecoder *s)
static int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, int p1, int p2)
static int get_bits_count(const GetBitContext *s)
int prim_dmix_type
Auxiliary primary channel downmix type.
int32_t * x96_subband_buffer
X96 subband sample buffer base.
static void ff_dca_core_dequantize(int32_t *output, const int32_t *input, int32_t step_size, int32_t scale, int residual, int len)
static const uint8_t header[24]
static int parse_aux_data(DCACoreDecoder *s)
static void inverse_adpcm(int32_t **subband_samples, const int16_t *vq_index, const int8_t *prediction_mode, int sb_start, int sb_end, int ofs, int len)
static int parse_xbr_subframe(DCACoreDecoder *s, int xbr_base_ch, int xbr_nchannels, int *xbr_nsubbands, int xbr_transition_mode, int sf, int *sub_pos)
int sync_ssf
Audio sync word insertion flag.
static int parse_x96_subframe_audio(DCACoreDecoder *s, int sf, int xch_base, int *sub_pos)
DCAExssParser exss
EXSS parser context.
static int parse_x96_frame_data(DCACoreDecoder *s, int exss, int xch_base)
const int32_t ff_dca_fir_64bands_fixed[1024]
int32_t * subband_buffer
Subband sample buffer base.
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
static int parse_x96_frame_exss(DCACoreDecoder *s)
int npcmsamples
Number of PCM samples per channel.
int8_t subband_vq_start[DCA_CHANNELS]
High frequency VQ start subband.
static int get_bits_left(GetBitContext *gb)
int8_t nsubbands[DCA_CHANNELS]
Subband activity count.
int xxch_offset
Offset to XXCH extension from start of substream.
const uint8_t ff_dca_bits_per_sample[8]
void(* lfe_fir_float[2])(float *pcm_samples, int32_t *lfe_samples, const float *filter_coeff, ptrdiff_t npcmblocks)
int sumdiff_front
Front sum/difference flag.
int8_t nsubsubframes[DCA_SUBFRAMES]
Subsubframe count for each subframe.
#define DCA_PCMBLOCK_SAMPLES
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
int8_t transition_mode_sel[DCA_CHANNELS]
Transient mode code book.
static int rand_x96(DCACoreDecoder *s)
int bit_rate
Transmission bit rate.
const float ff_dca_lfe_fir_128[256]
DCAVLC ff_dca_vlc_transition_mode
static const uint16_t mask[17]
int xxch_crc_present
CRC presence flag for XXCH channel set header.
AVFloatDSPContext * float_dsp
int offset
Code values offset.
const uint8_t ff_dca_quant_index_group_size[DCA_CODE_BOOKS]
const uint32_t ff_dca_lossless_quant[32]
struct DCADSPData::@51::@52 flt
static int32_t mul31(int32_t a, int32_t b)
const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE]
void(* butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len)
Calculate the sum and difference of two vectors of floats.
const float ff_dca_lfe_fir_64[256]
#define FF_PROFILE_DTS_ES
int flags
AV_CODEC_FLAG_*.
void(* butterflies_fixed)(int *av_restrict v1, int *av_restrict v2, int len)
Calculate the sum and difference of two vectors of integers.
static int parse_subframe_audio(DCACoreDecoder *s, int sf, enum HeaderType header, int xch_base, int *sub_pos, int *lfe_pos)
#define DCA_SPEAKER_LAYOUT_3_1
int aux_present
Auxiliary data flag.
const uint32_t ff_dca_quant_levels[32]
static const int8_t prm_ch_to_spkr_map[DCA_AMODE_COUNT][5]
static const uint8_t offset[127][2]
#define DCA_SPEAKER_LAYOUT_STEREO
int32_t * lfe_samples
Decimated LFE samples.
int xbr_offset
Offset to XBR extension from start of substream.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
int prim_dmix_embedded
Auxiliary dynamic downmix flag.
int sample_rate
Core audio sampling frequency.
int request_mask
Requested channel layout (for stereo downmix)
static int parse_huffman_codes(DCACoreDecoder *s, int32_t *audio, int abits, int sel)
int output_rate
Output sample rate (1x or 2x header rate)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int nchannels
Number of primary audio channels (incl. extension channels)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i)
void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
Allocate and clear a buffer, reusing the given one if large enough.
const uint8_t ff_dca_dmix_primary_nch[8]
int xxch_pos
Bit position of XXCH frame in core substream.
static int parse_joint_scale(DCACoreDecoder *s, int sel)
int sumdiff_surround
Surround sum/difference flag.
#define DCA_SPEAKER_LAYOUT_2_1
static int parse_optional_info(DCACoreDecoder *s)
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
static int parse_block_codes(DCACoreDecoder *s, int32_t *audio, int abits)
int x96_crc_present
CRC presence flag for X96 channel set header.
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
void(* lfe_x96_float)(float *dst, const float *src, float *hist, ptrdiff_t len)
#define DCA_SPEAKER_LAYOUT_2_2
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static void get_array(GetBitContext *s, int32_t *array, int size, int n)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
static const uint8_t block_code_nbits[7]
av_cold void ff_dca_core_flush(DCACoreDecoder *s)
#define AV_EF_EXPLODE
abort decoding on minor error detection
const uint32_t avpriv_dca_sample_rates[16]
DCAExssAsset assets[1]
Audio asset descriptors.
static int parse_scale(DCACoreDecoder *s, int *scale_index, int sel)
static void erase_x96_adpcm_history(DCACoreDecoder *s)
const uint32_t ff_dca_inv_dmixtable[FF_DCA_INV_DMIXTABLE_SIZE]
static int parse_x96_frame(DCACoreDecoder *s)
#define FF_ARRAY_ELEMS(a)
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
const uint32_t ff_dca_scale_factor_quant7[128]
int xxch_core_mask
Core loudspeaker activity mask.
#define FF_PROFILE_DTS_96_24
const uint8_t ff_dca_channels[16]
void(* decode_hf)(int32_t **dst, const int32_t *vq_index, const int8_t hf_vq[1024][32], int32_t scale_factors[32][2], ptrdiff_t sb_start, ptrdiff_t sb_end, ptrdiff_t ofs, ptrdiff_t len)
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
int ts_present
Embedded time stamp flag.
int xxch_spkr_mask
Loudspeaker layout mask.
void(* decode_joint)(int32_t **dst, int32_t **src, const int32_t *scale_factors, ptrdiff_t sb_start, ptrdiff_t sb_end, ptrdiff_t ofs, ptrdiff_t len)
int crc_present
CRC present flag.
int sample_rate
samples per second
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void erase_dsp_history(DCACoreDecoder *s)
main external API structure.
int8_t bit_allocation_sel[DCA_CHANNELS]
Bit allocation quantizer select.
int ext_audio_present
Extended coding flag.
int es_format
Extended surround (ES) mastering flag.
#define FF_DCA_INV_DMIXTABLE_SIZE
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int filter_frame_fixed(DCACoreDecoder *s, AVFrame *frame)
static int parse_x96_subframe_header(DCACoreDecoder *s, int xch_base)
int x96_subband_start
First encoded subband in X96 extension.
int xxch_dmix_coeff[DCA_XXCH_CHANNELS_MAX *DCA_CORE_CHANNELS_MAX]
Downmix coefficients.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
int x96_pos
Bit position of X96 frame in core substream.
const uint32_t ff_dca_scale_factor_quant6[64]
int xch_pos
Bit position of XCH frame in core substream.
int x96_size
Size of X96 extension in extension substream.
int xxch_dmix_mask[DCA_XXCH_CHANNELS_MAX]
Downmix channel mapping mask.
av_cold int ff_dca_core_init(DCACoreDecoder *s)
int32_t * x96_subband_samples[DCA_CHANNELS][DCA_SUBBANDS_X96]
X96 subband samples.
int8_t bit_allocation[DCA_CHANNELS][DCA_SUBBANDS_X96]
Bit allocation index.
av_cold void ff_dcadct_init(DCADCTContext *c)
int x96_rev_no
X96 revision number.
int8_t transition_mode[DCA_SUBFRAMES][DCA_CHANNELS][DCA_SUBBANDS]
Transition mode.
const uint8_t ff_dca_quant_index_sel_nbits[DCA_CODE_BOOKS]
int32_t * output_samples[DCA_SPEAKER_COUNT]
PCM output for fixed point mode.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int x96_nchannels
Number of primary channels in X96 extension.
int32_t joint_scale_factors[DCA_CHANNELS][DCA_SUBBANDS_X96]
Scale factors for joint subband coding.
#define DCA_SPEAKER_LAYOUT_5POINT0
static int parse_xxch_frame(DCACoreDecoder *s)
#define DCA_SYNCWORD_REV1AUX
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
Allocate and initialize a fixed DSP context.
void(* sub_qmf_fixed[2])(SynthFilterContext *synth, DCADCTContext *imdct, int32_t *pcm_samples, int32_t **subband_samples_lo, int32_t **subband_samples_hi, int32_t *hist1, int *offset, int32_t *hist2, const int32_t *filter_coeff, ptrdiff_t npcmblocks)
#define DCA_EXSS_CHSETS_MAX
unsigned int subband_size
int lfe_present
Low frequency effects flag.
int xbr_size
Size of XBR extension in extension substream.
int8_t scale_factor_sel[DCA_CHANNELS]
Scale factor code book.
int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame)
DCAVLC ff_dca_vlc_scale_factor
#define DCA_SYNCWORD_XXCH
int32_t scale_factors[DCA_CHANNELS][DCA_SUBBANDS][2]
Scale factors (2x for transients and X96)
int ch_remap[DCA_SPEAKER_COUNT]
Channel to speaker map.
#define DCA_XXCH_CHANNELS_MAX
#define DCA_SPEAKER_LAYOUT_MONO
int max_depth
Parameter for get_vlc2()
int request_channel_layout
Converted from avctx.request_channel_layout.
const uint32_t ff_dca_joint_scale_factors[129]
DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]
static int parse_x96_coding_header(DCACoreDecoder *s, int exss, int xch_base)
#define FF_DCA_DMIXTABLE_SIZE
int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb)
Parse and validate core frame header.
AVFixedDSPContext * fixed_dsp
int xxch_size
Size of XXCH extension in extension substream.
static void erase_adpcm_history(DCACoreDecoder *s)
void(* dmix_sub_xch)(int32_t *dst1, int32_t *dst2, const int32_t *src, ptrdiff_t len)
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
int ch_mask
Speaker layout mask (incl. LFE and extension channels)
void(* dmix_sub)(int32_t *dst, const int32_t *src, int coeff, ptrdiff_t len)
static const double coeff[2][5]
int x96_offset
Offset to X96 extension from start of substream.
int drc_present
Embedded dynamic range flag.
const int32_t ff_dca_fir_32bands_nonperfect_fixed[512]
#define DCA_SUBBAND_SAMPLES
void(* lfe_x96_fixed)(int32_t *dst, const int32_t *src, int32_t *hist, ptrdiff_t len)
int x96_high_res
X96 high resolution flag.
static int array[MAX_W *MAX_W]
int ext_audio_mask
Bit mask of fully decoded core extensions.
int predictor_history
Predictor history flag switch.
const int32_t ff_dca_fir_32bands_perfect_fixed[512]
int32_t output_history_lfe_fixed
LFE PCM history for X96 filter.
int8_t quant_index_sel[DCA_CHANNELS][DCA_CODE_BOOKS]
Quantization index codebook select.
const float ff_dca_fir_32bands_perfect[512]
uint8_t ** extended_data
pointers to the data planes/channels.
const uint32_t ff_dca_scale_factor_adj[4]
mode
Use these values in ebur128_init (or'ed).
int nb_samples
number of audio samples (per channel) described by this frame
int npcmblocks
Number of PCM sample blocks.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch