36 #define MAX_CHANNELS 6
37 #define DCA_SUBBANDS_32 32
38 #define DCA_MAX_FRAME_SIZE 16383
39 #define DCA_HEADER_SIZE 13
41 #define DCA_SUBBANDS 32
42 #define QUANTIZER_BITS 16
44 #define SUBSUBFRAMES 4
45 #define PCM_SAMPLES (SUBFRAMES*SUBSUBFRAMES*8)
47 #define LFE_INTERPOLATION 64
52 1,2,2,2,2,3,2,3,2,3,2,3,1,3,2,3
56 { 0, -1, -1, -1, -1, -1, -1, -1, -1 },
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 { 1, 2, 0, -1, -1, -1, -1, -1, -1 },
62 { 0, 1, -1, 2, -1, -1, -1, -1, -1 },
63 { 1, 2, 0, -1, 3, -1, -1, -1, -1 },
64 { 0, 1, -1, 2, 3, -1, -1, -1, -1 },
65 { 1, 2, 0, -1, 3, 4, -1, -1, -1 },
66 { 2, 3, -1, 0, 1, 4, 5, -1, -1 },
67 { 1, 2, 0, -1, 3, 4, 5, -1, -1 },
68 { 0, -1, 4, 5, 2, 3, 1, -1, -1 },
69 { 3, 4, 1, -1, 0, 2, 5, 6, -1 },
70 { 2, 3, -1, 5, 7, 0, 1, 4, 6 },
71 { 3, 4, 1, -1, 0, 2, 5, 7, 6 },
75 { 0, -1, -1, -1, -1, -1, -1, -1, -1 },
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 { 1, 2, 0, -1, -1, -1, -1, -1, -1 },
81 { 0, 1, 2, -1, -1, -1, -1, -1, -1 },
82 { 1, 2, 0, 3, -1, -1, -1, -1, -1 },
83 { 0, 1, 2, 3, -1, -1, -1, -1, -1 },
84 { 1, 2, 0, 3, 4, -1, -1, -1, -1 },
85 { 2, 3, 0, 1, 4, 5, -1, -1, -1 },
86 { 1, 2, 0, 3, 4, 5, -1, -1, -1 },
87 { 0, 4, 5, 2, 3, 1, -1, -1, -1 },
88 { 3, 4, 1, 0, 2, 5, 6, -1, -1 },
89 { 2, 3, 5, 7, 0, 1, 4, 6, -1 },
90 { 3, 4, 1, 0, 2, 5, 7, 6, -1 },
102 int lfe_scale_factor;
109 const int8_t *channel_order_tab;
119 int64_t
r = (int64_t) a * b;
121 return (r + 0x80000000) >> 32;
133 for (i = 1; i <= 16; i++) {
134 s[i] = 2 * (
mul32(c[i - 1], 105372028) +
mul32(s[i - 1], 2144896908));
135 c[i] = 2 * (
mul32(c[i - 1], 2144896908) -
mul32(s[i - 1], 105372028));
138 for (i = 0; i < 16; i++) {
152 int index = band * (2 * sample_num + 1);
160 int count,
int channel)
165 for (i = 0; i < count; i++) {
169 c->
start[channel] += count;
170 if (c->
start[channel] == 512)
171 c->
start[channel] = 0;
189 for (k = 48, j = 0, i = c->
start[channel]; i < 512; k++, j++, i++)
190 accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] +=
mul32(c->
history[channel][i],
UnQMF[j]);
191 for (i = 0; i < c->
start[channel]; k++, j++, i++)
192 accum[(k & 32) ? (31 - (k & 31)) : (k & 31)] +=
mul32(c->
history[channel][i],
UnQMF[j]);
197 for (j = 0; j < 32; j++)
200 out[
band] = (band & 2) ? (-resp) : resp;
212 for (i = c->
start[channel], j = 0; i < 512; i++, j++)
214 for (i = 0; i < c->
start[channel]; i++, j++)
221 static int initialized = 0;
226 for (i = 0; i < 512; i++)
316 static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
317 static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
353 for (i = 1; i < 11; i++)
369 return sample & ((1 <<
bits) - 1);
374 int i = 0, j = 128, q;
375 max_value = ((max_value << 15) /
lossy_quant[bits + 3]) >> (bits - 1);
398 int i, sub, ss, ch, max_value;
430 max_value =
FFMAX(max_value,
FFABS(subband_data[i][ch][sub]));
437 max_value =
FFMAX(max_value,
FFABS(lfe_data[i]));
466 for (i = 0; i < 8; i++)
498 int ret, real_channel = 0;
503 samples = (
const int16_t *)frame->
data[0];
505 for (channel = 0; channel < c->
prim_channels + 1; channel++) {
507 if (real_channel >= 0) {
509 for (k = 0; k < 32; k++) {
510 c->
pcm[k] = samples[avctx->
channels * (32 * i + k) + channel] << 16;
519 for (i = 0; i < PCM_SAMPLES / 2; i++) {
544 "encoder will guess the layout, but it "
545 "might be incorrect.\n");
556 "Only stereo, 5.0, 5.1 channel layouts supported at the moment!\n");
571 for (i = 0; i < 16; i++) {
577 for (i = 0; i < 16; i++)