[SCM] libav/experimental: Process all EXP_REUSE blocks at once in exponent_min(). 43% faster in function encode_exponents().

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:21:56 UTC 2013


The following commit has been merged in the experimental branch:
commit 964f2cf2a0e6c06dd4491d729a5437ab74336967
Author: Justin Ruggles <justin.ruggles at gmail.com>
Date:   Sat Jan 15 01:59:21 2011 +0000

    Process all EXP_REUSE blocks at once in exponent_min().
    43% faster in function encode_exponents().
    
    Originally committed as revision 26358 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 61986be..9b8efaa 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -500,15 +500,25 @@ static void compute_exp_strategy(AC3EncodeContext *s)
 
 /**
  * Set each encoded exponent in a block to the minimum of itself and the
- * exponent in the same frequency bin of a following block.
- * exp[i] = min(exp[i], exp1[i]
+ * exponents in the same frequency bin of up to 5 following blocks.
  */
-static void exponent_min(uint8_t *exp, uint8_t *exp1, int n)
+static void exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
 {
-    int i;
-    for (i = 0; i < n; i++) {
-        if (exp1[i] < exp[i])
-            exp[i] = exp1[i];
+    int blk, i;
+
+    if (!num_reuse_blocks)
+        return;
+
+    for (i = 0; i < nb_coefs; i++) {
+        uint8_t min_exp = *exp;
+        uint8_t *exp1 = exp + AC3_MAX_COEFS;
+        for (blk = 0; blk < num_reuse_blocks; blk++) {
+            uint8_t next_exp = *exp1;
+            if (next_exp < min_exp)
+                min_exp = next_exp;
+            exp1 += AC3_MAX_COEFS;
+        }
+        *exp++ = min_exp;
     }
 }
 
@@ -589,7 +599,7 @@ static void encode_exponents(AC3EncodeContext *s)
 {
     int blk, blk1, ch;
     uint8_t *exp, *exp1, *exp_strategy;
-    int nb_coefs;
+    int nb_coefs, num_reuse_blocks;
 
     for (ch = 0; ch < s->channels; ch++) {
         exp          = s->blocks[0].exp[ch];
@@ -599,13 +609,16 @@ static void encode_exponents(AC3EncodeContext *s)
         blk = 0;
         while (blk < AC3_MAX_BLOCKS) {
             blk1 = blk + 1;
-            exp1 = exp + AC3_MAX_COEFS;
-            /* for the EXP_REUSE case we select the min of the exponents */
+
+            /* count the number of EXP_REUSE blocks after the current block */
             while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) {
-                exponent_min(exp, exp1, nb_coefs);
                 blk1++;
-                exp1 += AC3_MAX_COEFS;
             }
+            num_reuse_blocks = blk1 - blk - 1;
+
+            /* for the EXP_REUSE case we select the min of the exponents */
+            exponent_min(exp, num_reuse_blocks, nb_coefs);
+
             encode_exponents_blk_ch(exp, nb_coefs,
                                     exp_strategy[blk]);
             /* copy encoded exponents for reuse case */

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list