OSDN Git Service

more fixes
authorRudolf Polzer <divverent@xonotic.org>
Wed, 13 Jul 2011 15:14:21 +0000 (17:14 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 14 Jul 2011 17:12:26 +0000 (19:12 +0200)
s2tc_decompress.cpp [moved from s2tc_decompress.c with 92% similarity]
test.sh

similarity index 92%
rename from s2tc_decompress.c
rename to s2tc_decompress.cpp
index befe280..0f8eeb9 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <algorithm>
 #include "libtxc_dxtn.h"
 
 uint32_t LittleLong(uint32_t w)
@@ -60,7 +61,7 @@ int main()
        fwrite(t, 18, 1, stdout);
 
        int n = ((width + 3) / 4) * ((height + 3) / 4);
-       unsigned char *buf = malloc(n * blocksize);
+       unsigned char *buf = (unsigned char *) malloc(n * blocksize);
        fread(buf, blocksize, n, stdin);
 
        int x, y;
@@ -69,6 +70,7 @@ int main()
                {
                        char data[4];
                        fetch(width, buf, x, y, &data);
+                       std::swap(data[0], data[2]);
                        fwrite(data, 4, 1, stdout);
                }
        return 0;
diff --git a/test.sh b/test.sh
index 346a00d..ac061c8 100644 (file)
--- a/test.sh
+++ b/test.sh
@@ -53,6 +53,7 @@ EOF
        echo >&3 "<tr><th>Picture</th>"
        echo >&3 "<th>Original</th>"
        echo >&3 "<th>nvcompress</th>"
+       echo >&3 "<th>nvcompress (S2TC)</th>"
        echo >&3 "<th>rand64-sRGB-mixed</th>"
        echo >&3 "<th>norand-sRGB-mixed</th>"
        echo >&3 "<th>faster-sRGB-mixed</th>"
@@ -73,6 +74,11 @@ html()
        convert "$1" -crop 256x256+192+128 "html/$1.png"
        echo >&3 "<td><img src=\"$1.png\" alt=\"$1\"></td>"
 }
+html2()
+{
+       ./s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
+       echo >&3 "<td><img src=\"$1.png\" alt=\"$1\"></td>"
+}
 html_rowend()
 {
        echo >&3 "</tr>"
@@ -98,6 +104,7 @@ for i in dxtfail base_concrete1a disabled floor_tile3a lift02 panel_ceil1a sunse
 
        nvcompress "$i".tga "$i".dds
        html "$i".dds
+       html2 "$i".dds
 
        t "$i".tga "$i"-rand64-mrgb.dds ./s2tc -c SRGB_MIXED -r 64
        t "$i".tga "$i"-norand-mrgb.dds ./s2tc -c SRGB_MIXED -r 0