changeset 3509:21c7b77b3e83

fixed endian-ness for FLI and MS Video 1 decoders; fixed padding bug in FLI decoder and also implemented (untested due to lack of sample data) the FLI_COPY chunk type
author melanson
date Sun, 16 Dec 2001 00:26:21 +0000
parents b5220cf63fc3
children 0e5829f1fb75
files fli.c msvidc.c
diffstat 2 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/fli.c	Sat Dec 15 23:26:52 2001 +0000
+++ b/fli.c	Sun Dec 16 00:26:21 2001 +0000
@@ -6,8 +6,11 @@
     32bpp support (c) alex
 */
 
-#define LE_16(x) *(unsigned short *)(x)
-#define LE_32(x) *(unsigned int *)(x)
+#include "config.h"
+#include "bswap.h"
+
+#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
+#define LE_32(x) (le2me_32(*(unsigned int *)(x)))
 
 #define FLI_256_COLOR 4
 #define FLI_DELTA     7
@@ -99,6 +102,10 @@
           stream_ptr += 3;
         }
       }
+      // it seems that a color packet has to be an even number of bytes
+      // so account for a pad byte
+      if (stream_ptr & 0x01)
+        stream_ptr++;
       break;
 
     case FLI_DELTA:
@@ -270,9 +277,16 @@
       break;
 
     case FLI_COPY:
-// currently unimplemented
-printf ("FLI_COPY chunk (currently unimplemented)\n");
-stream_ptr += chunk_size - 6;
+      // copy the chunk (uncompressed frame)
+      for (pixel_ptr = 0; pixel_ptr < chunk_size - 6; pixel_ptr++)
+      {
+        palette_ptr1 = encoded[stream_ptr++] * 4;
+        decoded[pixel_ptr++] = palette[palette_ptr1 + 0];
+        decoded[pixel_ptr++] = palette[palette_ptr1 + 1];
+        decoded[pixel_ptr++] = palette[palette_ptr1 + 2];
+        if (bytes_per_pixel == 4) /* 32bpp */
+          pixel_ptr++;
+      }
       break;
 
     case FLI_MINI:
--- a/msvidc.c	Sat Dec 15 23:26:52 2001 +0000
+++ b/msvidc.c	Sun Dec 16 00:26:21 2001 +0000
@@ -9,7 +9,10 @@
     32bpp support (c) alex
 */
 
-#define LE_16(x) *(unsigned short *)(x)
+#include "config.h"
+#include "bswap.h"
+
+#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
 
 #define DECODE_BGR555_TO_BGR888(x) \
         x.c1_b = (x.c1 >> 7) & 0xF8; \
@@ -100,6 +103,7 @@
       {
         flags = (byte_b << 8) | byte_a;
 
+//        quad[0][0].c1 = LE_16(&encoded[stream_ptr]);
         quad[0][0].c1 = LE_16(&encoded[stream_ptr]);
         stream_ptr += 2;
         quad[0][0].c2 = LE_16(&encoded[stream_ptr]);