Mercurial > libavcodec.hg
comparison aac.c @ 8109:7baa25290231 libavcodec
Fix perceptual noise shaping scaling including an oversight of the offset for
the EIGHT_SHORT window type. Fixes issue 664.
Patch by Alex Converse (alex converse gmail com)
author | superdump |
---|---|
date | Wed, 05 Nov 2008 13:59:42 +0000 |
parents | e70975d5ff80 |
children | 8a8d40fe77d9 |
comparison
equal
deleted
inserted
replaced
8108:5de6db4225d6 | 8109:7baa25290231 |
---|---|
397 ac->sf_scale = 1. / -1024.; | 397 ac->sf_scale = 1. / -1024.; |
398 ac->sf_offset = 60; | 398 ac->sf_offset = 60; |
399 } | 399 } |
400 | 400 |
401 #ifndef CONFIG_HARDCODED_TABLES | 401 #ifndef CONFIG_HARDCODED_TABLES |
402 for (i = 0; i < 316; i++) | 402 for (i = 0; i < 428; i++) |
403 ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); | 403 ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.); |
404 #endif /* CONFIG_HARDCODED_TABLES */ | 404 #endif /* CONFIG_HARDCODED_TABLES */ |
405 | 405 |
406 INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), | 406 INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), |
407 ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), | 407 ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]), |
571 if(offset[1] > 255U) { | 571 if(offset[1] > 255U) { |
572 av_log(ac->avccontext, AV_LOG_ERROR, | 572 av_log(ac->avccontext, AV_LOG_ERROR, |
573 "%s (%d) out of range.\n", sf_str[1], offset[1]); | 573 "%s (%d) out of range.\n", sf_str[1], offset[1]); |
574 return -1; | 574 return -1; |
575 } | 575 } |
576 sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset]; | 576 sf[idx] = -ff_aac_pow2sf_tab[ offset[1] + sf_offset + 100]; |
577 } | 577 } |
578 }else { | 578 }else { |
579 for(; i < run_end; i++, idx++) { | 579 for(; i < run_end; i++, idx++) { |
580 offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; | 580 offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; |
581 if(offset[0] > 255U) { | 581 if(offset[0] > 255U) { |
702 if (cur_band_type == ZERO_BT) { | 702 if (cur_band_type == ZERO_BT) { |
703 for (group = 0; group < ics->group_len[g]; group++) { | 703 for (group = 0; group < ics->group_len[g]; group++) { |
704 memset(coef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(float)); | 704 memset(coef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(float)); |
705 } | 705 } |
706 }else if (cur_band_type == NOISE_BT) { | 706 }else if (cur_band_type == NOISE_BT) { |
707 const float scale = sf[idx] / ((offsets[i+1] - offsets[i]) * PNS_MEAN_ENERGY); | |
708 for (group = 0; group < ics->group_len[g]; group++) { | 707 for (group = 0; group < ics->group_len[g]; group++) { |
708 float scale; | |
709 float band_energy = 0; | |
709 for (k = offsets[i]; k < offsets[i+1]; k++) { | 710 for (k = offsets[i]; k < offsets[i+1]; k++) { |
710 ac->random_state = lcg_random(ac->random_state); | 711 ac->random_state = lcg_random(ac->random_state); |
711 coef[group*128+k] = ac->random_state * scale; | 712 coef[group*128+k] = ac->random_state; |
713 band_energy += coef[group*128+k]*coef[group*128+k]; | |
714 } | |
715 scale = sf[idx] / sqrtf(band_energy); | |
716 for (k = offsets[i]; k < offsets[i+1]; k++) { | |
717 coef[group*128+k] *= scale; | |
712 } | 718 } |
713 } | 719 } |
714 }else if (cur_band_type != INTENSITY_BT2 && cur_band_type != INTENSITY_BT) { | 720 }else if (cur_band_type != INTENSITY_BT2 && cur_band_type != INTENSITY_BT) { |
715 for (group = 0; group < ics->group_len[g]; group++) { | 721 for (group = 0; group < ics->group_len[g]; group++) { |
716 for (k = offsets[i]; k < offsets[i+1]; k += dim) { | 722 for (k = offsets[i]; k < offsets[i+1]; k += dim) { |