OSDN Git Service

dds: Fix palette decoding
authorVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 20 Jul 2015 22:47:12 +0000 (23:47 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Wed, 22 Jul 2015 12:35:44 +0000 (13:35 +0100)
Red and blue channels were decoded in the wrong order.

Found-By: ami_stuff
libavcodec/dds.c
tests/ref/fate/dds-pal
tests/ref/fate/dds-pal-ati

index d259b5e..85d85fd 100644 (file)
@@ -645,11 +645,15 @@ static int dds_decode(AVCodecContext *avctx, void *data,
 
         if (ctx->paletted) {
             int i;
-            uint32_t *p = (uint32_t *)frame->data[1];
+            uint8_t *p = frame->data[1];
 
             /* Use the first 1024 bytes as palette, then copy the rest. */
-            for (i = 0; i < 256; i++)
-                p[i] = bytestream2_get_le32(gbc);
+            for (i = 0; i < 256; i++) {
+                p[i * 4 + 2] = bytestream2_get_byte(gbc);
+                p[i * 4 + 1] = bytestream2_get_byte(gbc);
+                p[i * 4 + 0] = bytestream2_get_byte(gbc);
+                p[i * 4 + 3] = bytestream2_get_byte(gbc);
+            }
 
             frame->palette_has_changed = 1;
         }
index 8541441..575a4bd 100644 (file)
@@ -1,2 +1,2 @@
 #tb 0: 1/25
-0,          0,          0,        1,    65536, 0xbffee5cd
+0,          0,          0,        1,    65536, 0x4287e5cd
index 6b43bb4..6de8adb 100644 (file)
@@ -1,2 +1,2 @@
 #tb 0: 1/25
-0,          0,          0,        1,    16384, 0x23068060
+0,          0,          0,        1,    16384, 0x6ac18060