Go to the documentation of this file.
40 if (!num_reuse_blocks)
44 uint8_t min_exp = *
exp;
45 uint8_t *exp1 =
exp + 256;
46 for (
blk = 0;
blk < num_reuse_blocks;
blk++) {
47 uint8_t next_exp = *exp1;
48 if (next_exp < min_exp)
58 const float scale = 1 << 24;
74 int snr_offset,
int floor,
75 const uint8_t *
bap_tab, uint8_t *bap)
77 int bin, band, band_end;
80 if (snr_offset == -960) {
90 band_end =
FFMIN(band_end, end);
92 for (; bin < band_end; bin++) {
96 }
while (end > band_end);
103 mant_cnt[bap[
len]]++;
107 0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
117 bits += (mant_cnt[
blk][1] / 3) * 5;
120 bits += ((mant_cnt[
blk][2] / 3) + (mant_cnt[
blk][4] >> 1)) * 7;
124 for (bap = 5; bap < 16; bap++)
135 int v =
abs(coef[
i]);
147 sum[0] = sum[1] = sum[2] = sum[3] = 0;
149 for (
i = 0;
i <
len;
i++) {
154 MAC64(sum[0], lt, lt);
155 MAC64(sum[1], rt, rt);
157 MAC64(sum[3], sd, sd);
168 sum[0] = sum[1] = sum[2] = sum[3] = 0;
170 for (
i = 0;
i <
len;
i++) {
187 float front_mix = matrix[0][0];
188 float center_mix = matrix[0][1];
189 float surround_mix = matrix[0][3];
191 for (
i = 0;
i <
len;
i++) {
209 float front_mix = matrix[0][0];
210 float center_mix = matrix[0][1];
211 float surround_mix = matrix[0][3];
213 for (
i = 0;
i <
len;
i++) {
223 int out_ch,
int in_ch,
int len)
229 for (
i = 0;
i <
len;
i++) {
231 for (j = 0; j < in_ch; j++) {
238 }
else if (out_ch == 1) {
239 for (
i = 0;
i <
len;
i++) {
241 for (j = 0; j < in_ch; j++)
253 int16_t front_mix = matrix[0][0];
254 int16_t center_mix = matrix[0][1];
255 int16_t surround_mix = matrix[0][3];
257 for (
i = 0;
i <
len;
i++) {
259 (int64_t)
samples[1][
i] * center_mix +
260 (int64_t)
samples[3][
i] * surround_mix;
262 v1 = (int64_t)
samples[1][
i] * center_mix +
263 (int64_t)
samples[2][
i] * front_mix +
264 (int64_t)
samples[4][
i] * surround_mix;
276 int16_t front_mix = matrix[0][0];
277 int16_t center_mix = matrix[0][1];
278 int16_t surround_mix = matrix[0][3];
280 for (
i = 0;
i <
len;
i++) {
282 (int64_t)
samples[1][
i] * center_mix +
283 (int64_t)
samples[2][
i] * front_mix +
284 (int64_t)
samples[3][
i] * surround_mix +
285 (int64_t)
samples[4][
i] * surround_mix;
292 int out_ch,
int in_ch,
int len)
297 for (
i = 0;
i <
len;
i++) {
299 for (j = 0; j < in_ch; j++) {
301 v1 += (int64_t)
samples[j][
i] * matrix[1][j];
306 }
else if (out_ch == 1) {
307 for (
i = 0;
i <
len;
i++) {
309 for (j = 0; j < in_ch; j++)
317 int out_ch,
int in_ch,
int len)
319 if (
c->in_channels != in_ch ||
c->out_channels != out_ch) {
320 c->in_channels = in_ch;
321 c->out_channels = out_ch;
322 c->downmix_fixed =
NULL;
324 if (in_ch == 5 && out_ch == 2 &&
325 !(matrix[1][0] | matrix[0][2] |
326 matrix[1][3] | matrix[0][4] |
327 (matrix[0][1] ^ matrix[1][1]) |
328 (matrix[0][0] ^ matrix[1][2]))) {
330 }
else if (in_ch == 5 && out_ch == 1 &&
331 matrix[0][0] == matrix[0][2] &&
332 matrix[0][3] == matrix[0][4]) {
337 if (
c->downmix_fixed)
344 int out_ch,
int in_ch,
int len)
346 if (
c->in_channels != in_ch ||
c->out_channels != out_ch) {
347 int **matrix_cmp = (
int **)matrix;
349 c->in_channels = in_ch;
350 c->out_channels = out_ch;
353 if (in_ch == 5 && out_ch == 2 &&
354 !(matrix_cmp[1][0] | matrix_cmp[0][2] |
355 matrix_cmp[1][3] | matrix_cmp[0][4] |
356 (matrix_cmp[0][1] ^ matrix_cmp[1][1]) |
357 (matrix_cmp[0][0] ^ matrix_cmp[1][2]))) {
359 }
else if (in_ch == 5 && out_ch == 1 &&
360 matrix_cmp[0][0] == matrix_cmp[0][2] &&
361 matrix_cmp[0][3] == matrix_cmp[0][4]) {
388 c->downmix_fixed =
NULL;
static int nb_coefs(int length, int level, uint64_t sn)
static int ac3_compute_mantissa_size_c(uint16_t mant_cnt[6][16])
const uint8_t ff_ac3_bin_to_band_tab[253]
Map each frequency coefficient bin to the critical band that contains it.
void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact)
static void ac3_sum_square_butterfly_float_c(float sum[4], const float *coef0, const float *coef1, int len)
static av_always_inline float scale(float x, float s)
static void ac3_downmix_c(float **samples, float **matrix, int out_ch, int in_ch, int len)
static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap, int len)
void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
static const uint16_t mask[17]
static __device__ float floor(float a)
const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1]
Starting frequency coefficient bin for each critical band.
static const uint8_t bap_tab[64]
void ff_ac3dsp_init_mips(AC3DSPContext *c, int bit_exact)
const uint16_t ff_ac3_bap_bits[16]
Number of mantissa bits written for each bap value.
static void ac3_extract_exponents_c(uint8_t *exp, int32_t *coef, int nb_coefs)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void ac3_downmix_5_to_1_symmetric_c_fixed(int32_t **samples, int16_t **matrix, int len)
static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
static void ac3_downmix_5_to_2_symmetric_c(float **samples, float **matrix, int len)
static void ac3_sum_square_butterfly_int32_c(int64_t sum[4], const int32_t *coef0, const int32_t *coef1, int len)
static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd, int start, int end, int snr_offset, int floor, const uint8_t *bap_tab, uint8_t *bap)
#define DECLARE_ALIGNED(n, t, v)
#define i(width, name, range_min, range_max)
static void ac3_downmix_5_to_2_symmetric_c_fixed(int32_t **samples, int16_t **matrix, int len)
void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
void ff_ac3dsp_downmix(AC3DSPContext *c, float **samples, float **matrix, int out_ch, int in_ch, int len)
void ff_ac3dsp_downmix_fixed(AC3DSPContext *c, int32_t **samples, int16_t **matrix, int out_ch, int in_ch, int len)
Filter the word “frame” indicates either a video frame or a group of audio samples
av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
static void ac3_downmix_5_to_1_symmetric_c(float **samples, float **matrix, int len)
static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
static void ac3_downmix_c_fixed(int32_t **samples, int16_t **matrix, int out_ch, int in_ch, int len)