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"
43 #define NR_ALLPASS_BANDS20 30
44 #define NR_ALLPASS_BANDS34 50
49 static int HA[46][8][4];
50 static int HB[46][8][4];
59 Q31(0.00746082949812f),
Q31(0.02270420949825f),
Q31(0.04546865930473f),
Q31(0.07266113929591f),
60 Q31(0.09885108575264f),
Q31(0.11793710567217f),
Q31(0.125f)
64 Q31(0.04081179924692f),
Q31(0.03812810994926f),
Q31(0.05144908135699f),
Q31(0.06399831151592f),
65 Q31(0.07428313801106f),
Q31(0.08100347892914f),
Q31(0.08333333333333f)
69 Q31(0.01565675600122f),
Q31(0.03752716391991f),
Q31(0.05417891378782f),
Q31(0.08417044116767f),
70 Q31(0.10307344158036f),
Q31(0.12222452249753f),
Q31(0.125f)
74 Q31(-0.05908211155639f),
Q31(-0.04871498374946f),
Q31(0.0f),
Q31(0.07778723915851f),
75 Q31( 0.16486303567403f),
Q31( 0.23279856662996f),
Q31(0.25f)
78 static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 };
79 static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 };
80 static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125,
81 0, -759250125, -1073741824, -759250125 };
82 static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125,
83 -1073741824, -759250125, 0, 759250125 };
84 static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824,
85 929887697, 536870912, 0, -536870912,
86 -929887697, -1073741824, -929887697, -536870912 };
87 static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0,
88 -536870912, -929887697, -1073741824, -929887697,
89 -536870912, 0, 536870912, 929887697 };
94 const int *sinptr, *cosptr;
95 int s,
c, sinhalf, coshalf;
103 }
else if (bands == 8) {
112 coshalf = 1037154959;
115 for (q = 0; q < bands; q++) {
116 for (n = 0; n < 7; n++) {
117 int theta = (q*(n-6) + (n>>1) - 3) % bands;
125 theta = (
int)(((int64_t)c * coshalf - (int64_t)s * sinhalf + 0x20000000) >> 30);
126 s = (
int)(((int64_t)s * coshalf + (int64_t)c * sinhalf + 0x20000000) >> 30);
129 filter[q][
n][0] = (
int)(((int64_t)proto[
n] * c + 0x20000000) >> 30);
130 filter[q][
n][1] = -(
int)(((int64_t)proto[
n] * s + 0x20000000) >> 30);
192 static const int gamma_tab[] =
242 static const int iid_par_dequant_c1[] = {
244 Q30(1.41198278375959f),
Q30(1.40313815268360f),
Q30(1.38687670404960f),
Q30(1.34839972492648f),
245 Q30(1.29124937110028f),
Q30(1.19603741667993f),
Q30(1.10737240362323f),
Q30(1),
246 Q30(0.87961716655242f),
Q30(0.75464859232732f),
Q30(0.57677990744575f),
Q30(0.42640143271122f),
247 Q30(0.27671828230984f),
Q30(0.17664462766713f),
Q30(0.07940162697653f),
249 Q30(1.41420649135832f),
Q30(1.41419120222364f),
Q30(1.41414285699784f),
Q30(1.41399000859438f),
250 Q30(1.41350698548044f),
Q30(1.41198278375959f),
Q30(1.40977302262355f),
Q30(1.40539479488545f),
251 Q30(1.39677960498402f),
Q30(1.38005309967827f),
Q30(1.34839972492648f),
Q30(1.31392017367631f),
252 Q30(1.26431008149654f),
Q30(1.19603741667993f),
Q30(1.10737240362323f),
Q30(1),
253 Q30(0.87961716655242f),
Q30(0.75464859232732f),
Q30(0.63365607219232f),
Q30(0.52308104267543f),
254 Q30(0.42640143271122f),
Q30(0.30895540465965f),
Q30(0.22137464873077f),
Q30(0.15768788954414f),
255 Q30(0.11198225164225f),
Q30(0.07940162697653f),
Q30(0.04469901562677f),
Q30(0.02514469318284f),
256 Q30(0.01414142856998f),
Q30(0.00795258154731f),
Q30(0.00447211359449f),
259 static const int acos_icc_invq[] = {
265 static const int8_t f_center_20[] = {
266 -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
268 static const int32_t f_center_34[] = {
270 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),
271 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),
272 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)
274 static const int fractional_delay_links[] = {
Q31(0.43f),
Q31(0.75f),
Q31(0.347f) };
275 const int fractional_delay_gain =
Q31(0.39f);
277 for (pd0 = 0; pd0 < 8; pd0++) {
278 int pd0_re = (ipdopd_cos[pd0]+2)>>2;
279 int pd0_im = (ipdopd_sin[pd0]+2)>>2;
280 for (pd1 = 0; pd1 < 8; pd1++) {
281 int pd1_re = ipdopd_cos[pd1] >> 1;
282 int pd1_im = ipdopd_sin[pd1] >> 1;
283 for (pd2 = 0; pd2 < 8; pd2++) {
285 int pd2_re = ipdopd_cos[pd2];
286 int pd2_im = ipdopd_sin[pd2];
287 int re_smooth = pd0_re + pd1_re + pd2_re;
288 int im_smooth = pd0_im + pd1_im + pd2_im;
290 SoftFloat pd_mag =
av_int2sf(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) +
291 ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 28);
293 shift = 30 - pd_mag.
exp;
294 round = 1 << (shift-1);
302 for (iid = 0; iid < 46; iid++) {
305 c1 = iid_par_dequant_c1[iid];
307 c2 = iid_par_dequant_c1[14-iid];
309 c2 = iid_par_dequant_c1[60-iid];
311 for (icc = 0; icc < 8; icc++) {
316 alpha = acos_icc_invq[icc];
317 beta = (
int)(((int64_t)alpha * 1518500250 + 0x40000000) >> 31);
319 beta = (
int)(((int64_t)beta * (c1 -
c2) + 0x40000000) >> 31);
323 HA[iid][icc][0] = (
int)(((int64_t)c2 * ca + 0x20000000) >> 30);
324 HA[iid][icc][1] = (
int)(((int64_t)c1 * cb + 0x20000000) >> 30);
325 HA[iid][icc][2] = (
int)(((int64_t)c2 * sa + 0x20000000) >> 30);
326 HA[iid][icc][3] = (
int)(((int64_t)c1 * sb + 0x20000000) >> 30);
328 int alpha_int, gamma_int;
329 int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int;
331 alpha_int = alpha_tab[idx];
332 gamma_int = gamma_tab[idx];
337 alpha_c_int = (
int)(((int64_t)alpha_c_int * 1518500250 + 0x20000000) >> 30);
338 alpha_s_int = (
int)(((int64_t)alpha_s_int * 1518500250 + 0x20000000) >> 30);
340 HB[iid][icc][0] = (
int)(((int64_t)alpha_c_int * gamma_c_int + 0x20000000) >> 30);
341 HB[iid][icc][1] = (
int)(((int64_t)alpha_s_int * gamma_c_int + 0x20000000) >> 30);
342 HB[iid][icc][2] = -(
int)(((int64_t)alpha_s_int * gamma_s_int + 0x20000000) >> 30);
343 HB[iid][icc][3] = (
int)(((int64_t)alpha_c_int * gamma_s_int + 0x20000000) >> 30);
346 if (icc < 5 || icc > 6)
357 f_center = f_center_20[k];
359 f_center = (k << 3) - 52;
362 theta = (
int)(((int64_t)fractional_delay_links[m] * f_center + 8) >> 4);
368 theta = (
int)(((int64_t)fractional_delay_gain * f_center + 8) >> 4);
379 f_center = f_center_34[k];
381 f_center = ((int64_t)k << 26) - (53 << 25);
384 theta = (
int)(((int64_t)fractional_delay_links[m] * f_center + 0x10000000) >> 27);
390 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)
Memory handling functions.
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
static double cb(void *priv, double x, double y)
static int pd_im_smooth[8 *8 *8]
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
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)
static double alpha(void *priv, double x, double y)
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]
#define FF_ARRAY_ELEMS(a)
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]