summaryrefslogtreecommitdiff
path: root/libavcodec/wmadec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-03-30 14:58:36 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-03-30 14:58:36 +0000
commitd30ba3bb342567028345abba1ac15a1701c55daa (patch)
tree9f0cd398303d56ee9466e3e275e63dea92350d7a /libavcodec/wmadec.c
parent1adc29eedbafaffaf451b1633ba5ace74ad022ed (diff)
reverting 1.31->1.33
fix coverity warning CID: 255 (uninitalized variable used to build tables which arent used, well there is a slight change of a FPU exception maybe ...) (by michael) Init simplification and 2% faster wma_decode_block on amd64 with tables use instead of pow(). (by banan) the init simplifictaion is not correct its not binary identical the pow optimization breaks decoding of http://klif-e.mos.net.au/videos/extr.wmv Originally committed as revision 5247 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/wmadec.c')
-rw-r--r--libavcodec/wmadec.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index d796c805c0..5bf87ac386 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -130,9 +130,6 @@ typedef struct WMADecodeContext {
float lsp_pow_e_table[256];
float lsp_pow_m_table1[(1 << LSP_POW_BITS)];
float lsp_pow_m_table2[(1 << LSP_POW_BITS)];
- /* pow tables */
- float pow_005_10[121];
- float pow_00625_10[121];
#ifdef TRACE
int frame_count;
@@ -221,8 +218,8 @@ static int wma_decode_init(AVCodecContext * avctx)
int i, flags1, flags2;
float *window;
uint8_t *extradata;
- float bps, bps1;
- volatile float high_freq_factor= 0; //initial value should not matter as the tables build from this are unused if !use_noise_coding
+ float bps1, high_freq;
+ volatile float bps;
int sample_rate1;
int coef_vlc_table;
@@ -278,6 +275,7 @@ static int wma_decode_init(AVCodecContext * avctx)
/* init rate dependant parameters */
s->use_noise_coding = 1;
+ high_freq = s->sample_rate * 0.5;
/* if version 2, then the rates are normalized */
sample_rate1 = s->sample_rate;
@@ -306,44 +304,44 @@ static int wma_decode_init(AVCodecContext * avctx)
if (bps1 >= 0.61)
s->use_noise_coding = 0;
else
- high_freq_factor = 0.4;
+ high_freq = high_freq * 0.4;
} else if (sample_rate1 == 22050) {
if (bps1 >= 1.16)
s->use_noise_coding = 0;
else if (bps1 >= 0.72)
- high_freq_factor = 0.7;
+ high_freq = high_freq * 0.7;
else
- high_freq_factor = 0.6;
+ high_freq = high_freq * 0.6;
} else if (sample_rate1 == 16000) {
if (bps > 0.5)
- high_freq_factor = 0.5;
+ high_freq = high_freq * 0.5;
else
- high_freq_factor = 0.3;
+ high_freq = high_freq * 0.3;
} else if (sample_rate1 == 11025) {
- high_freq_factor = 0.7;
+ high_freq = high_freq * 0.7;
} else if (sample_rate1 == 8000) {
if (bps <= 0.625) {
- high_freq_factor = 0.5;
+ high_freq = high_freq * 0.5;
} else if (bps > 0.75) {
s->use_noise_coding = 0;
} else {
- high_freq_factor = 0.65;
+ high_freq = high_freq * 0.65;
}
} else {
if (bps >= 0.8) {
- high_freq_factor = 0.75;
+ high_freq = high_freq * 0.75;
} else if (bps >= 0.6) {
- high_freq_factor = 0.6;
+ high_freq = high_freq * 0.6;
} else {
- high_freq_factor = 0.5;
+ high_freq = high_freq * 0.5;
}
}
dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
s->version, s->nb_channels, s->sample_rate, s->bit_rate,
s->block_align);
- dprintf("bps=%f bps1=%f bitoffset=%d\n",
- bps, bps1, s->byte_offset_bits);
+ dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
+ bps, bps1, high_freq, s->byte_offset_bits);
dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
@@ -416,8 +414,8 @@ static int wma_decode_init(AVCodecContext * avctx)
/* max number of coefs */
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
/* high freq computation */
- s->high_band_start[k] = (int)((block_len * high_freq_factor) + 0.5);
-
+ s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
+ s->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
@@ -529,13 +527,6 @@ static int wma_decode_init(AVCodecContext * avctx)
&coef_vlcs[coef_vlc_table * 2]);
init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
&coef_vlcs[coef_vlc_table * 2 + 1]);
-
- /* init pow tables */
- for (i=0 ; i<121 ; i++) {
- s->pow_005_10[i] = pow(10, i * 0.05);
- s->pow_00625_10[i] = pow(10, i * (1.0 / 16.0));
- }
-
return 0;
}
@@ -687,7 +678,8 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
max_scale = 0;
if (s->version == 1) {
last_exp = get_bits(&s->gb, 5) + 10;
- v = s->pow_00625_10[last_exp];
+ /* XXX: use a table */
+ v = pow(10, last_exp * (1.0 / 16.0));
max_scale = v;
n = *ptr++;
do {
@@ -701,7 +693,8 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
return -1;
/* NOTE: this offset is the same as MPEG4 AAC ! */
last_exp += code - 60;
- v = s->pow_00625_10[last_exp];
+ /* XXX: use a table */
+ v = pow(10, last_exp * (1.0 / 16.0));
if (v > max_scale)
max_scale = v;
n = *ptr++;
@@ -946,7 +939,7 @@ static int wma_decode_block(WMADecodeContext *s)
coefs1 = s->coefs1[ch];
exponents = s->exponents[ch];
- mult = s->pow_005_10[total_gain] / s->max_exponent[ch];
+ mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
mult *= mdct_norm;
coefs = s->coefs[ch];
if (s->use_noise_coding) {
@@ -993,7 +986,8 @@ static int wma_decode_block(WMADecodeContext *s)
if (j >= 0 && s->high_band_coded[ch][j]) {
/* use noise with specified power */
mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
- mult1 = mult1 * s->pow_005_10[s->high_band_values[ch][j]];
+ /* XXX: use a table */
+ mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05);
mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult);
mult1 *= mdct_norm;
for(i = 0;i < n; i++) {