diff --git a/libavcodec/mips/compute_antialias_fixed.h b/libavcodec/mips/compute_antialias_fixed.h index a967f67de70cff6c697e817f851cccf29a99d78c..1f395d23027b3075317ead7d127eb5dc48827ae7 100644 --- a/libavcodec/mips/compute_antialias_fixed.h +++ b/libavcodec/mips/compute_antialias_fixed.h @@ -59,7 +59,8 @@ static void compute_antialias_mips_fixed(MPADecodeContext *s, GranuleDef *g) { - int32_t *ptr, *csa; + const int32_t *csa; + int32_t *ptr; int n, i; int MAX_lo = 0xffffffff; diff --git a/libavcodec/mips/compute_antialias_float.h b/libavcodec/mips/compute_antialias_float.h index e2b4f29f4ab1de621993ded7fe0a432c70825aea..633eb9589d8ca214325c31e4e1e1958f66a256f6 100644 --- a/libavcodec/mips/compute_antialias_float.h +++ b/libavcodec/mips/compute_antialias_float.h @@ -63,7 +63,7 @@ static void compute_antialias_mips_float(MPADecodeContext *s, GranuleDef *g) { float *ptr, *ptr_end; - float *csa = &csa_table[0][0]; + const float *csa = &csa_table[0][0]; /* temporary variables */ float in1, in2, in3, in4, in5, in6, in7, in8; float out1, out2, out3, out4; diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h index ec969353f32a6097dc2b1c93d6fe7d96bd75622f..01b1f88cd00a6e3b56f6f6a6e8fe36b4dec1e053 100644 --- a/libavcodec/mpegaudiodata.h +++ b/libavcodec/mpegaudiodata.h @@ -65,9 +65,6 @@ extern uint16_t ff_scale_factor_modshift[64]; extern const uint8_t ff_mpa_pretab[2][22]; -/* table for alias reduction (XXX: store it as integer !) */ -extern const float ff_ci_table[8]; - /* Initialize tables shared between the fixed and * floating point MPEG audio decoders. */ void ff_mpegaudiodec_common_init_static(void); diff --git a/libavcodec/mpegaudiodec_common.c b/libavcodec/mpegaudiodec_common.c index 2ac9bb95bc772559ce7f547b66fbb6da37781f7c..4333746e9a6508a476347426a28079a225774e94 100644 --- a/libavcodec/mpegaudiodec_common.c +++ b/libavcodec/mpegaudiodec_common.c @@ -396,10 +396,6 @@ const uint8_t ff_mpa_pretab[2][22] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 }, }; -const float ff_ci_table[8] = { - -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037, -}; - static av_cold void mpegaudiodec_common_init_static(void) { const uint8_t *huff_sym = mpa_huffsymbols, *huff_lens = mpa_hufflens; diff --git a/libavcodec/mpegaudiodec_fixed.c b/libavcodec/mpegaudiodec_fixed.c index 6fe372b38f953c1dd2477bf18b3f0c9e74d4b74c..a3c8ddc21ed9bfdc22f144b241b08d0dd9e8b468 100644 --- a/libavcodec/mpegaudiodec_fixed.c +++ b/libavcodec/mpegaudiodec_fixed.c @@ -36,6 +36,26 @@ #define OUT_FMT AV_SAMPLE_FMT_S16 #define OUT_FMT_P AV_SAMPLE_FMT_S16P +/* Intensity stereo table. See commit b91d46614df189e7905538e7f5c4ed9c7ed0d274 + * (float based mp1/mp2/mp3 decoders.) for how they were created. */ +static const int32_t is_table[2][16] = { + { 0x000000, 0x1B0CB1, 0x2ED9EC, 0x400000, 0x512614, 0x64F34F, 0x800000 }, + { 0x800000, 0x64F34F, 0x512614, 0x400000, 0x2ED9EC, 0x1B0CB1, 0x000000 } +}; + +/* Antialiasing table. See commit ce4a29c066cddfc180979ed86396812f24337985 + * (optimize antialias) for how they were created. */ +static const int32_t csa_table[8][4] = { + { 0x36E129F8, 0xDF128056, 0x15F3AA4E, 0xA831565E }, + { 0x386E75F2, 0xE1CF24A5, 0x1A3D9A97, 0xA960AEB3 }, + { 0x3CC6B73A, 0xEBF19FA6, 0x28B856E0, 0xAF2AE86C }, + { 0x3EEEA054, 0xF45B88BC, 0x334A2910, 0xB56CE868 }, + { 0x3FB6905C, 0xF9F27F18, 0x39A90F74, 0xBA3BEEBC }, + { 0x3FF23F20, 0xFD60D1E4, 0x3D531104, 0xBD6E92C4 }, + { 0x3FFE5932, 0xFF175EE4, 0x3F15B816, 0xBF1905B2 }, + { 0x3FFFE34A, 0xFFC3612F, 0x3FC34479, 0xBFC37DE5 } +}; + #include "mpegaudiodec_template.c" #if CONFIG_MP1_DECODER diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index cdee3374995383a409cefedebe08d4a1d37abe85..3ab7651d5b606eaa6c97e6d5bbc0296abd1f266b 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -36,6 +36,39 @@ #define OUT_FMT AV_SAMPLE_FMT_FLT #define OUT_FMT_P AV_SAMPLE_FMT_FLTP +/* Intensity stereo table. See commit b91d46614df189e7905538e7f5c4ed9c7ed0d274 + * (float based mp1/mp2/mp3 decoders.) for how they were created. */ +static const float is_table[2][16] = { + { 0.000000000000000000e+00, 2.113248705863952637e-01, 3.660253882408142090e-01, + 5.000000000000000000e-01, 6.339746117591857910e-01, 7.886751294136047363e-01, + 1.000000000000000000e+00 }, + { 1.000000000000000000e+00, 7.886751294136047363e-01, 6.339746117591857910e-01, + 5.000000000000000000e-01, 3.660253882408142090e-01, 2.113248705863952637e-01, + 0.000000000000000000e+00 } +}; + +/* Antialiasing table. See commit 6f1ec38ce2193d3d4cacd87edb452c6d7ba751ec + * (mpegaudio: clean up compute_antialias() definition) for how they were + * created. */ +static const float csa_table[8][4] = { + { 8.574929237365722656e-01, -5.144957900047302246e-01, + 3.429971337318420410e-01, -1.371988654136657715e+00 }, + { 8.817420005798339844e-01, -4.717319905757904053e-01, + 4.100100100040435791e-01, -1.353474020957946777e+00 }, + { 9.496286511421203613e-01, -3.133774697780609131e-01, + 6.362511515617370605e-01, -1.263006091117858887e+00 }, + { 9.833145737648010254e-01, -1.819131970405578613e-01, + 8.014013767242431641e-01, -1.165227770805358887e+00 }, + { 9.955177903175354004e-01, -9.457419067621231079e-02, + 9.009436368942260742e-01, -1.090092062950134277e+00 }, + { 9.991605877876281738e-01, -4.096558317542076111e-02, + 9.581949710845947266e-01, -1.040126085281372070e+00 }, + { 9.998992085456848145e-01, -1.419856864959001541e-02, + 9.857006072998046875e-01, -1.014097809791564941e+00 }, + { 9.999931454658508301e-01, -3.699974622577428818e-03, + 9.962931871414184570e-01, -1.003693103790283203e+00 } +}; + #include "mpegaudiodec_template.c" #if CONFIG_MP1FLOAT_DECODER diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index fa75445036363e4f212a7d956cdcf38d2351f4b0..1e8fd6064f2d8374625dedf8b4c8fc198f4a057a 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -99,9 +99,7 @@ typedef struct MPADecodeContext { #include "mpegaudio_tablegen.h" /* intensity stereo coef table */ -static INTFLOAT is_table[2][16]; static INTFLOAT is_table_lsf[2][2][16]; -static INTFLOAT csa_table[8][4]; /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ static int32_t scale_factor_mult[15][3]; @@ -258,22 +256,6 @@ static av_cold void decode_init_static(void) mpegaudio_tableinit(); - for (i = 0; i < 7; i++) { - float f; - INTFLOAT v; - if (i != 6) { - f = tan((double)i * M_PI / 12.0); - v = FIXR(f / (1.0 + f)); - } else { - v = FIXR(1.0); - } - is_table[0][ i] = v; - is_table[1][6 - i] = v; - } - /* invalid values */ - for (i = 7; i < 16; i++) - is_table[0][i] = is_table[1][i] = 0.0; - for (i = 0; i < 16; i++) { double f; int e, k; @@ -289,24 +271,6 @@ static av_cold void decode_init_static(void) (float) is_table_lsf[j][1][i]); } } - - for (i = 0; i < 8; i++) { - double ci, cs, ca; - ci = ff_ci_table[i]; - cs = 1.0 / sqrt(1.0 + ci * ci); - ca = cs * ci; -#if !USE_FLOATS - csa_table[i][0] = FIXHR(cs/4); - csa_table[i][1] = FIXHR(ca/4); - csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); - csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4); -#else - csa_table[i][0] = cs; - csa_table[i][1] = ca; - csa_table[i][2] = ca + cs; - csa_table[i][3] = ca - cs; -#endif - } RENAME(ff_mpa_synth_init)(); ff_mpegaudiodec_common_init_static(); } @@ -970,7 +934,8 @@ static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1) { int i, j, k, l; int sf_max, sf, len, non_zero_found; - INTFLOAT (*is_tab)[16], *tab0, *tab1, v1, v2; + INTFLOAT *tab0, *tab1, v1, v2; + const INTFLOAT (*is_tab)[16]; SUINTFLOAT tmp0, tmp1; int non_zero_found_short[3];