OSDN Git Service

effd30da36712f4bcff7239ce303b3f940a3d165
[android-x86/external-s2tc.git] / test.sh
1 #!/bin/sh
2
3 set -ex
4
5 CXX="g++ -Wall -Wextra -O3"
6 make clean all
7
8 mkdir -p html
9 exec 3>html/index.html
10
11 html_start()
12 {
13         echo >&3 "<html><title>S2TC</title>"
14         cat <<'EOF' >&3
15 <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
16 <script type="text/javascript">
17 var refsrc = "";
18 function clickfunc()
19 {
20         var me = $(this);
21         if(!me.data("src"))
22                 me.data("src", me.attr("src"));
23         me.attr("src", me.data("src"));
24         if(refsrc == me.data("src"))
25                 refsrc = "";
26         else
27                 refsrc = me.data("src");
28 }
29 function enterfunc()
30 {
31         var me = $(this);
32         if(!me.data("src"))
33                 me.data("src", me.attr("src"));
34         if(refsrc != "")
35                 me.attr("src", refsrc);
36 }
37 function leavefunc()
38 {
39         var me = $(this);
40         if(me.data("src"))
41                 me.attr("src", me.data("src"));
42 }
43 function run()
44 {
45         $('img').click(clickfunc);
46         $('img').mouseenter(enterfunc);
47         $('img').mouseleave(leavefunc);
48 }
49 </script>
50 EOF
51         echo >&3 "<body onLoad=\"run()\"><h1>S2TC</h1>"
52         echo >&3 "<table>"
53         echo >&3 "<tr><th>Picture</th>"
54         echo >&3 "<th>Original</th>"
55         echo >&3 "<th>Compressonator</th>"
56         echo >&3 "<th>nvcompress</th>"
57         echo >&3 "<th>libtxc_dxtn</th>"
58         echo >&3 "<th>rand64-sRGB-mixed</th>"
59         echo >&3 "<th>rand64-wavg</th>"
60         echo >&3 "<th>norand-wavg</th>"
61         echo >&3 "<th>faster-wavg</th>"
62         echo >&3 "<th>rand64-avg</th>"
63         echo >&3 "</tr>"
64 }
65 html_rowstart()
66 {
67         echo >&3 "<tr><th>$1</th>"
68 }
69 html()
70 {
71         convert "$1" -crop 256x256+192+128 "html/$1.png"
72         echo >&3 "<td><img src=\"$1.png\" alt=\"$1\"></td>"
73 }
74 html2()
75 {
76         ./s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
77         echo >&3 "<td><img src=\"$1-s2tc.png\" alt=\"$1\"></td>"
78 }
79 html_rowend()
80 {
81         echo >&3 "</tr>"
82 }
83 html_end()
84 {
85         echo >&3 "</table></body></html>"
86 }
87
88 t()
89 {
90         in=$1; shift
91         out=$1; shift
92         time "$@" < "$in" > "$out"
93         html "$out"
94         echo "$LD_PRELOAD"
95 }
96
97 html_start
98 for i in dxtfail base_concrete1a disabled floor_tile3a lift02 panel_ceil1a sunset amelia rms noise noise_solid supernova ishihara augenkrebs; do
99         html_rowstart "$i"
100
101         html "$i".tga
102
103         time wine "c:/Program Files (x86)/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -overwrite -mipmaps "$i".tga "$i"-amdcompress.dds -codec DXTC.dll +fourCC DXT1 -mipper BoxFilter.dll
104         html "$i"-amdcompress.dds
105
106         time nvcompress "$i".tga "$i"-nvcompress.dds
107         html "$i"-nvcompress.dds
108
109         ( LD_PRELOAD=/usr/lib/libtxc_dxtn.so                   t "$i".tga "$i"-libtxc_dxtn.dds ./s2tc )
110         ( S2TC_COLORDIST_MODE=SRGB_MIXED S2TC_RANDOM_COLORS=64 t "$i".tga "$i"-rand64-mrgb.dds ./s2tc )
111         ( S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=64 t "$i".tga "$i"-rand64-wavg.dds ./s2tc )
112         ( S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=0  t "$i".tga "$i"-norand-wavg.dds ./s2tc )
113         ( S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=-1 t "$i".tga "$i"-faster-wavg.dds ./s2tc )
114         ( S2TC_COLORDIST_MODE=AVG        S2TC_RANDOM_COLORS=64 t "$i".tga "$i"-rand64-avg.dds  ./s2tc )
115
116         html_rowend
117 done
118 html_end