OSDN Git Service

autoreconf works now
[android-x86/external-s2tc.git] / test.sh
1 #!/bin/sh
2
3 set -e
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
56         if $use_compressonator; then
57                 echo >&3 "<th>Compressonator</th>"
58         fi
59         if $use_nvcompress; then
60                 echo >&3 "<th>nvcompress</th>"
61         fi
62         echo >&3 "<th>rand32-sRGB-mixed</th>"
63         echo >&3 "<th>rand32-wavg</th>"
64         echo >&3 "<th>rand32-avg</th>"
65
66         if $use_libtxc_dxtn; then
67                 echo >&3 "<th>libtxc_dxtn</th>"
68         fi
69         echo >&3 "<th>norand-wavg</th>"
70         echo >&3 "<th>faster-wavg</th>"
71
72         echo >&3 "</tr>"
73 }
74 html_rowstart()
75 {
76         echo >&3 "<tr><th>$1</th>"
77         deltatime=
78         deltatime_raw=0
79         col=0
80 }
81 html()
82 {
83         convert "$1" -crop 256x256+192+128 "html/$1.png"
84         echo >&3 "<td><img src=\"$1.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
85         eval "prevdeltatime=\$deltatime_$col"
86         prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
87         eval "deltatime_$col=\$prevdeltatime"
88         col=$(($col+1))
89 }
90 html2()
91 {
92         ./s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
93         echo >&3 "<td><img src=\"$1-s2tc.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
94         eval "prevdeltatime=\$deltatime_$col"
95         prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
96         eval "deltatime_$col=\$prevdeltatime"
97         col=$(($col+1))
98 }
99 html_rowend()
100 {
101         echo >&3 "</tr>"
102 }
103 html_end()
104 {
105         echo >&3 "<tr><th>Total runtime</th><td>(original)</td>"
106         col=1
107         while :; do
108                 eval "prevdeltatime=\$deltatime_$col"
109                 [ -n "$prevdeltatime" ] || break
110                 deltatime=`echo "scale=3; $prevdeltatime / 1000000000" | bc -l`
111                 echo >&3 "<td>$deltatime seconds</td>"
112                 col=$(($col+1))
113         done
114         echo >&3 "</table></body></html>"
115 }
116
117 timing()
118 {
119         t0=`date +%s%N`
120         "$@"
121         t1=`date +%s%N`
122         deltatime_raw=`echo "$t1 - $t0" | bc`
123         deltatime=`echo "scale=3; $deltatime_raw / 1000000000" | bc -l`
124         deltatime=" ($deltatime seconds)"
125 }
126
127 t()
128 {
129         in=$1; shift
130         out=$1; shift
131         timing "$@" < "$in" > "$out"
132         html "$out"
133 }
134
135 if which nvcompress >/dev/null 2>&1; then
136         use_nvcompress=true
137 else
138         use_nvcompress=false
139 fi
140 if which wine >/dev/null 2>&1 && [ -f "$HOME/.wine/drive_c/Program Files (x86)/AMD/The Compressonator 1.50/TheCompressonator.exe" ]; then
141         use_compressonator=true
142 else
143         use_compressonator=false
144 fi
145 if [ -f /usr/lib/libtxc_dxtn.so ]; then
146         use_libtxc_dxtn=true
147 else
148         use_libtxc_dxtn=false
149 fi
150
151 html_start
152 for i in dxtfail fract001 base_concrete1a disabled floor_tile3a lift02 panel_ceil1a sunset amelia rms noise noise_solid supernova ishihara augenkrebs; do
153         html_rowstart "$i"
154
155         html "$i".tga
156
157         if $use_compressonator; then
158                 timing 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
159                 html "$i"-amdcompress.dds
160         fi
161
162         if $use_nvcompress; then
163                 timing nvcompress "$i".tga "$i"-nvcompress.dds
164                 html "$i"-nvcompress.dds
165         fi
166
167         S2TC_COLORDIST_MODE=SRGB_MIXED S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-mrgb-r.dds ./s2tc
168         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-wavg-r.dds ./s2tc
169         S2TC_COLORDIST_MODE=AVG        S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-avg-r.dds  ./s2tc
170         if $use_libtxc_dxtn; then
171                 LD_PRELOAD=/usr/lib/libtxc_dxtn.so                                     t "$i".tga "$i"-libtxc_dxtn.dds ./s2tc
172                 unset LD_PRELOAD
173         fi
174         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=0  S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-norand-wavg-r.dds ./s2tc
175         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=-1 S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-faster-wavg-r.dds ./s2tc
176
177         html_rowend
178 done
179 html_end