Go to the documentation of this file.
41 if (!num_reuse_blocks)
45 uint8_t min_exp = *
exp;
46 uint8_t *exp1 =
exp + 256;
47 for (
blk = 0;
blk < num_reuse_blocks;
blk++) {
48 uint8_t next_exp = *exp1;
49 if (next_exp < min_exp)
59 const float scale = 1 << 24;
75 int snr_offset,
int floor,
76 const uint8_t *
bap_tab, uint8_t *bap)
78 int bin, band, band_end;
81 if (snr_offset == -960) {
91 band_end =
FFMIN(band_end, end);
93 for (; bin < band_end; bin++) {
97 }
while (end > band_end);
104 mant_cnt[bap[
len]]++;
108 0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
118 bits += (mant_cnt[
blk][1] / 3) * 5;
121 bits += ((mant_cnt[
blk][2] / 3) + (mant_cnt[
blk][4] >> 1)) * 7;
125 for (bap = 5; bap < 16; bap++)
136 int v =
abs(coef[
i]);
148 sum[0] = sum[1] = sum[2] = sum[3] = 0;
150 for (
i = 0;
i <
len;
i++) {
155 MAC64(sum[0], lt, lt);
156 MAC64(sum[1], rt, rt);
158 MAC64(sum[3], sd, sd);
169 sum[0] = sum[1] = sum[2] = sum[3] = 0;
171 for (
i = 0;
i <
len;
i++) {
188 float front_mix =
matrix[0][0];
189 float center_mix =
matrix[0][1];
190 float surround_mix =
matrix[0][3];
192 for (
i = 0;
i <
len;
i++) {
210 float front_mix =
matrix[0][0];
211 float center_mix =
matrix[0][1];
212 float surround_mix =
matrix[0][3];
214 for (
i = 0;
i <
len;
i++) {
224 int out_ch,
int in_ch,
int len)
230 for (
i = 0;
i <
len;
i++) {
232 for (j = 0; j < in_ch; j++) {
239 }
else if (out_ch == 1) {
240 for (
i = 0;
i <
len;
i++) {
242 for (j = 0; j < in_ch; j++)
254 int16_t front_mix =
matrix[0][0];
255 int16_t center_mix =
matrix[0][1];
256 int16_t surround_mix =
matrix[0][3];
258 for (
i = 0;
i <
len;
i++) {
260 (int64_t)
samples[1][
i] * center_mix +
261 (int64_t)
samples[3][
i] * surround_mix;
263 v1 = (int64_t)
samples[1][
i] * center_mix +
264 (int64_t)
samples[2][
i] * front_mix +
265 (int64_t)
samples[4][
i] * surround_mix;
277 int16_t front_mix =
matrix[0][0];
278 int16_t center_mix =
matrix[0][1];
279 int16_t surround_mix =
matrix[0][3];
281 for (
i = 0;
i <
len;
i++) {
283 (int64_t)
samples[1][
i] * center_mix +
284 (int64_t)
samples[2][
i] * front_mix +
285 (int64_t)
samples[3][
i] * surround_mix +
286 (int64_t)
samples[4][
i] * surround_mix;
293 int out_ch,
int in_ch,
int len)
298 for (
i = 0;
i <
len;
i++) {
300 for (j = 0; j < in_ch; j++) {
307 }
else if (out_ch == 1) {
308 for (
i = 0;
i <
len;
i++) {
310 for (j = 0; j < in_ch; j++)
318 int out_ch,
int in_ch,
int len)
320 if (
c->in_channels != in_ch ||
c->out_channels != out_ch) {
321 c->in_channels = in_ch;
322 c->out_channels = out_ch;
323 c->downmix_fixed =
NULL;
325 if (in_ch == 5 && out_ch == 2 &&
331 }
else if (in_ch == 5 && out_ch == 1 &&
338 if (
c->downmix_fixed)
345 int out_ch,
int in_ch,
int len)
347 if (
c->in_channels != in_ch ||
c->out_channels != out_ch) {
348 int **matrix_cmp = (
int **)
matrix;
350 c->in_channels = in_ch;
351 c->out_channels = out_ch;
354 if (in_ch == 5 && out_ch == 2 &&
355 !(matrix_cmp[1][0] | matrix_cmp[0][2] |
356 matrix_cmp[1][3] | matrix_cmp[0][4] |
357 (matrix_cmp[0][1] ^ matrix_cmp[1][1]) |
358 (matrix_cmp[0][0] ^ matrix_cmp[1][2]))) {
360 }
else if (in_ch == 5 && out_ch == 1 &&
361 matrix_cmp[0][0] == matrix_cmp[0][2] &&
362 matrix_cmp[0][3] == matrix_cmp[0][4]) {
390 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_riscv(AC3DSPContext *c)
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.
av_cold void ff_ac3dsp_init(AC3DSPContext *c)
static const uint8_t bap_tab[64]
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)
#define DECLARE_ALIGNED(n, t, v)
static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
void ff_ac3dsp_init_arm(AC3DSPContext *c)
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 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_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
void ff_ac3dsp_init_x86(AC3DSPContext *c)
static void ac3_downmix_5_to_1_symmetric_c(float **samples, float **matrix, int len)
void ff_ac3dsp_init_mips(AC3DSPContext *c)
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)