cosmetics, rename loop to frame_available
[ffmpeg.git] / libavcodec / jrevdct.c
index 728d251..9e28dae 100644 (file)
@@ -1,9 +1,42 @@
 /*
  * jrevdct.c
  *
- * Copyright (C) 1991, 1992, Thomas G. Lane.
  * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
+ *
+ * The authors make NO WARRANTY or representation, either express or implied,
+ * with respect to this software, its quality, accuracy, merchantability, or
+ * fitness for a particular purpose.  This software is provided "AS IS", and
+ * you, its user, assume the entire risk as to its quality and accuracy.
+ *
+ * This software is copyright (C) 1991, 1992, Thomas G. Lane.
+ * All Rights Reserved except as specified below.
+ *
+ * Permission is hereby granted to use, copy, modify, and distribute this
+ * software (or portions thereof) for any purpose, without fee, subject to
+ * these conditions:
+ * (1) If any part of the source code for this software is distributed, then
+ * this README file must be included, with this copyright and no-warranty
+ * notice unaltered; and any additions, deletions, or changes to the original
+ * files must be clearly indicated in accompanying documentation.
+ * (2) If only executable code is distributed, then the accompanying
+ * documentation must state that "this software is based in part on the work
+ * of the Independent JPEG Group".
+ * (3) Permission for use of this software is granted only if the user accepts
+ * full responsibility for any undesirable consequences; the authors accept
+ * NO LIABILITY for damages of any kind.
+ *
+ * These conditions apply to any software derived from or based on the IJG
+ * code, not just to the unmodified library.  If you use our work, you ought
+ * to acknowledge us.
+ *
+ * Permission is NOT granted for the use of any IJG author's name or company
+ * name in advertising or publicity relating to this software or products
+ * derived from it.  This software may be referred to only as "the Independent
+ * JPEG Group's software".
+ *
+ * We specifically permit and encourage the use of this software as the basis
+ * of commercial products, provided that all warranty or liability claims are
+ * assumed by the product vendor.
  *
  * This file contains the basic inverse-DCT transformation subroutine.
  *
@@ -16,7 +49,7 @@
  * The advantage of this method is that no data path contains more than one
  * multiplication; this allows a very simple and accurate implementation in
  * scaled fixed-point arithmetic, with a minimal number of shifts.
- * 
+ *
  * I've made lots of modifications to attempt to take advantage of the
  * sparse nature of the DCT matrices we're getting.  Although the logic
  * is cumbersome, it's straightforward and the resulting code is much
  * 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
+ * @file
  * Independent JPEG Group's LLM idct.
  */
-#include "common.h"
+
+#include "libavutil/common.h"
 #include "dsputil.h"
 
 #define EIGHT_BIT_SAMPLES
@@ -95,10 +128,10 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
 #ifdef EIGHT_BIT_SAMPLES
 #define PASS1_BITS  2
 #else
-#define PASS1_BITS  1          /* lose a little precision to avoid overflow */
+#define PASS1_BITS  1   /* lose a little precision to avoid overflow */
 #endif
 
-#define ONE    ((int32_t) 1)
+#define ONE         ((int32_t) 1)
 
 #define CONST_SCALE (ONE << CONST_BITS)
 
@@ -109,7 +142,7 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
  */
 
 /* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5)) 
+#define FIX(x)  ((int32_t) ((x) * CONST_SCALE + 0.5))
 
 /* Descale and correctly round an int32_t value that's scaled by N bits.
  * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
@@ -130,22 +163,22 @@ typedef DCTELEM DCTBLOCK[DCTSIZE2];
  */
 
 #ifdef EIGHT_BIT_SAMPLES
-#ifdef SHORTxSHORT_32          /* may work if 'int' is 32 bits */
+#ifdef SHORTxSHORT_32           /* may work if 'int' is 32 bits */
 #define MULTIPLY(var,const)  (((int16_t) (var)) * ((int16_t) (const)))
 #endif
-#ifdef SHORTxLCONST_32         /* known to work with Microsoft C 6.0 */
+#ifdef SHORTxLCONST_32          /* known to work with Microsoft C 6.0 */
 #define MULTIPLY(var,const)  (((int16_t) (var)) * ((int32_t) (const)))
 #endif
 #endif
 
-#ifndef MULTIPLY               /* default definition */
+#ifndef MULTIPLY                /* default definition */
 #define MULTIPLY(var,const)  ((var) * (const))
 #endif
 
 
-/* 
+/*
   Unlike our decoder where we approximate the FIXes, we need to use exact
-ones here or successive P-frames will drift too much with Reference frame coding 
+ones here or successive P-frames will drift too much with Reference frame coding
 */
 #define FIX_0_211164243 1730
 #define FIX_0_275899380 2260
@@ -184,7 +217,7 @@ void j_rev_dct(DCTBLOCK data)
   int32_t d0, d1, d2, d3, d4, d5, d6, d7;
   register DCTELEM *dataptr;
   int rowctr;
-   
+
   /* Pass 1: process rows. */
   /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
   /* furthermore, we scale the results by 2**PASS1_BITS. */
@@ -217,17 +250,17 @@ void j_rev_dct(DCTBLOCK data)
     if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) {
       /* AC terms all zero */
       if (d0) {
-         /* Compute a 32 bit value to assign. */
-         DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
-         register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-         
-         idataptr[0] = v;
-         idataptr[1] = v;
-         idataptr[2] = v;
-         idataptr[3] = v;
+          /* Compute a 32 bit value to assign. */
+          DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
+          register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
+
+          idataptr[0] = v;
+          idataptr[1] = v;
+          idataptr[2] = v;
+          idataptr[3] = v;
       }
-      
-      dataptr += DCTSIZE;      /* advance pointer to next row */
+
+      dataptr += DCTSIZE;       /* advance pointer to next row */
       continue;
     }
 
@@ -235,180 +268,50 @@ void j_rev_dct(DCTBLOCK data)
     /* The rotator is sqrt(2)*c(-6). */
 {
     if (d6) {
-       if (d4) {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           }
-       } else {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           }
-       }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            }
     } else {
-       if (d4) {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-                   tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = d4 << CONST_BITS;
-                   tmp11 = tmp12 = -tmp10;
-               }
-           }
-       } else {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
-                   tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
-                   tmp10 = tmp13 = tmp11 = tmp12 = 0;
-               }
-           }
-       }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+            }
       }
 
     /* Odd part per figure 8; the matrix is unitary and hence its
@@ -416,259 +319,259 @@ void j_rev_dct(DCTBLOCK data)
      */
 
     if (d7) {
-       if (d5) {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z2 = d5 + d3;
-                   z3 = d7 + d3;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-                   z2 = d5 + d3;
-                   z3 = d7 + d3;
-                   z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 = z1 + z4;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 = z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-                   tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z3;
-                   tmp1 += z4;
-                   tmp2 = z2 + z3;
-                   tmp3 = z1 + z4;
-               }
-           }
-       } else {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z3 = d7 + d3;
-                   z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-d3, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-d1, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 = z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-                   z3 = d7 + d3;
-                   
-                   tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   tmp2 = MULTIPLY(d3, FIX_0_509795579);
-                   z2 = MULTIPLY(-d3, FIX_2_562915447);
-                   z5 = MULTIPLY(z3, FIX_1_175875602);
-                   z3 = MULTIPLY(-z3, FIX_0_785694958);
-                   
-                   tmp0 += z3;
-                   tmp1 = z2 + z5;
-                   tmp2 += z3;
-                   tmp3 = z1 + z5;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z5 = MULTIPLY(z1, FIX_1_175875602);
-
-                   z1 = MULTIPLY(z1, FIX_0_275899380);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-                   z4 = MULTIPLY(-d1, FIX_0_390180644);
-                   tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-                   tmp0 += z1;
-                   tmp1 = z4 + z5;
-                   tmp2 = z3 + z5;
-                   tmp3 += z1;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-                   tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-                   tmp1 = MULTIPLY(d7, FIX_1_175875602);
-                   tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-                   tmp3 = MULTIPLY(d7, FIX_0_275899380);
-               }
-           }
-       }
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 = z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z3;
+                    tmp1 += z4;
+                    tmp2 = z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 = z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z3 = d7 + d3;
+
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    tmp2 = MULTIPLY(d3, FIX_0_509795579);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z5 = MULTIPLY(z3, FIX_1_175875602);
+                    z3 = MULTIPLY(-z3, FIX_0_785694958);
+
+                    tmp0 += z3;
+                    tmp1 = z2 + z5;
+                    tmp2 += z3;
+                    tmp3 = z1 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z5 = MULTIPLY(z1, FIX_1_175875602);
+
+                    z1 = MULTIPLY(z1, FIX_0_275899380);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp0 = MULTIPLY(-d7, FIX_1_662939225);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+                    tmp3 = MULTIPLY(d1, FIX_1_111140466);
+
+                    tmp0 += z1;
+                    tmp1 = z4 + z5;
+                    tmp2 = z3 + z5;
+                    tmp3 += z1;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
+                    tmp1 = MULTIPLY(d7, FIX_1_175875602);
+                    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
+                    tmp3 = MULTIPLY(d7, FIX_0_275899380);
+                }
+            }
+        }
     } else {
-       if (d5) {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-                   z2 = d5 + d3;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-                   
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-d1, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-d3, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 = z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-                   z2 = d5 + d3;
-                   
-                   z5 = MULTIPLY(z2, FIX_1_175875602);
-                   tmp1 = MULTIPLY(d5, FIX_1_662939225);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   z2 = MULTIPLY(-z2, FIX_1_387039845);
-                   tmp2 = MULTIPLY(d3, FIX_1_111140466);
-                   z3 = MULTIPLY(-d3, FIX_1_961570560);
-                   
-                   tmp0 = z3 + z5;
-                   tmp1 += z2;
-                   tmp2 += z2;
-                   tmp3 = z4 + z5;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-                   z4 = d5 + d1;
-                   
-                   z5 = MULTIPLY(z4, FIX_1_175875602);
-                   z1 = MULTIPLY(-d1, FIX_0_899976223);
-                   tmp3 = MULTIPLY(d1, FIX_0_601344887);
-                   tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z4 = MULTIPLY(z4, FIX_0_785694958);
-                   
-                   tmp0 = z1 + z5;
-                   tmp1 += z4;
-                   tmp2 = z2 + z5;
-                   tmp3 += z4;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-                   tmp0 = MULTIPLY(d5, FIX_1_175875602);
-                   tmp1 = MULTIPLY(d5, FIX_0_275899380);
-                   tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-                   tmp3 = MULTIPLY(d5, FIX_0_785694958);
-               }
-           }
-       } else {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-                   z5 = d1 + d3;
-                   tmp3 = MULTIPLY(d1, FIX_0_211164243);
-                   tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-                   z1 = MULTIPLY(d1, FIX_1_061594337);
-                   z2 = MULTIPLY(-d3, FIX_2_172734803);
-                   z4 = MULTIPLY(z5, FIX_0_785694958);
-                   z5 = MULTIPLY(z5, FIX_1_175875602);
-                   
-                   tmp0 = z1 - z4;
-                   tmp1 = z2 + z4;
-                   tmp2 += z5;
-                   tmp3 += z5;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-                   tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-                   tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-                   tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-                   tmp3 = MULTIPLY(d3, FIX_1_175875602);
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-                   tmp0 = MULTIPLY(d1, FIX_0_275899380);
-                   tmp1 = MULTIPLY(d1, FIX_0_785694958);
-                   tmp2 = MULTIPLY(d1, FIX_1_175875602);
-                   tmp3 = MULTIPLY(d1, FIX_1_387039845);
-               } else {
-                   /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-                   tmp0 = tmp1 = tmp2 = tmp3 = 0;
-               }
-           }
-       }
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
+
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 = z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+
+                    z5 = MULTIPLY(z2, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_1_662939225);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z2 = MULTIPLY(-z2, FIX_1_387039845);
+                    tmp2 = MULTIPLY(d3, FIX_1_111140466);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+
+                    tmp0 = z3 + z5;
+                    tmp1 += z2;
+                    tmp2 += z2;
+                    tmp3 = z4 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
+                    z4 = d5 + d1;
+
+                    z5 = MULTIPLY(z4, FIX_1_175875602);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    tmp3 = MULTIPLY(d1, FIX_0_601344887);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(z4, FIX_0_785694958);
+
+                    tmp0 = z1 + z5;
+                    tmp1 += z4;
+                    tmp2 = z2 + z5;
+                    tmp3 += z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d5, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_0_275899380);
+                    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
+                    tmp3 = MULTIPLY(d5, FIX_0_785694958);
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
+                    z5 = d1 + d3;
+                    tmp3 = MULTIPLY(d1, FIX_0_211164243);
+                    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
+                    z1 = MULTIPLY(d1, FIX_1_061594337);
+                    z2 = MULTIPLY(-d3, FIX_2_172734803);
+                    z4 = MULTIPLY(z5, FIX_0_785694958);
+                    z5 = MULTIPLY(z5, FIX_1_175875602);
+
+                    tmp0 = z1 - z4;
+                    tmp1 = z2 + z4;
+                    tmp2 += z5;
+                    tmp3 += z5;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
+                    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
+                    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
+                    tmp3 = MULTIPLY(d3, FIX_1_175875602);
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d1, FIX_0_275899380);
+                    tmp1 = MULTIPLY(d1, FIX_0_785694958);
+                    tmp2 = MULTIPLY(d1, FIX_1_175875602);
+                    tmp3 = MULTIPLY(d1, FIX_1_387039845);
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = tmp1 = tmp2 = tmp3 = 0;
+                }
+            }
+        }
     }
 }
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
@@ -682,7 +585,7 @@ void j_rev_dct(DCTBLOCK data)
     dataptr[3] = (DCTELEM) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
     dataptr[4] = (DCTELEM) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
 
-    dataptr += DCTSIZE;                /* advance pointer to next row */
+    dataptr += DCTSIZE;         /* advance pointer to next row */
   }
 
   /* Pass 2: process columns. */
@@ -711,464 +614,332 @@ void j_rev_dct(DCTBLOCK data)
     /* Even part: reverse the even part of the forward DCT. */
     /* The rotator is sqrt(2)*c(-6). */
     if (d6) {
-       if (d4) {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           }
-       } else {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 == 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 == 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 == 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 == 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           }
-       }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            }
     } else {
-       if (d4) {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = d4 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp2 - tmp0;
-                   tmp12 = -(tmp0 + tmp2);
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-                   tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = d4 << CONST_BITS;
-                   tmp11 = tmp12 = -tmp10;
-               }
-           }
-       } else {
-           if (d2) {
-               if (d0) {
-                   /* d0 != 0, d2 != 0, d4 == 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = d0 << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp0 + tmp2;
-                   tmp12 = tmp0 - tmp2;
-               } else {
-                   /* d0 == 0, d2 != 0, d4 == 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp10 = tmp3;
-                   tmp13 = -tmp3;
-                   tmp11 = tmp2;
-                   tmp12 = -tmp2;
-               }
-           } else {
-               if (d0) {
-                   /* d0 != 0, d2 == 0, d4 == 0, d6 == 0 */
-                   tmp10 = tmp13 = tmp11 = tmp12 = d0 << CONST_BITS;
-               } else {
-                   /* d0 == 0, d2 == 0, d4 == 0, d6 == 0 */
-                   tmp10 = tmp13 = tmp11 = tmp12 = 0;
-               }
-           }
-       }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+            }
     }
 
     /* Odd part per figure 8; the matrix is unitary and hence its
      * transpose is its inverse.  i0..i3 are y7,y5,y3,y1 respectively.
      */
     if (d7) {
-       if (d5) {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z2 = d5 + d3;
-                   z3 = d7 + d3;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
-                   z1 = d7;
-                   z2 = d5 + d3;
-                   z3 = d7 + d3;
-                   z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 = z1 + z4;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z2 = d5;
-                   z3 = d7;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 = z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
-                   tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z3;
-                   tmp1 += z4;
-                   tmp2 = z2 + z3;
-                   tmp3 = z1 + z4;
-               }
-           }
-       } else {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z3 = d7 + d3;
-                   z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-                   
-                   tmp0 = MULTIPLY(d7, FIX_0_298631336); 
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-z1, FIX_0_899976223);
-                   z2 = MULTIPLY(-d3, FIX_2_562915447);
-                   z3 = MULTIPLY(-z3, FIX_1_961570560);
-                   z4 = MULTIPLY(-d1, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 += z1 + z3;
-                   tmp1 = z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
-                   z3 = d7 + d3;
-                   
-                   tmp0 = MULTIPLY(-d7, FIX_0_601344887); 
-                   z1 = MULTIPLY(-d7, FIX_0_899976223);
-                   tmp2 = MULTIPLY(d3, FIX_0_509795579);
-                   z2 = MULTIPLY(-d3, FIX_2_562915447);
-                   z5 = MULTIPLY(z3, FIX_1_175875602);
-                   z3 = MULTIPLY(-z3, FIX_0_785694958);
-                   
-                   tmp0 += z3;
-                   tmp1 = z2 + z5;
-                   tmp2 += z3;
-                   tmp3 = z1 + z5;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
-                   z1 = d7 + d1;
-                   z5 = MULTIPLY(z1, FIX_1_175875602);
-
-                   z1 = MULTIPLY(z1, FIX_0_275899380);
-                   z3 = MULTIPLY(-d7, FIX_1_961570560);
-                   tmp0 = MULTIPLY(-d7, FIX_1_662939225); 
-                   z4 = MULTIPLY(-d1, FIX_0_390180644);
-                   tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
-                   tmp0 += z1;
-                   tmp1 = z4 + z5;
-                   tmp2 = z3 + z5;
-                   tmp3 += z1;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
-                   tmp0 = MULTIPLY(-d7, FIX_1_387039845);
-                   tmp1 = MULTIPLY(d7, FIX_1_175875602);
-                   tmp2 = MULTIPLY(-d7, FIX_0_785694958);
-                   tmp3 = MULTIPLY(d7, FIX_0_275899380);
-               }
-           }
-       }
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
+                    z2 = d5 + d3;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z3 = d7;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 = z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z3;
+                    tmp1 += z4;
+                    tmp2 = z2 + z3;
+                    tmp3 = z1 + z4;
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z3 = d7 + d3;
+                    z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
+
+                    tmp0 = MULTIPLY(d7, FIX_0_298631336);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-z1, FIX_0_899976223);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z3 = MULTIPLY(-z3, FIX_1_961570560);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 += z1 + z3;
+                    tmp1 = z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
+                    z3 = d7 + d3;
+
+                    tmp0 = MULTIPLY(-d7, FIX_0_601344887);
+                    z1 = MULTIPLY(-d7, FIX_0_899976223);
+                    tmp2 = MULTIPLY(d3, FIX_0_509795579);
+                    z2 = MULTIPLY(-d3, FIX_2_562915447);
+                    z5 = MULTIPLY(z3, FIX_1_175875602);
+                    z3 = MULTIPLY(-z3, FIX_0_785694958);
+
+                    tmp0 += z3;
+                    tmp1 = z2 + z5;
+                    tmp2 += z3;
+                    tmp3 = z1 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
+                    z1 = d7 + d1;
+                    z5 = MULTIPLY(z1, FIX_1_175875602);
+
+                    z1 = MULTIPLY(z1, FIX_0_275899380);
+                    z3 = MULTIPLY(-d7, FIX_1_961570560);
+                    tmp0 = MULTIPLY(-d7, FIX_1_662939225);
+                    z4 = MULTIPLY(-d1, FIX_0_390180644);
+                    tmp3 = MULTIPLY(d1, FIX_1_111140466);
+
+                    tmp0 += z1;
+                    tmp1 = z4 + z5;
+                    tmp2 = z3 + z5;
+                    tmp3 += z1;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
+                    tmp0 = MULTIPLY(-d7, FIX_1_387039845);
+                    tmp1 = MULTIPLY(d7, FIX_1_175875602);
+                    tmp2 = MULTIPLY(-d7, FIX_0_785694958);
+                    tmp3 = MULTIPLY(d7, FIX_0_275899380);
+                }
+            }
+        }
     } else {
-       if (d5) {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
-                   z2 = d5 + d3;
-                   z4 = d5 + d1;
-                   z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-                   
-                   tmp1 = MULTIPLY(d5, FIX_2_053119869);
-                   tmp2 = MULTIPLY(d3, FIX_3_072711026);
-                   tmp3 = MULTIPLY(d1, FIX_1_501321110);
-                   z1 = MULTIPLY(-d1, FIX_0_899976223);
-                   z2 = MULTIPLY(-z2, FIX_2_562915447);
-                   z3 = MULTIPLY(-d3, FIX_1_961570560);
-                   z4 = MULTIPLY(-z4, FIX_0_390180644);
-                   
-                   z3 += z5;
-                   z4 += z5;
-                   
-                   tmp0 = z1 + z3;
-                   tmp1 += z2 + z4;
-                   tmp2 += z2 + z3;
-                   tmp3 += z1 + z4;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
-                   z2 = d5 + d3;
-                   
-                   z5 = MULTIPLY(z2, FIX_1_175875602);
-                   tmp1 = MULTIPLY(d5, FIX_1_662939225);
-                   z4 = MULTIPLY(-d5, FIX_0_390180644);
-                   z2 = MULTIPLY(-z2, FIX_1_387039845);
-                   tmp2 = MULTIPLY(d3, FIX_1_111140466);
-                   z3 = MULTIPLY(-d3, FIX_1_961570560);
-                   
-                   tmp0 = z3 + z5;
-                   tmp1 += z2;
-                   tmp2 += z2;
-                   tmp3 = z4 + z5;
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
-                   z4 = d5 + d1;
-                   
-                   z5 = MULTIPLY(z4, FIX_1_175875602);
-                   z1 = MULTIPLY(-d1, FIX_0_899976223);
-                   tmp3 = MULTIPLY(d1, FIX_0_601344887);
-                   tmp1 = MULTIPLY(-d5, FIX_0_509795579);
-                   z2 = MULTIPLY(-d5, FIX_2_562915447);
-                   z4 = MULTIPLY(z4, FIX_0_785694958);
-                   
-                   tmp0 = z1 + z5;
-                   tmp1 += z4;
-                   tmp2 = z2 + z5;
-                   tmp3 += z4;
-               } else {
-                   /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
-                   tmp0 = MULTIPLY(d5, FIX_1_175875602);
-                   tmp1 = MULTIPLY(d5, FIX_0_275899380);
-                   tmp2 = MULTIPLY(-d5, FIX_1_387039845);
-                   tmp3 = MULTIPLY(d5, FIX_0_785694958);
-               }
-           }
-       } else {
-           if (d3) {
-               if (d1) {
-                   /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
-                   z5 = d1 + d3;
-                   tmp3 = MULTIPLY(d1, FIX_0_211164243);
-                   tmp2 = MULTIPLY(-d3, FIX_1_451774981);
-                   z1 = MULTIPLY(d1, FIX_1_061594337);
-                   z2 = MULTIPLY(-d3, FIX_2_172734803);
-                   z4 = MULTIPLY(z5, FIX_0_785694958);
-                   z5 = MULTIPLY(z5, FIX_1_175875602);
-                   
-                   tmp0 = z1 - z4;
-                   tmp1 = z2 + z4;
-                   tmp2 += z5;
-                   tmp3 += z5;
-               } else {
-                   /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
-                   tmp0 = MULTIPLY(-d3, FIX_0_785694958);
-                   tmp1 = MULTIPLY(-d3, FIX_1_387039845);
-                   tmp2 = MULTIPLY(-d3, FIX_0_275899380);
-                   tmp3 = MULTIPLY(d3, FIX_1_175875602);
-               }
-           } else {
-               if (d1) {
-                   /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
-                   tmp0 = MULTIPLY(d1, FIX_0_275899380);
-                   tmp1 = MULTIPLY(d1, FIX_0_785694958);
-                   tmp2 = MULTIPLY(d1, FIX_1_175875602);
-                   tmp3 = MULTIPLY(d1, FIX_1_387039845);
-               } else {
-                   /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
-                   tmp0 = tmp1 = tmp2 = tmp3 = 0;
-               }
-           }
-       }
+        if (d5) {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+                    z4 = d5 + d1;
+                    z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
+
+                    tmp1 = MULTIPLY(d5, FIX_2_053119869);
+                    tmp2 = MULTIPLY(d3, FIX_3_072711026);
+                    tmp3 = MULTIPLY(d1, FIX_1_501321110);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    z2 = MULTIPLY(-z2, FIX_2_562915447);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+                    z4 = MULTIPLY(-z4, FIX_0_390180644);
+
+                    z3 += z5;
+                    z4 += z5;
+
+                    tmp0 = z1 + z3;
+                    tmp1 += z2 + z4;
+                    tmp2 += z2 + z3;
+                    tmp3 += z1 + z4;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
+                    z2 = d5 + d3;
+
+                    z5 = MULTIPLY(z2, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_1_662939225);
+                    z4 = MULTIPLY(-d5, FIX_0_390180644);
+                    z2 = MULTIPLY(-z2, FIX_1_387039845);
+                    tmp2 = MULTIPLY(d3, FIX_1_111140466);
+                    z3 = MULTIPLY(-d3, FIX_1_961570560);
+
+                    tmp0 = z3 + z5;
+                    tmp1 += z2;
+                    tmp2 += z2;
+                    tmp3 = z4 + z5;
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
+                    z4 = d5 + d1;
+
+                    z5 = MULTIPLY(z4, FIX_1_175875602);
+                    z1 = MULTIPLY(-d1, FIX_0_899976223);
+                    tmp3 = MULTIPLY(d1, FIX_0_601344887);
+                    tmp1 = MULTIPLY(-d5, FIX_0_509795579);
+                    z2 = MULTIPLY(-d5, FIX_2_562915447);
+                    z4 = MULTIPLY(z4, FIX_0_785694958);
+
+                    tmp0 = z1 + z5;
+                    tmp1 += z4;
+                    tmp2 = z2 + z5;
+                    tmp3 += z4;
+                } else {
+                    /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d5, FIX_1_175875602);
+                    tmp1 = MULTIPLY(d5, FIX_0_275899380);
+                    tmp2 = MULTIPLY(-d5, FIX_1_387039845);
+                    tmp3 = MULTIPLY(d5, FIX_0_785694958);
+                }
+            }
+        } else {
+            if (d3) {
+                if (d1) {
+                    /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
+                    z5 = d1 + d3;
+                    tmp3 = MULTIPLY(d1, FIX_0_211164243);
+                    tmp2 = MULTIPLY(-d3, FIX_1_451774981);
+                    z1 = MULTIPLY(d1, FIX_1_061594337);
+                    z2 = MULTIPLY(-d3, FIX_2_172734803);
+                    z4 = MULTIPLY(z5, FIX_0_785694958);
+                    z5 = MULTIPLY(z5, FIX_1_175875602);
+
+                    tmp0 = z1 - z4;
+                    tmp1 = z2 + z4;
+                    tmp2 += z5;
+                    tmp3 += z5;
+                } else {
+                    /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(-d3, FIX_0_785694958);
+                    tmp1 = MULTIPLY(-d3, FIX_1_387039845);
+                    tmp2 = MULTIPLY(-d3, FIX_0_275899380);
+                    tmp3 = MULTIPLY(d3, FIX_1_175875602);
+                }
+            } else {
+                if (d1) {
+                    /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = MULTIPLY(d1, FIX_0_275899380);
+                    tmp1 = MULTIPLY(d1, FIX_0_785694958);
+                    tmp2 = MULTIPLY(d1, FIX_1_175875602);
+                    tmp3 = MULTIPLY(d1, FIX_1_387039845);
+                } else {
+                    /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
+                    tmp0 = tmp1 = tmp2 = tmp3 = 0;
+                }
+            }
+        }
     }
 
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
 
     dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp3,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp10 - tmp3,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp11 + tmp2,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(tmp11 - tmp2,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(tmp12 + tmp1,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp12 - tmp1,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp13 + tmp0,
-                                          CONST_BITS+PASS1_BITS+3);
+                                           CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp13 - tmp0,
-                                          CONST_BITS+PASS1_BITS+3);
-    
-    dataptr++;                 /* advance pointer to next column */
+                                           CONST_BITS+PASS1_BITS+3);
+
+    dataptr++;                  /* advance pointer to next column */
   }
 }
 
@@ -1190,7 +961,7 @@ void j_rev_dct4(DCTBLOCK data)
   /* furthermore, we scale the results by 2**PASS1_BITS. */
 
   data[0] += 4;
-  
+
   dataptr = data;
 
   for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
@@ -1213,65 +984,65 @@ void j_rev_dct4(DCTBLOCK data)
     if ((d2 | d4 | d6) == 0) {
       /* AC terms all zero */
       if (d0) {
-         /* Compute a 32 bit value to assign. */
-         DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
-         register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-         
-         idataptr[0] = v;
-         idataptr[1] = v;
+          /* Compute a 32 bit value to assign. */
+          DCTELEM dcval = (DCTELEM) (d0 << PASS1_BITS);
+          register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
+
+          idataptr[0] = v;
+          idataptr[1] = v;
       }
-      
-      dataptr += DCTSTRIDE;    /* advance pointer to next row */
+
+      dataptr += DCTSTRIDE;     /* advance pointer to next row */
       continue;
     }
-    
+
     /* Even part: reverse the even part of the forward DCT. */
     /* The rotator is sqrt(2)*c(-6). */
     if (d6) {
-           if (d2) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           } else {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            }
     } else {
-           if (d2) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           } else {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-                   tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-           }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+            }
       }
 
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
@@ -1281,7 +1052,7 @@ void j_rev_dct4(DCTBLOCK data)
     dataptr[2] = (DCTELEM) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
     dataptr[3] = (DCTELEM) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
 
-    dataptr += DCTSTRIDE;              /* advance pointer to next row */
+    dataptr += DCTSTRIDE;       /* advance pointer to next row */
   }
 
   /* Pass 2: process columns. */
@@ -1306,50 +1077,50 @@ void j_rev_dct4(DCTBLOCK data)
     /* Even part: reverse the even part of the forward DCT. */
     /* The rotator is sqrt(2)*c(-6). */
     if (d6) {
-           if (d2) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
-                   z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
-                   tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
-                   tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           } else {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
-                   tmp2 = MULTIPLY(-d6, FIX_1_306562965);
-                   tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
+                    z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
+                    tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
+                    tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
+                    tmp2 = MULTIPLY(-d6, FIX_1_306562965);
+                    tmp3 = MULTIPLY(d6, FIX_0_541196100);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            }
     } else {
-           if (d2) {
-                   /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
-                   tmp2 = MULTIPLY(d2, FIX_0_541196100);
-                   tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
-                   tmp0 = (d0 + d4) << CONST_BITS;
-                   tmp1 = (d0 - d4) << CONST_BITS;
-
-                   tmp10 = tmp0 + tmp3;
-                   tmp13 = tmp0 - tmp3;
-                   tmp11 = tmp1 + tmp2;
-                   tmp12 = tmp1 - tmp2;
-           } else {
-                   /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
-                   tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
-                   tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
-           }
+            if (d2) {
+                    /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
+                    tmp2 = MULTIPLY(d2, FIX_0_541196100);
+                    tmp3 = MULTIPLY(d2, FIX_1_306562965);
+
+                    tmp0 = (d0 + d4) << CONST_BITS;
+                    tmp1 = (d0 - d4) << CONST_BITS;
+
+                    tmp10 = tmp0 + tmp3;
+                    tmp13 = tmp0 - tmp3;
+                    tmp11 = tmp1 + tmp2;
+                    tmp12 = tmp1 - tmp2;
+            } else {
+                    /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
+                    tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
+                    tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
+            }
     }
 
     /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
@@ -1358,8 +1129,8 @@ void j_rev_dct4(DCTBLOCK data)
     dataptr[DCTSTRIDE*1] = tmp11 >> (CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSTRIDE*2] = tmp12 >> (CONST_BITS+PASS1_BITS+3);
     dataptr[DCTSTRIDE*3] = tmp13 >> (CONST_BITS+PASS1_BITS+3);
-    
-    dataptr++;                 /* advance pointer to next column */
+
+    dataptr++;                  /* advance pointer to next column */
   }
 }
 
@@ -1371,7 +1142,7 @@ void j_rev_dct2(DCTBLOCK data){
   d01 = data[0+0*DCTSTRIDE] - data[1+0*DCTSTRIDE];
   d10 = data[0+1*DCTSTRIDE] + data[1+1*DCTSTRIDE];
   d11 = data[0+1*DCTSTRIDE] - data[1+1*DCTSTRIDE];
+
   data[0+0*DCTSTRIDE]= (d00 + d10)>>3;
   data[1+0*DCTSTRIDE]= (d01 + d11)>>3;
   data[0+1*DCTSTRIDE]= (d00 - d10)>>3;