History

aacenc: Factor out find_min_book so it can be used by multiple coefficient coders.

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

Alex Converse committed 16 years ago

Commit 05e659e1 parent aafb8221 file · +22 −17Browse files

Showing the changes to libavcodec/aaccoder.c (1 of 1 file). Show all

Unified · Split

libavcodec/aaccoder.c+22−17
@@ -216,6 +216,27 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 215 unmodified lines
216 INFINITY, NULL);216 INFINITY, NULL);
217}217}
218 218
219static int find_min_book(int sf, int group_len, int swb_size, const float *scaled) {
220 float maxval = 0.0f;
221 float Q = ff_aac_pow2sf_tab[200 - sf + SCALE_ONE_POS - SCALE_DIV_512];
222 float Q34 = sqrtf(Q * sqrtf(Q));
223 int qmaxval, cb, w2, i;
224 for (w2 = 0; w2 < group_len; w2++) {
225 for (i = 0; i < swb_size; i++) {
226 maxval = FFMAX(maxval, scaled[w2*128+i]);
227 }
228 }
229 qmaxval = maxval * Q34 + 0.4054f;
230 if (qmaxval == 0) cb = 0;
231 else if (qmaxval == 1) cb = 1;
232 else if (qmaxval == 2) cb = 3;
233 else if (qmaxval <= 4) cb = 5;
234 else if (qmaxval <= 7) cb = 7;
235 else if (qmaxval <= 12) cb = 9;
236 else cb = 11;
237 return cb;
238}
239
219/**240/**
220 * structure used in optimal codebook search241 * structure used in optimal codebook search
221 */242 */
@@ -673,23 +694,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 451 unmodified lines
673 {694 {
674 float dist = 0.0f;695 float dist = 0.0f;
675 int bb = 0;696 int bb = 0;
676 float maxval = 0.0f;697 cb = find_min_book(sce->sf_idx[w*16+g], sce->ics.group_len[w], sce->ics.swb_sizes[g], scaled);
677 float Q = ff_aac_pow2sf_tab[200 - sce->sf_idx[w*16+g] + SCALE_ONE_POS - SCALE_DIV_512];
678 float Q34 = sqrtf(Q * sqrtf(Q));
679 int qmaxval;
680 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
681 for (i = 0; i < sce->ics.swb_sizes[g]; i++) {
682 maxval = FFMAX(maxval, scaled[w2*128+i]);
683 }
684 }
685 qmaxval = maxval * Q34 + 0.4054;
686 if (qmaxval == 0) cb = 0;
687 else if (qmaxval == 1) cb = 1;
688 else if (qmaxval == 2) cb = 3;
689 else if (qmaxval <= 4) cb = 5;
690 else if (qmaxval <= 7) cb = 7;
691 else if (qmaxval <= 12) cb = 9;
692 else cb = 11;
693 sce->band_type[w*16+g] = cb;698 sce->band_type[w*16+g] = cb;
694 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {699 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
695 int b;700 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