Unified · Split
| @@ -130,6 +130,7 @@ typedef struct { · 129 unmodified lines | ||
| 130 | 130 | #define SCALE_MAX_POS 255 ///< scalefactor index maximum value |
| 131 | 131 | #define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard |
| 132 | 132 | #define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference |
| 133 | +#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0); | |
| 133 | 134 | |
| 134 | 135 | /** |
| 135 | 136 | * Long Term Prediction |
| @@ -29,13 +29,14 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavcodec/aac_tables.h" |
| 30 | 30 | #else |
| 31 | 31 | #include "libavutil/mathematics.h" |
| 32 | +#include "libavcodec/aac.h" | |
| 32 | 33 | float ff_aac_pow2sf_tab[428]; |
| 33 | 34 | |
| 34 | 35 | void ff_aac_tableinit(void) |
| 35 | 36 | { |
| 36 | 37 | int i; |
| 37 | 38 | for (i = 0; i < 428; i++) |
| 38 | − ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); | |
| 39 | + ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.); | |
| 39 | 40 | } |
| 40 | 41 | #endif /* CONFIG_HARDCODED_TABLES */ |
| 41 | 42 | |
| @@ -108,8 +108,8 @@ static av_always_inline float quantize_and_encode_band_cost_template( · 107 unmodified lines | ||
| 108 | 108 | int *bits, int BT_ZERO, int BT_UNSIGNED, |
| 109 | 109 | int BT_PAIR, int BT_ESC) |
| 110 | 110 | { |
| 111 | − const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; | |
| 112 | − const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; | |
| 111 | + const float IQ = ff_aac_pow2sf_tab[POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; | |
| 112 | + const float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; | |
| 113 | 113 | const float CLIPPED_ESCAPE = 165140.0f*IQ; |
| 114 | 114 | int i, j; |
| 115 | 115 | float cost = 0; |
| @@ -280,7 +280,7 @@ static float find_max_val(int group_len, int swb_size, const float *scaled) { · 164 unmodified lines | ||
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | static int find_min_book(float maxval, int sf) { |
| 283 | − float Q = ff_aac_pow2sf_tab[200 - sf + SCALE_ONE_POS - SCALE_DIV_512]; | |
| 283 | + float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - sf + SCALE_ONE_POS - SCALE_DIV_512]; | |
| 284 | 284 | float Q34 = sqrtf(Q * sqrtf(Q)); |
| 285 | 285 | int qmaxval, cb; |
| 286 | 286 | qmaxval = maxval * Q34 + 0.4054f; |
| @@ -955,7 +955,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 668 unmodified lines | ||
| 955 | 955 | dist -= b; |
| 956 | 956 | } |
| 957 | 957 | dist *= 1.0f / 512.0f / lambda; |
| 958 | − quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]); | |
| 958 | + quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512]); | |
| 959 | 959 | if (quant_max >= 8191) { // too much, return to the previous quantizer |
| 960 | 960 | sce->sf_idx[w*16+g] = prev_scf; |
| 961 | 961 | break; |
| @@ -811,7 +811,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 810 unmodified lines | ||
| 811 | 811 | "audible artifact, there may be a bug in the " |
| 812 | 812 | "decoder. ", offset[2], clipped_offset); |
| 813 | 813 | } |
| 814 | − sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + 200]; | |
| 814 | + sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; | |
| 815 | 815 | } |
| 816 | 816 | } else if (band_type[idx] == NOISE_BT) { |
| 817 | 817 | for (; i < run_end; i++, idx++) { |
| @@ -826,7 +826,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 8 unmodified lines | ||
| 826 | 826 | "artifact, there may be a bug in the decoder. ", |
| 827 | 827 | offset[1], clipped_offset); |
| 828 | 828 | } |
| 829 | − sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + sf_offset + 100]; | |
| 829 | + sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + sf_offset - 100 + POW_SF2_ZERO]; | |
| 830 | 830 | } |
| 831 | 831 | } else { |
| 832 | 832 | for (; i < run_end; i++, idx++) { |
| @@ -836,7 +836,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 3 unmodified lines | ||
| 836 | 836 | "%s (%d) out of range.\n", sf_str[0], offset[0]); |
| 837 | 837 | return -1; |
| 838 | 838 | } |
| 839 | − sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset]; | |
| 839 | + sf[idx] = -ff_aac_pow2sf_tab[offset[0] + sf_offset - 200 + POW_SF2_ZERO]; | |
| 840 | 840 | } |
| 841 | 841 | } |
| 842 | 842 | } |