29 #include "config_components.h"
50 for (ch = 0; ch <
s->channels; ch++) {
52 sizeof(**
s->planar_samples))))
68 for (ch = 0; ch <
s->channels; ch++) {
70 memcpy(&
s->planar_samples[ch][0], &
s->planar_samples[ch][
AC3_BLOCK_SIZE *
s->num_blocks],
90 for (ch = 0; ch <
s->channels; ch++) {
95 s->fdsp->vector_fmul(
s->windowed_samples, input_samples,
101 s->tx_fn(
s->tx,
block->mdct_coef[ch+1],
102 s->windowed_samples,
sizeof(
float));
121 int cpl_start, num_cpl_coefs;
125 memset(fixed_cpl_coords, 0,
AC3_MAX_BLOCKS *
sizeof(*cpl_coords));
130 cpl_start =
s->start_freq[
CPL_CH] - 1;
131 num_cpl_coefs =
FFALIGN(
s->num_cpl_subbands * 12 + 1, 32);
132 cpl_start =
FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
138 if (!
block->cpl_in_use)
140 memset(cpl_coef, 0, num_cpl_coefs *
sizeof(*cpl_coef));
141 for (ch = 1; ch <=
s->fbw_channels; ch++) {
143 if (!
block->channel_in_cpl[ch])
145 for (
i = 0;
i < num_cpl_coefs;
i++)
146 cpl_coef[
i] += ch_coef[
i];
158 int band_size =
s->cpl_band_sizes[bnd];
159 for (ch =
CPL_CH; ch <=
s->fbw_channels; ch++) {
164 for (j = 0; j < band_size; j++) {
177 if (!
block->cpl_in_use)
179 for (ch = 1; ch <=
s->fbw_channels; ch++) {
180 if (!
block->channel_in_cpl[ch])
182 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
194 memset(
block->new_cpl_coords, 0,
sizeof(
block->new_cpl_coords));
196 if (
block->cpl_in_use) {
203 for (ch = 1; ch <=
s->fbw_channels; ch++)
204 block->new_cpl_coords[ch] = 1;
206 for (ch = 1; ch <=
s->fbw_channels; ch++) {
207 if (!
block->channel_in_cpl[ch])
210 block->new_cpl_coords[ch] = 1;
213 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
214 coord_diff +=
FFABS(cpl_coords[
blk-1][ch][bnd] -
215 cpl_coords[
blk ][ch][bnd]);
217 coord_diff /=
s->num_cpl_bands;
219 block->new_cpl_coords[ch] = 1;
228 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
234 if (!
block->cpl_in_use) {
239 for (ch = 1; ch <=
s->fbw_channels; ch++) {
241 if (!
block->channel_in_cpl[ch])
244 energy_ch = energy[
blk][ch][bnd];
246 while (blk1 < s->
num_blocks && !
s->blocks[blk1].new_cpl_coords[ch]) {
247 if (
s->blocks[blk1].cpl_in_use) {
248 energy_cpl += energy[blk1][
CPL_CH][bnd];
249 energy_ch += energy[blk1][ch][bnd];
262 if (!
block->cpl_in_use)
266 s->ac3dsp.float_to_fixed24(fixed_cpl_coords[
blk][1],
268 s->fbw_channels * 16);
270 s->ac3dsp.extract_exponents(
block->cpl_coord_exp[1],
271 fixed_cpl_coords[
blk][1],
272 s->fbw_channels * 16);
274 for (ch = 1; ch <=
s->fbw_channels; ch++) {
275 int bnd, min_exp, max_exp, master_exp;
277 if (!
block->new_cpl_coords[ch])
281 min_exp = max_exp =
block->cpl_coord_exp[ch][0];
282 for (bnd = 1; bnd <
s->num_cpl_bands; bnd++) {
283 int exp =
block->cpl_coord_exp[ch][bnd];
287 master_exp = ((max_exp - 15) + 2) / 3;
288 master_exp =
FFMAX(master_exp, 0);
289 while (min_exp < master_exp * 3)
291 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
293 master_exp * 3, 0, 15);
295 block->cpl_master_exp[ch] = master_exp;
298 for (bnd = 0; bnd <
s->num_cpl_bands; bnd++) {
299 int cpl_exp =
block->cpl_coord_exp[ch][bnd];
300 int cpl_mant = (fixed_cpl_coords[
blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
306 block->cpl_coord_mant[ch][bnd] = cpl_mant;
330 block->new_rematrixing_strategy = !
blk;
332 block->num_rematrixing_bands = 4;
333 if (
block->cpl_in_use) {
334 block->num_rematrixing_bands -= (
s->start_freq[
CPL_CH] <= 61);
335 block->num_rematrixing_bands -= (
s->start_freq[
CPL_CH] == 37);
337 block->new_rematrixing_strategy = 1;
341 if (!
s->rematrixing_enabled) {
346 for (bnd = 0; bnd <
block->num_rematrixing_bands; bnd++) {
352 block->mdct_coef[2] + start, end - start);
355 if (
FFMIN(sum[2], sum[3]) <
FFMIN(sum[0], sum[1]))
356 block->rematrixing_flags[bnd] = 1;
358 block->rematrixing_flags[bnd] = 0;
363 block->new_rematrixing_strategy = 1;
377 if (
s->options.allow_per_frame_metadata) {
390 s->cpl_on =
s->cpl_enabled;