shithub: aacenc

Download patch

ref: e0066b4725069ce120acde8d584ade9bc2d3d0cf
parent: 1142f086784e83999d53a560448aa80e392f0811
author: Krzysztof Nikiel <knik@users.sourceforge.net>
date: Sat Oct 28 09:48:41 EDT 2017

scalefactor step more compliant with AAC specs

--- a/libfaac/quantize.c
+++ b/libfaac/quantize.c
@@ -146,8 +146,12 @@
                   )
 {
     int sb, cnt;
-    // 1.5dB step
-    static const double sfstep = 20.0 / 1.5 / M_LN10;
+#ifndef __clang__
+    /* 2^0.25 (1.50515 dB) step from AAC specs */
+    static const double sfstep = 1.0 / log10(sqrt(sqrt(2.0)));
+#else
+    static const double sfstep = 20 / 1.50515;
+#endif
     int gsize = coderInfo->groups.len[gnum];
 #ifdef __SSE2__
     int cpuid[4];
@@ -200,11 +204,11 @@
       }
 
       //printf("qual:%f/%f\n", bandqual[sb], bandqual[sb]/rmsx);
-      sfac = lrint(log(bandqual[sb] / rmsx) * sfstep);
+      sfac = lrint(log10(bandqual[sb] / rmsx) * sfstep);
       if ((SF_OFFSET - sfac) < 10)
           sfacfix = 0.0;
       else
-          sfacfix = exp(sfac / sfstep);
+          sfacfix = pow(10, sfac / sfstep);
 
       xr = xr0 + start;
       end -= start;