changeset 1473:873100cd2108 libavcodec

wrong, wrong, wrong...coded bits are read in the opposite direction
author tmmm
date Wed, 17 Sep 2003 05:17:31 +0000
parents db00afcbd2ac
children 94c7f7c23dd9
files interplayvideo.c
diffstat 1 files changed, 57 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/interplayvideo.c	Tue Sep 16 20:28:53 2003 +0000
+++ b/interplayvideo.c	Wed Sep 17 05:17:31 2003 +0000
@@ -292,7 +292,7 @@
 
         for (y = 0; y < 8; y++) {
             flags = B[y];
-            for (x = 0x80; x != 0; x >>= 1) {
+            for (x = 0x01; x <= 0x80; x <<= 1) {
                 if (flags & x)
                     *sg_output_plane++ = P1;
                 else
@@ -308,10 +308,10 @@
         B[0] = *sg_stream_ptr++;
         B[1] = *sg_stream_ptr++;
 
-        flags = (B[0] << 8) | B[1];
-        bitmask = 0x8000;
+        flags = (B[1] << 8) | B[0];
+        bitmask = 0x0001;
         for (y = 0; y < 8; y += 2) {
-            for (x = 0; x < 8; x += 2, bitmask >>= 1) {
+            for (x = 0; x < 8; x += 2, bitmask <<= 1) {
                 if (flags & bitmask) {
                     *(sg_output_plane + x) = P0;
                     *(sg_output_plane + x + 1) = P0;
@@ -366,23 +366,23 @@
             /* time to reload flags? */
             if (y == 0) {
                 flags =
-                    ((B[0] & 0xF0) << 24) | ((B[4] & 0xF0) << 20) |
-                    ((B[0] & 0x0F) << 20) | ((B[4] & 0x0F) << 16) |
-                    ((B[1] & 0xF0) <<  8) | ((B[5] & 0xF0) <<  4) |
-                    ((B[1] & 0x0F) <<  4) | ((B[5] & 0x0F) <<  0);
-                bitmask = 0x80000000;
+                    ((B[0] & 0xF0) <<  4) | ((B[4] & 0xF0) <<  8) |
+                    ((B[0] & 0x0F)      ) | ((B[4] & 0x0F) <<  4) |
+                    ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) |
+                    ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20);
+                bitmask = 0x00000001;
                 lower_half = 0;  /* still on top half */
             } else if (y == 4) {
                 flags =
-                    ((B[2] & 0xF0) << 24) | ((B[6] & 0xF0) << 20) |
-                    ((B[2] & 0x0F) << 20) | ((B[6] & 0x0F) << 16) |
-                    ((B[3] & 0xF0) <<  8) | ((B[7] & 0xF0) <<  4) |
-                    ((B[3] & 0x0F) <<  4) | ((B[7] & 0x0F) <<  0);
-                bitmask = 0x80000000;
+                    ((B[2] & 0xF0) <<  4) | ((B[6] & 0xF0) <<  8) |
+                    ((B[2] & 0x0F)      ) | ((B[6] & 0x0F) <<  4) |
+                    ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) |
+                    ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20);
+                bitmask = 0x00000001;
                 lower_half = 4;
             }
 
-            for (x = 0; x < 8; x++, bitmask >>= 1) {
+            for (x = 0; x < 8; x++, bitmask <<= 1) {
                 /* get the pixel values ready for this quadrant */
                 if (x == 0) {
                     P0 = P[lower_half + 0];
@@ -419,21 +419,21 @@
                 /* time to reload flags? */
                 if (y == 0) {
                     flags =
-                        ((B[0] & 0xF0) << 24) | ((B[4] & 0xF0) << 20) |
-                        ((B[0] & 0x0F) << 20) | ((B[4] & 0x0F) << 16) |
-                        ((B[1] & 0xF0) <<  8) | ((B[5] & 0xF0) <<  4) |
-                        ((B[1] & 0x0F) <<  4) | ((B[5] & 0x0F) <<  0);
-                    bitmask = 0x80000000;
+                        ((B[0] & 0xF0) <<  4) | ((B[4] & 0xF0) <<  8) |
+                        ((B[0] & 0x0F)      ) | ((B[4] & 0x0F) <<  4) |
+                        ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) |
+                        ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20);
+                    bitmask = 0x00000001;
                 } else if (y == 4) {
                     flags =
-                        ((B[2] & 0xF0) << 24) | ((B[6] & 0xF0) << 20) |
-                        ((B[2] & 0x0F) << 20) | ((B[6] & 0x0F) << 16) |
-                        ((B[3] & 0xF0) <<  8) | ((B[7] & 0xF0) <<  4) |
-                        ((B[3] & 0x0F) <<  4) | ((B[7] & 0x0F) <<  0);
-                    bitmask = 0x80000000;
+                        ((B[2] & 0xF0) <<  4) | ((B[6] & 0xF0) <<  8) |
+                        ((B[2] & 0x0F)      ) | ((B[6] & 0x0F) <<  4) |
+                        ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) |
+                        ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20);
+                    bitmask = 0x00000001;
                 }
 
-                for (x = 0; x < 8; x++, bitmask >>= 1) {
+                for (x = 0; x < 8; x++, bitmask <<= 1) {
                     /* get the pixel values ready for this half */
                     if (x == 0) {
                         P0 = P[0];
@@ -466,7 +466,7 @@
                     P1 = P[3];
                 }
 
-                for (bitmask = 0x80; bitmask != 0; bitmask >>= 1) {
+                for (bitmask = 0x01; bitmask <= 0x80; bitmask <<= 1) {
 
                     if (flags & bitmask)
                         *sg_output_plane++ = P0;
@@ -486,6 +486,7 @@
 {
     int x, y;
     unsigned char P[4];
+    unsigned char B[4];
     unsigned int flags = 0;
     int shifter = 0;
     unsigned char pix;
@@ -503,9 +504,9 @@
 
         for (y = 0; y < 8; y++) {
             /* get the next set of 8 2-bit flags */
-            flags = (sg_stream_ptr[0] << 8) | sg_stream_ptr[1];
+            flags = (sg_stream_ptr[1] << 8) | sg_stream_ptr[0];
             sg_stream_ptr += 2;
-            for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
+            for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
                 *sg_output_plane++ = P[(flags >> shifter) & 0x03];
             }
             sg_output_plane += sg_line_inc;
@@ -516,15 +517,15 @@
         /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
         CHECK_STREAM_PTR(4);
 
-        flags = 0;
-        flags = (flags << 8) | *sg_stream_ptr++;
-        flags = (flags << 8) | *sg_stream_ptr++;
-        flags = (flags << 8) | *sg_stream_ptr++;
-        flags = (flags << 8) | *sg_stream_ptr++;
-        shifter = 30;
+        B[0] = *sg_stream_ptr++;
+        B[1] = *sg_stream_ptr++;
+        B[2] = *sg_stream_ptr++;
+        B[3] = *sg_stream_ptr++;
+        flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+        shifter = 0;
 
         for (y = 0; y < 8; y += 2) {
-            for (x = 0; x < 8; x += 2, shifter -= 2) {
+            for (x = 0; x < 8; x += 2, shifter += 2) {
                 pix = P[(flags >> shifter) & 0x03];
                 *(sg_output_plane + x) = pix;
                 *(sg_output_plane + x + 1) = pix;
@@ -542,14 +543,14 @@
         for (y = 0; y < 8; y++) {
             /* time to reload flags? */
             if ((y == 0) || (y == 4)) {
-                flags = 0;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                shifter = 30;
+                B[0] = *sg_stream_ptr++;
+                B[1] = *sg_stream_ptr++;
+                B[2] = *sg_stream_ptr++;
+                B[3] = *sg_stream_ptr++;
+                flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+                shifter = 0;
             }
-            for (x = 0; x < 8; x += 2, shifter -= 2) {
+            for (x = 0; x < 8; x += 2, shifter += 2) {
                 pix = P[(flags >> shifter) & 0x03];
                 *(sg_output_plane + x) = pix;
                 *(sg_output_plane + x + 1) = pix;
@@ -565,14 +566,14 @@
         for (y = 0; y < 8; y += 2) {
             /* time to reload flags? */
             if ((y == 0) || (y == 4)) {
-                flags = 0;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                flags = (flags << 8) | *sg_stream_ptr++;
-                shifter = 30;
+                B[0] = *sg_stream_ptr++;
+                B[1] = *sg_stream_ptr++;
+                B[2] = *sg_stream_ptr++;
+                B[3] = *sg_stream_ptr++;
+                flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
+                shifter = 0;
             }
-            for (x = 0; x < 8; x++, shifter -= 2) {
+            for (x = 0; x < 8; x++, shifter += 2) {
                 pix = P[(flags >> shifter) & 0x03];
                 *(sg_output_plane + x) = pix;
                 *(sg_output_plane + sg_stride + x) = pix;
@@ -620,9 +621,9 @@
         for (y = 0; y < 8; y++) {
 
             lower_half = (y >= 4) ? 4 : 0;
-            flags = (B[y] << 8) | B[y + 8];
+            flags = (B[y + 8] << 8) | B[y];
 
-            for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
+            for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
                 split = (x >= 4) ? 8 : 0;
                 index = split + lower_half + ((flags >> shifter) & 0x03);
                 *sg_output_plane++ = P[index];
@@ -649,10 +650,10 @@
             /* block is divided into left and right halves */
             for (y = 0; y < 8; y++) {
 
-                flags = (B[y] << 8) | B[y + 8];
+                flags = (B[y + 8] << 8) | B[y];
                 split = 0;
 
-                for (x = 0, shifter = 14; x < 8; x++, shifter -= 2) {
+                for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
                     if (x == 4)
                         split = 4;
                     *sg_output_plane++ = P[split + ((flags >> shifter) & 0x03)];
@@ -667,11 +668,11 @@
             split = 0;
             for (y = 0; y < 8; y++) {
 
-                flags = (B[y * 2] << 8) | B[y * 2 + 1];
+                flags = (B[y * 2 + 1] << 8) | B[y * 2];
                 if (y == 4)
                     split = 4;
 
-                for (x = 0, shifter = 14; x < 8; x++, shifter -= 2)
+                for (x = 0, shifter = 0; x < 8; x++, shifter += 2)
                     *sg_output_plane++ = P[split + ((flags >> shifter) & 0x03)];
 
                 sg_output_plane += sg_line_inc;