29 #include "libavutil/channel_layout.h"
30 #include "libavutil/common.h"
33 #include "libavutil/intreadwrite.h"
34 #include "libavutil/mathematics.h"
35 #include "libavutil/samplefmt.h"
54 #define DCA_PRIM_CHANNELS_MAX (7)
55 #define DCA_SUBBANDS (64)
56 #define DCA_ABITS_MAX (32)
57 #define DCA_SUBSUBFRAMES_MAX (4)
58 #define DCA_SUBFRAMES_MAX (16)
59 #define DCA_BLOCKS_MAX (16)
60 #define DCA_LFE_MAX (3)
61 #define DCA_CHSETS_MAX (4)
62 #define DCA_CHSET_CHANS_MAX (8)
186 #define DCA_CORE_EXTS (DCA_EXT_XCH | DCA_EXT_XXCH | DCA_EXT_X96)
235 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3
239 { 0, -1, -1, -1, -1, -1, -1, -1, -1},
240 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
241 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
242 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
243 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
244 { 2, 0, 1, -1, -1, -1, -1, -1, -1},
245 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
246 { 2, 0, 1, 4, -1, -1, -1, -1, -1},
247 { 0, 1, 3, 4, -1, -1, -1, -1, -1},
248 { 2, 0, 1, 4, 5, -1, -1, -1, -1},
249 { 3, 4, 0, 1, 5, 6, -1, -1, -1},
250 { 2, 0, 1, 4, 5, 6, -1, -1, -1},
251 { 0, 6, 4, 5, 2, 3, -1, -1, -1},
252 { 4, 2, 5, 0, 1, 6, 7, -1, -1},
253 { 5, 6, 0, 1, 7, 3, 8, 4, -1},
254 { 4, 2, 5, 0, 1, 6, 8, 7, -1},
258 { 0, 2, -1, -1, -1, -1, -1, -1, -1},
259 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
260 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
261 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
262 { 0, 1, 3, -1, -1, -1, -1, -1, -1},
263 { 2, 0, 1, 4, -1, -1, -1, -1, -1},
264 { 0, 1, 3, 4, -1, -1, -1, -1, -1},
265 { 2, 0, 1, 4, 5, -1, -1, -1, -1},
266 { 0, 1, 4, 5, 3, -1, -1, -1, -1},
267 { 2, 0, 1, 5, 6, 4, -1, -1, -1},
268 { 3, 4, 0, 1, 6, 7, 5, -1, -1},
269 { 2, 0, 1, 4, 5, 6, 7, -1, -1},
270 { 0, 6, 4, 5, 2, 3, 7, -1, -1},
271 { 4, 2, 5, 0, 1, 7, 8, 6, -1},
272 { 5, 6, 0, 1, 8, 3, 9, 4, 7},
273 { 4, 2, 5, 0, 1, 6, 9, 8, 7},
277 { 0, -1, -1, -1, -1, -1, -1, -1, -1},
278 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
279 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
280 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
281 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
282 { 2, 0, 1, -1, -1, -1, -1, -1, -1},
283 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
284 { 2, 0, 1, 3, -1, -1, -1, -1, -1},
285 { 0, 1, 2, 3, -1, -1, -1, -1, -1},
286 { 2, 0, 1, 3, 4, -1, -1, -1, -1},
287 { 2, 3, 0, 1, 4, 5, -1, -1, -1},
288 { 2, 0, 1, 3, 4, 5, -1, -1, -1},
289 { 0, 5, 3, 4, 1, 2, -1, -1, -1},
290 { 3, 2, 4, 0, 1, 5, 6, -1, -1},
291 { 4, 5, 0, 1, 6, 2, 7, 3, -1},
292 { 3, 2, 4, 0, 1, 5, 7, 6, -1},
296 { 0, 1, -1, -1, -1, -1, -1, -1, -1},
297 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
298 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
299 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
300 { 0, 1, 2, -1, -1, -1, -1, -1, -1},
301 { 2, 0, 1, 3, -1, -1, -1, -1, -1},
302 { 0, 1, 2, 3, -1, -1, -1, -1, -1},
303 { 2, 0, 1, 3, 4, -1, -1, -1, -1},
304 { 0, 1, 3, 4, 2, -1, -1, -1, -1},
305 { 2, 0, 1, 4, 5, 3, -1, -1, -1},
306 { 2, 3, 0, 1, 5, 6, 4, -1, -1},
307 { 2, 0, 1, 3, 4, 5, 6, -1, -1},
308 { 0, 5, 3, 4, 1, 2, 6, -1, -1},
309 { 3, 2, 4, 0, 1, 6, 7, 5, -1},
310 { 4, 5, 0, 1, 7, 2, 8, 3, 6},
311 { 3, 2, 4, 0, 1, 5, 8, 7, 6},
314 #define DCA_DOLBY 101
316 #define DCA_CHANNEL_BITS 6
317 #define DCA_CHANNEL_MASK 0x3F
321 #define HEADER_SIZE 14
323 #define DCA_MAX_FRAME_SIZE 16384
324 #define DCA_MAX_EXSS_HEADER_SIZE 4096
326 #define DCA_BUFFER_PADDING_SIZE 1024
445 uint32_t xxch_spk_masks[4];
446 int xxch_chset_nch[4];
452 int8_t xxch_order_tab[32];
459 int mix_config_num_ch[4];
472 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364,
473 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508,
474 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564,
475 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240,
476 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264,
477 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622,
482 static int vlcs_initialized = 0;
484 static VLC_TYPE dca_table[23622][2];
486 if (vlcs_initialized)
489 dca_bitalloc_index.
offset = 1;
490 dca_bitalloc_index.
wrap = 2;
491 for (i = 0; i < 5; i++) {
498 dca_scalefactor.
offset = -64;
499 dca_scalefactor.
wrap = 2;
500 for (i = 0; i < 5; i++) {
509 for (i = 0; i < 4; i++) {
517 for (i = 0; i < 10; i++)
518 for (j = 0; j < 7; j++) {
522 dca_smpl_bitalloc[i + 1].
wrap = 1 + (j > 4);
532 vlcs_initialized = 1;
547 i <= s->xxch_chset && !(mask & xxch_ch); mask = s->
xxch_spk_masks[++i])
548 base += av_popcount(mask);
550 return base + av_popcount(mask & (xxch_ch - 1));
557 static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
558 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
559 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
560 int hdr_pos = 0, hdr_size = 0;
561 float sign, mag, scale_factor;
562 int this_chans, acc_mask;
563 int embedded_downmix;
604 if (mask[j] & (1 << i)) {
607 "DCA-XXCH: dmix to LFE1 not supported.\n");
612 sign = (coeff & 64) ? 1.0 : -1.0;
644 for (j = 1; j < 11; j++)
649 for (j = 0; j < 11; j++)
653 for (j = 1; j < 11; j++)
666 if (hdr_pos + 8 * hdr_size > i)
690 for (j = 0; j < 11; j++)
694 for (j = 0; j < 11; j++)
791 "source pcm resolution: %i (%i bits/sample)\n",
811 value = av_clip(value, 0, (1 << log2range) - 1);
812 }
else if (level < 8) {
813 if (level + 1 > log2range) {
860 "Invalid bit allocation index\n");
868 av_dlog(s->
avctx,
"bitalloc index [%i][%i] too big (%i)\n",
880 k < s->vq_start_subband[j] && s->
bitalloc[j][k] > 0) {
891 const uint32_t *scale_table;
892 int scale_sum, log_size;
944 for (k = s->
subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
951 "Joint stereo coding not supported\n");
968 "Invalid channel mode %d\n", am);
1004 if (!base_channel && s->
lfe) {
1007 int lfe_samples = 2 * s->
lfe * (4 + block_index);
1011 for (j = lfe_samples; j < lfe_end_sample; j++) {
1027 for (j = lfe_samples; j < lfe_end_sample; j++)
1046 "prediction coefs: %f, %f, %f, %f\n",
1078 for (k = s->
subband_activity[j]; k < s->subband_activity[source_channel]; k++)
1096 if (!base_channel && s->
lfe) {
1097 int lfe_samples = 2 * s->
lfe * (4 + block_index);
1101 for (j = lfe_samples; j < lfe_end_sample; j++)
1111 float samples_in[32][8],
float *samples_out,
1114 const float *prCoeff;
1118 scale *= sqrt(1 / 8.0);
1130 samples_out, s->
raXin, scale);
1134 int num_deci_sample,
float *samples_in,
1135 float *samples_out,
float scale)
1146 const float *prCoeff;
1150 if (decimation_select == 1) {
1158 for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
1159 s->
dcadsp.
lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale);
1161 samples_out += 2 * decifactor;
1166 #define MIX_REAR1(samples, s1, rs, coef) \
1167 samples[0][i] += samples[s1][i] * coef[rs][0]; \
1168 samples[1][i] += samples[s1][i] * coef[rs][1];
1170 #define MIX_REAR2(samples, s1, s2, rs, coef) \
1171 samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \
1172 samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1];
1174 #define MIX_FRONT3(samples, coef) \
1175 t = samples[c][i]; \
1176 u = samples[l][i]; \
1177 v = samples[r][i]; \
1178 samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
1179 samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
1181 #define DOWNMIX_TO_STEREO(op1, op2) \
1182 for (i = 0; i < 256; i++) { \
1189 const int8_t *channel_mapping)
1191 int c, l,
r, sl, sr,
s;
1212 c = channel_mapping[0];
1213 l = channel_mapping[1];
1214 r = channel_mapping[2];
1218 s = channel_mapping[2];
1222 c = channel_mapping[0];
1223 l = channel_mapping[1];
1224 r = channel_mapping[2];
1225 s = channel_mapping[3];
1230 sl = channel_mapping[2];
1231 sr = channel_mapping[3];
1235 c = channel_mapping[0];
1236 l = channel_mapping[1];
1237 r = channel_mapping[2];
1238 sl = channel_mapping[3];
1239 sr = channel_mapping[4];
1247 #ifndef decode_blockcodes
1253 int offset = (levels - 1) >> 1;
1255 for (i = 0; i < 4; i++) {
1256 int div =
FASTDIV(code, levels);
1257 values[i] = code - offset - div * levels;
1274 #ifndef int8x8_fmul_int32
1277 float fscale = scale / 16.0;
1279 for (i = 0; i < 8; i++)
1280 dst[i] = src[i] * fscale;
1289 const float *quant_step_table;
1317 float quant_step_size = quant_step_table[abits];
1331 memset(
block + 8 * l, 0, 8 *
sizeof(
block[0]));
1335 rscale[l] = quant_step_size * s->
scale_factor[k][l][sfi] *
1338 if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].
table) {
1341 int block_code1, block_code2,
size, levels, err;
1349 levels,
block + 8 * l);
1352 "ERROR: block code look-up failed\n");
1357 for (m = 0; m < 8; m++)
1362 for (m = 0; m < 8; m++)
1364 &dca_smpl_bitalloc[abits], sel);
1380 for (m = 0; m < 8; m++) {
1381 for (n = 1; n <= 4; n++)
1383 subband_samples[k][l][
m] +=
1385 subband_samples[k][l][m -
n] / 8192);
1387 subband_samples[k][l][
m] +=
1404 "Stream with high frequencies VQ coding\n");
1430 &subband_samples[k][l][4],
1431 4 *
sizeof(subband_samples[0][0][0]));
1461 1.0 / (256.0 * 32768.0));
1471 int aux_data_count = 0, i;
1478 if (!base_channel) {
1485 for (i = 0; i < aux_data_count; i++)
1552 return av_popcount(mask) +
1571 for (i = 0; i < channels; i++) {
1572 int mix_map_mask =
get_bits(gb, out_ch);
1573 int num_coeffs = av_popcount(mix_map_mask);
1586 int embedded_stereo = 0;
1587 int embedded_6ch = 0;
1588 int drc_code_present;
1621 int spkr_remap_sets;
1622 int spkr_mask_size = 16;
1631 spkr_mask_size = (
get_bits(&s->
gb, 2) + 1) << 2;
1637 for (i = 0; i < spkr_remap_sets; i++) {
1642 for (i = 0; i < spkr_remap_sets; i++) {
1643 int num_dec_ch_remaps =
get_bits(&s->
gb, 5) + 1;
1647 for (j = 0; j < num_spkrs[i]; j++) {
1649 int num_dec_ch = av_popcount(remap_dec_ch_mask);
1660 if (drc_code_present)
1666 if (drc_code_present && embedded_stereo)
1690 if (embedded_stereo)
1696 case 0: extensions_mask =
get_bits(&s->
gb, 12);
break;
1699 case 3: extensions_mask = 0;
break;
1723 "DTS extensions detection mismatch (%d, %d)\n",
1737 int hdr_size, num_chsets, xbr_tmode, hdr_pos;
1738 int i, j, k, l, chset, chan_base;
1748 for(i = 0; i < num_chsets; i++)
1753 for(i = 0; i < num_chsets; i++) {
1756 for(j = 0; j < n_xbr_ch[i]; j++)
1757 active_bands[i][j] =
get_bits(&s->
gb, k) + 1;
1762 if(hdr_pos + hdr_size * 8 > i)
1767 for(chset = 0, chan_base = 0;
1768 chset < num_chsets && chan_base + n_xbr_ch[chset] <= s->
prim_channels;
1769 chan_base += n_xbr_ch[chset++]) {
1771 int subsubframe = 0;
1777 if(subsubframe == 0) {
1779 for(i = 0; i < n_xbr_ch[chset]; i++) {
1783 for(i = 0; i < n_xbr_ch[chset]; i++) {
1784 get_array(&s->
gb, abits_high[i], active_bands[chset][i], anctemp[i]);
1787 for(i = 0; i < n_xbr_ch[chset]; i++) {
1789 if(anctemp[i] < 1) {
1796 for(i = 0; i < n_xbr_ch[chset]; i++) {
1797 const uint32_t *scale_table;
1808 for(j = 0; j < active_bands[chset][i]; j++) {
1809 if(abits_high[i][j] > 0) {
1810 scale_table_high[i][j][0] =
1814 scale_table_high[i][j][1] =
1823 for(i = 0; i < n_xbr_ch[chset]; i++) {
1824 for(j = 0; j < active_bands[chset][i]; j++) {
1825 const int xbr_abits = abits_high[i][j];
1828 const float rscale = quant_step_size * scale_table_high[i][j][sfi];
1838 int block_code1, block_code2,
size, levels, err;
1849 "ERROR: DTS-XBR: block code look-up failed\n");
1855 for(l = 0; l < 8; l++)
1856 subband_samples[l] += (
float)block[l] * rscale;
1877 if(start_posn + chset_fsize[chset] * 8 != i) {
1878 j = start_posn + chset_fsize[chset] * 8 - i;
1881 " skipping further than expected (%d bits)\n", j);
1892 int hdr_size, spkmsk_bits, num_chsets, core_spk, hdr_pos;
1893 int i, chset, base_channel, chstart, fsize[8];
1902 for (i = 0; i < num_chsets; i++)
1912 if (hdr_pos + hdr_size * 8 > i)
1915 for (chset = 0; chset < num_chsets; chset++) {
1928 "Error decoding DTS-XXCH extension\n");
1935 if (chstart + fsize[chset] * 8 > i)
1953 int active_ss_mask[8];
1968 hdrsize =
get_bits(&s->
gb, 8 + 4 * blownup) + 1;
1983 if (num_audiop > 1) {
1985 "Multiple DTS-HD audio presentations");
1991 if (num_assets > 1) {
1997 for (i = 0; i < num_audiop; i++)
1998 active_ss_mask[i] =
get_bits(&s->
gb, ss_index + 1);
2000 for (i = 0; i < num_audiop; i++)
2001 for (j = 0; j <= ss_index; j++)
2002 if (active_ss_mask[i] & (1 << j))
2007 int mix_out_mask_size;
2010 mix_out_mask_size = (
get_bits(&s->
gb, 2) + 1) << 2;
2014 int mix_out_mask =
get_bits(&s->
gb, mix_out_mask_size);
2020 for (i = 0; i < num_assets; i++)
2023 for (i = 0; i < num_assets; i++) {
2031 if (num_assets > 0) {
2033 if (start_posn + hdrsize * 8 > j)
2036 for (i = 0; i < num_assets; i++) {
2041 if (mkr == 0x655e315e) {
2043 }
else if (mkr == 0x47004a03) {
2048 "DTS-ExSS: unknown marker = 0x%08x\n", mkr);
2053 if (start_posn + asset_size[i] * 8 > j)
2064 int *got_frame_ptr,
AVPacket *avpkt)
2068 int buf_size = avpkt->
size;
2072 int num_core_channels = 0;
2074 float **samples_flt;
2079 int channels, full_channels;
2142 int ext_amode, xch_fsize;
2159 if ((ext_amode =
get_bits(&s->
gb, 4)) != 1) {
2161 " supported!\n", ext_amode);
2234 if (s->
amode < 16) {
2239 > num_core_channels + !!s->
lfe)) {
2250 channels = num_core_channels + !!s->
lfe;
2259 if (channels > !!s->
lfe &&
2274 static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
2280 "Non standard configuration %d !\n", s->
amode);
2291 channels = num_core_channels + !!s->
lfe;
2307 if (channel_mask & (1 << i)) {
2314 if (av_popcount(channel_mask) != av_popcount(channel_layout)) {
2316 "DTS-XXCH: Inconsistant avcodec/dts channel layouts\n");
2324 for (chset = -1, j = 0; chset < s->
xxch_chset; ++chset) {
2330 posn = av_popcount(channel_layout & (lavc - 1));
2338 for (i = 0; i < channels; i++)
2374 full_channels - channels,
2384 for (ch = 0; ch < channels; ch++)
2386 for (; ch < full_channels; ch++)
2404 ch = num_core_channels;
2405 for (chset = 0; chset < s->
xxch_chset; chset++) {
2410 for (j = ch; j < endch; j++) {
2411 if (mask & (1 << j)) {
2413 for (k = 0; k < endch; k++) {
2426 if ((mask & (1 << ch)) && s->
xxch_dmix_sf[chset] != 1.0f) {
2429 for (j = 0; j < ch; j++) {
2431 for (k = 0; k < 256; k++)
2432 src_chan[k] *= scale;
2438 for (k = 0; k < 256; k++)
2439 src_chan[k] *= scale;
2451 for (i = 0; i < 2 * s->
lfe * 4; i++)
int wrap
wrap for get_vlc2()
int ext_descr
extension audio descriptor flag
static const int8_t bitalloc_offsets[10]
int downmix
embedded downmix enabled
int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]
quantization index codebook select
#define AVERROR_PATCHWELCOME
int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]
bit allocation quantizer select
int crc_present
crc is present in the bitstream
#define DCA_CHSET_CHANS_MAX
This structure describes decoded (raw) audio or video data.
low bitrate component in ExSS
#define AV_CH_TOP_FRONT_RIGHT
int timestamp
embedded time stamp flag
int amode
audio channels arrangement
static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
static const AVProfile profiles[]
static const uint16_t tmode_codes[TMODE_COUNT][4]
int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]
stereo downmix coefficients
int transient_huffman[DCA_PRIM_CHANNELS_MAX]
transient mode code book
int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2]
scale factors (2 if transient)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const uint32_t scale_factor_quant6[64]
int mix_config_num_ch[4]
number of channels in each mix out configuration
static void skip_bits_long(GetBitContext *s, int n)
attribute_deprecated int request_channels
Decoder should decode to this many channels if it can (0 for default)
static av_cold int init(AVCodecContext *avctx)
FmtConvertContext fmt_conv
static int dca_parse_frame_header(DCAContext *s)
static struct endianess table[]
static int dca_exss_parse_asset_header(DCAContext *s)
Parse extension substream asset header (HD)
static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
Skip mixing coefficients of a single mix out configuration (HD)
#define AV_CH_TOP_FRONT_LEFT
int vq_start_subband[DCA_PRIM_CHANNELS_MAX]
high frequency vq start subband
XXCh channels extension in core substream.
#define AV_CH_TOP_FRONT_CENTER
uint8_t ** extended_data
pointers to the data planes/channels.
float subband_fir_noidea[DCA_PRIM_CHANNELS_MAX][32]
int hist_index[DCA_PRIM_CHANNELS_MAX]
int samples_deficit
deficit sample count
#define DECLARE_ALIGNED(n, t, v)
static const float lossless_quant_d[32]
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int dynrange
embedded dynamic range flag
int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
joint subband scale factors
int version
encoder software revision
#define FF_PROFILE_DTS_HD_HRA
static const int8_t dca_channel_reorder_lfe_xch[][9]
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
#define AV_CH_LAYOUT_STEREO
void(* lfe_fir)(float *out, const float *in, const float *coefs, int decifactor, float scale)
static BitAlloc dca_scalefactor
scalefactor VLCs
#define DCA_BUFFER_PADDING_SIZE
static int get_sbits(GetBitContext *s, int n)
float subband_fir_hist[DCA_PRIM_CHANNELS_MAX][512]
float xxch_dmix_coeff[DCA_PRIM_CHANNELS_MAX][32]
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
float * extra_channels[DCA_PRIM_CHANNELS_MAX+1]
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
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 dca_subframe_footer(DCAContext *s, int base_channel)
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
static BitAlloc dca_tmode
transition mode VLCs
#define MIX_FRONT3(samples, coef)
static int dca_exss_mask2count(int mask)
Return the number of channels in an ExSS speaker mask (HD)
static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]
scale factor code book
static int dca_decode_block(DCAContext *s, int base_channel, int block_index)
Decode a dca frame block.
static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
enum AVSampleFormat sample_fmt
audio sample format
uint32_t xxch_core_spkmask
static const uint16_t dca_vlc_offs[]
int xch_base_channel
index of first (only) channel containing XCH data
float subband_samples_hist[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4]
#define AV_CH_TOP_BACK_LEFT
static const uint8_t offset[511][2]
static int dca_parse_audio_coding_header(DCAContext *s, int base_channel, int xxch)
int dca_buffer_size
how much data is in the dca_buffer
static const uint32_t scale_factor_quant7[128]
#define MIX_REAR2(samples, s1, s2, rs, coef)
av_export const uint32_t avpriv_dca_sample_rates[16]
static void get_array(GetBitContext *gb, int *dst, int len, int bits)
#define AV_CH_TOP_BACK_CENTER
int8_t xxch_order_tab[32]
const char * name
Name of the codec implementation.
static av_cold int dca_decode_end(AVCodecContext *avctx)
void(* int32_to_float_fmul_array8)(struct FmtConvertContext *c, float *dst, const int32_t *src, const float *mul, int len)
Convert an array of int32_t to float and multiply by a float value from another array, stepping along the float array once for each 8 integers.
#define AV_CH_LOW_FREQUENCY
int header_crc
header crc check bytes
int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
transition mode (transients)
static int dca_xxch2index(DCAContext *s, int xxch_ch)
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
av_cold void ff_dcadsp_init(DCADSPContext *s)
static int get_bits_count(const GetBitContext *s)
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Fill plane data pointers and linesize for samples with sample format sample_fmt.
int sample_rate
audio sampling rate
bitstream reader API header.
uint32_t xxch_spk_masks[4]
XCh channel extension in core substream.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static BitAlloc dca_bitalloc_index
indexes for samples VLC select
int lfe
low frequency effects flag
static const float fir_32bands_nonperfect[]
static BitAlloc dca_smpl_bitalloc[11]
samples VLCs
XXCh channels extension in ExSS.
static const uint8_t bitalloc_sizes[10]
int predictor_history
predictor history flag
static int dca_xbr_parse_frame(DCAContext *s)
int dynrange_coef
dynamic range coefficient
int joint_huff[DCA_PRIM_CHANNELS_MAX]
joint subband scale factors codebook
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
float subband_samples[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]
static const uint16_t mask[17]
#define MIX_REAR1(samples, s1, rs, coef)
#define DCA_PRIM_CHANNELS_MAX
static const uint16_t bitalloc_12_codes[BITALLOC_12_COUNT][12]
#define FF_PROFILE_DTS_HD_MA
int hdcd
source material is mastered in HDCD
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void(* qmf_32_subbands)(float samples_in[32][8], int sb_act, SynthFilterContext *synth, FFTContext *imdct, float synth_buf_ptr[512], int *synth_buf_offset, float synth_buf2[32], const float window[512], float *samples_out, float raXin[32], float scale)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int mix_metadata
mixing metadata present
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static const uint8_t bitalloc_12_bits[BITALLOC_12_COUNT][12]
int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
bit allocation index
static int dca_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Main frame decoding function FIXME add arguments.
int debug_flag
used for suppressing repeated error messages output
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
static const int8_t dca_lfe_index[]
const int8_t * channel_order_tab
channel reordering table, lfe and non lfe
float lfe_data[2 *DCA_LFE_MAX *(DCA_BLOCKS_MAX+4)]
Low frequency effect data.
common internal API header
static const uint8_t tmode_bits[TMODE_COUNT][4]
static void qmf_32_subbands(DCAContext *s, int chans, float samples_in[32][8], float *samples_out, float scale)
#define FF_ARRAY_ELEMS(a)
int front_sum
front sum/difference flag
static const float dca_downmix_coeffs[65]
int source_pcm_res
source pcm resolution
static int dca_xxch_decode_frame(DCAContext *s)
static const uint32_t map_xxch_to_native[28]
int bit_rate
the average bitrate
static const int8_t dca_channel_reorder_lfe[][9]
static const int8_t dca_channel_reorder_nolfe[][9]
int surround_sum
surround sum/difference flag
static av_cold void dca_init_vlcs(void)
static const float dca_downmix_scale_factors[241]
av_cold void ff_synth_filter_init(SynthFilterContext *c)
uint8_t dca_buffer[DCA_MAX_FRAME_SIZE+DCA_MAX_EXSS_HEADER_SIZE+DCA_BUFFER_PADDING_SIZE]
static const uint8_t scales_bits[SCALES_COUNT][129]
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
int joint_intensity[DCA_PRIM_CHANNELS_MAX]
joint intensity coding index
int ff_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.
static const int16_t adpcm_vb[4096][4]
static const uint16_t *const bitalloc_codes[10][8]
int multirate_inter
multirate interpolator switch
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint8_t dca_channels[16]
#define AV_CH_FRONT_LEFT_OF_CENTER
lossless extension in ExSS
#define FF_PROFILE_UNKNOWN
#define AV_CH_FRONT_CENTER
int bit_rate
transmission bit rate
static const uint8_t *const bitalloc_bits[10][8]
#define INIT_VLC_USE_NEW_STATIC
int offset
code values offset
static const uint8_t abits_levels[7]
#define AV_CH_FRONT_RIGHT_OF_CENTER
static const float lfe_fir_64[]
int xch_present
XCh extension present and valid.
int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
VQ encoded high frequency subbands.
int core_ext_mask
present extensions in the core substream
AVSampleFormat
Audio Sample Formats.
#define DCA_MAX_FRAME_SIZE
#define AV_LOG_INFO
Standard information.
int aux_data
auxiliary data flag
int sample_rate
samples per second
int ext_coding
extended coding flag
#define AV_CH_LAYOUT_NATIVE
Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests ...
int subband_activity[DCA_PRIM_CHANNELS_MAX]
subband activity count
main external API structure.
static void close(AVCodecParserContext *s)
float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]
scale factor adjustment
int copy_history
copy history
static void dca_exss_parse_header(DCAContext *s)
Parse extension substream header (HD)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void int8x8_fmul_int32(float *dst, const int8_t *src, int scale)
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
#define AV_CH_TOP_BACK_RIGHT
core in ExSS (extension substream)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint64_t dca_core_channel_layout[]
static void dca_downmix(float **samples, int srcfmt, int downmix_coef[DCA_PRIM_CHANNELS_MAX][2], const int8_t *channel_mapping)
static const float lossy_quant_d[32]
extended bitrate extension in ExSS
int sample_blocks
number of PCM sample blocks
static const uint8_t abits_sizes[7]
static const int8_t dca_channel_reorder_nolfe_xch[][9]
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int decode_blockcode(int code, int levels, int32_t *values)
static const uint16_t scale[4]
#define AV_CH_BACK_CENTER
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
prediction mode (ADPCM used or not)
static av_cold int dca_decode_init(AVCodecContext *avctx)
DCA initialization.
static const float fir_32bands_perfect[]
int num_mix_configs
number of mix out configurations
static const uint8_t dca_default_coeffs[10][5][2]
96/24 extension in core substream
common internal api header.
static void lfe_interpolation_fir(DCAContext *s, int decimation_select, int num_deci_sample, float *samples_in, float *samples_out, float scale)
uint8_t * extra_channels_buffer
#define CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int total_channels
number of channels including extensions
static const uint16_t scales_codes[SCALES_COUNT][129]
static int dca_filter_channels(DCAContext *s, int block_index)
int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]
prediction VQ coefs
int dialog_norm
dialog normalisation parameter
int bit_rate_index
transmission bit rate index
#define FF_PROFILE_DTS_ES
static const uint8_t bitalloc_maxbits[10][7]
#define AVERROR_INVALIDDATA
av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
int channels
number of audio channels
static const uint32_t dca_bit_rates[32]
VLC_TYPE(* table)[2]
code, bits
float * samples_chanptr[DCA_PRIM_CHANNELS_MAX+1]
static const int8_t high_freq_vq[1024][32]
int subsubframes[DCA_SUBFRAMES_MAX]
number of subsubframes
#define DCA_MAX_EXSS_HEADER_SIZE
static const float lfe_fir_128[]
static const double coeff[2][5]
static const int dca_ext_audio_descr_mask[]
#define DOWNMIX_TO_STEREO(op1, op2)
int frame_size
primary frame byte size
#define DCA_SUBFRAMES_MAX
#define AV_CH_FRONT_RIGHT
static enum AVSampleFormat sample_fmts[]
float xxch_dmix_sf[DCA_CHSETS_MAX]
int aspf
audio sync word insertion flag
#define LOCAL_ALIGNED_16(t, v,...)
#define FF_PROFILE_DTS_96_24
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int prim_channels
number of primary audio channels
#define DCA_HD_MARKER
DCA-HD specific block starts with this marker.
static const uint8_t bitalloc_12_vlc_bits[BITALLOC_12_COUNT]
static int get_scale(GetBitContext *gb, int level, int value, int log2range)
uint64_t request_channel_layout
Request decoder to use this channel layout if it can (0 for default)
int partial_samples[DCA_SUBFRAMES_MAX]
partial subsubframe samples count
This structure stores compressed data.
uint32_t xxch_dmix_embedded
int subframes
number of subframes
int nb_samples
number of audio samples (per channel) described by this frame
unsigned int extra_channels_buffer_size
static const uint8_t tmode_vlc_bits[TMODE_COUNT]
static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
int static_fields
static fields present
int frame_type
type of the current frame
static const uint8_t dca_bits_per_sample[7]