changeset 479:40ffce2cb6ef libavcodec

added inlined put/add functions
author bellard
date Wed, 05 Jun 2002 18:46:25 +0000
parents 055d9ac1584d
children a7cbee351b55
files simple_idct.c simple_idct.h
diffstat 2 files changed, 118 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/simple_idct.c	Wed Jun 05 18:36:03 2002 +0000
+++ b/simple_idct.c	Wed Jun 05 18:46:25 2002 +0000
@@ -22,7 +22,7 @@
   written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>) 
  */
 #include "avcodec.h"
-
+#include "dsputil.h"
 #include "simple_idct.h"
 
 #if 0
@@ -261,9 +261,11 @@
 }
 #endif /* not ARCH_ALPHA */
 
-static inline void idctSparseCol (int16_t * col)
+static inline void idctSparseColPut (UINT8 *dest, int line_size, 
+                                     int16_t * col)
 {
 	int a0, a1, a2, a3, b0, b1, b2, b3;
+        UINT8 *cm = cropTbl + MAX_NEG_CROP;
 
         /* XXX: I did that only to give same values as previous code */
 	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
@@ -314,14 +316,93 @@
             MAC16(b3, - W1, col[8*7]);
 	}
 
-        col[8*0] = (a0 + b0) >> COL_SHIFT;
-        col[8*7] = (a0 - b0) >> COL_SHIFT;
-        col[8*1] = (a1 + b1) >> COL_SHIFT;
-        col[8*6] = (a1 - b1) >> COL_SHIFT;
-        col[8*2] = (a2 + b2) >> COL_SHIFT;
-        col[8*5] = (a2 - b2) >> COL_SHIFT;
-        col[8*3] = (a3 + b3) >> COL_SHIFT;
-        col[8*4] = (a3 - b3) >> COL_SHIFT;
+        dest[0] = cm[(a0 + b0) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a1 + b1) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a2 + b2) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a3 + b3) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a3 - b3) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a2 - b2) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a1 - b1) >> COL_SHIFT];
+        dest += line_size;
+        dest[0] = cm[(a0 - b0) >> COL_SHIFT];
+}
+
+static inline void idctSparseColAdd (UINT8 *dest, int line_size, 
+                                     int16_t * col)
+{
+	int a0, a1, a2, a3, b0, b1, b2, b3;
+        UINT8 *cm = cropTbl + MAX_NEG_CROP;
+
+        /* XXX: I did that only to give same values as previous code */
+	a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4));
+	a1 = a0;
+	a2 = a0;
+	a3 = a0;
+
+        a0 +=  + W2*col[8*2];
+        a1 +=  + W6*col[8*2];
+        a2 +=  - W6*col[8*2];
+        a3 +=  - W2*col[8*2];
+
+        MUL16(b0, W1, col[8*1]);
+        MUL16(b1, W3, col[8*1]);
+        MUL16(b2, W5, col[8*1]);
+        MUL16(b3, W7, col[8*1]);
+
+        MAC16(b0, + W3, col[8*3]);
+        MAC16(b1, - W7, col[8*3]);
+        MAC16(b2, - W1, col[8*3]);
+        MAC16(b3, - W5, col[8*3]);
+
+	if(col[8*4]){
+            a0 += + W4*col[8*4];
+            a1 += - W4*col[8*4];
+            a2 += - W4*col[8*4];
+            a3 += + W4*col[8*4];
+	}
+
+	if (col[8*5]) {
+            MAC16(b0, + W5, col[8*5]);
+            MAC16(b1, - W1, col[8*5]);
+            MAC16(b2, + W7, col[8*5]);
+            MAC16(b3, + W3, col[8*5]);
+	}
+
+	if(col[8*6]){
+            a0 += + W6*col[8*6];
+            a1 += - W2*col[8*6];
+            a2 += + W2*col[8*6];
+            a3 += - W6*col[8*6];
+	}
+
+	if (col[8*7]) {
+            MAC16(b0, + W7, col[8*7]);
+            MAC16(b1, - W5, col[8*7]);
+            MAC16(b2, + W3, col[8*7]);
+            MAC16(b3, - W1, col[8*7]);
+	}
+
+        dest[0] = cm[dest[0] + ((a0 + b0) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a1 + b1) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a2 + b2) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a3 + b3) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a3 - b3) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a2 - b2) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a1 - b1) >> COL_SHIFT)];
+        dest += line_size;
+        dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
 }
 
 #ifdef ARCH_ALPHA
@@ -389,16 +470,39 @@
 	}
 }
 
+/* XXX: suppress this mess */
+void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
+{
+    simple_idct(block);
+    put_pixels_clamped(block, dest, line_size);
+}
+
+void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
+{
+    simple_idct(block);
+    add_pixels_clamped(block, dest, line_size);
+}
+
 #else
 
-void simple_idct (short *block)
+void simple_idct_put(UINT8 *dest, int line_size, INT16 *block)
 {
     int i;
     for(i=0; i<8; i++)
         idctRowCondDC(block + i*8);
     
     for(i=0; i<8; i++)
-        idctSparseCol(block + i);
+        idctSparseColPut(dest + i, line_size, block + i);
+}
+
+void simple_idct_add(UINT8 *dest, int line_size, INT16 *block)
+{
+    int i;
+    for(i=0; i<8; i++)
+        idctRowCondDC(block + i*8);
+    
+    for(i=0; i<8; i++)
+        idctSparseColAdd(dest + i, line_size, block + i);
 }
 
 #endif
--- a/simple_idct.h	Wed Jun 05 18:36:03 2002 +0000
+++ b/simple_idct.h	Wed Jun 05 18:46:25 2002 +0000
@@ -18,5 +18,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-void simple_idct(short *block);
+void simple_idct_put(UINT8 *dest, int line_size, INT16 *block);
+void simple_idct_add(UINT8 *dest, int line_size, INT16 *block);
 void simple_idct_mmx(short *block);