aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aaccoder.c
diff options
context:
space:
mode:
authorAlex Converse <alex.converse@gmail.com>2010-07-24 16:36:01 +0000
committerAlex Converse <alex.converse@gmail.com>2010-07-24 16:36:01 +0000
commitfe461767e69b4f1b63a8e619e9b88e5f790bf60b (patch)
treef65f6523f30826b420dd7546b1295ebafd1f2978 /libavcodec/aaccoder.c
parent6cce7cabdb2cd49f7182c8f74aac1e981d781c43 (diff)
downloadffmpeg-fe461767e69b4f1b63a8e619e9b88e5f790bf60b.tar.gz
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. Originally committed as revision 24482 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r--libavcodec/aaccoder.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 9d768d4ee4..919f9ffa54 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -806,13 +806,18 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
for (g = 0; g < sce->ics.num_swb; g++) {
int prevsc = sce->sf_idx[w*16+g];
const float *scaled = s->scoefs + start;
- if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60)
+ if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60) {
+ 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))
sce->sf_idx[w*16+g]--;
+ else //Try to make sure there is some energy in every band
+ sce->sf_idx[w*16+g]-=2;
+ }
sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF);
sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219);
if (sce->sf_idx[w*16+g] != prevsc)
fflag = 1;
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]);
+//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]);
start += sce->ics.swb_sizes[g];
}
}