Mercurial > libavcodec.hg
comparison aaccoder.c @ 12263:c7c07caedd2f libavcodec
aacenc: TLS: Try to preserve some energy in each non-zero band.
Reduce scalefactors in non-zero bands that underflow by twice as much as those
in bands that just fail to hit psy targets.
author | alexc |
---|---|
date | Sat, 24 Jul 2010 16:36:01 +0000 |
parents | 940736055764 |
children | aff96d44f992 |
comparison
equal
deleted
inserted
replaced
12262:dde20597f15e | 12263:c7c07caedd2f |
---|---|
804 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { | 804 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
805 start = w*128; | 805 start = w*128; |
806 for (g = 0; g < sce->ics.num_swb; g++) { | 806 for (g = 0; g < sce->ics.num_swb; g++) { |
807 int prevsc = sce->sf_idx[w*16+g]; | 807 int prevsc = sce->sf_idx[w*16+g]; |
808 const float *scaled = s->scoefs + start; | 808 const float *scaled = s->scoefs + start; |
809 if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) | 809 if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) { |
810 if (find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]-1)) | |
810 sce->sf_idx[w*16+g]--; | 811 sce->sf_idx[w*16+g]--; |
812 else //Try to make sure there is some energy in every band | |
813 sce->sf_idx[w*16+g]-=2; | |
814 } | |
811 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); | 815 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF); |
812 sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); | 816 sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219); |
813 if (sce->sf_idx[w*16+g] != prevsc) | 817 if (sce->sf_idx[w*16+g] != prevsc) |
814 fflag = 1; | 818 fflag = 1; |
815 sce->band_type[w*16+g] = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); | 819 sce->band_type[w*16+g] = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); |
820 //av_log(NULL, AV_LOG_ERROR, "w %d swb %2d sf %3d bt %2d dist %f uplim %f ratio %f\n", w, g, sce->sf_idx[w*16+g], sce->band_type[w*16+g], dists[w*16+g], uplims[w*16+g], dists[w*16+g]/uplims[w*16+g]); | |
816 start += sce->ics.swb_sizes[g]; | 821 start += sce->ics.swb_sizes[g]; |
817 } | 822 } |
818 } | 823 } |
819 its++; | 824 its++; |
820 } while (fflag && its < 10); | 825 } while (fflag && its < 10); |