92 7, 10, 12, 13, 15, 17, 19
104 for (i = 0; i <
size; i++)
111 int normal_frame, pcmr_index;
311 for (ch = 0; ch < nchannels; ch++) {
321 for (ch = 0; ch < nchannels; ch++) {
325 int sign = (code >> 6) - 1;
327 index = code * 4 - 3;
347 for (ch = xch_base; ch < s->
nchannels; ch++) {
356 for (ch = xch_base; ch < s->
nchannels; ch++)
360 for (ch = xch_base; ch < s->
nchannels; ch++) {
371 for (ch = xch_base; ch < s->
nchannels; ch++)
375 for (ch = xch_base; ch < s->
nchannels; ch++) {
384 for (ch = xch_base; ch < s->
nchannels; ch++) {
394 for (ch = xch_base; ch < s->
nchannels; ch++)
399 for (ch = xch_base; ch < s->
nchannels; ch++)
422 const uint32_t *scale_table;
423 unsigned int scale_size;
441 if ((
unsigned int)*scale_index >= scale_size) {
446 return scale_table[*scale_index];
489 for (ch = xch_base; ch < s->
nchannels; ch++)
494 for (ch = xch_base; ch < s->
nchannels; ch++)
500 for (ch = xch_base; ch < s->
nchannels; ch++) {
521 for (ch = xch_base; ch < s->
nchannels; ch++) {
535 for (ch = xch_base; ch < s->
nchannels; ch++) {
564 for (ch = xch_base; ch < s->
nchannels; ch++) {
575 for (ch = xch_base; ch < s->
nchannels; ch++) {
579 for (band = s->
nsubbands[ch]; band < s->nsubbands[src_ch]; band++) {
598 #ifndef decode_blockcodes
601 int offset = (levels - 1) / 2;
606 audio[
n] = code1 - div * levels -
offset;
611 audio[
n] = code2 - div * levels -
offset;
615 return code1 | code2;
677 int64_t step_scale = (int64_t)step_size * scale;
681 if (step_scale > (1 << 23)) {
682 shift =
av_log2(step_scale >> 23) + 1;
683 step_scale >>=
shift;
689 output[n] +=
clip23(
norm__(input[n] * step_scale, 22 - shift));
692 output[n] =
clip23(
norm__(input[n] * step_scale, 22 - shift));
697 const int16_t *vq_index,
698 const int8_t *prediction_mode,
699 int sb_start,
int sb_end,
704 for (i = sb_start; i < sb_end; i++) {
705 if (prediction_mode[i]) {
707 int32_t *ptr = subband_samples[i] + ofs;
708 for (j = 0; j <
len; j++) {
711 err += (int64_t)ptr[j - k - 1] * coeff[k];
720 int xch_base,
int *sub_pos,
int *lfe_pos)
736 for (ch = xch_base; ch < s->
nchannels; ch++) {
773 scale =
mul23(4697620 , scale);
776 for (n = 0, ofs = *lfe_pos; n < nlfesamples; n++, ofs++)
784 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
785 for (ch = xch_base; ch < s->
nchannels; ch++) {
809 if (trans_ssf == 0 || ssf < trans_ssf)
817 scale =
clip23(adj * scale >> 22);
821 audio, step_size, scale, 0);
835 for (ch = xch_base; ch < s->
nchannels; ch++) {
842 for (ch = xch_base; ch < s->
nchannels; ch++) {
847 s->
nsubbands[src_ch], *sub_pos, nsamples);
879 (nframesamples + nlfesamples) *
sizeof(
int32_t));
899 int sf,
ch, ret,
band, sub_pos, lfe_pos;
911 for (ch = xch_base; ch < s->
nchannels; ch++) {
918 for (band = 0; band < nsubbands; band++) {
958 int xxch_nchsets, xxch_frame_size;
988 if (xxch_nchsets > 1) {
1034 int *xbr_nsubbands,
int xbr_transition_mode,
int sf,
int *sub_pos)
1052 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++)
1056 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
1057 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
1067 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
1069 if (!xbr_scale_nbits[ch]) {
1076 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
1077 const uint32_t *scale_table;
1091 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
1092 if (xbr_bit_allocation[ch][band]) {
1093 int scale_index =
get_bits(&s->
gb, xbr_scale_nbits[ch]);
1094 if (scale_index >= scale_size) {
1098 xbr_scale_factors[
ch][
band][0] = scale_table[scale_index];
1100 scale_index =
get_bits(&s->
gb, xbr_scale_nbits[ch]);
1101 if (scale_index >= scale_size) {
1105 xbr_scale_factors[
ch][
band][1] = scale_table[scale_index];
1112 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
1113 for (ch = xbr_base_ch; ch < xbr_nchannels; ch++) {
1117 for (band = 0; band < xbr_nsubbands[
ch]; band++) {
1118 int ret, trans_ssf, abits = xbr_bit_allocation[
ch][
band];
1125 }
else if (abits > 0) {
1138 if (xbr_transition_mode)
1144 if (trans_ssf == 0 || ssf < trans_ssf)
1145 scale = xbr_scale_factors[
ch][
band][0];
1147 scale = xbr_scale_factors[
ch][
band][1];
1150 audio, step_size, scale, 1);
1173 int xbr_nchsets, xbr_transition_mode, xbr_band_nbits, xbr_base_ch;
1195 for (i = 0; i < xbr_nchsets; i++)
1196 xbr_frame_size[i] =
get_bits(&s->
gb, 14) + 1;
1202 for (i = 0, ch2 = 0; i < xbr_nchsets; i++) {
1205 for (ch1 = 0; ch1 < xbr_nchannels[i]; ch1++, ch2++) {
1206 xbr_nsubbands[ch2] =
get_bits(&s->
gb, xbr_band_nbits) + 1;
1223 for (i = 0, xbr_base_ch = 0; i < xbr_nchsets; i++) {
1226 if (xbr_base_ch + xbr_nchannels[i] <= s->
nchannels) {
1229 for (sf = 0, sub_pos = 0; sf < s->
nsubframes; sf++) {
1231 xbr_base_ch + xbr_nchannels[i],
1232 xbr_nsubbands, xbr_transition_mode,
1238 xbr_base_ch += xbr_nchannels[i];
1254 return (s->
x96_rand & 0x7fffffff) - 0x40000000;
1281 memset(samples, 0, nsamples *
sizeof(
int32_t));
1282 else for (n = 0; n < nsamples; n++)
1288 for (ssf = 0; ssf < (s->
nsubsubframes[sf] + 1) / 2; ssf++) {
1293 for (n = 0; n <
FFMIN(nsamples - ssf * 16, 16); n++)
1294 *samples++ =
clip23(vq_samples[n] * scale + (1 << 3) >> 4);
1302 for (ssf = 0, ofs = *sub_pos; ssf < s->
nsubsubframes[sf]; ssf++) {
1330 audio, step_size, scale, 0);
1347 *sub_pos, nsamples);
1356 s->
nsubbands[src_ch], *sub_pos, nsamples);
1387 nframesamples *
sizeof(
int32_t));
1446 int scale_index = 0;
1451 if ((ret =
parse_scale(s, &scale_index, sel)) < 0)
1473 for (band = s->
nsubbands[ch]; band < s->nsubbands[src_ch]; band++) {
1577 int sf,
ch, ret,
band, sub_pos;
1582 for (sf = 0, sub_pos = 0; sf < s->
nsubframes; sf++) {
1643 int x96_nchsets, x96_base_ch;
1675 for (i = 0; i < x96_nchsets; i++)
1676 x96_frame_size[i] =
get_bits(&s->
gb, 12) + 1;
1679 for (i = 0; i < x96_nchsets; i++)
1695 for (i = 0, x96_base_ch = 0; i < x96_nchsets; i++) {
1698 if (x96_base_ch + x96_nchannels[i] <= s->
nchannels) {
1704 x96_base_ch += x96_nchannels[i];
1756 for (i = 0; i < m *
n; i++) {
1758 int sign = (code >> 8) - 1;
1759 unsigned int index = code & 0xff;
1819 for (; sync_pos >= last_pos; sync_pos--) {
1821 s->
gb.
index = (sync_pos + 1) * 32;
1825 && (size == dist || size - 1 == dist)
1844 for (; sync_pos >= last_pos; sync_pos--) {
1846 s->
gb.
index = (sync_pos + 1) * 32;
1849 if (size >= 96 && size == dist) {
1869 for (; sync_pos >= last_pos; sync_pos--) {
1871 s->
gb.
index = (sync_pos + 1) * 32;
1874 if (size >= 11 && size <= dist &&
1876 (sync_pos + 1) * 4, size - 4)) {
1934 int ret = 0, ext = 0;
2057 int n,
ch, spkr, nsamples, x96_nchannels = 0;
2136 samples += nsamples / 2;
2163 int i,
n,
ch, ret, spkr, nsamples;
2199 scale_inv, nsamples);
2204 for (ch = xch_base; ch < s->
nchannels; ch++) {
2246 for (i = 0; i < avctx->
channels; i++) {
2249 for (n = 0; n < nsamples; n++)
2250 plane[n] =
clip23(samples[n]) * (1 << 8);
2259 int x96_nchannels = 0, x96_synth = 0;
2260 int i,
n,
ch, ret, spkr, nsamples, nchannels;
2262 const float *filter_coeff;
2278 for (i = 0; i < avctx->
channels; i++)
2283 if (nchannels > 0) {
2285 nsamples * nchannels *
sizeof(
float));
2293 if (output_samples[spkr])
2295 output_samples[spkr] = ptr;
2321 &s->
imdct[x96_synth],
2322 output_samples[spkr],
2330 1.0f / (1 << (17 - x96_synth)));
2337 int nlfesamples = s->
npcmblocks >> (dec_select + 1);
2341 samples += nsamples / 2;
2374 output_samples[DCA_SPEAKER_Cs],
2387 for (ch = xch_base; ch < s->
nchannels; ch++) {
2393 int coeff = *coeff_ptr++;
2396 output_samples[src_spkr],
2397 coeff * (-1.0f / (1 << 15)),
2408 output_samples[spkr],
2409 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.
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.
static int shift(int a, int b)
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)
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)
static const int8_t prm_ch_to_spkr_map[AMODE_COUNT][5]
av_cold void ff_dca_core_close(DCACoreDecoder *s)
int8_t joint_intensity_index[DCA_CHANNELS]
Joint intensity coding index.
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)
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.
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
Allocate and initialize a fixed DSP context.
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.
static void dequantize(int32_t *output, const int32_t *input, int32_t step_size, int32_t scale, int residual)
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.
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.
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]
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
struct DCADSPData::@53::@54 flt
int aux_present
Auxiliary data flag.
const uint32_t ff_dca_quant_levels[32]
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.
const int16_t ff_dca_adpcm_vb[4096][4]
#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
const uint8_t ff_dca_bits_per_sample[8]
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.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define FF_DCA_INV_DMIXTABLE_SIZE
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_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.
static const uint8_t audio_mode_ch_mask[AMODE_COUNT]
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]
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
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.
struct DCADSPData::@53::@55 fix
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
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.
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_YASM &&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
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
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
static int32_t norm__(int64_t a, int bits)
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
static int32_t norm13(int64_t a)
int npcmblocks
Number of PCM sample blocks.