29 #include "config_components.h"
42 #define RENAME(element) element ## _float
44 #define RENAME(element) element ## _fixed
56 for (
int ch = 0; ch <
s->channels; ch++) {
64 SampleType *windowed_samples =
s->RENAME(windowed_samples);
66 s->fdsp->vector_fmul(windowed_samples, input_samples0,
72 s->tx_fn(
s->tx,
block->mdct_coef[ch+1],
73 windowed_samples,
sizeof(*windowed_samples));
74 input_samples0 = input_samples1;
76 }
while (++blk < s->num_blocks);
79 memcpy(
s->planar_samples[ch], input_samples0,
98 int cpl_start, num_cpl_coefs;
102 memset(fixed_cpl_coords, 0,
AC3_MAX_BLOCKS *
sizeof(*cpl_coords));
107 cpl_start =
s->start_freq[
CPL_CH] - 1;
108 num_cpl_coefs =
FFALIGN(
s->num_cpl_subbands * 12 + 1, 32);
109 cpl_start =
FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
115 if (!
block->cpl_in_use)
117 memset(cpl_coef, 0, num_cpl_coefs *
sizeof(*cpl_coef));
118 for (ch = 1; ch <=
s->fbw_channels; ch++) {
120 if (!
block->channel_in_cpl[ch])
122 for (
i = 0;
i < num_cpl_coefs;
i++)
123 cpl_coef[
i] += ch_coef[
i];
134 while (i < s->cpl_end_freq) {
135 int band_size =
s->cpl_band_sizes[bnd];
136 for (ch =
CPL_CH; ch <=
s->fbw_channels; ch++) {
141 for (j = 0; j < band_size; j++) {
154 if (!
block->cpl_in_use)
156 for (ch = 1; ch <=
s->fbw_channels; ch++) {
157 if (!
block->channel_in_cpl[ch])
159 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
171 memset(
block->new_cpl_coords, 0,
sizeof(
block->new_cpl_coords));
173 if (
block->cpl_in_use) {
180 for (ch = 1; ch <=
s->fbw_channels; ch++)
181 block->new_cpl_coords[ch] = 1;
183 for (ch = 1; ch <=
s->fbw_channels; ch++) {
184 if (!
block->channel_in_cpl[ch])
187 block->new_cpl_coords[ch] = 1;
190 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
191 coord_diff +=
FFABS(cpl_coords[
blk-1][ch][bnd] -
192 cpl_coords[
blk ][ch][bnd]);
194 coord_diff /=
s->num_cpl_bands;
196 block->new_cpl_coords[ch] = 1;
207 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
209 while (blk < s->num_blocks) {
213 if (!
block->cpl_in_use) {
218 for (ch = 1; ch <=
s->fbw_channels; ch++) {
220 if (!
block->channel_in_cpl[ch])
223 energy_ch = energy[
blk][ch][bnd];
225 while (blk1 < s->num_blocks && !
s->blocks[blk1].new_cpl_coords[ch]) {
226 if (
s->blocks[blk1].cpl_in_use) {
227 energy_cpl += energy[blk1][
CPL_CH][bnd];
228 energy_ch += energy[blk1][ch][bnd];
241 if (!
block->cpl_in_use)
245 s->ac3dsp.float_to_fixed24(fixed_cpl_coords[
blk][1],
247 s->fbw_channels * 16);
249 s->ac3dsp.extract_exponents(
block->cpl_coord_exp[1],
250 fixed_cpl_coords[
blk][1],
251 s->fbw_channels * 16);
253 for (ch = 1; ch <=
s->fbw_channels; ch++) {
254 int bnd, min_exp, max_exp, master_exp;
256 if (!
block->new_cpl_coords[ch])
260 min_exp = max_exp =
block->cpl_coord_exp[ch][0];
261 for (bnd = 1; bnd <
s->num_cpl_bands; bnd++) {
262 int exp =
block->cpl_coord_exp[ch][bnd];
266 master_exp = ((max_exp - 15) + 2) / 3;
267 master_exp =
FFMAX(master_exp, 0);
268 while (min_exp < master_exp * 3)
270 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
272 master_exp * 3, 0, 15);
274 block->cpl_master_exp[ch] = master_exp;
277 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
278 int cpl_exp =
block->cpl_coord_exp[ch][bnd];
279 int cpl_mant = (fixed_cpl_coords[
blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
285 block->cpl_coord_mant[ch][bnd] = cpl_mant;
309 block->new_rematrixing_strategy = !
blk;
311 block->num_rematrixing_bands = 4;
312 if (
block->cpl_in_use) {
313 block->num_rematrixing_bands -= (
s->start_freq[
CPL_CH] <= 61);
314 block->num_rematrixing_bands -= (
s->start_freq[
CPL_CH] == 37);
316 block->new_rematrixing_strategy = 1;
320 if (!
s->rematrixing_enabled) {
325 for (bnd = 0; bnd <
block->num_rematrixing_bands; bnd++) {
331 block->mdct_coef[2] + start, end - start);
334 if (
FFMIN(sum[2], sum[3]) <
FFMIN(sum[0], sum[1]))
335 block->rematrixing_flags[bnd] = 1;
337 block->rematrixing_flags[bnd] = 0;
342 block->new_rematrixing_strategy = 1;
354 s->cpl_on =
s->cpl_enabled;