[FFmpeg-cvslog] r26226 - trunk/libavcodec/ac3enc.c

jbr subversion
Wed Jan 5 17:02:08 CET 2011


Author: jbr
Date: Wed Jan  5 17:02:08 2011
New Revision: 26226

Log:
Use local variables outside the inner loop in extract_exponents() to reduce
accessing of structs and arrays inside the loop.
Approx. 30% faster in function extract_exponents().

Modified:
   trunk/libavcodec/ac3enc.c

Modified: trunk/libavcodec/ac3enc.c
==============================================================================
--- trunk/libavcodec/ac3enc.c	Wed Jan  5 15:15:13 2011	(r26225)
+++ trunk/libavcodec/ac3enc.c	Wed Jan  5 17:02:08 2011	(r26226)
@@ -285,19 +285,22 @@ static void extract_exponents(AC3EncodeC
     for (ch = 0; ch < s->channels; ch++) {
         for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
             AC3Block *block = &s->blocks[blk];
+            uint8_t *exp   = block->exp[ch];
+            CoefType *coef = block->mdct_coef[ch];
+            int exp_shift  = block->exp_shift[ch];
             for (i = 0; i < AC3_MAX_COEFS; i++) {
                 int e;
-                int v = abs(SCALE_COEF(block->mdct_coef[ch][i]));
+                int v = abs(SCALE_COEF(coef[i]));
                 if (v == 0)
                     e = 24;
                 else {
-                    e = 23 - av_log2(v) + block->exp_shift[ch];
+                    e = 23 - av_log2(v) + exp_shift;
                     if (e >= 24) {
                         e = 24;
-                        block->mdct_coef[ch][i] = 0;
+                        coef[i] = 0;
                     }
                 }
-                block->exp[ch][i] = e;
+                exp[i] = e;
             }
         }
     }



More information about the ffmpeg-cvslog mailing list