• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -u
4set -e
5trap onexit INT
6trap onexit TERM
7trap onexit EXIT
8
9onexit()
10{
11	if [ -d $OUTDIR ]; then
12		rm -rf $OUTDIR
13	fi
14}
15
16runme()
17{
18	echo \*\*\* $*
19	$*
20}
21
22IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
23IMGDIR=@srcdir@/testimages
24OUTDIR=`mktemp -d /tmp/__tjbenchtest_java_output.XXXXXX`
25EXEDIR=.
26JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs"
27BMPARG=
28NSARG=
29YUVARG=
30
31if [ -d $OUTDIR ]; then
32	rm -rf $OUTDIR
33fi
34mkdir -p $OUTDIR
35
36exec >$EXEDIR/tjbenchtest-java.log
37
38if [ $# -gt 0 ]; then
39	if [ "$1" = "-yuv" ]; then
40		NSARG=-nosmooth
41		YUVARG=-yuv
42
43# NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not
44# always produce bitwise-identical results to tjCompress*() if subsampling is
45# enabled.  In both cases, if the image width or height are not evenly
46# divisible by the MCU width/height, then the bottom and/or right edge are
47# expanded.  However, the libjpeg code performs this expansion prior to
48# downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is
49# after downsampling.  Thus, the two will agree only if the width/height along
50# each downsampled dimension is an odd number or is evenly divisible by the MCU
51# width/height.  This disagreement basically amounts to a round-off error, but
52# there is no easy way around it, so for now, we just test the only image that
53# works.  (NOTE: nightshot_iso_100 does not suffer from the above issue, but
54# it suffers from an unrelated problem whereby the combination of
55# tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical
56# results to tjDecompress*() if decompression scaling is enabled.  This latter
57# phenomenon is not yet fully understood but is also believed to be some sort
58# of round-off error.)
59		IMAGES="vgl_6548_0026a.bmp"
60	fi
61fi
62
63# Standard tests
64for image in $IMAGES; do
65
66	cp $IMGDIR/$image $OUTDIR
67	basename=`basename $image .bmp`
68	runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
69	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
70	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
71	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
72	runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
73	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
74	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
75	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
76	for samp in GRAY 420 422 444; do
77		runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
78		runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
79		runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
80	done
81	for samp in 420 422; do
82		runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
83		runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
84		runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
85	done
86
87	# Compression
88	for dct in accurate fast; do
89		runme $JAVA TJBench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG
90		for samp in GRAY 420 422 444; do
91			runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg
92		done
93	done
94
95	for dct in fast accurate default; do
96		dctarg=-${dct}dct
97		if [ "${dct}" = "default" ]; then
98			dctarg=
99		fi
100
101		# Tiled compression & decompression
102		runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG
103		for samp in GRAY 444; do
104			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
105				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
106				runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp
107				rm $i
108			done
109		done
110		runme $JAVA TJBench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG
111		for samp in 420 422; do
112			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
113				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
114				runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp
115				rm $i
116			done
117		done
118
119		# Tiled decompression
120		for samp in GRAY 444; do
121			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG
122			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
123				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
124				runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.bmp
125				rm $i
126			done
127		done
128		for samp in 420 422; do
129			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG
130			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
131				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
132				runme cmp $i -i 54:54 $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.bmp
133				rm $i
134			done
135		done
136	done
137
138	# Scaled decompression
139	for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
140		scalearg=`echo $scale | sed s@_@/@g`
141		for samp in GRAY 420 422 444; do
142			runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
143			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG
144			runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
145			rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp
146		done
147	done
148
149	# Transforms
150	for samp in GRAY 420 422 444; do
151		runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
152		runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
153		runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
154		runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
155		runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
156		runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
157		runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
158	done
159	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
160		for samp in GRAY 444; do
161			runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
162			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG
163			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
164				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
165				runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
166				rm $i
167			done
168		done
169		for samp in 420 422; do
170			runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
171			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG
172			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
173				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
174				runme cmp -i 54:54 $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
175				rm $i
176			done
177		done
178	done
179
180	# Grayscale transform
181	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
182		for samp in GRAY 444 422 420; do
183			runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG
184			for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].bmp \
185				$OUTDIR/${basename}_${samp}_Q95_full.bmp; do
186				runme cmp -i 54:54 $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp
187				rm $i
188			done
189		done
190	done
191
192	# Transforms with scaling
193	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
194		for samp in GRAY 444 422 420; do
195			for scale in 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8; do
196				scalearg=`echo $scale | sed s@_@/@g`
197				runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
198				runme $JAVA TJBench $OUTDIR/${basename}_${samp}_Q95.jpg -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG
199				runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
200				rm $OUTDIR/${basename}_${samp}_Q95_${scale}.bmp
201			done
202		done
203	done
204
205done
206
207echo SUCCESS!
208