OSDN Git Service

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