History

Make the faac inspired quantizer search make sense for a slightly narrower definition of "make sense."

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

Alex Converse committed 16 years ago

Commit 32fa7721 parent 9e94bd31 file · +9 −7Browse files

Unified · Split

libavcodec/aaccoder.c+9−7
@@ -763,7 +763,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 762 unmodified lines
763763 const float *scaled = s->scoefs + start;
764764 const int size = sce->ics.swb_sizes[g];
765765 int scf, prev_scf, step;
766− int min_scf = 0, max_scf = 255;
766+ int min_scf = -1, max_scf = 256;
767767 float curdiff;
768768 if (maxq[w*16+g] < 21.544) {
769769 sce->zeroes[w*16+g] = 1;
@@ -797,21 +797,23 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 27 unmodified lines
797797 }
798798 prev_scf = scf;
799799 curdiff = fabsf(dist - uplim[w*16+g]);
800− if (curdiff == 0.0f)
800+ if (curdiff <= 1.0f)
801801 step = 0;
802802 else
803− step = fabsf(log2(curdiff));
803+ step = log2(curdiff);
804804 if (dist > uplim[w*16+g])
805805 step = -step;
806+ scf += step;
807+ av_clip_uint8(scf);
808+ step = scf - prev_scf;
806809 if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) {
807− sce->sf_idx[w*16+g] = scf;
810+ sce->sf_idx[w*16+g] = av_clip(scf, min_scf, max_scf);
808811 break;
809812 }
810− scf += step;
811813 if (step > 0)
812− min_scf = scf;
814+ min_scf = prev_scf;
813815 else
814− max_scf = scf;
816+ max_scf = prev_scf;
815817 }
816818 start += size;
817819 }

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