31#define DCA_XLL_X_HEADER_SIZE 22
32#define DCA_XLL_X_HEIGHT_FOLD 23170
33#define DCA_XLL_X_HEIGHT_MASK (DCA_SPEAKER_MASK_Lh | DCA_SPEAKER_MASK_Rh | \
34 DCA_SPEAKER_MASK_Lhr | DCA_SPEAKER_MASK_Rhr)
43 return (v >> 1) ^ -(v & 1);
55 return (v >> 1) ^ -(v & 1);
92 int i, j, *coeff_ptr =
c->dmix_coeff;
94 for (
i = 0;
i < m;
i++) {
95 int code, sign, coeff,
scale, scale_inv = 0;
99 if (!
c->primary_chset) {
101 sign = (
code >> 8) - 1;
109 c->dmix_scale[
i] = (
scale ^ sign) - sign;
110 c->dmix_scale_inv[
i] = (scale_inv ^ sign) - sign;
114 for (j = 0; j <
c->nchannels; j++) {
116 sign = (
code >> 8) - 1;
123 if (!
c->primary_chset)
125 coeff =
mul16(scale_inv, coeff);
126 *coeff_ptr++ = (coeff ^ sign) - sign;
154 if (
c == &
s->x_chset &&
c->nchannels != 4) {
160 c->residual_encode =
get_bits(&
s->gb,
c->nchannels);
167 if (
c->storage_bit_res != 16 &&
c->storage_bit_res != 20 &&
c->storage_bit_res != 24) {
172 if (
c->pcm_bit_res >
c->storage_bit_res) {
173 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid PCM bit resolution for XLL channel set (%d > %d)\n",
c->pcm_bit_res,
c->storage_bit_res);
179 if (
c->freq > 192000) {
196 if (
c == &
s->x_chset) {
203 c->primary_chset = 1;
204 c->dmix_coeffs_present = 0;
205 c->dmix_embedded = 0;
208 for (
i = 0;
i < 4;
i++)
213 if (
c->primary_chset != (
c == p)) {
222 c->dmix_embedded =
c->dmix_coeffs_present &&
get_bits1(&
s->gb);
225 if (
c->dmix_coeffs_present &&
c->primary_chset) {
235 if (!
c->hier_chset &&
s->nchsets != 1) {
258 for (
i = 0, j = 0;
i <
s->ch_mask_nbits;
i++)
259 if (
c->ch_mask & (1U <<
i))
260 c->ch_remap[j++] =
i;
263 if (
c->nchannels != 2 ||
s->nchsets != 1 ||
get_bits1(&
s->gb)) {
269 c->primary_chset = 1;
270 c->dmix_coeffs_present = 0;
271 c->dmix_embedded = 0;
278 if (
c->freq > 96000) {
291 c->freq >>=
c->nfreqbands - 1;
295 if (
c != p && (
c->nfreqbands != p->nfreqbands ||
c->freq != p->freq
296 || (
c->pcm_bit_res != p->pcm_bit_res &&
297 (
c != &
s->x_chset ||
c->pcm_bit_res > p->pcm_bit_res))
298 ||
c->storage_bit_res != p->storage_bit_res)) {
304 if (
c->storage_bit_res > 16)
306 else if (
c->storage_bit_res > 8)
312 if ((
s->nchsets > 1 ||
c->nfreqbands > 1) &&
c->nabits < 5)
315 for (band = 0,
b =
c->bands; band < c->nfreqbands; band++,
b++) {
317 if ((
b->decor_enabled =
get_bits1(&
s->gb)) &&
c->nchannels > 1) {
321 for (
i = 0;
i <
c->nchannels;
i++) {
323 if (
b->orig_order[
i] >=
c->nchannels) {
330 for (
i = 0;
i <
c->nchannels / 2;
i++)
333 for (
i = 0;
i <
c->nchannels;
i++)
334 b->orig_order[
i] =
i;
335 for (
i = 0;
i <
c->nchannels / 2;
i++)
336 b->decor_coeff[
i] = 0;
340 b->highest_pred_order = 0;
341 for (
i = 0;
i <
c->nchannels;
i++) {
343 if (
b->adapt_pred_order[
i] >
b->highest_pred_order)
344 b->highest_pred_order =
b->adapt_pred_order[
i];
346 if (
b->highest_pred_order >
s->nsegsamples) {
352 for (
i = 0;
i <
c->nchannels;
i++)
353 b->fixed_pred_order[
i] =
b->adapt_pred_order[
i] ? 0 :
get_bits(&
s->gb, 2);
356 for (
i = 0;
i <
c->nchannels;
i++) {
357 for (j = 0; j <
b->adapt_pred_order[
i]; j++) {
371 b->dmix_embedded =
c->dmix_embedded && (band == 0 ||
get_bits1(&
s->gb));
374 if ((band == 0 &&
s->scalable_lsbs) || (band != 0 &&
get_bits1(&
s->gb))) {
377 if (
b->lsb_section_size < 0 ||
b->lsb_section_size >
s->frame_size) {
383 if (
b->lsb_section_size && (
s->band_crc_present > 2 ||
384 (band == 0 &&
s->band_crc_present > 1)))
385 b->lsb_section_size += 2;
388 for (
i = 0;
i <
c->nchannels;
i++) {
390 if (
b->nscalablelsbs[
i] && !
b->lsb_section_size) {
396 b->lsb_section_size = 0;
397 for (
i = 0;
i <
c->nchannels;
i++)
398 b->nscalablelsbs[
i] = 0;
402 if ((band == 0 &&
s->scalable_lsbs) || (band != 0 &&
get_bits1(&
s->gb))) {
404 for (
i = 0;
i <
c->nchannels;
i++)
407 for (
i = 0;
i <
c->nchannels;
i++)
408 b->bit_width_adjust[
i] = 0;
426 int nchsamples =
s->nframesamples + ndecisamples;
427 int i, j, nsamples = nchsamples *
c->nchannels *
c->nfreqbands;
432 if (!
c->sample_buffer[0])
435 ptr =
c->sample_buffer[0] + ndecisamples;
436 for (
i = 0;
i <
c->nfreqbands;
i++) {
437 for (j = 0; j <
c->nchannels; j++) {
438 c->bands[
i].msb_sample_buffer[j] = ptr;
448 int i, j, nsamples = 0;
452 for (
i = 0;
i <
c->nfreqbands;
i++)
453 if (
c->bands[
i].lsb_section_size)
454 nsamples +=
s->nframesamples *
c->nchannels;
460 if (!
c->sample_buffer[1])
463 ptr =
c->sample_buffer[1];
464 for (
i = 0;
i <
c->nfreqbands;
i++) {
465 if (
c->bands[
i].lsb_section_size) {
466 for (j = 0; j <
c->nchannels; j++) {
467 c->bands[
i].lsb_sample_buffer[j] = ptr;
468 ptr +=
s->nframesamples;
471 for (j = 0; j <
c->nchannels; j++)
472 c->bands[
i].lsb_sample_buffer[j] =
NULL;
492 k =
c->seg_common ? 1 :
c->nchannels;
495 for (
i = 0;
i < k;
i++) {
501 if (!
c->seg_common &&
c->rice_code_flag[
i] &&
get_bits1(&
s->gb))
503 c->bitalloc_hybrid_linear[
i] =
get_bits(&
s->gb,
c->nabits) + 1;
506 c->bitalloc_hybrid_linear[
i] = 0;
510 for (
i = 0;
i < k;
i++) {
516 if (!
c->rice_code_flag[
i] &&
c->bitalloc_part_a[
i])
517 c->bitalloc_part_a[
i]++;
520 c->nsamples_part_a[
i] =
b->adapt_pred_order[
i];
522 c->nsamples_part_a[
i] =
b->highest_pred_order;
524 c->bitalloc_part_a[
i] = 0;
525 c->nsamples_part_a[
i] = 0;
532 if (!
c->rice_code_flag[
i] &&
c->bitalloc_part_b[
i])
533 c->bitalloc_part_b[
i]++;
538 for (
i = 0;
i <
c->nchannels;
i++) {
543 k =
c->seg_common ? 0 :
i;
546 part_a =
b->msb_sample_buffer[
i] + seg *
s->nsegsamples;
547 part_b = part_a +
c->nsamples_part_a[k];
548 nsamples_part_b =
s->nsegsamples -
c->nsamples_part_a[k];
553 if (!
c->rice_code_flag[k]) {
557 c->bitalloc_part_a[k]);
561 c->bitalloc_part_b[k]);
566 c->bitalloc_part_a[k]);
570 if (
c->bitalloc_hybrid_linear[k]) {
573 int nisosamples =
get_bits(&
s->gb,
s->nsegsamples_log2);
576 memset(part_b, 0,
sizeof(*part_b) * nsamples_part_b);
579 for (j = 0; j < nisosamples; j++) {
580 int loc =
get_bits(&
s->gb,
s->nsegsamples_log2);
581 if (loc >= nsamples_part_b) {
589 for (j = 0; j < nsamples_part_b; j++) {
591 part_b[j] =
get_linear(&
s->gb,
c->bitalloc_hybrid_linear[k]);
593 part_b[j] =
get_rice(&
s->gb,
c->bitalloc_part_b[k]);
606 if (seg == 0 && band == 1) {
608 for (
i = 0;
i <
c->nchannels;
i++)
614 if (
b->lsb_section_size) {
622 for (
i = 0;
i <
c->nchannels;
i++) {
623 if (
b->nscalablelsbs[
i]) {
625 b->lsb_sample_buffer[
i] + seg *
s->nsegsamples,
626 s->nsegsamples,
b->nscalablelsbs[
i]);
647 nsamples =
s->nframesamples;
650 nsamples =
s->nsegsamples;
653 for (
i = 0;
i <
c->nchannels;
i++) {
654 memset(
b->msb_sample_buffer[
i] +
offset, 0, nsamples *
sizeof(
int32_t));
655 if (
b->lsb_section_size)
656 memset(
b->lsb_sample_buffer[
i] +
offset, 0, nsamples *
sizeof(
int32_t));
659 if (seg <= 0 && band)
660 memset(
c->deci_history, 0,
sizeof(
c->deci_history));
663 memset(
b->nscalablelsbs, 0,
sizeof(
b->nscalablelsbs));
664 memset(
b->bit_width_adjust, 0,
sizeof(
b->bit_width_adjust));
671 int nsamples =
s->nframesamples;
675 for (
i = 0;
i <
c->nchannels;
i++) {
677 int order =
b->adapt_pred_order[
i];
681 for (j = 0; j < order; j++) {
682 int rc =
b->adapt_refl_coeff[
i][j];
683 for (k = 0; k < (j + 1) / 2; k++) {
684 int tmp1 = coeff[ k ];
685 int tmp2 = coeff[j - k - 1];
686 coeff[ k ] = tmp1 +
mul16(rc, tmp2);
687 coeff[j - k - 1] = tmp2 +
mul16(rc, tmp1);
692 for (j = 0; j < nsamples - order; j++) {
694 for (k = 0; k < order; k++)
695 err += (
int64_t)buf[j + k] * coeff[order - k - 1];
700 for (j = 0; j <
b->fixed_pred_order[
i]; j++)
701 for (k = 1; k < nsamples; k++)
702 buf[k] += (
unsigned)buf[k - 1];
707 if (
b->decor_enabled) {
710 for (
i = 0;
i <
c->nchannels / 2;
i++) {
711 int coeff =
b->decor_coeff[
i];
713 s->dcadsp->decor(
b->msb_sample_buffer[
i * 2 + 1],
714 b->msb_sample_buffer[
i * 2 ],
720 for (
i = 0;
i <
c->nchannels;
i++)
721 tmp[
i] =
b->msb_sample_buffer[
i];
723 for (
i = 0;
i <
c->nchannels;
i++)
724 b->msb_sample_buffer[
b->orig_order[
i]] =
tmp[
i];
728 if (
c->nfreqbands == 1)
729 for (
i = 0;
i <
c->nchannels;
i++)
730 s->output_samples[
c->ch_remap[
i]] =
b->msb_sample_buffer[
i];
735 int adj =
c->bands[band].bit_width_adjust[ch];
736 int shift =
c->bands[band].nscalablelsbs[ch];
738 if (
s->fixed_lsb_width)
739 shift =
s->fixed_lsb_width;
740 else if (
shift && adj)
751 int n, ch, nsamples =
s->nframesamples;
753 for (ch = 0; ch <
c->nchannels; ch++) {
756 int32_t *msb =
b->msb_sample_buffer[ch];
757 if (
b->nscalablelsbs[ch]) {
758 int32_t *lsb =
b->lsb_sample_buffer[ch];
759 int adj =
b->bit_width_adjust[ch];
760 for (n = 0; n < nsamples; n++)
761 msb[n] = msb[n] * (
SUINT)(1 <<
shift) + (lsb[n] << adj);
763 for (n = 0; n < nsamples; n++)
772 int ch, nsamples =
s->nframesamples;
779 2 * nsamples *
c->nchannels *
sizeof(
int32_t));
780 if (!
c->sample_buffer[2])
784 ptr =
c->sample_buffer[2];
785 for (ch = 0; ch <
c->nchannels; ch++) {
786 int32_t *band0 =
c->bands[0].msb_sample_buffer[ch];
787 int32_t *band1 =
c->bands[1].msb_sample_buffer[ch];
791 c->deci_history[ch],
sizeof(
c->deci_history[0]));
794 s->dcadsp->assemble_freq_bands(ptr, band0, band1,
799 s->output_samples[
c->ch_remap[ch]] = ptr;
808 int stream_ver, header_size, frame_size_nbits, nframesegs_log2;
818 if (stream_ver > 1) {
833 frame_size_nbits =
get_bits(&
s->gb, 5) + 1;
852 s->nframesegs = 1 << nframesegs_log2;
853 if (
s->nframesegs > 1024) {
862 if (!
s->nsegsamples_log2) {
866 s->nsegsamples = 1 <<
s->nsegsamples_log2;
867 if (
s->nsegsamples > 512) {
873 s->nframesamples_log2 =
s->nsegsamples_log2 + nframesegs_log2;
874 s->nframesamples = 1 <<
s->nframesamples_log2;
875 if (
s->nframesamples > 65536) {
897 if (
s->scalable_lsbs)
900 s->fixed_lsb_width = 0;
915 return !
c->primary_chset &&
c->dmix_embedded &&
c->hier_chset;
930 int i, j, *coeff_ptr =
c->dmix_coeff;
932 for (
i = 0;
i <
c->hier_ofs;
i++) {
936 c->dmix_scale_inv[
i] =
mul16(
c->dmix_scale_inv[
i], scale_inv);
937 for (j = 0; j <
c->nchannels; j++) {
938 int coeff =
mul16(*coeff_ptr, scale_inv);
955 c->hier_ofs =
s->nchannels;
958 if (
c->nfreqbands >
s->nfreqbands)
959 s->nfreqbands =
c->nfreqbands;
961 s->nchannels +=
c->nchannels;
962 if (
c->residual_encode != (1 <<
c->nchannels) - 1)
967 for (
i =
s->nchsets - 1,
c = &
s->chset[
i];
i > 0;
i--,
c--) {
978 s->nactivechsets = 1;
982 s->nactivechsets = (
s->chset[0].nchannels < 5 &&
s->nchsets > 1) ? 2 : 1;
985 s->nactivechsets =
s->nchsets;
994 int chs, seg, band, navi_nb, navi_pos, *navi_ptr;
998 navi_nb =
s->nfreqbands *
s->nframesegs *
s->nchsets;
999 if (navi_nb > 1024) {
1012 for (band = 0; band <
s->nfreqbands; band++) {
1013 for (seg = 0; seg <
s->nframesegs; seg++) {
1014 for (chs = 0,
c =
s->chset; chs < s->nchsets; chs++,
c++) {
1016 if (
c->nfreqbands > band) {
1045 int ret, chs, seg, band, navi_pos, *navi_ptr;
1048 for (chs = 0,
c =
s->chset; chs < s->nactivechsets; chs++,
c++) {
1057 for (band = 0; band <
s->nfreqbands; band++) {
1058 for (seg = 0; seg <
s->nframesegs; seg++) {
1059 for (chs = 0,
c =
s->chset; chs < s->nchsets; chs++,
c++) {
1060 if (
c->nfreqbands > band) {
1061 navi_pos += *navi_ptr * 8;
1062 if (navi_pos >
s->gb.size_in_bits) {
1066 if (chs < s->nactivechsets &&
1090 int ret, seg, navi_pos, band_pos, navi[1024];
1092 if (
s->nfreqbands != 1)
1102 if (
c->residual_encode != (1 <<
c->nchannels) - 1) {
1108 for (seg = 0; seg <
s->nframesegs; seg++) {
1110 if (navi[seg] < 0 || navi[seg] >=
s->frame_size) {
1111 av_log(
s->avctx,
AV_LOG_ERROR,
"Invalid DTS:X NAVI segment size (%d bytes)\n", navi[seg]);
1129 for (seg = 0; seg <
s->nframesegs; seg++) {
1130 band_pos += navi[seg] * 8;
1131 if (band_pos >
s->frame_size * 8) {
1141 if (
s->frame_size * 8 - band_pos > 5 * 8) {
1142 av_log(
s->avctx,
AV_LOG_ERROR,
"DTS:X height channel set ends %d bytes before its frame\n",
1143 s->frame_size - band_pos / 8);
1166 s->x_heights_decoded = 0;
1168 unsigned int extradata_syncword;
1176 s->x_syncword_present = 1;
1188 s->x_heights_decoded = 1;
1192 s->x_imax_syncword_present = 1;
1219 s->pbr_length =
size;
1220 s->pbr_delay = delay;
1251 if (
s->frame_size >
size)
1255 if (
s->frame_size <
size)
1271 memcpy(
s->pbr_buffer +
s->pbr_length,
data,
size);
1272 s->pbr_length +=
size;
1276 if (
s->pbr_delay > 0 && --
s->pbr_delay)
1282 if (
s->frame_size >
s->pbr_length) {
1287 if (
s->frame_size ==
s->pbr_length) {
1291 s->pbr_length -=
s->frame_size;
1292 memmove(
s->pbr_buffer,
s->pbr_buffer +
s->frame_size,
s->pbr_length);
1324 int i, j, k, nchannels = 0, *coeff_ptr = o->
dmix_coeff;
1327 for (
i = 0,
c =
s->chset;
i < s->nactivechsets;
i++,
c++) {
1332 for (j = 0; j <
c->nchannels; j++) {
1334 int coeff = *coeff_ptr++;
1336 s->dcadsp->dmix_sub(
c->bands[band].msb_sample_buffer[j],
1338 coeff,
s->nframesamples);
1340 s->dcadsp->dmix_sub(
c->deci_history[j],
1347 nchannels +=
c->nchannels;
1355 int i, j, nchannels = 0;
1358 for (
i = 0,
c =
s->chset;
i < s->nactivechsets;
i++,
c++) {
1363 for (j = 0; j <
c->nchannels; j++) {
1365 if (
scale != (1 << 15)) {
1366 s->dcadsp->dmix_scale(
c->bands[band].msb_sample_buffer[j],
1367 scale,
s->nframesamples);
1369 s->dcadsp->dmix_scale(
c->deci_history[j],
1386 for (band = 0; band <
c->nfreqbands; band++)
1389 for (ch = 0; ch <
c->nchannels; ch++) {
1390 if (!(
c->residual_encode & (1 << ch)))
1394 c->residual_encode &= ~(1 << ch);
1401 int ch, nsamples =
s->nframesamples;
1426 for (ch = 0; ch <
c->nchannels; ch++) {
1427 int n, spkr,
shift, round;
1430 if (
c->residual_encode & (1 << ch))
1436 av_log(
s->avctx,
AV_LOG_WARNING,
"Residual encoded channel (%d) references unavailable core channel\n",
c->ch_remap[ch]);
1450 dst =
c->bands[0].msb_sample_buffer[ch];
1454 for (n = 0; n < nsamples; n++)
1458 for (n = 0; n < nsamples; n++)
1473 int i, j, k,
ret,
shift, nsamples, request_mask, x_fold = 0;
1475 static const uint8_t fold_spkr[4] = {
1485 if (!
c->primary_chset)
1486 c->dmix_embedded = 0;
1489 s->scalable_lsbs = 0;
1490 s->fixed_lsb_width = 0;
1495 for (
i = 0,
c =
s->chset;
i < s->nactivechsets;
i++,
c++) {
1498 if (
c->residual_encode != (1 <<
c->nchannels) - 1
1502 if (
s->scalable_lsbs)
1505 if (
c->nfreqbands > 1) {
1510 s->output_mask |=
c->ch_mask;
1514 for (
i = 1,
c = &
s->chset[1];
i < s->nchsets;
i++,
c++) {
1518 if (
i >=
s->nactivechsets) {
1519 for (j = 0; j <
c->nfreqbands; j++)
1520 if (
c->bands[j].dmix_embedded)
1525 for (j = 0; j <
c->nfreqbands; j++)
1526 if (
c->bands[j].dmix_embedded)
1531 if (
s->nfreqbands > 1) {
1532 for (
i = 0;
i <
s->nactivechsets;
i++)
1550 if (
s->scalable_lsbs)
1554 for (
i = 0;
i < 4;
i++) {
1556 for (k = 0; k <
s->nframesamples; k++)
1563 s->nframesamples *
sizeof(*
s->x_silence));
1566 memset(
s->x_silence, 0,
s->nframesamples *
sizeof(*
s->x_silence));
1567 for (
i = 0;
i < 4;
i++)
1593 request_mask =
s->output_mask;
1599 switch (p->storage_bit_res) {
1602 shift = 16 - p->pcm_bit_res;
1607 shift = 24 - p->pcm_bit_res;
1617 for (
i = 0;
i < 4;
i++) {
1619 int32_t *bed =
s->output_samples[fold_spkr[
i]];
1620 for (k = 0; k <
s->nframesamples; k++) {
1628 if (
s->x_imax_syncword_present) {
1630 }
else if (
s->x_syncword_present) {
1639 frame->nb_samples = nsamples =
s->nframesamples << (
s->nfreqbands - 1);
1644 if (request_mask !=
s->output_mask) {
1646 p->dmix_coeff, nsamples,
1651 int32_t *samples =
s->output_samples[ch_remap[
i]];
1652 int ch_shift =
shift;
1657 int16_t *plane = (int16_t *)
frame->extended_data[
i];
1658 for (k = 0; k < nsamples; k++)
1662 for (k = 0; k < nsamples; k++)
1663 plane[k] =
clip23(samples[k] * (
SUINT)(1 << ch_shift)) * (1 << 8);
1705 c->sample_size[j] = 0;
1711 s->x_chset.sample_size[j] = 0;
1714 s->x_silence_size = 0;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
const uint32_t ff_dca_sampling_freqs[16]
#define DCA_SPEAKER_LAYOUT_5POINT0
#define DCA_SPEAKER_LAYOUT_STEREO
#define DCA_HAS_STEREO(mask)
#define DCA_SPEAKER_LAYOUT_3_0
#define DCA_SPEAKER_LAYOUT_5POINT1
static int ff_dca_core_map_spkr(DCACoreDecoder *core, int spkr)
#define DCA_SYNCWORD_XLL_X_IMAX
#define DCA_SYNCWORD_XLL_X
static int combine_residual_frame(DCAXllDecoder *s, DCAXllChSet *c)
static int get_rice(GetBitContext *gb, int k)
static int parse_navi_table(DCAXllDecoder *s)
#define DCA_XLL_X_HEIGHT_MASK
int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame)
static int parse_sub_headers(DCAXllDecoder *s, DCAExssAsset *asset)
static void prescale_down_mix(DCAXllChSet *c, DCAXllChSet *o)
static int get_rice_array(GetBitContext *gb, int32_t *array, int size, int k)
static const uint8_t x_height_spkr[4]
int ff_dca_xll_parse(DCAXllDecoder *s, const uint8_t *data, DCAExssAsset *asset)
static void chs_filter_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band)
static int chs_assemble_freq_bands(DCAXllDecoder *s, DCAXllChSet *c)
#define DCA_XLL_X_HEADER_SIZE
static DCAXllChSet * find_next_hier_dmix_chset(DCAXllDecoder *s, DCAXllChSet *c)
static int parse_frame_no_pbr(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
static int parse_frame_pbr(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
static int parse_dmix_coeffs(DCAXllDecoder *s, DCAXllChSet *c)
static int chs_parse_header(DCAXllDecoder *s, DCAXllChSet *c, DCAExssAsset *asset)
static void clear_pbr(DCAXllDecoder *s)
static int parse_x_heights(DCAXllDecoder *s, DCAExssAsset *asset)
static int chs_alloc_msb_band_data(DCAXllDecoder *s, DCAXllChSet *c)
static int get_linear(GetBitContext *gb, int n)
static int get_rice_un(GetBitContext *gb, int k)
av_cold void ff_dca_xll_flush(DCAXllDecoder *s)
static int copy_to_pbr(DCAXllDecoder *s, const uint8_t *data, int size, int delay)
static void get_linear_array(GetBitContext *gb, int32_t *array, int size, int n)
static av_cold void chs_clear_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int seg)
static int chs_get_lsb_width(DCAXllDecoder *s, DCAXllChSet *c, int band, int ch)
static void scale_down_mix(DCAXllDecoder *s, DCAXllChSet *o, int band)
static void get_array(GetBitContext *gb, int32_t *array, int size, int n)
#define DCA_XLL_X_HEIGHT_FOLD
static void undo_down_mix(DCAXllDecoder *s, DCAXllChSet *o, int band)
static int parse_common_header(DCAXllDecoder *s)
static av_cold void force_lossy_output(DCAXllDecoder *s, DCAXllChSet *c)
static void chs_assemble_msbs_lsbs(DCAXllDecoder *s, DCAXllChSet *c, int band)
static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
static int is_hier_dmix_chset(DCAXllChSet *c)
static int chs_alloc_lsb_band_data(DCAXllDecoder *s, DCAXllChSet *c)
static int parse_band_data(DCAXllDecoder *s)
av_cold void ff_dca_xll_close(DCAXllDecoder *s)
static int chs_parse_band_data(DCAXllDecoder *s, DCAXllChSet *c, int band, int seg, int band_data_end)
#define DCA_XLL_CHANNELS_MAX
#define DCA_XLL_DECI_HISTORY_MAX
#define DCA_XLL_CHSETS_MAX
#define DCA_XLL_SAMPLE_BUFFERS_MAX
#define DCA_XLL_PBR_BUFFER_MAX
#define DCA_XLL_ADAPT_PRED_ORDER_MAX
const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE]
const uint16_t ff_dca_xll_refl_coeff[128]
const int32_t ff_dca_xll_band_coeff[20]
const uint8_t ff_dca_dmix_primary_nch[8]
const uint32_t ff_dca_inv_dmixtable[FF_DCA_INV_DMIXTABLE_SIZE]
#define FF_DCA_INV_DMIXTABLE_SIZE
#define FF_DCA_DMIXTABLE_SIZE
#define FF_DCA_DMIXTABLE_OFFSET
int ff_dca_export_downmix_matrix(AVCodecContext *avctx, AVFrame *frame, enum DCADownMixType downmix_type, int output_mask, const int *coeff_l)
int ff_dca_set_channel_layout(AVCodecContext *avctx, int *ch_remap, int dca_mask)
void ff_dca_downmix_to_stereo_fixed(DCADSPContext *dcadsp, int32_t **samples, int *coeff_l, int nsamples, int ch_mask)
#define DCA_PACKET_RECOVERY
Sync error recovery flag.
static int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s, int p1, int p2)
static int ff_dca_seek_bits(GetBitContext *s, int p)
static int32_t mul16(int32_t a, int32_t b)
static int32_t norm16(int64_t a)
static int32_t clip23(int32_t a)
static int32_t mul15(int32_t a, int32_t b)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
#define AV_PROFILE_DTS_HD_MA
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_PROFILE_DTS_HD_MA_X
#define AV_PROFILE_DTS_HD_MA_X_IMAX
static int get_sbits_long(GetBitContext *s, int n)
Read 0-32 bits as a signed integer.
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AV_MATRIX_ENCODING_NONE
@ AV_MATRIX_ENCODING_DOLBY
@ AV_MATRIX_ENCODING_DOLBYHEADPHONE
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
static av_always_inline void scale(vec_s32 res[4], vec_s16 res_packed[2], const int shift)
static int shift(int a, int b)
Memory handling functions.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int64_t bit_rate
the average bitrate
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int sample_rate
samples per second
This structure describes decoded (raw) audio or video data.
DCACoreDecoder core
Core decoder context.
DCAExssParser exss
EXSS parser context.
int request_channel_layout
Converted from avctx.request_channel_layout.
int x_bed_only
Keep a DTS:X 7.1 bed as coded, without its heights.
int npcmsamples
Number of PCM samples per channel.
int output_rate
Output sample rate (1x or 2x header rate)
int32_t * output_samples[DCA_SPEAKER_COUNT]
PCM output for fixed point mode.
int xll_offset
Offset to XLL data from start of substream.
int hd_stream_id
DTS-HD stream ID.
int xll_sync_present
XLL sync word present flag.
int xll_size
Size of XLL data in extension substream.
int xll_delay_nframes
Initial XLL decoding delay in frames.
int representation_type
Representation type.
int xll_sync_offset
Number of bytes offset to XLL sync.
int one_to_one_map_ch_to_spkr
One to one channel to speaker mapping flag.
DCAExssAsset assets[1]
Audio asset descriptors.
int32_t * msb_sample_buffer[DCA_XLL_CHANNELS_MAX]
MSB sample buffer pointers.
int32_t deci_history[DCA_XLL_CHANNELS_MAX][DCA_XLL_DECI_HISTORY_MAX]
Decimator history for frequency band 1.
int nchannels
Number of channels in the channel set (N)
int pcm_bit_res
PCM bit resolution (variable)
DCAXllBand bands[DCA_XLL_BANDS_MAX]
Frequency bands.
int dmix_scale[DCA_XLL_DMIX_SCALES_MAX]
Downmixing scales.
int dmix_coeff[DCA_XLL_DMIX_COEFFS_MAX]
Downmixing coefficients.
int dmix_scale_inv[DCA_XLL_DMIX_SCALES_MAX]
Inverse downmixing scales.
int hier_ofs
Number of preceding channels in a hierarchy (M)
#define avpriv_request_sample(...)
static int array[MAX_W *MAX_W]
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.