Browse code

Use log2(x) instead of log(x) / log(2)

Signed-off-by: Mans Rullgard <mans@mansr.com>

Mans Rullgard authored on 2012/08/06 06:22:10
Showing 4 changed files
... ...
@@ -820,7 +820,7 @@ static void print_report(int is_last_report, int64_t timer_start)
820 820
                 if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram))
821 821
                     qp_histogram[qp]++;
822 822
                 for (j = 0; j < 32; j++)
823
-                    snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j] + 1) / log(2)));
823
+                    snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1)));
824 824
             }
825 825
             if (enc->flags&CODEC_FLAG_PSNR) {
826 826
                 int j;
... ...
@@ -468,7 +468,7 @@ static char *value_string(char *buf, int buf_size, double val, const char *unit)
468 468
         int index;
469 469
 
470 470
         if (unit == unit_byte_str && use_byte_value_binary_prefix) {
471
-            index = (int) (log(val)/log(2)) / 10;
471
+            index = (int) log2(val) / 10;
472 472
             index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 1);
473 473
             val  /= pow(2, index * 10);
474 474
             prefix_string = binary_unit_prefixes[index];
... ...
@@ -342,7 +342,7 @@ static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf,
342 342
     // maybe some frequency division thingy
343 343
 
344 344
     flcoeffs1[0] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125
345
-    flcoeffs2[0] = log(flcoeffs1[0]) / log(2);
345
+    flcoeffs2[0] = log2f(flcoeffs1[0]);
346 346
     tmp  = flcoeffs1[0];
347 347
     tmp2 = flcoeffs2[0];
348 348
 
... ...
@@ -414,7 +414,7 @@ static int bit_allocation(IMCContext *q, IMCChannel *chctx,
414 414
         highest = FFMAX(highest, chctx->flcoeffs1[i]);
415 415
 
416 416
     for (i = 0; i < BANDS - 1; i++)
417
-        chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log(chctx->flcoeffs5[i]) / log(2);
417
+        chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
418 418
     chctx->flcoeffs4[BANDS - 1] = limit;
419 419
 
420 420
     highest = highest * 0.25;
... ...
@@ -1529,7 +1529,7 @@ static void update_last_header_values(SnowContext *s){
1529 1529
 }
1530 1530
 
1531 1531
 static int qscale2qlog(int qscale){
1532
-    return rint(QROOT*log(qscale / (float)FF_QP2LAMBDA)/log(2))
1532
+    return rint(QROOT*log2(qscale / (float)FF_QP2LAMBDA))
1533 1533
            + 61*QROOT/8; ///< 64 > 60
1534 1534
 }
1535 1535