History

aacenc: Split find_max_val() from find_min_book() to eliminate duplicate searches.

Originally committed as revision 23322 to svn://svn.ffmpeg.org/ffmpeg/trunk

Alex Converse committed 16 years ago

Commit 0ecfa7b1 parent af2ee6f1 file · +12 −6Browse files

Unified · Split

libavcodec/aaccoder.c+12−6
@@ -217,16 +217,21 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 216 unmodified lines
217217 INFINITY, NULL);
218218 }
219219
220−static int find_min_book(int sf, int group_len, int swb_size, const float *scaled) {
220+static float find_max_val(int group_len, int swb_size, const float *scaled) {
221221 float maxval = 0.0f;
222− float Q = ff_aac_pow2sf_tab[200 - sf + SCALE_ONE_POS - SCALE_DIV_512];
223− float Q34 = sqrtf(Q * sqrtf(Q));
224− int qmaxval, cb, w2, i;
222+ int w2, i;
225223 for (w2 = 0; w2 < group_len; w2++) {
226224 for (i = 0; i < swb_size; i++) {
227225 maxval = FFMAX(maxval, scaled[w2*128+i]);
228226 }
229227 }
228+ return maxval;
229+}
230+
231+static int find_min_book(float maxval, int sf) {
232+ float Q = ff_aac_pow2sf_tab[200 - sf + SCALE_ONE_POS - SCALE_DIV_512];
233+ float Q34 = sqrtf(Q * sqrtf(Q));
234+ int qmaxval, cb;
230235 qmaxval = maxval * Q34 + 0.4054f;
231236 if (qmaxval == 0) cb = 0;
232237 else if (qmaxval == 1) cb = 1;
@@ -567,9 +572,10 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 334 unmodified lines
567572 maxscale = av_clip_uint8(log2(qmax)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
568573 minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1);
569574 maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES);
575+ float maxval = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start);
570576 for (q = minscale; q < maxscale; q++) {
571577 float dist = 0;
572− int cb = find_min_book(sce->sf_idx[w*16+g], sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start);
578+ int cb = find_min_book(maxval, sce->sf_idx[w*16+g]);
573579 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
574580 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
575581 dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g],
@@ -700,7 +706,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 124 unmodified lines
700706 {
701707 float dist = 0.0f;
702708 int bb = 0;
703− cb = find_min_book(sce->sf_idx[w*16+g], sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled);
709+ cb = find_min_book(find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled), sce->sf_idx[w*16+g]);
704710 sce->band_type[w*16+g] = cb;
705711 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
706712 int b;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t