History

Define POW_SF2_ZERO in aac.h and use for ff_aac_pow2sf_tabp[] offsets instead of hardcoding 200 everywhere.

Alex Converse committed 15 years ago

Commit d70fa4c1 parent e4744b54 files · +10 −8Browse files

Unified · Split

4 files
  1. libavcodec/aac.h +1 −0
  2. libavcodec/aac_tablegen.h +2 −1
  3. libavcodec/aaccoder.c +4 −4
  4. libavcodec/aacdec.c +3 −3
libavcodec/aac.h+1−0
@@ -130,6 +130,7 @@ typedef struct { · 129 unmodified lines
130130 #define SCALE_MAX_POS 255 ///< scalefactor index maximum value
131131 #define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
132132 #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);
133134
134135 /**
135136 * Long Term Prediction
libavcodec/aac_tablegen.h+2−1
@@ -29,13 +29,14 @@ · 28 unmodified lines
2929 #include "libavcodec/aac_tables.h"
3030 #else
3131 #include "libavutil/mathematics.h"
32+#include "libavcodec/aac.h"
3233 float ff_aac_pow2sf_tab[428];
3334
3435 void ff_aac_tableinit(void)
3536 {
3637 int i;
3738 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.);
3940 }
4041 #endif /* CONFIG_HARDCODED_TABLES */
4142
libavcodec/aaccoder.c+4−4
@@ -108,8 +108,8 @@ static av_always_inline float quantize_and_encode_band_cost_template( · 107 unmodified lines
108108 int *bits, int BT_ZERO, int BT_UNSIGNED,
109109 int BT_PAIR, int BT_ESC)
110110 {
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];
113113 const float CLIPPED_ESCAPE = 165140.0f*IQ;
114114 int i, j;
115115 float cost = 0;
@@ -280,7 +280,7 @@ static float find_max_val(int group_len, int swb_size, const float *scaled) { · 164 unmodified lines
280280 }
281281
282282 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];
284284 float Q34 = sqrtf(Q * sqrtf(Q));
285285 int qmaxval, cb;
286286 qmaxval = maxval * Q34 + 0.4054f;
@@ -955,7 +955,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 668 unmodified lines
955955 dist -= b;
956956 }
957957 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]);
959959 if (quant_max >= 8191) { // too much, return to the previous quantizer
960960 sce->sf_idx[w*16+g] = prev_scf;
961961 break;
libavcodec/aacdec.c+3−3
@@ -811,7 +811,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 810 unmodified lines
811811 "audible artifact, there may be a bug in the "
812812 "decoder. ", offset[2], clipped_offset);
813813 }
814− sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + 200];
814+ sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO];
815815 }
816816 } else if (band_type[idx] == NOISE_BT) {
817817 for (; i < run_end; i++, idx++) {
@@ -826,7 +826,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 8 unmodified lines
826826 "artifact, there may be a bug in the decoder. ",
827827 offset[1], clipped_offset);
828828 }
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];
830830 }
831831 } else {
832832 for (; i < run_end; i++, idx++) {
@@ -836,7 +836,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, · 3 unmodified lines
836836 "%s (%d) out of range.\n", sf_str[0], offset[0]);
837837 return -1;
838838 }
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];
840840 }
841841 }
842842 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t