Revision d30ba3bb

View differences:

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];
136 133

  
137 134
#ifdef TRACE
138 135
    int frame_count;
......
221 218
    int i, flags1, flags2;
222 219
    float *window;
223 220
    uint8_t *extradata;
224
    float bps, bps1;
225
    volatile float high_freq_factor= 0; //initial value should not matter as the tables build from this are unused if !use_noise_coding
221
    float bps1, high_freq;
222
    volatile float bps;
226 223
    int sample_rate1;
227 224
    int coef_vlc_table;
228 225

  
......
278 275

  
279 276
    /* init rate dependant parameters */
280 277
    s->use_noise_coding = 1;
278
    high_freq = s->sample_rate * 0.5;
281 279

  
282 280
    /* if version 2, then the rates are normalized */
283 281
    sample_rate1 = s->sample_rate;
......
306 304
        if (bps1 >= 0.61)
307 305
            s->use_noise_coding = 0;
308 306
        else
309
            high_freq_factor = 0.4;
307
            high_freq = high_freq * 0.4;
310 308
    } else if (sample_rate1 == 22050) {
311 309
        if (bps1 >= 1.16)
312 310
            s->use_noise_coding = 0;
313 311
        else if (bps1 >= 0.72)
314
            high_freq_factor = 0.7;
312
            high_freq = high_freq * 0.7;
315 313
        else
316
            high_freq_factor = 0.6;
314
            high_freq = high_freq * 0.6;
317 315
    } else if (sample_rate1 == 16000) {
318 316
        if (bps > 0.5)
319
            high_freq_factor = 0.5;
317
            high_freq = high_freq * 0.5;
320 318
        else
321
            high_freq_factor = 0.3;
319
            high_freq = high_freq * 0.3;
322 320
    } else if (sample_rate1 == 11025) {
323
        high_freq_factor = 0.7;
321
        high_freq = high_freq * 0.7;
324 322
    } else if (sample_rate1 == 8000) {
325 323
        if (bps <= 0.625) {
326
            high_freq_factor = 0.5;
324
            high_freq = high_freq * 0.5;
327 325
        } else if (bps > 0.75) {
328 326
            s->use_noise_coding = 0;
329 327
        } else {
330
            high_freq_factor = 0.65;
328
            high_freq = high_freq * 0.65;
331 329
        }
332 330
    } else {
333 331
        if (bps >= 0.8) {
334
            high_freq_factor = 0.75;
332
            high_freq = high_freq * 0.75;
335 333
        } else if (bps >= 0.6) {
336
            high_freq_factor = 0.6;
334
            high_freq = high_freq * 0.6;
337 335
        } else {
338
            high_freq_factor = 0.5;
336
            high_freq = high_freq * 0.5;
339 337
        }
340 338
    }
341 339
    dprintf("flags1=0x%x flags2=0x%x\n", flags1, flags2);
342 340
    dprintf("version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
343 341
           s->version, s->nb_channels, s->sample_rate, s->bit_rate,
344 342
           s->block_align);
345
    dprintf("bps=%f bps1=%f bitoffset=%d\n",
346
           bps, bps1, s->byte_offset_bits);
343
    dprintf("bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
344
           bps, bps1, high_freq, s->byte_offset_bits);
347 345
    dprintf("use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
348 346
           s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
349 347

  
......
416 414
            /* max number of coefs */
417 415
            s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
418 416
            /* high freq computation */
419
            s->high_band_start[k] = (int)((block_len * high_freq_factor) + 0.5);
420

  
417
            s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
418
                                          s->sample_rate + 0.5);
421 419
            n = s->exponent_sizes[k];
422 420
            j = 0;
423 421
            pos = 0;
......
529 527
                  &coef_vlcs[coef_vlc_table * 2]);
530 528
    init_coef_vlc(&s->coef_vlc[1], &s->run_table[1], &s->level_table[1],
531 529
                  &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

  
539 530
    return 0;
540 531
}
541 532

  
......
687 678
    max_scale = 0;
688 679
    if (s->version == 1) {
689 680
        last_exp = get_bits(&s->gb, 5) + 10;
690
        v = s->pow_00625_10[last_exp];
681
        /* XXX: use a table */
682
        v = pow(10, last_exp * (1.0 / 16.0));
691 683
        max_scale = v;
692 684
        n = *ptr++;
693 685
        do {
......
701 693
            return -1;
702 694
        /* NOTE: this offset is the same as MPEG4 AAC ! */
703 695
        last_exp += code - 60;
704
        v = s->pow_00625_10[last_exp];
696
        /* XXX: use a table */
697
        v = pow(10, last_exp * (1.0 / 16.0));
705 698
        if (v > max_scale)
706 699
            max_scale = v;
707 700
        n = *ptr++;
......
946 939

  
947 940
            coefs1 = s->coefs1[ch];
948 941
            exponents = s->exponents[ch];
949
            mult = s->pow_005_10[total_gain] / s->max_exponent[ch];
942
            mult = pow(10, total_gain * 0.05) / s->max_exponent[ch];
950 943
            mult *= mdct_norm;
951 944
            coefs = s->coefs[ch];
952 945
            if (s->use_noise_coding) {
......
993 986
                    if (j >= 0 && s->high_band_coded[ch][j]) {
994 987
                        /* use noise with specified power */
995 988
                        mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);
996
                        mult1 = mult1 * s->pow_005_10[s->high_band_values[ch][j]];
989
                        /* XXX: use a table */
990
                        mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05);
997 991
                        mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult);
998 992
                        mult1 *= mdct_norm;
999 993
                        for(i = 0;i < n; i++) {

Also available in: Unified diff