Go to the documentation of this file.
65 7, 10, 12, 13, 15, 17, 19
127 s->crc_present =
h.crc_present;
128 s->npcmblocks =
h.npcmblocks;
129 s->frame_size =
h.frame_size;
130 s->audio_mode =
h.audio_mode;
133 s->drc_present =
h.drc_present;
134 s->ts_present =
h.ts_present;
135 s->aux_present =
h.aux_present;
136 s->ext_audio_type =
h.ext_audio_type;
137 s->ext_audio_present =
h.ext_audio_present;
138 s->sync_ssf =
h.sync_ssf;
139 s->lfe_present =
h.lfe_present;
140 s->predictor_history =
h.predictor_history;
141 s->filter_perfect =
h.filter_perfect;
143 s->es_format =
h.pcmr_code & 1;
144 s->sumdiff_front =
h.sumdiff_front;
145 s->sumdiff_surround =
h.sumdiff_surround;
167 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid number of primary audio channels (%d) for audio channel arrangement (%d)\n",
s->nchannels,
s->audio_mode);
190 if (
s->xxch_crc_present
209 if (av_popcount(
s->xxch_spkr_mask) != nchannels) {
214 if (
s->xxch_core_mask &
s->xxch_spkr_mask) {
215 av_log(
s->avctx,
AV_LOG_ERROR,
"XXCH speaker layout mask (%#x) overlaps with core (%#x)\n",
s->xxch_spkr_mask,
s->xxch_core_mask);
220 s->ch_mask =
s->xxch_core_mask |
s->xxch_spkr_mask;
224 int *coeff_ptr =
s->xxch_dmix_coeff;
238 for (
ch = 0;
ch < nchannels;
ch++) {
240 if ((
mask &
s->xxch_core_mask) !=
mask) {
248 for (
ch = 0;
ch < nchannels;
ch++) {
249 for (
n = 0;
n <
s->xxch_mask_nbits;
n++) {
250 if (
s->xxch_dmix_mask[
ch] & (1
U <<
n)) {
252 int sign = (
code >> 6) - 1;
267 s->xxch_dmix_embedded = 0;
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++) {
290 if (
n >
s->nchannels) {
294 s->joint_intensity_index[
ch] =
n;
298 for (
ch = xch_base;
ch <
s->nchannels;
ch++)
302 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
304 if (
s->scale_factor_sel[
ch] == 7) {
311 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
313 if (
s->bit_allocation_sel[
ch] == 7) {
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;
365 *scale_index =
get_bits(&
s->gb, sel + 1);
368 if ((
unsigned int)*scale_index >= scale_size) {
373 return scale_table[*scale_index];
409 s->nsubsubframes[sf] =
get_bits(&
s->gb, 2) + 1;
416 for (
ch = xch_base;
ch <
s->nchannels;
ch++)
417 for (band = 0; band <
s->nsubbands[
ch]; band++)
421 for (
ch = xch_base;
ch <
s->nchannels;
ch++)
422 for (band = 0; band <
s->nsubbands[
ch]; band++)
423 if (
s->prediction_mode[
ch][band])
424 s->prediction_vq_index[
ch][band] =
get_bits(&
s->gb, 12);
427 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
428 int sel =
s->bit_allocation_sel[
ch];
430 for (band = 0; band <
s->subband_vq_start[
ch]; band++) {
443 s->bit_allocation[
ch][band] = abits;
448 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
450 memset(
s->transition_mode[sf][
ch], 0,
sizeof(
s->transition_mode[0][0]));
453 if (
s->nsubsubframes[sf] > 1) {
454 int sel =
s->transition_mode_sel[
ch];
455 for (band = 0; band <
s->subband_vq_start[
ch]; band++)
456 if (
s->bit_allocation[
ch][band])
462 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
463 int sel =
s->scale_factor_sel[
ch];
467 for (band = 0; band <
s->subband_vq_start[
ch]; band++) {
468 if (
s->bit_allocation[
ch][band]) {
471 s->scale_factors[
ch][band][0] =
ret;
472 if (
s->transition_mode[sf][
ch][band]) {
475 s->scale_factors[
ch][band][1] =
ret;
478 s->scale_factors[
ch][band][0] = 0;
483 for (band =
s->subband_vq_start[
ch]; band < s->nsubbands[
ch]; band++) {
486 s->scale_factors[
ch][band][0] =
ret;
491 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
492 if (
s->joint_intensity_index[
ch]) {
494 if (
s->joint_scale_sel[
ch] == 7) {
502 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
503 int src_ch =
s->joint_intensity_index[
ch] - 1;
505 int sel =
s->joint_scale_sel[
ch];
506 for (band =
s->nsubbands[
ch]; band < s->nsubbands[src_ch]; band++) {
509 s->joint_scale_factors[
ch][band] =
ret;
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;
584 int sel =
s->quant_index_sel[
ch][abits - 1];
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;
629 if (*sub_pos + nsamples >
s->npcmblocks) {
638 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
641 for (band =
s->subband_vq_start[
ch]; band < s->nsubbands[
ch]; band++)
645 if (
s->subband_vq_start[
ch] <
s->nsubbands[
ch]) {
646 s->dcadsp->decode_hf(
s->subband_samples[
ch], vq_index,
648 s->subband_vq_start[
ch],
s->nsubbands[
ch],
658 int nlfesamples = 2 *
s->lfe_present *
s->nsubsubframes[sf];
675 scale =
mul23(4697620 , scale);
678 for (
n = 0, ofs = *lfe_pos;
n < nlfesamples;
n++, ofs++)
679 s->lfe_samples[ofs] =
clip23(audio[
n] * scale >> 4);
686 for (ssf = 0, ofs = *sub_pos; ssf <
s->nsubsubframes[sf]; ssf++) {
687 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
692 for (band = 0; band <
s->subband_vq_start[
ch]; band++) {
693 int ret, trans_ssf, abits =
s->bit_allocation[
ch][band];
702 if (
s->bit_rate == 3)
708 trans_ssf =
s->transition_mode[sf][
ch][band];
711 if (trans_ssf == 0 || ssf < trans_ssf)
712 scale =
s->scale_factors[
ch][band][0];
714 scale =
s->scale_factors[
ch][band][1];
718 int64_t adj =
s->scale_factor_adj[
ch][abits - 1];
719 scale =
clip23(adj * scale >> 22);
728 if ((ssf ==
s->nsubsubframes[sf] - 1 ||
s->sync_ssf) &&
get_bits(&
s->gb, 16) != 0xffff) {
737 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
739 s->prediction_mode[
ch], 0,
s->nsubbands[
ch],
744 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
745 int src_ch =
s->joint_intensity_index[
ch] - 1;
747 s->dcadsp->decode_joint(
s->subband_samples[
ch],
s->subband_samples[src_ch],
748 s->joint_scale_factors[
ch],
s->nsubbands[
ch],
749 s->nsubbands[src_ch], *sub_pos, nsamples);
776 unsigned int size =
s->subband_size;
781 (nframesamples + nlfesamples) *
sizeof(
int32_t));
782 if (!
s->subband_buffer)
785 if (
size !=
s->subband_size) {
788 s->subband_samples[
ch][band] =
s->subband_buffer +
790 s->lfe_samples =
s->subband_buffer + nframesamples;
793 if (!
s->predictor_history)
801 int sf,
ch,
ret, band, sub_pos, lfe_pos;
806 for (sf = 0, sub_pos = 0, lfe_pos =
DCA_LFE_HISTORY; sf <
s->nsubframes; sf++) {
813 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
815 int nsubbands =
s->nsubbands[
ch];
816 if (
s->joint_intensity_index[
ch])
817 nsubbands =
FFMAX(nsubbands,
s->nsubbands[
s->joint_intensity_index[
ch] - 1]);
820 for (band = 0; band < nsubbands; band++) {
860 int xxch_nchsets, xxch_frame_size;
873 if (
ff_dca_check_crc(
s->avctx, &
s->gb, header_pos + 32, header_pos + header_size * 8)) {
884 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid number of bits for XXCH speaker mask (%d)\n",
s->xxch_mask_nbits);
890 if (xxch_nchsets > 1) {
896 xxch_frame_size =
get_bits(&
s->gb, 14) + 1;
910 if (
mask !=
s->xxch_core_mask) {
911 av_log(
s->avctx,
AV_LOG_ERROR,
"XXCH core speaker activity mask (%#x) disagrees with core (%#x)\n",
s->xxch_core_mask,
mask);
927 if (
ff_dca_seek_bits(&
s->gb, header_pos + header_size * 8 + xxch_frame_size * 8)) {
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;
983 if (
s->scale_factor_sel[
ch] > 5) {
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];
1001 if (xbr_transition_mode &&
s->transition_mode[sf][
ch][band]) {
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)
1041 trans_ssf =
s->transition_mode[sf][
ch][band];
1046 if (trans_ssf == 0 || ssf < trans_ssf)
1047 scale = xbr_scale_factors[
ch][band][0];
1049 scale = xbr_scale_factors[
ch][band][1];
1057 if ((ssf ==
s->nsubsubframes[sf] - 1 ||
s->sync_ssf) &&
get_bits(&
s->gb, 16) != 0xffff) {
1075 int xbr_nchsets, xbr_transition_mode, xbr_band_nbits, xbr_base_ch;
1088 if (
ff_dca_check_crc(
s->avctx, &
s->gb, header_pos + 32, header_pos + header_size * 8)) {
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++) {
1106 xbr_band_nbits =
get_bits(&
s->gb, 2) + 5;
1107 for (ch1 = 0; ch1 < xbr_nchannels[
i]; ch1++, ch2++) {
1108 xbr_nsubbands[ch2] =
get_bits(&
s->gb, xbr_band_nbits) + 1;
1110 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid number of active XBR subbands (%d)\n", xbr_nsubbands[ch2]);
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];
1155 s->x96_rand = 1103515245
U *
s->x96_rand + 12345
U;
1156 return (
s->x96_rand & 0x7fffffff) - 0x40000000;
1161 int n, ssf,
ch, band, ofs;
1165 if (*sub_pos + nsamples >
s->npcmblocks) {
1174 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1175 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++) {
1178 int32_t scale =
s->scale_factors[
ch][band >> 1][band & 1];
1180 switch (
s->bit_allocation[
ch][band]) {
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++)
1204 for (ssf = 0, ofs = *sub_pos; ssf <
s->nsubsubframes[sf]; ssf++) {
1205 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1209 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++) {
1210 int ret, abits =
s->bit_allocation[
ch][band] - 1;
1223 if (
s->bit_rate == 3)
1229 scale =
s->scale_factors[
ch][band >> 1][band & 1];
1237 if ((ssf ==
s->nsubsubframes[sf] - 1 ||
s->sync_ssf) &&
get_bits(&
s->gb, 16) != 0xffff) {
1246 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1248 s->prediction_mode[
ch],
s->x96_subband_start,
s->nsubbands[
ch],
1249 *sub_pos, nsamples);
1253 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1254 int src_ch =
s->joint_intensity_index[
ch] - 1;
1256 s->dcadsp->decode_joint(
s->x96_subband_samples[
ch],
s->x96_subband_samples[src_ch],
1257 s->joint_scale_factors[
ch],
s->nsubbands[
ch],
1258 s->nsubbands[src_ch], *sub_pos, nsamples);
1284 unsigned int size =
s->x96_subband_size;
1289 nframesamples *
sizeof(
int32_t));
1290 if (!
s->x96_subband_buffer)
1293 if (
size !=
s->x96_subband_size) {
1296 s->x96_subband_samples[
ch][band] =
s->x96_subband_buffer +
1300 if (!
s->predictor_history)
1314 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++)
1315 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++)
1319 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++)
1320 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++)
1321 if (
s->prediction_mode[
ch][band])
1322 s->prediction_vq_index[
ch][band] =
get_bits(&
s->gb, 12);
1325 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1326 int sel =
s->bit_allocation_sel[
ch];
1329 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++) {
1334 abits =
get_bits(&
s->gb, 3 +
s->x96_high_res);
1336 if (abits < 0 || abits > 7 + 8 *
s->x96_high_res) {
1341 s->bit_allocation[
ch][band] = abits;
1346 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1347 int sel =
s->scale_factor_sel[
ch];
1348 int scale_index = 0;
1352 for (band =
s->x96_subband_start; band < s->nsubbands[
ch]; band++) {
1355 s->scale_factors[
ch][band >> 1][band & 1] =
ret;
1360 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1361 if (
s->joint_intensity_index[
ch]) {
1363 if (
s->joint_scale_sel[
ch] == 7) {
1371 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1372 int src_ch =
s->joint_intensity_index[
ch] - 1;
1374 int sel =
s->joint_scale_sel[
ch];
1375 for (band =
s->nsubbands[
ch]; band < s->nsubbands[src_ch]; band++) {
1378 s->joint_scale_factors[
ch][band] =
ret;
1402 if (
s->x96_crc_present
1413 if (
s->x96_rev_no < 8) {
1415 if (
s->x96_subband_start > 27) {
1416 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid X96 subband start index (%d)\n",
s->x96_subband_start);
1424 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1433 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1436 if (
n >
s->x96_nchannels) {
1440 s->joint_intensity_index[
ch] =
n;
1444 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1446 if (
s->scale_factor_sel[
ch] >= 6) {
1453 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++)
1457 for (
n = 0;
n < 6 + 4 *
s->x96_high_res;
n++)
1458 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++)
1479 int sf,
ch,
ret, band, sub_pos;
1484 for (sf = 0, sub_pos = 0; sf <
s->nsubframes; sf++) {
1491 for (
ch = xch_base;
ch <
s->x96_nchannels;
ch++) {
1493 int nsubbands =
s->nsubbands[
ch];
1494 if (
s->joint_intensity_index[
ch])
1495 nsubbands =
FFMAX(nsubbands,
s->nsubbands[
s->joint_intensity_index[
ch] - 1]);
1500 if (band >=
s->x96_subband_start && band < nsubbands)
1518 if (
s->x96_rev_no < 1 ||
s->x96_rev_no > 8) {
1523 s->x96_crc_present = 0;
1524 s->x96_nchannels =
s->nchannels;
1545 int x96_nchsets, x96_base_ch;
1558 if (
ff_dca_check_crc(
s->avctx, &
s->gb, header_pos + 32, header_pos + header_size * 8)) {
1565 if (
s->x96_rev_no < 1 ||
s->x96_rev_no > 8) {
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++)
1596 s->x96_nchannels = 0;
1597 for (
i = 0, x96_base_ch = 0;
i < x96_nchsets;
i++) {
1600 if (x96_base_ch + x96_nchannels[
i] <=
s->nchannels) {
1601 s->x96_nchannels = x96_base_ch + x96_nchannels[
i];
1606 x96_base_ch += x96_nchannels[
i];
1658 for (
i = 0;
i < m *
n;
i++) {
1660 int sign = (
code >> 8) - 1;
1700 s->prim_dmix_embedded = 0;
1703 if (
s->ext_audio_present && !dca->
core_only) {
1704 int sync_pos =
FFMIN(
s->frame_size / 4,
s->gb.size_in_bits / 32) - 1;
1707 uint32_t w1, w2 = 0;
1712 switch (
s->ext_audio_type) {
1722 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1723 w1 =
AV_RB32(
s->gb.buffer + sync_pos * 4);
1725 size = (w2 >> 22) + 1;
1726 dist =
s->frame_size - sync_pos * 4;
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) {
1748 w1 =
AV_RB32(
s->gb.buffer + sync_pos * 4);
1750 size = (w2 >> 20) + 1;
1751 dist =
s->frame_size - sync_pos * 4;
1753 s->x96_pos = sync_pos * 32 + 44;
1772 for (; sync_pos >= last_pos; sync_pos--, w2 = w1) {
1773 w1 =
AV_RB32(
s->gb.buffer + sync_pos * 4);
1775 size = (w2 >> 26) + 1;
1776 dist =
s->gb.size_in_bits / 8 - sync_pos * 4;
1779 (sync_pos + 1) * 4,
size - 4)) {
1780 s->xxch_pos = sync_pos * 32;
1802 s->ext_audio_mask = 0;
1803 s->xch_pos =
s->xxch_pos =
s->x96_pos = 0;
1819 if (
s->frame_size >
size)
1820 s->frame_size =
size;
1836 int ret = 0, ext = 0;
1845 }
else if (
s->xxch_pos) {
1850 }
else if (
s->xch_pos) {
1866 s->ext_audio_mask |= ext;
1893 }
else if (
s->x96_pos) {
1917 if (
s->xxch_core_mask & (1
U << spkr))
1935 if (
s->xxch_spkr_mask & (1
U << spkr))
1946 memset(
s->dcadsp_data, 0,
sizeof(
s->dcadsp_data));
1947 s->output_history_lfe_fixed = 0;
1948 s->output_history_lfe_float = 0;
1953 if (
s->filter_mode !=
mode) {
1955 s->filter_mode =
mode;
1961 int n,
ch, spkr, nsamples, x96_nchannels = 0;
1970 x96_nchannels =
s->x96_nchannels;
1976 s->output_rate =
s->sample_rate << x96_synth;
1981 nsamples * av_popcount(
s->ch_mask) *
sizeof(
int32_t));
1982 if (!
s->output_buffer)
1987 if (
s->ch_mask & (1
U << spkr)) {
1988 s->output_samples[spkr] = ptr;
1991 s->output_samples[spkr] =
NULL;
2001 else if (
s->filter_perfect)
2007 for (
ch = 0;
ch <
s->nchannels;
ch++) {
2014 s->dcadsp->sub_qmf_fixed[x96_synth](
2017 s->output_samples[spkr],
2018 s->subband_samples[
ch],
2019 ch < x96_nchannels ?
s->x96_subband_samples[
ch] :
NULL,
2020 s->dcadsp_data[
ch].u.fix.hist1,
2021 &
s->dcadsp_data[
ch].offset,
2022 s->dcadsp_data[
ch].u.fix.hist2,
2028 if (
s->lfe_present) {
2030 int nlfesamples =
s->npcmblocks >> 1;
2050 samples, &
s->output_history_lfe_fixed,
2057 s->lfe_samples[
n] =
s->lfe_samples[nlfesamples +
n];
2067 int i,
n,
ch,
ret, spkr, nsamples;
2077 frame->nb_samples = nsamples =
s->npcmsamples;
2093 &&
s->xxch_dmix_embedded) {
2094 int scale_inv =
s->xxch_dmix_scale_inv;
2095 int *coeff_ptr =
s->xxch_dmix_coeff;
2100 for (spkr = 0; spkr <
s->xxch_mask_nbits; spkr++) {
2101 if (
s->xxch_core_mask & (1
U << spkr)) {
2102 s->dcadsp->dmix_scale_inv(
s->output_samples[spkr],
2103 scale_inv, nsamples);
2108 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
2112 for (spkr = 0; spkr <
s->xxch_mask_nbits; spkr++) {
2113 if (
s->xxch_dmix_mask[
ch - xch_base] & (1
U << spkr)) {
2116 s->dcadsp->dmix_sub(
s->output_samples[spkr ],
2117 s->output_samples[src_spkr],
2143 if (
s->request_mask !=
s->ch_mask) {
2147 nsamples,
s->ch_mask);
2153 for (
n = 0;
n < nsamples;
n++)
2163 int x96_nchannels = 0, x96_synth = 0;
2164 int i,
n,
ch,
ret, spkr, nsamples, nchannels;
2166 const float *filter_coeff;
2169 x96_nchannels =
s->x96_nchannels;
2183 output_samples[
s->ch_remap[
i]] = (
float *)
frame->extended_data[
i];
2186 nchannels = av_popcount(
s->ch_mask) - avctx->
channels;
2187 if (nchannels > 0) {
2189 nsamples * nchannels *
sizeof(
float));
2190 if (!
s->output_buffer)
2193 ptr = (
float *)
s->output_buffer;
2195 if (!(
s->ch_mask & (1
U << spkr)))
2197 if (output_samples[spkr])
2199 output_samples[spkr] = ptr;
2210 else if (
s->filter_perfect)
2216 for (
ch = 0;
ch <
s->nchannels;
ch++) {
2223 s->dcadsp->sub_qmf_float[x96_synth](
2225 &
s->imdct[x96_synth],
2226 output_samples[spkr],
2227 s->subband_samples[
ch],
2228 ch < x96_nchannels ?
s->x96_subband_samples[
ch] :
NULL,
2229 s->dcadsp_data[
ch].u.flt.hist1,
2230 &
s->dcadsp_data[
ch].offset,
2231 s->dcadsp_data[
ch].u.flt.hist2,
2234 1.0f / (1 << (17 - x96_synth)));
2238 if (
s->lfe_present) {
2241 int nlfesamples =
s->npcmblocks >> (dec_select + 1);
2254 s->dcadsp->lfe_fir_float[dec_select](
2256 filter_coeff,
s->npcmblocks);
2262 samples, &
s->output_history_lfe_float,
2268 s->lfe_samples[
n] =
s->lfe_samples[nlfesamples +
n];
2284 &&
s->xxch_dmix_embedded) {
2285 float scale_inv =
s->xxch_dmix_scale_inv * (1.0f / (1 << 16));
2286 int *coeff_ptr =
s->xxch_dmix_coeff;
2291 for (
ch = xch_base;
ch <
s->nchannels;
ch++) {
2295 for (spkr = 0; spkr <
s->xxch_mask_nbits; spkr++) {
2296 if (
s->xxch_dmix_mask[
ch - xch_base] & (1
U << spkr)) {
2297 int coeff = *coeff_ptr++;
2299 s->float_dsp->vector_fmac_scalar(output_samples[ spkr],
2300 output_samples[src_spkr],
2301 coeff * (-1.0
f / (1 << 15)),
2309 for (spkr = 0; spkr <
s->xxch_mask_nbits; spkr++) {
2310 if (
s->xxch_core_mask & (1
U << spkr)) {
2311 s->float_dsp->vector_fmul_scalar(output_samples[spkr],
2312 output_samples[spkr],
2313 scale_inv, nsamples);
2336 if (
s->request_mask !=
s->ch_mask) {
2339 nsamples,
s->ch_mask);
2360 s->request_mask =
s->ch_mask;
2401 if (
s->subband_buffer) {
2406 if (
s->x96_subband_buffer)
2439 s->subband_size = 0;
2442 s->x96_subband_size = 0;
@ AV_SAMPLE_FMT_FLTP
float, planar
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
const int8_t ff_dca_high_freq_vq[1024][32]
static int parse_xch_frame(DCACoreDecoder *s)
static int alloc_x96_sample_buffer(DCACoreDecoder *s)
int sample_rate
samples per second
int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset)
#define DCA_SPEAKER_LAYOUT_5POINT0
static int dca_get_vlc(GetBitContext *s, DCAVLC *v, int i)
static int parse_aux_data(DCACoreDecoder *s)
av_cold void ff_dca_core_close(DCACoreDecoder *s)
const uint32_t ff_dca_bit_rates[32]
int offset
Code values offset.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_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), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;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)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8: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);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=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) { int planes=out->planar ? out->ch_count :1;unsigned m=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){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static int parse_xxch_frame(DCACoreDecoder *s)
static int get_bits_count(const GetBitContext *s)
static int parse_x96_subframe_audio(DCACoreDecoder *s, int sf, int xch_base, int *sub_pos)
static int parse_x96_frame_exss(DCACoreDecoder *s)
This structure describes decoded (raw) audio or video data.
int x96_size
Size of X96 extension in extension substream.
const uint32_t ff_dca_lossy_quant[32]
static int map_prm_ch_to_spkr(DCACoreDecoder *s, int ch)
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
#define DCA_SPEAKER_LAYOUT_STEREO
int request_channel_layout
Converted from avctx.request_channel_layout.
const float ff_dca_fir_64bands[1024]
static int ff_dca_seek_bits(GetBitContext *s, int p)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
@ DCA_AMODE_STEREO_SUMDIFF
#define DCA_SUBBAND_SAMPLES
static int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, int p1, int p2)
static int32_t mul23(int32_t a, int32_t b)
#define DCA_FILTER_MODE_FIXED
static int parse_x96_frame_data(DCACoreDecoder *s, int exss, int xch_base)
static int parse_coding_header(DCACoreDecoder *s, enum HeaderType header, int xch_base)
#define FF_DCA_DMIXTABLE_OFFSET
static int parse_block_codes(DCACoreDecoder *s, int32_t *audio, int abits)
static void erase_adpcm_history(DCACoreDecoder *s)
int xbr_size
Size of XBR extension in extension substream.
static void skip_bits(GetBitContext *s, int n)
int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
av_cold void ff_synth_filter_init(SynthFilterContext *c)
const float ff_dca_lfe_fir_128[256]
DCAVLC ff_dca_vlc_transition_mode
int core_only
Core only decoding flag.
const float ff_dca_fir_32bands_nonperfect[512]
static int parse_x96_subframe_header(DCACoreDecoder *s, int xch_base)
const uint8_t ff_dca_quant_index_group_size[DCA_CODE_BOOKS]
static int32_t mul31(int32_t a, int32_t b)
@ DCA_PARSE_ERROR_FRAME_SIZE
#define FF_PROFILE_DTS_HD_HRA
int flags
AV_CODEC_FLAG_*.
void ff_dca_downmix_to_stereo_float(AVFloatDSPContext *fdsp, float **samples, int *coeff_l, int nsamples, int ch_mask)
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)
const uint32_t ff_dca_quant_levels[32]
static int32_t clip23(int32_t a)
AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact)
Allocate and initialize a fixed DSP context.
static int parse_optional_info(DCACoreDecoder *s)
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)
DCAExssParser exss
EXSS parser context.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_MATRIX_ENCODING_DOLBY
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int64_t ff_dcaadpcm_predict(int pred_vq_index, const int32_t *input)
static const uint16_t mask[17]
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
const int32_t ff_dca_lfe_fir_64_fixed[256]
int max_depth
Parameter for get_vlc2()
static int parse_xbr_frame(DCACoreDecoder *s)
static void set_filter_mode(DCACoreDecoder *s, int mode)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
static int get_sbits(GetBitContext *s, int n)
@ DCA_PARSE_ERROR_PCM_RES
static int32_t mul16(int32_t a, int32_t b)
#define DCA_SPEAKER_LAYOUT_3_0
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
static int alloc_sample_buffer(DCACoreDecoder *s)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
av_cold void ff_dcadct_init(DCADCTContext *c)
static int parse_x96_frame(DCACoreDecoder *s)
const uint32_t ff_dca_lossless_quant[32]
const uint8_t ff_dca_dmix_primary_nch[8]
const float ff_dca_lfe_fir_64[256]
static int parse_subframe_audio(DCACoreDecoder *s, int sf, enum HeaderType header, int xch_base, int *sub_pos, int *lfe_pos)
#define FF_PROFILE_DTS_ES
int64_t bit_rate
the average bitrate
static unsigned int get_bits1(GetBitContext *s)
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.
#define DCA_SPEAKER_LAYOUT_2_2
const int32_t ff_dca_fir_64bands_fixed[1024]
static int extract_audio(DCACoreDecoder *s, int32_t *audio, int abits, int ch)
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define DCA_SPEAKER_LAYOUT_MONO
static int rand_x96(DCACoreDecoder *s)
const uint32_t ff_dca_inv_dmixtable[FF_DCA_INV_DMIXTABLE_SIZE]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE]
const uint32_t ff_dca_scale_factor_quant7[128]
const uint8_t ff_dca_channels[16]
@ AV_MATRIX_ENCODING_NONE
enum AVSampleFormat sample_fmt
audio sample format
int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
#define DCA_SYNCWORD_XXCH
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
static const uint8_t block_code_nbits[7]
static void erase_dsp_history(DCACoreDecoder *s)
static const uint8_t header[24]
static int parse_scale(DCACoreDecoder *s, int *scale_index, int sel)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
DCAVLC ff_dca_vlc_scale_factor
@ DCA_PARSE_ERROR_DEFICIT_SAMPLES
int channels
number of audio channels
int ff_dca_parse_core_frame_header(DCACoreFrameHeader *h, GetBitContext *gb)
Parse and validate core frame header.
av_cold int ff_dca_core_init(DCACoreDecoder *s)
const uint8_t ff_dca_quant_index_sel_nbits[DCA_CODE_BOOKS]
static const int8_t prm_ch_to_spkr_map[DCA_AMODE_COUNT][5]
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
DCAVLC ff_dca_vlc_quant_index[DCA_CODE_BOOKS]
static const uint8_t audio_mode_ch_mask[DCA_AMODE_COUNT]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static int filter_frame_fixed(DCACoreDecoder *s, AVFrame *frame)
#define DCA_SPEAKER_LAYOUT_3_1
DCAExssAsset assets[1]
Audio asset descriptors.
#define DCA_EXSS_CHSETS_MAX
const uint32_t ff_dca_scale_factor_quant6[64]
int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth)
#define DCA_PCMBLOCK_SAMPLES
static int array[MAX_W *MAX_W]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
const int32_t ff_dca_fir_32bands_nonperfect_fixed[512]
#define FF_PROFILE_DTS_96_24
static int parse_frame_data(DCACoreDecoder *s, enum HeaderType header, int xch_base)
const uint8_t ff_dca_bits_per_sample[8]
static int filter_frame_float(DCACoreDecoder *s, AVFrame *frame)
#define DCA_SPEAKER_LAYOUT_2_1
static int parse_joint_scale(DCACoreDecoder *s, int sel)
#define FF_ARRAY_ELEMS(a)
static void ff_dca_core_dequantize(int32_t *output, const int32_t *input, int32_t step_size, int32_t scale, int residual, int len)
@ DCA_PARSE_ERROR_PCM_BLOCKS
static int parse_x96_coding_header(DCACoreDecoder *s, int exss, int xch_base)
main external API structure.
#define FF_DCA_DMIXTABLE_SIZE
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
@ DCA_PARSE_ERROR_LFE_FLAG
#define FF_DCA_INV_DMIXTABLE_SIZE
static int parse_huffman_codes(DCACoreDecoder *s, int32_t *audio, int abits, int sel)
Filter the word “frame” indicates either a video frame or a group of audio samples
#define DCA_EXSS_CHANNELS_MAX
#define DCA_XXCH_CHANNELS_MAX
@ DCA_PARSE_ERROR_SAMPLE_RATE
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
int x96_offset
Offset to X96 extension from start of substream.
@ DCA_PARSE_ERROR_RESERVED_BIT
static int parse_subframe_header(DCACoreDecoder *s, int sf, enum HeaderType header, int xch_base)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static int parse_frame_header(DCACoreDecoder *s)
#define avpriv_request_sample(...)
DCAVLC ff_dca_vlc_bit_allocation
int xbr_offset
Offset to XBR extension from start of substream.
const int32_t ff_dca_fir_32bands_perfect_fixed[512]
int extension_mask
Coding components used in asset.
static void get_array(GetBitContext *s, int32_t *array, int size, int n)
int xxch_size
Size of XXCH extension in extension substream.
const uint32_t ff_dca_joint_scale_factors[129]
const float ff_dca_fir_32bands_perfect[512]
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
const uint32_t ff_dca_scale_factor_adj[4]
static void erase_x96_adpcm_history(DCACoreDecoder *s)
static const double coeff[2][5]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int xxch_offset
Offset to XXCH extension from start of substream.
const uint32_t avpriv_dca_sample_rates[16]
static int decode_blockcodes(int code1, int code2, int levels, int32_t *audio)
VLC_TYPE(* table)[2]
code, bits
#define DCA_SYNCWORD_REV1AUX
av_cold void ff_dca_core_flush(DCACoreDecoder *s)