diff options
author | Alex Converse <alex.converse@gmail.com> | 2010-07-24 17:11:51 +0000 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2010-07-24 17:11:51 +0000 |
commit | 63e1278d8842ce85cfe8998f5f3d9971e6bce4d5 (patch) | |
tree | e497a3389f3966e0bd9521e7edde4a2e73ee3b7f /libavcodec/aaccoder.c | |
parent | 031d5cea047bc7f19c28476001c40614429f0fa2 (diff) | |
download | ffmpeg-63e1278d8842ce85cfe8998f5f3d9971e6bce4d5.tar.gz |
aacenc: TLS: Save maximum values for each swb in a table.
This gives an almost 20% speedup.
Originally committed as revision 24484 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r-- | libavcodec/aaccoder.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 5ba9848319..8063fb6cd4 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -697,6 +697,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, int start = 0, i, w, w2, g; int destbits = avctx->bit_rate * 1024.0 / avctx->sample_rate / avctx->channels; float dists[128], uplims[128]; + float maxvals[128]; int fflag, minscaler; int its = 0; int allz = 0; @@ -738,6 +739,16 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, if (!allz) return; abs_pow34_v(s->scoefs, sce->coeffs, 1024); + + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { + start = w*128; + for (g = 0; g < sce->ics.num_swb; g++) { + const float *scaled = s->scoefs + start; + maxvals[w*16+g] = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled); + start += sce->ics.swb_sizes[g]; + } + } + //perform two-loop search //outer loop - improve quality do { @@ -763,7 +774,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, continue; } minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); - cb = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]); + cb = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { int b; dist += quantize_band_cost(s, coefs + w2*128, @@ -802,12 +813,10 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, fflag = 0; minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { - start = w*128; 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 (find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]-1)) + if (find_min_book(maxvals[w*16+g], 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; @@ -816,8 +825,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, 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]); - start += sce->ics.swb_sizes[g]; + sce->band_type[w*16+g] = find_min_book(maxvals[w*16+g], sce->sf_idx[w*16+g]); } } its++; |