changeset 1008:fb6cbb8a04a3 libavcodec

fixing DCTELEM != short
author michaelni
date Wed, 15 Jan 2003 19:21:21 +0000
parents b2cf2a1d9a51
children 3b7cc8e4b83f
files dsputil.c dsputil.h dv.c h263.c mpegvideo.h simple_idct.c simple_idct.h
diffstat 7 files changed, 65 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/dsputil.c	Wed Jan 15 18:05:23 2003 +0000
+++ b/dsputil.c	Wed Jan 15 19:21:21 2003 +0000
@@ -1822,7 +1822,7 @@
     return sum;
 }
 
-void simple_idct(INT16 *block); //FIXME
+void simple_idct(DCTELEM *block); //FIXME
 
 static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
     MpegEncContext * const s= (MpegEncContext *)c;
--- a/dsputil.h	Wed Jan 15 18:05:23 2003 +0000
+++ b/dsputil.h	Wed Jan 15 19:21:21 2003 +0000
@@ -25,6 +25,7 @@
 //#define DEBUG
 /* dct code */
 typedef short DCTELEM;
+//typedef int DCTELEM;
 
 void fdct_ifast (DCTELEM *data);
 void ff_jpeg_fdct_islow (DCTELEM *data);
@@ -156,7 +157,7 @@
  * permute block according to permuatation.
  * @param last last non zero element in scantable order
  */
-void ff_block_permute(INT16 *block, UINT8 *permutation, const UINT8 *scantable, int last);
+void ff_block_permute(DCTELEM *block, UINT8 *permutation, const UINT8 *scantable, int last);
 
 #define emms_c()
 
--- a/dv.c	Wed Jan 15 18:05:23 2003 +0000
+++ b/dv.c	Wed Jan 15 19:21:21 2003 +0000
@@ -157,7 +157,7 @@
 
 /* decode ac coefs */
 static void dv_decode_ac(DVVideoDecodeContext *s, 
-                         BlockInfo *mb, INT16 *block, int last_index)
+                         BlockInfo *mb, DCTELEM *block, int last_index)
 {
     int last_re_index;
     int shift_offset = mb->shift_offset;
--- a/h263.c	Wed Jan 15 18:05:23 2003 +0000
+++ b/h263.c	Wed Jan 15 19:21:21 2003 +0000
@@ -67,7 +67,7 @@
 static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
                               int n, int coded, int intra);
 static int h263_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr);
-static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n,
+static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
                               int dir);
 static void mpeg4_decode_sprite_trajectory(MpegEncContext * s);
 static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, UINT16 **dc_val_ptr, int *dir_ptr);
@@ -999,7 +999,7 @@
 }
 
 
-void h263_pred_acdc(MpegEncContext * s, INT16 *block, int n)
+void h263_pred_acdc(MpegEncContext * s, DCTELEM *block, int n)
 {
     int x, y, wrap, a, c, pred_dc, scale, i;
     INT16 *dc_val, *ac_val, *ac_val1;
@@ -1852,7 +1852,7 @@
     return pred;
 }
 
-void mpeg4_pred_ac(MpegEncContext * s, INT16 *block, int n,
+void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
                    int dir)
 {
     int i;
@@ -1907,7 +1907,7 @@
 
 }
 
-static void mpeg4_inv_pred_ac(MpegEncContext * s, INT16 *block, int n,
+static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
                               int dir)
 {
     int i;
--- a/mpegvideo.h	Wed Jan 15 18:05:23 2003 +0000
+++ b/mpegvideo.h	Wed Jan 15 19:21:21 2003 +0000
@@ -692,7 +692,7 @@
 int h263_encode_gob_header(MpegEncContext * s, int mb_line);
 INT16 *h263_pred_motion(MpegEncContext * s, int block, 
                         int *px, int *py);
-void mpeg4_pred_ac(MpegEncContext * s, INT16 *block, int n, 
+void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n, 
                    int dir);
 void ff_set_mpeg4_time(MpegEncContext * s, int picture_number);
 void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
--- a/simple_idct.c	Wed Jan 15 18:05:23 2003 +0000
+++ b/simple_idct.c	Wed Jan 15 19:21:21 2003 +0000
@@ -67,7 +67,7 @@
 
 #endif
 
-static inline void idctRowCondDC (int16_t * row)
+static inline void idctRowCondDC (DCTELEM * row)
 {
 	int a0, a1, a2, a3, b0, b1, b2, b3;
 #ifdef FAST_64BIT
@@ -82,26 +82,40 @@
 #else
 #define ROW0_MASK 0xffffLL
 #endif
-	if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) | 
-              ((uint64_t *)row)[1]) == 0) {
-            temp = (row[0] << 3) & 0xffff;
-            temp += temp << 16;
-            temp += temp << 32;
-            ((uint64_t *)row)[0] = temp;
-            ((uint64_t *)row)[1] = temp;
-            return;
-	}
+        if(sizeof(DCTELEM)==2){
+            if ( ((((uint64_t *)row)[0] & ~ROW0_MASK) | 
+                  ((uint64_t *)row)[1]) == 0) {
+                temp = (row[0] << 3) & 0xffff;
+                temp += temp << 16;
+                temp += temp << 32;
+                ((uint64_t *)row)[0] = temp;
+                ((uint64_t *)row)[1] = temp;
+                return;
+	    }
+        }else{
+            if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
+                row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
+                return;
+            }
+        }
 #else
-	if (!(((uint32_t*)row)[1] |
-              ((uint32_t*)row)[2] |
-              ((uint32_t*)row)[3] | 
-              row[1])) {
-            temp = (row[0] << 3) & 0xffff;
-            temp += temp << 16;
-            ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
-		((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
-		return;
-	}
+        if(sizeof(DCTELEM)==2){
+            if (!(((uint32_t*)row)[1] |
+                  ((uint32_t*)row)[2] |
+                  ((uint32_t*)row)[3] | 
+                  row[1])) {
+                temp = (row[0] << 3) & 0xffff;
+                temp += temp << 16;
+                ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
+                ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
+                return;
+            }
+        }else{
+            if (!(row[1]|row[2]|row[3]|row[4]|row[5]|row[6]|row[7])) {
+                row[0]=row[1]=row[2]=row[3]=row[4]=row[5]=row[6]=row[7]= row[0] << 3;
+                return;
+            }
+        }
 #endif
 
         a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
@@ -159,7 +173,7 @@
 }
 
 static inline void idctSparseColPut (UINT8 *dest, int line_size, 
-                                     int16_t * col)
+                                     DCTELEM * col)
 {
 	int a0, a1, a2, a3, b0, b1, b2, b3;
         UINT8 *cm = cropTbl + MAX_NEG_CROP;
@@ -231,7 +245,7 @@
 }
 
 static inline void idctSparseColAdd (UINT8 *dest, int line_size, 
-                                     int16_t * col)
+                                     DCTELEM * col)
 {
 	int a0, a1, a2, a3, b0, b1, b2, b3;
         UINT8 *cm = cropTbl + MAX_NEG_CROP;
@@ -302,7 +316,7 @@
         dest[0] = cm[dest[0] + ((a0 - b0) >> COL_SHIFT)];
 }
 
-static inline void idctSparseCol (int16_t * col)
+static inline void idctSparseCol (DCTELEM * col)
 {
 	int a0, a1, a2, a3, b0, b1, b2, b3;
 
@@ -365,7 +379,7 @@
         col[56] = ((a0 - b0) >> COL_SHIFT);
 }
 
-void simple_idct_put(UINT8 *dest, int line_size, INT16 *block)
+void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
 {
     int i;
     for(i=0; i<8; i++)
@@ -375,7 +389,7 @@
         idctSparseColPut(dest + i, line_size, block + i);
 }
 
-void simple_idct_add(UINT8 *dest, int line_size, INT16 *block)
+void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
 {
     int i;
     for(i=0; i<8; i++)
@@ -385,7 +399,7 @@
         idctSparseColAdd(dest + i, line_size, block + i);
 }
 
-void simple_idct(INT16 *block)
+void simple_idct(DCTELEM *block)
 {
     int i;
     for(i=0; i<8; i++)
@@ -406,7 +420,7 @@
    and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
 #define C_SHIFT (4+1+12)
 
-static inline void idct4col(UINT8 *dest, int line_size, const INT16 *col)
+static inline void idct4col(UINT8 *dest, int line_size, const DCTELEM *col)
 {
     int c0, c1, c2, c3, a0, a1, a2, a3;
     const UINT8 *cm = cropTbl + MAX_NEG_CROP;
@@ -443,10 +457,10 @@
 /* XXX: I think a 1.0/sqrt(2) normalization should be needed to
    compensate the extra butterfly stage - I don't have the full DV
    specification */
-void simple_idct248_put(UINT8 *dest, int line_size, INT16 *block)
+void simple_idct248_put(UINT8 *dest, int line_size, DCTELEM *block)
 {
     int i;
-    INT16 *ptr;
+    DCTELEM *ptr;
     
     /* butterfly */
     ptr = block;
@@ -486,7 +500,7 @@
 #define C2 C_FIX(0.2705980501)
 #define C3 C_FIX(0.5)
 #define C_SHIFT (4+1+12)
-static inline void idct4col_add(UINT8 *dest, int line_size, const INT16 *col)
+static inline void idct4col_add(UINT8 *dest, int line_size, const DCTELEM *col)
 {
     int c0, c1, c2, c3, a0, a1, a2, a3;
     const UINT8 *cm = cropTbl + MAX_NEG_CROP;
@@ -514,7 +528,7 @@
 #define R2 R_FIX(0.2705980501)
 #define R3 R_FIX(0.5)
 #define R_SHIFT 11
-static inline void idct4row(INT16 *row)
+static inline void idct4row(DCTELEM *row)
 {
     int c0, c1, c2, c3, a0, a1, a2, a3;
     const UINT8 *cm = cropTbl + MAX_NEG_CROP;
@@ -533,7 +547,7 @@
     row[3]= (c0 - c1) >> R_SHIFT;
 }
 
-void simple_idct84_add(UINT8 *dest, int line_size, INT16 *block)
+void simple_idct84_add(UINT8 *dest, int line_size, DCTELEM *block)
 {
     int i;
 
@@ -548,7 +562,7 @@
     }
 }
 
-void simple_idct48_add(UINT8 *dest, int line_size, INT16 *block)
+void simple_idct48_add(UINT8 *dest, int line_size, DCTELEM *block)
 {
     int i;
 
--- a/simple_idct.h	Wed Jan 15 18:05:23 2003 +0000
+++ b/simple_idct.h	Wed Jan 15 19:21:21 2003 +0000
@@ -18,14 +18,14 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-void simple_idct_put(UINT8 *dest, int line_size, INT16 *block);
-void simple_idct_add(UINT8 *dest, int line_size, INT16 *block);
-void ff_simple_idct_mmx(short *block);
-void ff_simple_idct_add_mmx(UINT8 *dest, int line_size, INT16 *block);
-void ff_simple_idct_put_mmx(UINT8 *dest, int line_size, INT16 *block);
-void simple_idct(short *block);
+void simple_idct_put(UINT8 *dest, int line_size, DCTELEM *block);
+void simple_idct_add(UINT8 *dest, int line_size, DCTELEM *block);
+void ff_simple_idct_mmx(int16_t *block);
+void ff_simple_idct_add_mmx(UINT8 *dest, int line_size, int16_t *block);
+void ff_simple_idct_put_mmx(UINT8 *dest, int line_size, int16_t *block);
+void simple_idct(DCTELEM *block);
 
-void simple_idct248_put(UINT8 *dest, int line_size, INT16 *block);
+void simple_idct248_put(UINT8 *dest, int line_size, DCTELEM *block);
 
-void simple_idct84_add(UINT8 *dest, int line_size, INT16 *block);
-void simple_idct48_add(UINT8 *dest, int line_size, INT16 *block);
+void simple_idct84_add(UINT8 *dest, int line_size, DCTELEM *block);
+void simple_idct48_add(UINT8 *dest, int line_size, DCTELEM *block);