]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/jrevdct.c
support a few more types of VQA files
[ffmpeg] / libavcodec / jrevdct.c
index 2ef40f38e540608e3d2a23115eee3f5742544e09..3bd78c1925115995148ec203d8d373c08258f162 100644 (file)
  * A better way to do this would be to pass in the DCT block as a sparse
  * matrix, perhaps with the difference cases encoded.
  */
+/**
+ * @file jrevdct.c
+ * Independent JPEG Group's LLM idct.
+ */
 #include "common.h"
 #include "dsputil.h"
 
@@ -92,7 +98,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
 #define PASS1_BITS  1          /* lose a little precision to avoid overflow */
 #endif
 
-#define ONE    ((INT32) 1)
+#define ONE    ((int32_t) 1)
 
 #define CONST_SCALE (ONE << CONST_BITS)
 
@@ -103,16 +109,16 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
  */
 
 /* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) 
+#define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5)) 
 
-/* Descale and correctly round an INT32 value that's scaled by N bits.
+/* Descale and correctly round an int32_t value that's scaled by N bits.
  * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
  * the fudge factor is correct for either sign of X.
  */
 
 #define DESCALE(x,n)  RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
 
-/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
+/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
  * For 8-bit samples with the recommended scaling, all the variable
  * and constant values involved are no more than 16 bits wide, so a
  * 16x16->32 bit multiply can be used instead of a full 32x32 multiply;
@@ -125,10 +131,10 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
 
 #ifdef EIGHT_BIT_SAMPLES
 #ifdef SHORTxSHORT_32          /* may work if 'int' is 32 bits */
-#define MULTIPLY(var,const)  (((INT16) (var)) * ((INT16) (const)))
+#define MULTIPLY(var,const)  (((int16_t) (var)) * ((int16_t) (const)))
 #endif
 #ifdef SHORTxLCONST_32         /* known to work with Microsoft C 6.0 */
-#define MULTIPLY(var,const)  (((INT16) (var)) * ((INT32) (const)))
+#define MULTIPLY(var,const)  (((int16_t) (var)) * ((int32_t) (const)))
 #endif
 #endif
 
@@ -172,10 +178,10 @@ ones here or successive P-frames will drift too much with Reference frame coding
 
 void j_rev_dct(DCTBLOCK data)
 {
-  INT32 tmp0, tmp1, tmp2, tmp3;
-  INT32 tmp10, tmp11, tmp12, tmp13;
-  INT32 z1, z2, z3, z4, z5;
-  INT32 d0, d1, d2, d3, d4, d5, d6, d7;
+  int32_t tmp0, tmp1, tmp2, tmp3;
+  int32_t tmp10, tmp11, tmp12, tmp13;
+  int32_t z1, z2, z3, z4, z5;
+  int32_t d0, d1, d2, d3, d4, d5, d6, d7;
   register DCTELEM *dataptr;
   int rowctr;
    
@@ -197,16 +203,18 @@ void j_rev_dct(DCTBLOCK data)
 
     register int *idataptr = (int*)dataptr;
 
+    /* WARNING: we do the same permutation as MMX idct to simplify the
+       video core */
     d0 = dataptr[0];
-    d1 = dataptr[1];
-    d2 = dataptr[2];
-    d3 = dataptr[3];
-    d4 = dataptr[4];
-    d5 = dataptr[5];
-    d6 = dataptr[6];
+    d2 = dataptr[1];
+    d4 = dataptr[2];
+    d6 = dataptr[3];
+    d1 = dataptr[4];
+    d3 = dataptr[5];
+    d5 = dataptr[6];
     d7 = dataptr[7];
 
-    if ((d1 == 0) && (idataptr[1] | idataptr[2] | idataptr[3]) == 0) {
+    if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) {
       /* AC terms all zero */
       if (d0) {
          /* Compute a 32 bit value to assign. */
@@ -1164,4 +1172,5 @@ void j_rev_dct(DCTBLOCK data)
   }
 }
 
-
+#undef FIX
+#undef CONST_BITS