History

aacenc: Favor log2f() and sqrtf() over log2() and sqrt().

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

Alex Converse committed 16 years ago

Commit 51ffd3a1 parent 04d72ab1 file · +7 −7Browse files

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

Unified · Split

libavcodec/aaccoder.c+7−7
@@ -517,12 +517,12 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 516 unmodified lines
517517
518518 /** Return the minimum scalefactor where the quantized coef does not clip. */
519519 static av_always_inline uint8_t coef2minsf(float coef) {
520− return av_clip_uint8(log2(coef)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
520+ return av_clip_uint8(log2f(coef)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
521521 }
522522
523523 /** Return the maximum scalefactor where the quantized coef is not zero. */
524524 static av_always_inline uint8_t coef2maxsf(float coef) {
525− return av_clip_uint8(log2(coef)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
525+ return av_clip_uint8(log2f(coef)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
526526 }
527527
528528 typedef struct TrellisPath {
@@ -572,7 +572,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 43 unmodified lines
572572 int q0low = q0;
573573 int q1high = q1;
574574 //minimum scalefactor index is when maximum nonzero coefficient after quantizing is not clipped
575− int qnrg = av_clip_uint8(log2(sqrt(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
575+ int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512);
576576 q1 = qnrg + 30;
577577 q0 = qnrg - 30;
578578 //av_log(NULL, AV_LOG_ERROR, "q0 %d, q1 %d\n", q0, q1);
@@ -731,7 +731,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 152 unmodified lines
731731 sce->sf_idx[w*16+g] = SCALE_ONE_POS;
732732 continue;
733733 }
734− sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2(uplims[w*16+g]/minthr)*4,59);
734+ sce->sf_idx[w*16+g] = SCALE_ONE_POS + FFMIN(log2f(uplims[w*16+g]/minthr)*4,59);
735735 }
736736 }
737737
@@ -925,7 +925,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 187 unmodified lines
925925 continue;
926926 }
927927 sce->zeroes[w*16+g] = 0;
928− scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2(1/maxq[w*16+g])*16/3, 60, 218);
928+ scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2f(1/maxq[w*16+g])*16/3, 60, 218);
929929 step = 16;
930930 for (;;) {
931931 float dist = 0.0f;
@@ -954,7 +954,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 22 unmodified lines
954954 if (curdiff <= 1.0f)
955955 step = 0;
956956 else
957− step = log2(curdiff);
957+ step = log2f(curdiff);
958958 if (dist > uplim[w*16+g])
959959 step = -step;
960960 scf += step;
@@ -1007,7 +1007,7 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 46 unmodified lines
10071007 sce->sf_idx[(w+w2)*16+g] = 218;
10081008 sce->zeroes[(w+w2)*16+g] = 1;
10091009 } else {
1010− sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2(band->threshold), 80, 218);
1010+ sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2f(band->threshold), 80, 218);
10111011 sce->zeroes[(w+w2)*16+g] = 0;
10121012 }
10131013 minq = FFMIN(minq, sce->sf_idx[(w+w2)*16+g]);

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