OSDN Git Service

more test cases
[android-x86/external-s2tc.git] / tests / test.sh
1 #!/bin/sh
2
3 set -e
4
5 cd ..
6 git clean -xdf
7 sh autogen.sh
8 ./configure --prefix="`pwd`/tests" CXXFLAGS="-O3"
9 make
10 make install
11 cd tests
12
13 mkdir -p html
14 exec 3>html/index.html
15
16 html_start()
17 {
18         echo >&3 "<html><title>S2TC</title>"
19         cat <<'EOF' >&3
20 <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
21 <script type="text/javascript">
22 var refsrc = "";
23 function clickfunc()
24 {
25         var me = $(this);
26         if(!me.data("src"))
27                 me.data("src", me.attr("src"));
28         me.attr("src", me.data("src"));
29         if(refsrc == me.data("src"))
30                 refsrc = "";
31         else
32                 refsrc = me.data("src");
33 }
34 function enterfunc()
35 {
36         var me = $(this);
37         if(!me.data("src"))
38                 me.data("src", me.attr("src"));
39         if(refsrc != "")
40                 me.attr("src", refsrc);
41 }
42 function leavefunc()
43 {
44         var me = $(this);
45         if(me.data("src"))
46                 me.attr("src", me.data("src"));
47 }
48 function run()
49 {
50         $('img').click(clickfunc);
51         $('img').mouseenter(enterfunc);
52         $('img').mouseleave(leavefunc);
53 }
54 </script>
55 EOF
56         echo >&3 "<body onLoad=\"run()\"><h1>S2TC</h1>"
57         echo >&3 "<table>"
58         echo >&3 "<tr><th>Picture</th>"
59         echo >&3 "<th>Original</th>"
60
61         if $use_compressonator; then
62                 echo >&3 "<th>Compressonator</th>"
63         fi
64         if $use_nvcompress; then
65                 echo >&3 "<th>nvcompress</th>"
66         fi
67         echo >&3 "<th>rand32-sRGB-mixed</th>"
68         echo >&3 "<th>rand32-wavg</th>"
69         echo >&3 "<th>rand32-avg</th>"
70
71         if $use_libtxc_dxtn; then
72                 echo >&3 "<th>libtxc_dxtn</th>"
73         fi
74         echo >&3 "<th>norand-wavg</th>"
75         echo >&3 "<th>faster-wavg</th>"
76
77         echo >&3 "</tr>"
78 }
79 html_rowstart()
80 {
81         echo >&3 "<tr><th>$1</th>"
82         deltatime=
83         deltatime_raw=0
84         col=0
85 }
86 html()
87 {
88         convert "$1" -crop 256x256+192+128 "html/$1.png"
89         echo >&3 "<td><img src=\"$1.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
90         eval "prevdeltatime=\$deltatime_$col"
91         prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
92         eval "deltatime_$col=\$prevdeltatime"
93         col=$(($col+1))
94 }
95 html2()
96 {
97         bin/s2tc_decompress < "$1" | convert TGA:- -crop 256x256+192+128 "html/$1-s2tc.png"
98         echo >&3 "<td><img src=\"$1-s2tc.png\" alt=\"$1\" title=\"$1$deltatime\"></td>"
99         eval "prevdeltatime=\$deltatime_$col"
100         prevdeltatime=`echo "($prevdeltatime-0)+$deltatime_raw" | bc`
101         eval "deltatime_$col=\$prevdeltatime"
102         col=$(($col+1))
103 }
104 html_rowend()
105 {
106         echo >&3 "</tr>"
107 }
108 html_end()
109 {
110         echo >&3 "<tr><th>Total runtime</th><td>(original)</td>"
111         col=1
112         while :; do
113                 eval "prevdeltatime=\$deltatime_$col"
114                 [ -n "$prevdeltatime" ] || break
115                 deltatime=`echo "scale=3; $prevdeltatime / 1000000000" | bc -l`
116                 echo >&3 "<td>$deltatime seconds</td>"
117                 col=$(($col+1))
118         done
119         echo >&3 "</table></body></html>"
120 }
121
122 timing()
123 {
124         t0=`date +%s%N`
125         "$@"
126         t1=`date +%s%N`
127         deltatime_raw=`echo "$t1 - $t0" | bc`
128         deltatime=`echo "scale=3; $deltatime_raw / 1000000000" | bc -l`
129         deltatime=" ($deltatime seconds)"
130 }
131
132 t()
133 {
134         in=$1; shift
135         out=$1; shift
136         timing "$@" < "$in" > "$out"
137         html "$out"
138 }
139
140 if which nvcompress >/dev/null 2>&1; then
141         use_nvcompress=true
142 else
143         use_nvcompress=false
144 fi
145 if which wine >/dev/null 2>&1 && [ -f "$HOME/.wine/drive_c/Program Files (x86)/AMD/The Compressonator 1.50/TheCompressonator.exe" ]; then
146         use_compressonator=true
147 else
148         use_compressonator=false
149 fi
150 if [ -f /usr/lib/libtxc_dxtn.so ]; then
151         use_libtxc_dxtn=true
152 else
153         use_libtxc_dxtn=false
154 fi
155
156 html_start
157 for i in dxtfail floor_tread01 floor_tread01_norm fract001 base_concrete1a disabled floor_tile3a lift02 panel_ceil1a sunset amelia rms noise noise_solid supernova ishihara augenkrebs; do
158         html_rowstart "$i"
159
160         html "$i".tga
161
162         if $use_compressonator; then
163                 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
164                 html "$i"-amdcompress.dds
165         fi
166
167         if $use_nvcompress; then
168                 timing nvcompress "$i".tga "$i"-nvcompress.dds
169                 html "$i"-nvcompress.dds
170         fi
171
172         S2TC_COLORDIST_MODE=SRGB_MIXED S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-mrgb-r.dds bin/s2tc
173         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-wavg-r.dds bin/s2tc
174         S2TC_COLORDIST_MODE=AVG        S2TC_RANDOM_COLORS=32 S2TC_REFINE_COLORS=CHECK  t "$i".tga "$i"-rand32-avg-r.dds  bin/s2tc
175         if $use_libtxc_dxtn; then
176                 LD_PRELOAD=/usr/lib/libtxc_dxtn.so                                     t "$i".tga "$i"-libtxc_dxtn.dds   bin/s2tc
177                 unset LD_PRELOAD
178         fi
179         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=0  S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-norand-wavg-r.dds bin/s2tc
180         S2TC_COLORDIST_MODE=WAVG       S2TC_RANDOM_COLORS=-1 S2TC_REFINE_COLORS=ALWAYS t "$i".tga "$i"-faster-wavg-r.dds bin/s2tc
181
182         html_rowend
183 done
184 html_end