37 #define MAX_CHANNELS 6
38 #define DCA_SUBBANDS_32 32
39 #define DCA_MAX_FRAME_SIZE 16383
40 #define DCA_HEADER_SIZE 13
42 #define DCA_SUBBANDS 32
43 #define QUANTIZER_BITS 16
45 #define SUBSUBFRAMES 4
46 #define PCM_SAMPLES (SUBFRAMES*SUBSUBFRAMES*8)
48 #define LFE_INTERPOLATION 64
53 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3
57 { 0, -1, -1, -1, -1, -1, -1, -1, -1 },
58 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
59 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
60 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
61 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
62 { 1, 2, 0, -1, -1, -1, -1, -1, -1 },
63 { 0, 1, -1, 2, -1, -1, -1, -1, -1 },
64 { 1, 2, 0, -1, 3, -1, -1, -1, -1 },
65 { 0, 1, -1, 2, 3, -1, -1, -1, -1 },
66 { 1, 2, 0, -1, 3, 4, -1, -1, -1 },
67 { 2, 3, -1, 0, 1, 4, 5, -1, -1 },
68 { 1, 2, 0, -1, 3, 4, 5, -1, -1 },
69 { 0, -1, 4, 5, 2, 3, 1, -1, -1 },
70 { 3, 4, 1, -1, 0, 2, 5, 6, -1 },
71 { 2, 3, -1, 5, 7, 0, 1, 4, 6 },
72 { 3, 4, 1, -1, 0, 2, 5, 7, 6 },
76 { 0, -1, -1, -1, -1, -1, -1, -1, -1 },
77 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
78 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
79 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
80 { 0, 1, -1, -1, -1, -1, -1, -1, -1 },
81 { 1, 2, 0, -1, -1, -1, -1, -1, -1 },
82 { 0, 1, 2, -1, -1, -1, -1, -1, -1 },
83 { 1, 2, 0, 3, -1, -1, -1, -1, -1 },
84 { 0, 1, 2, 3, -1, -1, -1, -1, -1 },
85 { 1, 2, 0, 3, 4, -1, -1, -1, -1 },
86 { 2, 3, 0, 1, 4, 5, -1, -1, -1 },
87 { 1, 2, 0, 3, 4, 5, -1, -1, -1 },
88 { 0, 4, 5, 2, 3, 1, -1, -1, -1 },
89 { 3, 4, 1, 0, 2, 5, 6, -1, -1 },
90 { 2, 3, 5, 7, 0, 1, 4, 6, -1 },
91 { 3, 4, 1, 0, 2, 5, 7, 6, -1 },
103 int lfe_scale_factor;
110 const int8_t *channel_order_tab;
120 int64_t
r = (int64_t) a * b;
122 return (r + 0x80000000) >> 32;
134 for (i = 1; i <= 16; i++) {
135 s[i] = 2 * (
mul32(c[i - 1], 105372028) +
mul32(s[i - 1], 2144896908));
136 c[i] = 2 * (
mul32(c[i - 1], 2144896908) -
mul32(s[i - 1], 105372028));
139 for (i = 0; i < 16; i++) {
153 int index = band * (2 * sample_num + 1);
161 int count,
int channel)
166 for (i = 0; i < count; i++) {
170 c->
start[channel] += count;
171 if (c->
start[channel] == 512)
172 c->
start[channel] = 0;
190 for (k = 48, j = 0, i = c->
start[channel]; i < 512; k++, j++, i++)
191 accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] +=
mul32(c->
history[channel][i],
UnQMF[j]);
192 for (i = 0; i < c->
start[channel]; k++, j++, i++)
193 accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] +=
mul32(c->
history[channel][i],
UnQMF[j]);
198 for (j = 0; j < 32; j++)
201 out[band] = (band & 2) ? (-resp) : resp;
213 for (i = c->
start[channel], j = 0; i < 512; i++, j++)
215 for (i = 0; i < c->
start[channel]; i++, j++)
222 static int initialized = 0;
227 for (i = 0; i < 512; i++)
317 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
318 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
354 for (i = 1; i < 11; i++)
370 return sample & ((1 <<
bits) - 1);
375 int i = 0, j = 128, q;
376 max_value = ((max_value << 15) /
lossy_quant[bits + 3]) >> (bits - 1);
399 int i, sub, ss, ch, max_value;
431 max_value =
FFMAX(max_value,
FFABS(subband_data[i][ch][sub]));
438 max_value =
FFMAX(max_value,
FFABS(lfe_data[i]));
467 for (i = 0; i < 8; i++)
499 int ret, real_channel = 0;
504 samples = (
const int16_t *)frame->
data[0];
506 for (channel = 0; channel < c->
prim_channels + 1; channel++) {
508 if (real_channel >= 0) {
510 for (k = 0; k < 32; k++) {
511 c->
pcm[k] = samples[avctx->
channels * (32 * i + k) + channel] << 16;
520 for (i = 0; i < PCM_SAMPLES / 2; i++) {
545 "encoder will guess the layout, but it "
546 "might be incorrect.\n");
557 "Only stereo, 5.0, 5.1 channel layouts supported at the moment!\n");
572 for (i = 0; i < 16; i++) {
578 for (i = 0; i < 16; i++)