1 /*
2 * DCA encoder
3 * Copyright (C) 2008-2012 Alexander E. Patrakov
4 * 2010 Benjamin Larsson
5 * 2011 Xiang Wang
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
42
43 #define MAX_CHANNELS 6
44 #define DCA_MAX_FRAME_SIZE 16384
45 #define DCA_HEADER_SIZE 13
46 #define DCA_LFE_SAMPLES 8
47
48 #define DCAENC_SUBBANDS 32
50 #define SUBSUBFRAMES 2
51 #define SUBBAND_SAMPLES (SUBFRAMES * SUBSUBFRAMES * 8)
53
54 #define COS_T(x) (c->cos_table[(x) & 2047])
55
59
81
102
111
112 /* Transfer function of outer and middle ear, Hz -> dB */
114 {
115 double f1 =
f / 1000;
116
117 return -3.64 * pow(f1, -0.8)
118 + 6.8 *
exp(-0.6 * (f1 - 3.4) * (f1 - 3.4))
119 - 6.0 *
exp(-0.15 * (f1 - 8.7) * (f1 - 8.7))
120 - 0.0006 * (f1 * f1) * (f1 * f1);
121 }
122
124 {
126
129 return 20 * log10(
h);
130 }
131
133 {
134 int ch, band;
138 if (!bufer)
140
141 /* we need a place for DCA_ADPCM_COEFF samples from previous frame
142 * to calc prediction coefficients for each subband */
145 c->subband[ch][band] = bufer +
148 }
149 }
150 return 0;
151 }
152
154 {
155 if (
c->subband[0][0]) {
158 c->subband[0][0] =
NULL;
159 }
160 }
161
163
166
168 const uint8_t (**src_tablep)[2])
169 {
170 const uint8_t (*src_table)[2] = *src_tablep;
172
173 for (
unsigned i = 0;
i < count;
i++) {
174 unsigned dst_idx = src_table[
i][0];
175
176 dst[dst_idx][0] =
code >> (16 - src_table[
i][1]);
177 dst[dst_idx][1] = src_table[
i][1];
178
179 code += 1 << (16 - src_table[
i][1]);
180 }
181 *src_tablep += count;
182 }
183
185 {
188
192 &src_table);
195 }
196 }
197
200 }
201
203 {
207 int i, j, k, min_frame_bits;
210
213
214 c->fullband_channels =
c->channels =
layout.nb_channels;
215 c->lfe_channel = (
c->channels == 3 ||
c->channels == 6);
216 c->band_interpolation =
c->band_interpolation_tab[1];
217 c->band_spectrum =
c->band_spectrum_tab[1];
218 c->worst_quantization_noise = -2047;
219 c->worst_noise_ever = -2047;
220 c->consumed_adpcm_bits = 0;
221
224
225 switch (
layout.nb_channels) {
226 case 1: /* mono */
227 c->channel_config = 0;
228 break;
229 case 2: /* stereo */
230 c->channel_config = 2;
231 break;
232 case 4: /* 2.2 */
233 c->channel_config = 8;
234 break;
235 case 5: /* 5.0 */
236 c->channel_config = 9;
237 break;
238 case 6: /* 5.1 */
239 c->channel_config = 9;
240 break;
241 default:
243 }
244
245 if (
c->lfe_channel) {
246 c->fullband_channels--;
248 } else {
250 }
251
255 }
256 /* 6 - no Huffman */
257 c->bit_allocation_sel[
i] = 6;
258
260 /* -1 - no ADPCM */
261 c->prediction_mode[
i][j] = -1;
263 }
264 }
265
266 for (
i = 0;
i < 9;
i++) {
268 break;
269 }
272 c->samplerate_index =
i;
273
277 }
279 ;
280 c->bitrate_index =
i;
282 min_frame_bits = 132 + (493 + 28 * 32) *
c->fullband_channels +
c->lfe_channel * 72;
285
286 c->frame_size = (
c->frame_bits + 7) / 8;
287
289
292
293 /* Init all tables */
294 c->cos_table[0] = 0x7fffffff;
295 c->cos_table[512] = 0;
296 c->cos_table[1024] = -
c->cos_table[0];
297 for (
i = 1;
i < 512;
i++) {
299 c->cos_table[1024-
i] = -
c->cos_table[
i];
300 c->cos_table[1024+
i] = -
c->cos_table[
i];
301 c->cos_table[2048-
i] = +
c->cos_table[
i];
302 }
303
304 for (
i = 0;
i < 2048;
i++)
306
307 for (k = 0; k < 32; k++) {
308 for (j = 0; j < 8; j++) {
311 }
312 }
313
314 for (
i = 0;
i < 512;
i++) {
317 }
318
319 for (
i = 0;
i < 9;
i++) {
320 for (j = 0; j <
AUBANDS; j++) {
321 for (k = 0; k < 256; k++) {
323
325 }
326 }
327 }
328
329 for (
i = 0;
i < 256;
i++) {
331 c->cb_to_add[
i] = (
int32_t)(100 * log10(add));
332 }
333 for (j = 0; j < 8; j++) {
334 double accum = 0;
335 for (
i = 0;
i < 512;
i++) {
337 accum += reconst * cos(2 *
M_PI * (
i + 0.5 - 256) * (j + 0.5) / 512);
338 }
339 c->band_spectrum_tab[0][j] = (
int32_t)(200 * log10(accum));
340 }
341 for (j = 0; j < 8; j++) {
342 double accum = 0;
343 for (
i = 0;
i < 512;
i++) {
345 accum += reconst * cos(2 *
M_PI * (
i + 0.5 - 256) * (j + 0.5) / 512);
346 }
347 c->band_spectrum_tab[1][j] = (
int32_t)(200 * log10(accum));
348 }
349
351 return 0;
352 }
353
355 {
360
361 return 0;
362 }
363
365 {
366 int ch, subs,
i, k, j;
367
368 for (ch = 0; ch <
c->fullband_channels; ch++) {
369 /* History is copied because it is also needed for PSY */
371 int hist_start = 0;
372 const int chi =
c->channel_order_tab[ch];
373
374 memcpy(hist, &
c->history[ch][0], 512 *
sizeof(
int32_t));
375
379 int band;
380
381 /* Calculate the convolutions at once */
382 memset(accum, 0, 64 *
sizeof(
int32_t));
383
384 for (k = 0,
i = hist_start, j = 0;
385 i < 512; k = (k + 1) & 63,
i++, j++)
386 accum[k] +=
mul32(hist[
i],
c->band_interpolation[j]);
387 for (
i = 0;
i < hist_start; k = (k + 1) & 63,
i++, j++)
388 accum[k] +=
mul32(hist[
i],
c->band_interpolation[j]);
389
390 for (k = 16; k < 32; k++)
391 accum[k] = accum[k] - accum[31 - k];
392 for (k = 32; k < 48; k++)
393 accum[k] = accum[k] + accum[95 - k];
394
395 for (band = 0; band < 32; band++) {
396 resp = 0;
397 for (
i = 16;
i < 48;
i++) {
398 int s = (2 * band + 1) * (2 * (
i + 16) + 1);
400 }
401
402 c->subband[ch][band][subs] = ((band + 1) & 2) ? -resp : resp;
403 }
404
405 /* Copy in 32 new samples from input */
406 for (
i = 0;
i < 32;
i++)
407 hist[
i + hist_start] =
input[(subs * 32 +
i) *
c->channels + chi];
408
409 hist_start = (hist_start + 32) & 511;
410 }
411 }
412 }
413
415 {
416 /* FIXME: make 128x LFE downsampling possible */
417 const int lfech =
lfe_index[
c->channel_config];
421 int hist_start = 0;
422
423 memcpy(hist, &
c->history[
c->channels - 1][0], 512 *
sizeof(
int32_t));
424
426 /* Calculate the convolution */
427 accum = 0;
428
429 for (
i = hist_start, j = 0;
i < 512;
i++, j++)
430 accum +=
mul32(hist[
i],
c->lfe_fir_64i[j]);
431 for (
i = 0;
i < hist_start;
i++, j++)
432 accum +=
mul32(hist[
i],
c->lfe_fir_64i[j]);
433
434 c->downsampled_lfe[lfes] = accum;
435
436 /* Copy in 64 new samples from input */
437 for (
i = 0;
i < 64;
i++)
438 hist[
i + hist_start] =
input[(lfes * 64 +
i) *
c->channels + lfech];
439
440 hist_start = (hist_start + 64) & 511;
441 }
442 }
443
445 {
446 uint32_t sum = 0;
447 for (
unsigned i = 0;
i < n;
i++)
449 return sum;
450 }
451
453 uint8_t n, uint8_t sel)
454 {
455 for (
unsigned i = 0;
i < n;
i++)
458 }
459
461 uint8_t sel, uint8_t
table)
462 {
463 uint32_t sum = 0;
464 for (
unsigned i = 0;
i < n;
i++)
466 return sum;
467 }
468
470 uint8_t n, uint8_t sel, uint8_t
table)
471 {
472 for (
unsigned i = 0;
i < n;
i++)
475 }
476
478 {
481
482 for (
i = 1024;
i > 0;
i >>= 1) {
483 if (
c->cb_to_level[
i + res] >= in)
485 }
486 return -res;
487 }
488
490 {
493
496 return a +
c->cb_to_add[
a -
b];
497 }
498
501 {
505
506 for (
i = 0;
i < 512;
i++)
508
510 for (
i = 0;
i < 256;
i++) {
513 }
514 }
515
518 {
524 const int samplerate_index =
c->samplerate_index;
526
528
529 for (j = 0; j < 256; j++)
530 out_cb_unnorm[j] = -2047; /* and can only grow */
531
533 denom = ca_cb; /* and can only grow */
534 for (j = 0; j < 256; j++)
535 denom =
add_cb(
c, denom,
power[j] +
c->auf[samplerate_index][
i][j]);
536 for (j = 0; j < 256; j++)
537 out_cb_unnorm[j] =
add_cb(
c, out_cb_unnorm[j],
538 -denom +
c->auf[samplerate_index][
i][j]);
539 }
540
541 for (j = 0; j < 256; j++)
542 out_cb[j] =
add_cb(
c, out_cb[j], -out_cb_unnorm[j] - ca_cb - cs_cb);
543 }
544
548
551 {
553
554 if (band == 0) {
555 for (
f = 0;
f < 4;
f++)
557 } else {
558 for (
f = 0;
f < 8;
f++)
559 walk(
c, band, band - 1, 8 * band - 4 +
f,
561 }
562 }
563
566 {
568
569 if (band == 31) {
570 for (
f = 0;
f < 4;
f++)
572 } else {
573 for (
f = 0;
f < 8;
f++)
574 walk(
c, band, band + 1, 8 * band + 4 +
f,
576 }
577 }
578
582 {
584
585 if (value < c->band_masking_cb[band1])
586 c->band_masking_cb[band1] =
value;
587 }
588
590 {
591 int i, k, band, ch, ssf;
593
594 for (
i = 0;
i < 256;
i++)
596 c->masking_curve_cb[ssf][
i] = -2047;
597
599 for (ch = 0; ch <
c->fullband_channels; ch++) {
600 const int chi =
c->channel_order_tab[ch];
601
602 for (
i = 0, k = 128 + 256 * ssf; k < 512;
i++, k++)
603 data[
i] =
c->history[ch][k];
604 for (k -= 512;
i < 512;
i++, k++)
607 }
608 for (
i = 0;
i < 256;
i++) {
610
612 if (
c->masking_curve_cb[ssf][
i] < m)
613 m =
c->masking_curve_cb[ssf][
i];
614 c->eff_masking_curve_cb[
i] = m;
615 }
616
617 for (band = 0; band < 32; band++) {
618 c->band_masking_cb[band] = 2048;
621 }
622 }
623
625 {
632 }
634 }
635
637 {
638 int band, ch;
639
640 for (ch = 0; ch <
c->fullband_channels; ch++) {
641 for (band = 0; band < 32; band++)
642 c->peak_cb[ch][band] =
find_peak(
c,
c->subband[ch][band],
644 }
645
648 }
649
651 {
652 int ch, band;
653 int pred_vq_id;
656
657 c->consumed_adpcm_bits = 0;
658 for (ch = 0; ch <
c->fullband_channels; ch++) {
659 for (band = 0; band < 32; band++) {
663 if (pred_vq_id >= 0) {
664 c->prediction_mode[ch][band] = pred_vq_id;
665 c->consumed_adpcm_bits += 12;
//12 bits to transmit prediction vq index
666 c->diff_peak_cb[ch][band] =
find_peak(
c, estimated_diff, 16);
667 } else {
668 c->prediction_mode[ch][band] = -1;
669 }
670 }
671 }
672 }
673
675 #define USED_1ABITS 1
676 #define USED_26ABITS 4
677
679 {
681
682 if (
c->bitrate_index == 3)
684 else
686
687 return step_size;
688 }
689
692 {
694 int our_nscale, try_remove;
696
699
700 our_nscale = 127;
701 peak =
c->cb_to_level[-peak_cb];
702
703 for (try_remove = 64; try_remove > 0; try_remove >>= 1) {
705 continue;
709 continue;
710 our_nscale -= try_remove;
711 }
712
713 if (our_nscale >= 125)
714 our_nscale = 124;
715
719
720 return our_nscale;
721 }
722
724 {
726 int32_t diff_peak_cb =
c->diff_peak_cb[ch][band];
729 &
c->quant[ch][band]);
730
735 step_size,
c->adpcm_history[ch][band],
c->subband[ch][band],
736 c->adpcm_history[ch][band] + 4,
c->quantized[ch][band],
738 }
739
741 {
742 int band, ch;
743
744 for (ch = 0; ch <
c->fullband_channels; ch++)
745 for (band = 0; band < 32; band++)
746 if (
c->prediction_mode[ch][band] >= 0)
748 }
749
751 {
753
754 for (ch = 0; ch <
c->fullband_channels; ch++) {
755 for (band = 0; band < 32; band++) {
756 if (
c->prediction_mode[ch][band] == -1) {
761 }
762 }
763 }
764 }
765 }
766
769 {
770 uint8_t sel, id = abits - 1;
773 sel, id);
774 }
775
779 {
783 uint32_t t,
bits = 0;
784
786
788 if (vlc_bits[
i][0] == 0) {
789 /* do not transmit adjustment index for empty codebooks */
791 /* and skip it */
792 continue;
793 }
794
795 best_sel_bits[
i] = vlc_bits[
i][0];
798 if (best_sel_bits[
i] > vlc_bits[
i][sel] && vlc_bits[
i][sel]) {
799 best_sel_bits[
i] = vlc_bits[
i][sel];
800 best_sel_id[
i] = sel;
801 }
802 }
803
804 /* 2 bits to transmit scale factor adjustment index */
805 t = best_sel_bits[
i] + 2;
806 if (t < clc_bits[
i]) {
807 res[
i] = best_sel_id[
i];
809 } else {
812 }
813 }
815 }
816
819 {
821 uint32_t t;
824
825 /* Check do we have subband which cannot be encoded by Huffman tables */
827 if (abits[
i] > 12 || abits[
i] == 0) {
828 *res = best_sel;
829 return best_bits;
830 }
831 }
832
835 if (t < best_bits) {
836 best_bits = t;
838 }
839 }
840
841 *res = best_sel;
842 return best_bits;
843 }
844
846 {
850 uint32_t bits_counter = 0;
851
852 c->consumed_bits = 132 + 333 *
c->fullband_channels;
853 c->consumed_bits +=
c->consumed_adpcm_bits;
855 c->consumed_bits += 72;
856
857 /* attempt to guess the bit distribution based on the prevoius frame */
858 for (ch = 0; ch <
c->fullband_channels; ch++) {
859 for (band = 0; band < 32; band++) {
860 int snr_cb =
c->peak_cb[ch][band] -
c->band_masking_cb[band] -
noise;
861
862 if (snr_cb >= 1312) {
863 c->abits[ch][band] = 26;
865 } else if (snr_cb >= 222) {
866 c->abits[ch][band] = 8 +
mul32(snr_cb - 222, 69000000);
868 } else if (snr_cb >= 0) {
869 c->abits[ch][band] = 2 +
mul32(snr_cb, 106000000);
871 } else if (forbid_zero || snr_cb >= -140) {
872 c->abits[ch][band] = 1;
874 } else {
875 c->abits[ch][band] = 0;
877 }
878 }
880 &
c->bit_allocation_sel[ch]);
881 }
882
883 /* Recalc scale_factor each time to get bits consumption in case of Huffman coding.
884 It is suboptimal solution */
885 /* TODO: May be cache scaled values */
886 for (ch = 0; ch <
c->fullband_channels; ch++) {
887 for (band = 0; band < 32; band++) {
888 if (
c->prediction_mode[ch][band] == -1) {
891 &
c->quant[ch][band]);
892 }
893 }
894 }
897
900 for (ch = 0; ch <
c->fullband_channels; ch++) {
901 for (band = 0; band < 32; band++) {
904 c->quantized[ch][band],
905 huff_bit_count_accum[ch][
c->abits[ch][band] - 1]);
906 clc_bit_count_accum[ch][
c->abits[ch][band] - 1] +=
bit_consumption[
c->abits[ch][band]];
907 } else {
909 }
910 }
911 }
912
913 for (ch = 0; ch <
c->fullband_channels; ch++) {
915 clc_bit_count_accum[ch],
916 c->quant_index_sel[ch]);
917 }
918
919 c->consumed_bits += bits_counter;
920
922 }
923
925 {
926 /* Find the bounds where the binary search should work */
928 int used_abits = 0;
929 int forbid_zero = 1;
930 restart:
932 low =
high =
c->worst_quantization_noise;
933 if (
c->consumed_bits >
c->frame_bits) {
934 while (
c->consumed_bits >
c->frame_bits) {
936 forbid_zero = 0;
937 goto restart;
938 }
942 }
943 } else {
944 while (
c->consumed_bits <=
c->frame_bits) {
947 goto out;
/* The requested bitrate is too high, pad with zeros */
950 }
951 }
952
953 /* Now do a binary search between low and high to see what fits */
954 for (down =
snr_fudge >> 1; down; down >>= 1) {
956 if (
c->consumed_bits <=
c->frame_bits)
958 }
961 c->worst_quantization_noise =
high;
962 if (
high >
c->worst_noise_ever)
963 c->worst_noise_ever =
high;
964 }
965
967 {
968 int k, ch;
969
970 for (k = 0; k < 512; k++)
971 for (ch = 0; ch <
c->channels; ch++) {
972 const int chi =
c->channel_order_tab[ch];
973
974 c->history[ch][k] =
input[k *
c->channels + chi];
975 }
976 }
977
979 {
980 int ch, band;
982 /* We fill in ADPCM work buffer for subbands which hasn't been ADPCM coded
983 * in current frame - we need this data if subband of next frame is
984 * ADPCM
985 */
986 for (ch = 0; ch <
c->channels; ch++) {
987 for (band = 0; band < 32; band++) {
989 if (
c->prediction_mode[ch][band] == -1) {
991
993 c->quantized[ch][band]+12, step_size,
995 } else {
996 AV_COPY128U(
c->adpcm_history[ch][band],
c->adpcm_history[ch][band]+4);
997 }
998 /* Copy dequantized values for LPC analysis.
999 * It reduces artifacts in case of extreme quantization,
1000 * example: in current frame abits is 1 and has no prediction flag,
1001 * but end of this frame is sine like signal. In this case, if LPC analysis uses
1002 * original values, likely LPC analysis returns good prediction gain, and sets prediction flag.
1003 * But there are no proper value in decoder history, so likely result will be no good.
1004 * Bitstream has "Predictor history flag switch", but this flag disables history for all subbands
1005 */
1006 samples[0] =
c->adpcm_history[ch][band][0] * (1 << 7);
1007 samples[1] =
c->adpcm_history[ch][band][1] * (1 << 7);
1008 samples[2] =
c->adpcm_history[ch][band][2] * (1 << 7);
1009 samples[3] =
c->adpcm_history[ch][band][3] * (1 << 7);
1010 }
1011 }
1012 }
1013
1015 {
1018 }
1019
1021 {
1022 /* SYNC */
1025
1026 /* Frame type: normal */
1028
1029 /* Deficit sample count: none */
1031
1032 /* CRC is not present */
1034
1035 /* Number of PCM sample blocks */
1037
1038 /* Primary frame byte size */
1040
1041 /* Audio channel arrangement */
1043
1044 /* Core audio sampling frequency */
1046
1047 /* Transmission bit rate */
1049
1050 /* Embedded down mix: disabled */
1052
1053 /* Embedded dynamic range flag: not present */
1055
1056 /* Embedded time stamp flag: not present */
1058
1059 /* Auxiliary data flag: not present */
1061
1062 /* HDCD source: no */
1064
1065 /* Extension audio ID: N/A */
1067
1068 /* Extended audio data: not present */
1070
1071 /* Audio sync word insertion flag: after each sub-frame */
1073
1074 /* Low frequency effects flag: not present or 64x subsampling */
1076
1077 /* Predictor history switch flag: on */
1079
1080 /* No CRC */
1081 /* Multirate interpolator switch: non-perfect reconstruction */
1083
1084 /* Encoder software revision: 7 */
1086
1087 /* Copy history: 0 */
1089
1090 /* Source PCM resolution: 16 bits, not DTS ES */
1092
1093 /* Front sum/difference coding: no */
1095
1096 /* Surrounds sum/difference coding: no */
1098
1099 /* Dialog normalization: 0 dB */
1101 }
1102
1104 {
1106 /* Number of subframes */
1108
1109 /* Number of primary audio channels */
1110 put_bits(&
c->pb, 3,
c->fullband_channels - 1);
1111
1112 /* Subband activity count */
1113 for (ch = 0; ch <
c->fullband_channels; ch++)
1115
1116 /* High frequency VQ start subband */
1117 for (ch = 0; ch <
c->fullband_channels; ch++)
1119
1120 /* Joint intensity coding index: 0, 0 */
1121 for (ch = 0; ch <
c->fullband_channels; ch++)
1123
1124 /* Transient mode codebook: A4, A4 (arbitrary) */
1125 for (ch = 0; ch <
c->fullband_channels; ch++)
1127
1128 /* Scale factor code book: 7 bit linear, 7-bit sqrt table (for each channel) */
1129 for (ch = 0; ch <
c->fullband_channels; ch++)
1131
1132 /* Bit allocation quantizer select: linear 5-bit */
1133 for (ch = 0; ch <
c->fullband_channels; ch++)
1134 put_bits(&
c->pb, 3,
c->bit_allocation_sel[ch]);
1135
1136 /* Quantization index codebook select */
1138 for (ch = 0; ch <
c->fullband_channels; ch++)
1140
1141 /* Scale factor adjustment index: transmitted in case of Huffman coding */
1143 for (ch = 0; ch <
c->fullband_channels; ch++)
1146
1147 /* Audio header CRC check word: not transmitted */
1148 }
1149
1151 {
1152 int i, j, sum,
bits, sel;
1155 sel =
c->quant_index_sel[ch][
c->abits[ch][band] - 1];
1156 // Huffman codes
1159 sel,
c->abits[ch][band] - 1);
1160 return;
1161 }
1162
1163 // Block codes
1164 if (
c->abits[ch][band] <= 7) {
1165 for (
i = 0;
i < 8;
i += 4) {
1166 sum = 0;
1167 for (j = 3; j >= 0; j--) {
1169 sum +=
c->quantized[ch][band][
ss * 8 +
i + j];
1171 }
1173 }
1174 return;
1175 }
1176 }
1177
1178 for (
i = 0;
i < 8;
i++) {
1181 }
1182 }
1183
1185 {
1186 int i, band,
ss, ch;
1187
1188 /* Subsubframes count */
1190
1191 /* Partial subsubframe sample count: dummy */
1193
1194 /* Prediction mode: no ADPCM, in each channel and subband */
1195 for (ch = 0; ch <
c->fullband_channels; ch++)
1197 put_bits(&
c->pb, 1, !(
c->prediction_mode[ch][band] == -1));
1198
1199 /* Prediction VQ address */
1200 for (ch = 0; ch <
c->fullband_channels; ch++)
1202 if (
c->prediction_mode[ch][band] >= 0)
1203 put_bits(&
c->pb, 12,
c->prediction_mode[ch][band]);
1204
1205 /* Bit allocation index */
1206 for (ch = 0; ch <
c->fullband_channels; ch++) {
1207 if (
c->bit_allocation_sel[ch] == 6) {
1210 }
1211 } else {
1213 c->bit_allocation_sel[ch]);
1214 }
1215 }
1216
1218 /* Transition mode: none for each channel and subband */
1219 for (ch = 0; ch <
c->fullband_channels; ch++)
1221 if (
c->abits[ch][band])
1222 put_bits(&
c->pb, 1, 0);
/* codebook A4 */
1223 }
1224
1225 /* Scale factors */
1226 for (ch = 0; ch <
c->fullband_channels; ch++)
1228 if (
c->abits[ch][band])
1229 put_bits(&
c->pb, 7,
c->scale_factor[ch][band]);
1230
1231 /* Joint subband scale factor codebook select: not transmitted */
1232 /* Scale factors for joint subband coding: not transmitted */
1233 /* Stereo down-mix coefficients: not transmitted */
1234 /* Dynamic range coefficient: not transmitted */
1235 /* Stde information CRC check word: not transmitted */
1236 /* VQ encoded high frequency subbands: not transmitted */
1237
1238 /* LFE data: 8 samples and scalefactor */
1239 if (
c->lfe_channel) {
1243 }
1244
1245 /* Audio data (subsubframes) */
1247 for (ch = 0; ch <
c->fullband_channels; ch++)
1249 if (
c->abits[ch][band])
1251
1252 /* DSYNC */
1254 }
1255
1258 {
1262
1265
1267
1271
1273 if (
c->options.adpcm_mode)
1279
1286
1289
1290 *got_packet_ptr = 1;
1291 return 0;
1292 }
1293
1294 #define DCAENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
1295
1299 };
1300
1302 .
class_name =
"DCA (DTS Coherent Acoustics)",
1306 };
1307
1309 { "b", "1411200" },
1311 };
1312
1334 { 0 },
1335 },
1338 };