[SCM] libav/experimental: move dequantization into its own inline function

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:03:10 UTC 2013


The following commit has been merged in the experimental branch:
commit 218b3ae970ee79dbd1d35a479c7fc83effb543d5
Author: Stefan Gehrer <stefan.gehrer at gmx.de>
Date:   Sat Jul 7 07:14:58 2007 +0000

    move dequantization into its own inline function
    
    Originally committed as revision 9518 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c
index 9a1f8dd..bd5620f 100644
--- a/libavcodec/cavs.c
+++ b/libavcodec/cavs.c
@@ -499,14 +499,9 @@ static inline int get_ue_code(GetBitContext *gb, int order) {
 static int decode_residual_block(AVSContext *h, GetBitContext *gb,
                                  const dec_2dvlc_t *r, int esc_golomb_order,
                                  int qp, uint8_t *dst, int stride) {
-    int i,pos = -1;
-    int level_code, esc_code, level, run, mask;
-    int level_buf[64];
-    int run_buf[64];
-    int dqm = dequant_mul[qp];
-    int dqs = dequant_shift[qp];
-    int dqa = 1 << (dqs - 1);
-    const uint8_t *scantab = h->scantable.permutated;
+    int i, level_code, esc_code, level, run, mask;
+    DCTELEM level_buf[64];
+    uint8_t run_buf[64];
     DCTELEM *block = h->block;
 
     for(i=0;i<65;i++) {
@@ -529,17 +524,9 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
         level_buf[i] = level;
         run_buf[i] = run;
     }
-    /* inverse scan and dequantization */
-    while(--i >= 0){
-        pos += run_buf[i];
-        if(pos > 63) {
-            av_log(h->s.avctx, AV_LOG_ERROR,
-                   "position out of block bounds at pic %d MB(%d,%d)\n",
-                   h->picture.poc, h->mbx, h->mby);
-            return -1;
-        }
-        block[scantab[pos]] = (level_buf[i]*dqm + dqa) >> dqs;
-    }
+    if(dequant(h,level_buf, run_buf, block, dequant_mul[qp],
+               dequant_shift[qp], i))
+        return -1;
     h->s.dsp.cavs_idct8_add(dst,block,stride);
     return 0;
 }
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index b98ffd7..71a0aba 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -441,4 +441,24 @@ static inline int next_mb(AVSContext *h) {
     return 1;
 }
 
+static inline int dequant(AVSContext *h, DCTELEM *level_buf, uint8_t *run_buf,
+                          DCTELEM *dst, int mul, int shift, int coeff_num) {
+    int round = 1 << (shift - 1);
+    int pos = -1;
+    const uint8_t *scantab = h->scantable.permutated;
+
+    /* inverse scan and dequantization */
+    while(--coeff_num >= 0){
+        pos += run_buf[coeff_num];
+        if(pos > 63) {
+            av_log(h->s.avctx, AV_LOG_ERROR,
+                "position out of block bounds at pic %d MB(%d,%d)\n",
+                h->picture.poc, h->mbx, h->mby);
+            return -1;
+        }
+        dst[scantab[pos]] = (level_buf[coeff_num]*mul + round) >> shift;
+    }
+    return 0;
+}
+
 #endif /* CAVS_H */

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list