From: Michael Niedermayer <[email protected]>

Float:   4700 -> 2700 cycles
Integer: 4400 -> 2800 cycles

(sandybridge  i7)
---
 libavcodec/jpeg2kdec.c |   31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavcodec/jpeg2kdec.c b/libavcodec/jpeg2kdec.c
index 878d6c7..d6f6cbe 100644
--- a/libavcodec/jpeg2kdec.c
+++ b/libavcodec/jpeg2kdec.c
@@ -1006,13 +1006,14 @@ static void dequantization_float(int x, int y, 
Jpeg2KCblk *cblk,
                                  Jpeg2KComponent *comp,
                                  Jpeg2KT1Context *t1, Jpeg2KBand *band)
 {
-    int i, j, idx;
-    float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * y + 
x];
-    for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j)
-        for (i = 0; i < (cblk->coord[0][1] - cblk->coord[0][0]); ++i) {
-            idx        = (comp->coord[0][1] - comp->coord[0][0]) * j + i;
-            datap[idx] = (float)(t1->data[j][i]) * band->f_stepsize;
-        }
+    int i, j;
+    int w = cblk->coord[0][1] - cblk->coord[0][0];
+    for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
+        float *datap = &comp->f_data[(comp->coord[0][1] - comp->coord[0][0]) * 
(y + j) + x];
+        int *src = t1->data[j];
+        for (i = 0; i < w; ++i)
+            datap[i] = src[i] * band->f_stepsize;
+    }
 }
 
 /* Integer dequantization of a codeblock.*/
@@ -1020,14 +1021,14 @@ static void dequantization_int(int x, int y, Jpeg2KCblk 
*cblk,
                                Jpeg2KComponent *comp,
                                Jpeg2KT1Context *t1, Jpeg2KBand *band)
 {
-    int i, j, idx;
-    int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) * y 
+ x];
-    for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j)
-        for (i = 0; i < (cblk->coord[0][1] - cblk->coord[0][0]); ++i) {
-            idx        = (comp->coord[0][1] - comp->coord[0][0]) * j + i;
-            datap[idx] =
-                ((int32_t)(t1->data[j][i]) * band->i_stepsize + (1 << 15)) >> 
16;
-        }
+    int i, j;
+    int w = cblk->coord[0][1] - cblk->coord[0][0];
+    for (j = 0; j < (cblk->coord[1][1] - cblk->coord[1][0]); ++j) {
+        int32_t *datap = &comp->i_data[(comp->coord[0][1] - comp->coord[0][0]) 
* (y + j) + x];
+        int *src = t1->data[j];
+        for (i = 0; i < w; ++i)
+            datap[i] = (src[i] * band->i_stepsize + (1 << 15)) >> 16;
+    }
 }
 
 /* Inverse ICT parameters in float and integer.
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to