summaryrefslogtreecommitdiff
path: root/libavcodec/aaccoder_twoloop.h
diff options
context:
space:
mode:
authorClaudio Freire <klaussfreire@gmail.com>2015-10-12 03:56:22 -0300
committerClaudio Freire <klaussfreire@gmail.com>2015-10-12 03:56:22 -0300
commitb629c67ddfceb7026e407685f04d1bb09cb08d31 (patch)
tree71bd57e7a1b2d8bd8bbc5d82b259bd847e4fb853 /libavcodec/aaccoder_twoloop.h
parentce0834bdd6e6490d240d76ec8d7845ca0aef1e44 (diff)
AAC encoder: memoize quantize_band_cost
The bulk of calls to quantize_band_cost are replaced by a call to a version that memoizes, greatly improving performance, since during coefficient search there is a great deal of repeat work. Memoization cannot always be applied, so do this in a different function, and leave the original as-is.
Diffstat (limited to 'libavcodec/aaccoder_twoloop.h')
-rw-r--r--libavcodec/aaccoder_twoloop.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/aaccoder_twoloop.h b/libavcodec/aaccoder_twoloop.h
index a46f8dc809..2cc9a52d73 100644
--- a/libavcodec/aaccoder_twoloop.h
+++ b/libavcodec/aaccoder_twoloop.h
@@ -287,6 +287,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
if (!allz)
return;
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
+ ff_quantize_band_cost_cache_init(s);
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
start = w*128;
@@ -380,7 +381,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
int b;
float sqenergy;
- dist += quantize_band_cost(s, coefs + w2*128,
+ dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
scaled + w2*128,
sce->ics.swb_sizes[g],
sce->sf_idx[w*16+g],
@@ -460,7 +461,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
int b;
float sqenergy;
- dist += quantize_band_cost(s, coefs + w2*128,
+ dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
scaled + w2*128,
sce->ics.swb_sizes[g],
sce->sf_idx[w*16+g],
@@ -588,7 +589,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
int b;
float sqenergy;
- dist += quantize_band_cost(s, coefs + w2*128,
+ dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
scaled + w2*128,
sce->ics.swb_sizes[g],
sce->sf_idx[w*16+g]-1,
@@ -625,7 +626,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
int b;
float sqenergy;
- dist += quantize_band_cost(s, coefs + w2*128,
+ dist += quantize_band_cost_cached(s, w + w2, g, coefs + w2*128,
scaled + w2*128,
sce->ics.swb_sizes[g],
sce->sf_idx[w*16+g]+1,