[Mplayer-cvslog] CVS: main qtsmc.c,1.2,1.3

Mike Melanson melanson at mplayer.dev.hu
Tue Jan 22 03:00:59 CET 2002


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv3700

Modified Files:
	qtsmc.c 
Log Message:
fixed some major flaws; decoder is now almost correct


Index: qtsmc.c
===================================================================
RCS file: /cvsroot/mplayer/main/qtsmc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- qtsmc.c	20 Jan 2002 01:35:02 -0000	1.2
+++ qtsmc.c	22 Jan 2002 02:00:57 -0000	1.3
@@ -49,10 +49,6 @@
     COLORS_PER_TABLE * BYTES_PER_COLOR * 8)) == 0)
     return 1;
 
-  color_pair_index = 0;
-  color_quad_index = 0;
-  color_octet_index = 0;
-
   // if execution got this far, initialization succeeded
   smc_initialized = 1;
   return 0;
@@ -65,6 +61,7 @@
   pixel_ptr += block_x_inc; \
   if (pixel_ptr >= (width * bytes_per_pixel)) \
   { \
+counter++; \
     pixel_ptr = 0; \
     row_ptr += block_y_inc * 4; \
   } \
@@ -118,6 +115,11 @@
   if (!smc_initialized)
     return;
 
+  // reset color tables
+  color_pair_index = 0;
+  color_quad_index = 0;
+  color_octet_index = 0;
+
   chunk_size = BE_32(&encoded[stream_ptr]) & 0x00FFFFFF;
   stream_ptr += 4;
   if (chunk_size != encoded_size)
@@ -148,8 +150,8 @@
     }
 
     opcode = encoded[stream_ptr++];
-//printf ("opcode %02X\n", opcode & 0xF0);
-counter++;
+//if (counter < 3)
+//printf ("%d: opcode %02X\n", counter, opcode);
     switch (opcode & 0xF0)
     {
     // skip n blocks
@@ -263,6 +265,7 @@
     case 0x60:
     case 0x70:
       n_blocks = GET_BLOCK_COUNT;
+//printf ("1-color encoding for %d blocks\n", n_blocks);
       color_index = encoded[stream_ptr++] * 4;
 
       while (n_blocks--)
@@ -428,14 +431,27 @@
 
       while (n_blocks--)
       {
+        /*
+          For this input:
+            01 23 45 67 89 AB
+          This is the output:
+            flags_a = xx012456, flags_b = xx89A37B
+        */
         // build the color flags
         color_flags_a = color_flags_b = 0;
-        color_flags_a |= (encoded[stream_ptr++] << 16);
-        color_flags_b |= (encoded[stream_ptr++] << 16);
-        color_flags_a |= (encoded[stream_ptr++] << 8);
-        color_flags_b |= (encoded[stream_ptr++] << 8);
-        color_flags_a |= (encoded[stream_ptr++] << 0);
-        color_flags_b |= (encoded[stream_ptr++] << 0);
+        color_flags_a =
+          (encoded[stream_ptr + 0] << 16) |
+          ((encoded[stream_ptr + 1] & 0xF0) << 8) |
+          ((encoded[stream_ptr + 2] & 0xF0) << 4) |
+          ((encoded[stream_ptr + 2] & 0x0F) << 4) |
+          ((encoded[stream_ptr + 3] & 0xF0) >> 4);
+        color_flags_b =
+          (encoded[stream_ptr + 4] << 16) |
+          ((encoded[stream_ptr + 5] & 0xF0) << 8) |
+          ((encoded[stream_ptr + 1] & 0x0F) << 8) |
+          ((encoded[stream_ptr + 3] & 0x0F) << 4) |
+          (encoded[stream_ptr + 5] & 0x0F);
+        stream_ptr += 6;
 
         color_flags = color_flags_a;
         // flag mask actually acts as a bit shift count here




More information about the MPlayer-cvslog mailing list