26 #ifndef AVCODEC_AACPS_FIXED_TABLEGEN_H 27 #define AVCODEC_AACPS_FIXED_TABLEGEN_H 32 #if CONFIG_HARDCODED_TABLES 33 #define ps_tableinit() 34 #define TABLE_CONST const 35 #include "libavcodec/aacps_fixed_tables.h" 40 #undef DECLARE_ALIGNED 41 #define DECLARE_ALIGNED(align, type, variable) type variable 48 #define NR_ALLPASS_BANDS20 30 49 #define NR_ALLPASS_BANDS34 50 54 static int HA[46][8][4];
55 static int HB[46][8][4];
64 Q31(0.00746082949812
f),
Q31(0.02270420949825
f),
Q31(0.04546865930473
f),
Q31(0.07266113929591
f),
65 Q31(0.09885108575264
f),
Q31(0.11793710567217
f),
Q31(0.125
f)
69 Q31(0.04081179924692
f),
Q31(0.03812810994926
f),
Q31(0.05144908135699
f),
Q31(0.06399831151592
f),
70 Q31(0.07428313801106
f),
Q31(0.08100347892914
f),
Q31(0.08333333333333
f)
74 Q31(0.01565675600122
f),
Q31(0.03752716391991
f),
Q31(0.05417891378782
f),
Q31(0.08417044116767
f),
75 Q31(0.10307344158036
f),
Q31(0.12222452249753
f),
Q31(0.125
f)
79 Q31(-0.05908211155639
f),
Q31(-0.04871498374946
f),
Q31(0.0
f),
Q31(0.07778723915851
f),
80 Q31( 0.16486303567403
f),
Q31( 0.23279856662996
f),
Q31(0.25
f)
83 static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 };
84 static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 };
85 static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125,
86 0, -759250125, -1073741824, -759250125 };
87 static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125,
88 -1073741824, -759250125, 0, 759250125 };
89 static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824,
90 929887697, 536870912, 0, -536870912,
91 -929887697, -1073741824, -929887697, -536870912 };
92 static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0,
93 -536870912, -929887697, -1073741824, -929887697,
94 -536870912, 0, 536870912, 929887697 };
99 const int *sinptr, *cosptr;
100 int s,
c, sinhalf, coshalf;
108 }
else if (bands == 8) {
117 coshalf = 1037154959;
120 for (q = 0; q <
bands; q++) {
121 for (n = 0; n < 7; n++) {
122 int theta = (q*(n-6) + (n>>1) - 3) % bands;
130 theta = (
int)(((int64_t)c * coshalf - (int64_t)s * sinhalf + 0x20000000) >> 30);
131 s = (
int)(((int64_t)s * coshalf + (int64_t)c * sinhalf + 0x20000000) >> 30);
134 filter[q][n][0] = (
int)(((int64_t)proto[n] * c + 0x20000000) >> 30);
135 filter[q][n][1] = -(
int)(((int64_t)proto[n] * s + 0x20000000) >> 30);
197 static const int gamma_tab[] =
247 static const int iid_par_dequant_c1[] = {
249 Q30(1.41198278375959
f),
Q30(1.40313815268360
f),
Q30(1.38687670404960
f),
Q30(1.34839972492648
f),
250 Q30(1.29124937110028
f),
Q30(1.19603741667993
f),
Q30(1.10737240362323
f),
Q30(1),
251 Q30(0.87961716655242
f),
Q30(0.75464859232732
f),
Q30(0.57677990744575
f),
Q30(0.42640143271122
f),
252 Q30(0.27671828230984
f),
Q30(0.17664462766713
f),
Q30(0.07940162697653
f),
254 Q30(1.41420649135832
f),
Q30(1.41419120222364
f),
Q30(1.41414285699784
f),
Q30(1.41399000859438
f),
255 Q30(1.41350698548044
f),
Q30(1.41198278375959
f),
Q30(1.40977302262355
f),
Q30(1.40539479488545
f),
256 Q30(1.39677960498402
f),
Q30(1.38005309967827
f),
Q30(1.34839972492648
f),
Q30(1.31392017367631
f),
257 Q30(1.26431008149654
f),
Q30(1.19603741667993
f),
Q30(1.10737240362323
f),
Q30(1),
258 Q30(0.87961716655242
f),
Q30(0.75464859232732
f),
Q30(0.63365607219232
f),
Q30(0.52308104267543
f),
259 Q30(0.42640143271122
f),
Q30(0.30895540465965
f),
Q30(0.22137464873077
f),
Q30(0.15768788954414
f),
260 Q30(0.11198225164225
f),
Q30(0.07940162697653
f),
Q30(0.04469901562677
f),
Q30(0.02514469318284
f),
261 Q30(0.01414142856998
f),
Q30(0.00795258154731
f),
Q30(0.00447211359449
f),
264 static const int acos_icc_invq[] = {
270 static const int8_t f_center_20[] = {
271 -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
273 static const int32_t f_center_34[] = {
275 Q31( 34/768.0),
Q31(-10/768.0),
Q31(-6/768.0),
Q31(-2/768.0),
Q31( 51/768.0),
Q31( 57/768.0),
Q31( 15/768.0),
Q31(21/768.0),
276 Q31( 27/768.0),
Q31( 33/768.0),
Q31(39/768.0),
Q31(45/768.0),
Q31( 54/768.0),
Q31( 66/768.0),
Q31( 78/768.0),
Q31(42/768.0),
277 Q31(102/768.0),
Q31( 66/768.0),
Q31(78/768.0),
Q31(90/768.0),
Q31(102/768.0),
Q31(114/768.0),
Q31(126/768.0),
Q31(90/768.0)
279 static const int fractional_delay_links[] = {
Q31(0.43
f),
Q31(0.75
f),
Q31(0.347
f) };
280 const int fractional_delay_gain =
Q31(0.39
f);
282 for (pd0 = 0; pd0 < 8; pd0++) {
283 int pd0_re = (ipdopd_cos[pd0]+2)>>2;
284 int pd0_im = (ipdopd_sin[pd0]+2)>>2;
285 for (pd1 = 0; pd1 < 8; pd1++) {
286 int pd1_re = ipdopd_cos[pd1] >> 1;
287 int pd1_im = ipdopd_sin[pd1] >> 1;
288 for (pd2 = 0; pd2 < 8; pd2++) {
290 int pd2_re = ipdopd_cos[pd2];
291 int pd2_im = ipdopd_sin[pd2];
292 int re_smooth = pd0_re + pd1_re + pd2_re;
293 int im_smooth = pd0_im + pd1_im + pd2_im;
295 SoftFloat pd_mag =
av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) +
296 ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28);
298 shift = 30 - pd_mag.
exp;
299 round = 1 << (shift-1);
307 for (iid = 0; iid < 46; iid++) {
310 c1 = iid_par_dequant_c1[iid];
312 c2 = iid_par_dequant_c1[14-iid];
314 c2 = iid_par_dequant_c1[60-iid];
316 for (icc = 0; icc < 8; icc++) {
321 alpha = acos_icc_invq[icc];
322 beta = (
int)(((int64_t)alpha * 1518500250 + 0x40000000) >> 31);
324 beta = (
int)(((int64_t)beta * (c1 -
c2) + 0x40000000) >> 31);
328 HA[iid][icc][0] = (
int)(((int64_t)c2 * ca + 0x20000000) >> 30);
329 HA[iid][icc][1] = (
int)(((int64_t)c1 * cb + 0x20000000) >> 30);
330 HA[iid][icc][2] = (
int)(((int64_t)c2 * sa + 0x20000000) >> 30);
331 HA[iid][icc][3] = (
int)(((int64_t)c1 * sb + 0x20000000) >> 30);
333 int alpha_int, gamma_int;
334 int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int;
336 alpha_int = alpha_tab[idx];
337 gamma_int = gamma_tab[idx];
342 alpha_c_int = (
int)(((int64_t)alpha_c_int * 1518500250 + 0x20000000) >> 30);
343 alpha_s_int = (
int)(((int64_t)alpha_s_int * 1518500250 + 0x20000000) >> 30);
345 HB[iid][icc][0] = (
int)(((int64_t)alpha_c_int * gamma_c_int + 0x20000000) >> 30);
346 HB[iid][icc][1] = (
int)(((int64_t)alpha_s_int * gamma_c_int + 0x20000000) >> 30);
347 HB[iid][icc][2] = -(
int)(((int64_t)alpha_s_int * gamma_s_int + 0x20000000) >> 30);
348 HB[iid][icc][3] = (
int)(((int64_t)alpha_c_int * gamma_s_int + 0x20000000) >> 30);
351 if (icc < 5 || icc > 6)
362 f_center = f_center_20[k];
364 f_center = (k << 3) - 52;
367 theta = (
int)(((int64_t)fractional_delay_links[m] * f_center + 8) >> 4);
373 theta = (
int)(((int64_t)fractional_delay_gain * f_center + 8) >> 4);
384 f_center = f_center_34[k];
386 f_center = ((int64_t)k << 26) - (53 << 25);
389 theta = (
int)(((int64_t)fractional_delay_links[m] * f_center + 0x10000000) >> 27);
395 theta = (
int)(((int64_t)fractional_delay_gain * f_center + 0x10000000) >> 27);
static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val)
Rounding-to-nearest used.
static int shift(int a, int b)
static TABLE_CONST int Q_fract_allpass[2][50][3][2]
static av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b)
b has to be normalized and not zero.
#define NR_ALLPASS_BANDS34
#define FF_ARRAY_ELEMS(a)
static double cb(void *priv, double x, double y)
static int pd_im_smooth[8 *8 *8]
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 const int costbl_4[4]
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static int f34_0_12[12][8][2]
static const int g0_Q12[]
static void make_filters_from_proto(int(*filter)[8][2], const int *proto, int bands)
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
static const SoftFloat FLOAT_1
1.0
static const int sintbl_12[12]
static av_always_inline av_const double round(double x)
static int phi_fract[2][50][2]
static av_unused void av_sincos_sf(int a, int *s, int *c)
Rounding-to-nearest used.
#define NR_ALLPASS_BANDS20
static int f34_1_8[8][8][2]
static const int sintbl_8[8]
static const int sintbl_4[4]
static const int16_t alpha[]
static const float bands[]
static const int costbl_8[8]
static void ps_tableinit(void)
static const int costbl_12[12]
common internal and external API header
static int pd_re_smooth[8 *8 *8]
static int f34_2_4[4][8][2]
static av_const SoftFloat av_int2sf(int v, int frac_bits)
Converts a mantisse and exponent to a SoftFloat.
static int f20_0_8[8][8][2]
static const uint8_t alpha_tab[64]