Revision 6f3dda93 libavcodec/wmadec.c
libavcodec/wmadec.c  

130  130 
float lsp_pow_e_table[256]; 
131  131 
float lsp_pow_m_table1[(1 << LSP_POW_BITS)]; 
132  132 
float lsp_pow_m_table2[(1 << LSP_POW_BITS)]; 
133 
/* pow tables */ 

134 
float pow_005_10[121]; 

135 
float pow_00625_10[121]; 

133  136  
134  137 
#ifdef TRACE 
135  138 
int frame_count; 
...  ...  
218  221 
int i, flags1, flags2; 
219  222 
float *window; 
220  223 
uint8_t *extradata; 
221 
float bps1, high_freq;


222 
volatile float bps;


224 
float bps, bps1;


225 
volatile float high_freq_factor;


223  226 
int sample_rate1; 
224  227 
int coef_vlc_table; 
225  228  
...  ...  
275  278  
276  279 
/* init rate dependant parameters */ 
277  280 
s>use_noise_coding = 1; 
278 
high_freq = s>sample_rate * 0.5; 

279  281  
280  282 
/* if version 2, then the rates are normalized */ 
281  283 
sample_rate1 = s>sample_rate; 
...  ...  
304  306 
if (bps1 >= 0.61) 
305  307 
s>use_noise_coding = 0; 
306  308 
else 
307 
high_freq = high_freq * 0.4;


309 
high_freq_factor = 0.4;


308  310 
} else if (sample_rate1 == 22050) { 
309  311 
if (bps1 >= 1.16) 
310  312 
s>use_noise_coding = 0; 
311  313 
else if (bps1 >= 0.72) 
312 
high_freq = high_freq * 0.7;


314 
high_freq_factor = 0.7;


313  315 
else 
314 
high_freq = high_freq * 0.6;


316 
high_freq_factor = 0.6;


315  317 
} else if (sample_rate1 == 16000) { 
316  318 
if (bps > 0.5) 
317 
high_freq = high_freq * 0.5;


319 
high_freq_factor = 0.5;


318  320 
else 
319 
high_freq = high_freq * 0.3;


321 
high_freq_factor = 0.3;


320  322 
} else if (sample_rate1 == 11025) { 
321 
high_freq = high_freq * 0.7;


323 
high_freq_factor = 0.7;


322  324 
} else if (sample_rate1 == 8000) { 
323  325 
if (bps <= 0.625) { 
324 
high_freq = high_freq * 0.5;


326 
high_freq_factor = 0.5;


325  327 
} else if (bps > 0.75) { 
326  328 
s>use_noise_coding = 0; 
327  329 
} else { 
328 
high_freq = high_freq * 0.65;


330 
high_freq_factor = 0.65;


329  331 
} 
330  332 
} else { 
331  333 
if (bps >= 0.8) { 
332 
high_freq = high_freq * 0.75;


334 
high_freq_factor = 0.75;


333  335 
} else if (bps >= 0.6) { 
334 
high_freq = high_freq * 0.6;


336 
high_freq_factor = 0.6;


335  337 
} else { 
336 
high_freq = high_freq * 0.5;


338 
high_freq_factor = 0.5;


337  339 
} 
338  340 
} 
339  341 
dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2); 
340  342 
dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n", 
341  343 
s>version, s>nb_channels, s>sample_rate, s>bit_rate, 
342  344 
s>block_align); 
343 
dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",


344 
bps, bps1, high_freq, s>byte_offset_bits);


345 
dprintf("bps=%f bps1=%f bitoffset=%d\n", 

346 
bps, bps1, s>byte_offset_bits); 

345  347 
dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n", 
346  348 
s>use_noise_coding, s>use_exp_vlc, s>nb_block_sizes); 
347  349  
...  ...  
414  416 
/* max number of coefs */ 
415  417 
s>coefs_end[k] = (s>frame_len  ((s>frame_len * 9) / 100)) >> k; 
416  418 
/* high freq computation */ 
417 
s>high_band_start[k] = (int)((block_len * 2 * high_freq) /


418 
s>sample_rate + 0.5); 

419 
s>high_band_start[k] = (int)((block_len * high_freq_factor) + 0.5);


420  
419  421 
n = s>exponent_sizes[k]; 
420  422 
j = 0; 
421  423 
pos = 0; 
...  ...  
527  529 
&coef_vlcs[coef_vlc_table * 2]); 
528  530 
init_coef_vlc(&s>coef_vlc[1], &s>run_table[1], &s>level_table[1], 
529  531 
&coef_vlcs[coef_vlc_table * 2 + 1]); 
532  
533 
/* init pow tables */ 

534 
for (i=0 ; i<121 ; i++) { 

535 
s>pow_005_10[i] = pow(10, i * 0.05); 

536 
s>pow_00625_10[i] = pow(10, i * (1.0 / 16.0)); 

537 
} 

538  
530  539 
return 0; 
531  540 
} 
532  541  
...  ...  
678  687 
max_scale = 0; 
679  688 
if (s>version == 1) { 
680  689 
last_exp = get_bits(&s>gb, 5) + 10; 
681 
/* XXX: use a table */ 

682 
v = pow(10, last_exp * (1.0 / 16.0)); 

690 
v = s>pow_00625_10[last_exp]; 

683  691 
max_scale = v; 
684  692 
n = *ptr++; 
685  693 
do { 
...  ...  
693  701 
return 1; 
694  702 
/* NOTE: this offset is the same as MPEG4 AAC ! */ 
695  703 
last_exp += code  60; 
696 
/* XXX: use a table */ 

697 
v = pow(10, last_exp * (1.0 / 16.0)); 

704 
v = s>pow_00625_10[last_exp]; 

698  705 
if (v > max_scale) 
699  706 
max_scale = v; 
700  707 
n = *ptr++; 
...  ...  
939  946  
940  947 
coefs1 = s>coefs1[ch]; 
941  948 
exponents = s>exponents[ch]; 
942 
mult = pow(10, total_gain * 0.05) / s>max_exponent[ch];


949 
mult = s>pow_005_10[total_gain] / s>max_exponent[ch];


943  950 
mult *= mdct_norm; 
944  951 
coefs = s>coefs[ch]; 
945  952 
if (s>use_noise_coding) { 
...  ...  
986  993 
if (j >= 0 && s>high_band_coded[ch][j]) { 
987  994 
/* use noise with specified power */ 
988  995 
mult1 = sqrt(exp_power[j] / exp_power[last_high_band]); 
989 
/* XXX: use a table */ 

990 
mult1 = mult1 * pow(10, s>high_band_values[ch][j] * 0.05); 

996 
mult1 = mult1 * s>pow_005_10[s>high_band_values[ch][j]]; 

991  997 
mult1 = mult1 / (s>max_exponent[ch] * s>noise_mult); 
992  998 
mult1 *= mdct_norm; 
993  999 
for(i = 0;i < n; i++) { 
Also available in: Unified diff