1cb6157be7a4506b2401f52a1616744cd10790506DRC#!/bin/bash
2cb6157be7a4506b2401f52a1616744cd10790506DRC
3cb6157be7a4506b2401f52a1616744cd10790506DRCset -u
4cb6157be7a4506b2401f52a1616744cd10790506DRCset -e
5cb6157be7a4506b2401f52a1616744cd10790506DRCtrap onexit INT
6cb6157be7a4506b2401f52a1616744cd10790506DRCtrap onexit TERM
7cb6157be7a4506b2401f52a1616744cd10790506DRCtrap onexit EXIT
8cb6157be7a4506b2401f52a1616744cd10790506DRC
9cb6157be7a4506b2401f52a1616744cd10790506DRConexit()
10cb6157be7a4506b2401f52a1616744cd10790506DRC{
11cb6157be7a4506b2401f52a1616744cd10790506DRC	if [ -d $OUTDIR ]; then
12cb6157be7a4506b2401f52a1616744cd10790506DRC		rm -rf $OUTDIR
13cb6157be7a4506b2401f52a1616744cd10790506DRC	fi
14cb6157be7a4506b2401f52a1616744cd10790506DRC}
15cb6157be7a4506b2401f52a1616744cd10790506DRC
16cb6157be7a4506b2401f52a1616744cd10790506DRCrunme()
17cb6157be7a4506b2401f52a1616744cd10790506DRC{
18cb6157be7a4506b2401f52a1616744cd10790506DRC	echo \*\*\* $*
19cb6157be7a4506b2401f52a1616744cd10790506DRC	$*
20cb6157be7a4506b2401f52a1616744cd10790506DRC}
21cb6157be7a4506b2401f52a1616744cd10790506DRC
22cb6157be7a4506b2401f52a1616744cd10790506DRCEXT=bmp
23cb6157be7a4506b2401f52a1616744cd10790506DRCIMAGES="vgl_5674_0098.${EXT} vgl_6434_0018a.${EXT} vgl_6548_0026a.${EXT} nightshot_iso_100.${EXT}"
24cb6157be7a4506b2401f52a1616744cd10790506DRCIMGDIR=@srcdir@/testimages
25d92949b0ac7f2d90aa554e5c6eb8e99730e75f8eDRCOUTDIR=`mktemp -d /tmp/__tjbenchtest_output.XXXXXX`
26cb6157be7a4506b2401f52a1616744cd10790506DRCEXEDIR=.
27cb6157be7a4506b2401f52a1616744cd10790506DRCBMPARG=
28823fbed414c2eaf2b929727cb23a3af85e08cf4fDRCNSARG=
29823fbed414c2eaf2b929727cb23a3af85e08cf4fDRCYUVARG=
30684ace1924f95d71caa31e68330405cdb8043729DRCALLOC=0
31684ace1924f95d71caa31e68330405cdb8043729DRCALLOCARG=
32cb6157be7a4506b2401f52a1616744cd10790506DRCif [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi
33cb6157be7a4506b2401f52a1616744cd10790506DRC
34cb6157be7a4506b2401f52a1616744cd10790506DRCif [ -d $OUTDIR ]; then
35cb6157be7a4506b2401f52a1616744cd10790506DRC	rm -rf $OUTDIR
36cb6157be7a4506b2401f52a1616744cd10790506DRCfi
37cb6157be7a4506b2401f52a1616744cd10790506DRCmkdir -p $OUTDIR
38cb6157be7a4506b2401f52a1616744cd10790506DRC
39cb6157be7a4506b2401f52a1616744cd10790506DRCexec >$EXEDIR/tjbenchtest.log
40cb6157be7a4506b2401f52a1616744cd10790506DRC
41823fbed414c2eaf2b929727cb23a3af85e08cf4fDRCif [ $# -gt 0 ]; then
42823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	if [ "$1" = "-yuv" ]; then
43823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		NSARG=-nosmooth
44823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		YUVARG=-yuv
45823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC
46823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not
47823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# always produce bitwise-identical results to tjCompress*() if subsampling is
48823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# enabled.  In both cases, if the image width or height are not evenly
49823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# divisible by the MCU width/height, then the bottom and/or right edge are
50823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# expanded.  However, the libjpeg code performs this expansion prior to
51823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is
52823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# after downsampling.  Thus, the two will agree only if the width/height along
53823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# each downsampled dimension is an odd number or is evenly divisible by the MCU
54823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# width/height.  This disagreement basically amounts to a round-off error, but
55823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC# there is no easy way around it, so for now, we just test the only image that
56b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# works.  (NOTE: nightshot_iso_100 does not suffer from the above issue, but
57b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# it suffers from an unrelated problem whereby the combination of
58b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical
59b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# results to tjDecompress*() if decompression scaling is enabled.  This latter
60b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# phenomenon is not yet fully understood but is also believed to be some sort
61b53f410228cdc1fd1b3e973dc5af96a42509c0bfDRC# of round-off error.)
62823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		IMAGES="vgl_6548_0026a.${EXT}"
63823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	fi
64684ace1924f95d71caa31e68330405cdb8043729DRC	if [ "$1" = "-alloc" ]; then
65684ace1924f95d71caa31e68330405cdb8043729DRC		ALLOCARG=-alloc
66684ace1924f95d71caa31e68330405cdb8043729DRC		ALLOC=1
67684ace1924f95d71caa31e68330405cdb8043729DRC	fi
68823fbed414c2eaf2b929727cb23a3af85e08cf4fDRCfi
69823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC
70cb6157be7a4506b2401f52a1616744cd10790506DRC# Standard tests
71cb6157be7a4506b2401f52a1616744cd10790506DRCfor image in $IMAGES; do
72cb6157be7a4506b2401f52a1616744cd10790506DRC
73cb6157be7a4506b2401f52a1616744cd10790506DRC	cp $IMGDIR/$image $OUTDIR
74cb6157be7a4506b2401f52a1616744cd10790506DRC	basename=`basename $image .${EXT}`
75823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
76823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
77823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
78823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
79823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
80823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
81823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
82823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC	runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
83cb6157be7a4506b2401f52a1616744cd10790506DRC	for samp in GRAY 420 422 444; do
84823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
85823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -dct fast -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
86823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -dct int -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
87cb6157be7a4506b2401f52a1616744cd10790506DRC	done
88cb6157be7a4506b2401f52a1616744cd10790506DRC	for samp in 420 422; do
89823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
90823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -dct fast -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
91823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/djpeg -dct int -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
92cb6157be7a4506b2401f52a1616744cd10790506DRC	done
93cb6157be7a4506b2401f52a1616744cd10790506DRC
94cb6157be7a4506b2401f52a1616744cd10790506DRC	# Compression
9573d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC	for dct in accurate fast; do
96684ace1924f95d71caa31e68330405cdb8043729DRC		runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG $ALLOCARG
9773d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		for samp in GRAY 420 422 444; do
9873d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC			runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg
9973d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		done
100cb6157be7a4506b2401f52a1616744cd10790506DRC	done
101cb6157be7a4506b2401f52a1616744cd10790506DRC
10273d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC	for dct in fast accurate default; do
10373d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		dctarg=-${dct}dct
10473d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		if [ "${dct}" = "default" ]; then
10573d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC			dctarg=
10673d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		fi
10773d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC
10873d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		# Tiled compression & decompression
109684ace1924f95d71caa31e68330405cdb8043729DRC		runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG
11073d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		for samp in GRAY 444; do
111684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
112684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
113684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
114684ace1924f95d71caa31e68330405cdb8043729DRC			else
115684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
116684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
117684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
118684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
119684ace1924f95d71caa31e68330405cdb8043729DRC				done
120684ace1924f95d71caa31e68330405cdb8043729DRC			fi
121cb6157be7a4506b2401f52a1616744cd10790506DRC		done
122684ace1924f95d71caa31e68330405cdb8043729DRC		runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG $ALLOCARG
12373d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		for samp in 420 422; do
124684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
125684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
126684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
127684ace1924f95d71caa31e68330405cdb8043729DRC			else
128684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
129684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
130684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
131684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
132684ace1924f95d71caa31e68330405cdb8043729DRC				done
133684ace1924f95d71caa31e68330405cdb8043729DRC			fi
134cb6157be7a4506b2401f52a1616744cd10790506DRC		done
135cb6157be7a4506b2401f52a1616744cd10790506DRC
13673d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		# Tiled decompression
13773d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		for samp in GRAY 444; do
138684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG
139684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
140684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
141684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
142684ace1924f95d71caa31e68330405cdb8043729DRC			else
143684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
144684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
145684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
146684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
147684ace1924f95d71caa31e68330405cdb8043729DRC				done
148684ace1924f95d71caa31e68330405cdb8043729DRC			fi
149cb6157be7a4506b2401f52a1616744cd10790506DRC		done
15073d74c132b399fc761ebd9a5b2f60ae2a25f5955DRC		for samp in 420 422; do
151684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG $ALLOCARG
152684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
153684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
154684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
155684ace1924f95d71caa31e68330405cdb8043729DRC			else
156684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
157684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
158684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
159684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
160684ace1924f95d71caa31e68330405cdb8043729DRC				done
161684ace1924f95d71caa31e68330405cdb8043729DRC			fi
162cb6157be7a4506b2401f52a1616744cd10790506DRC		done
163cb6157be7a4506b2401f52a1616744cd10790506DRC	done
164cb6157be7a4506b2401f52a1616744cd10790506DRC
165cb6157be7a4506b2401f52a1616744cd10790506DRC	# Scaled decompression
166cb6157be7a4506b2401f52a1616744cd10790506DRC	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
167cb6157be7a4506b2401f52a1616744cd10790506DRC		scalearg=`echo $scale | sed s@_@/@g`
168cb6157be7a4506b2401f52a1616744cd10790506DRC		for samp in GRAY 420 422 444; do
169823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC			runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
170684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG
171cb6157be7a4506b2401f52a1616744cd10790506DRC			runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT}
172cb6157be7a4506b2401f52a1616744cd10790506DRC			rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}
173cb6157be7a4506b2401f52a1616744cd10790506DRC		done
174cb6157be7a4506b2401f52a1616744cd10790506DRC	done
175cb6157be7a4506b2401f52a1616744cd10790506DRC
176cb6157be7a4506b2401f52a1616744cd10790506DRC	# Transforms
177cb6157be7a4506b2401f52a1616744cd10790506DRC	for samp in GRAY 420 422 444; do
178823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
179823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
180823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
181823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
182823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
183823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
184823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC		runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
185cb6157be7a4506b2401f52a1616744cd10790506DRC	done
186cb6157be7a4506b2401f52a1616744cd10790506DRC	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
187cb6157be7a4506b2401f52a1616744cd10790506DRC		for samp in GRAY 444; do
1887a6ed075ea161e35469b6fddb2608c4e5f1db396DRC			runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
189684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG
190684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
191684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
192684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
193684ace1924f95d71caa31e68330405cdb8043729DRC			else
194684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
195684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
196684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
197684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
198684ace1924f95d71caa31e68330405cdb8043729DRC				done
199684ace1924f95d71caa31e68330405cdb8043729DRC			fi
200cb6157be7a4506b2401f52a1616744cd10790506DRC		done
201cb6157be7a4506b2401f52a1616744cd10790506DRC		for samp in 420 422; do
202823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC			runme $EXEDIR/djpeg -nosmooth -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
203684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG $ALLOCARG
204684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
205684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
206684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
207684ace1924f95d71caa31e68330405cdb8043729DRC			else
208684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
209684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
210684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
211684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
212684ace1924f95d71caa31e68330405cdb8043729DRC				done
213684ace1924f95d71caa31e68330405cdb8043729DRC			fi
214cb6157be7a4506b2401f52a1616744cd10790506DRC		done
215cb6157be7a4506b2401f52a1616744cd10790506DRC	done
216cb6157be7a4506b2401f52a1616744cd10790506DRC
217cb6157be7a4506b2401f52a1616744cd10790506DRC	# Grayscale transform
218cb6157be7a4506b2401f52a1616744cd10790506DRC	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
219cb6157be7a4506b2401f52a1616744cd10790506DRC		for samp in GRAY 444 422 420; do
220684ace1924f95d71caa31e68330405cdb8043729DRC			runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG $ALLOCARG
221684ace1924f95d71caa31e68330405cdb8043729DRC			if [ $ALLOC = 1 ]; then
222684ace1924f95d71caa31e68330405cdb8043729DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT}
223684ace1924f95d71caa31e68330405cdb8043729DRC				rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
224684ace1924f95d71caa31e68330405cdb8043729DRC			else
225684ace1924f95d71caa31e68330405cdb8043729DRC				for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
226684ace1924f95d71caa31e68330405cdb8043729DRC					$OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
227684ace1924f95d71caa31e68330405cdb8043729DRC					runme cmp $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT}
228684ace1924f95d71caa31e68330405cdb8043729DRC					rm $i
229684ace1924f95d71caa31e68330405cdb8043729DRC				done
230684ace1924f95d71caa31e68330405cdb8043729DRC			fi
231cb6157be7a4506b2401f52a1616744cd10790506DRC		done
232cb6157be7a4506b2401f52a1616744cd10790506DRC	done
233cb6157be7a4506b2401f52a1616744cd10790506DRC
234cb6157be7a4506b2401f52a1616744cd10790506DRC	# Transforms with scaling
235cb6157be7a4506b2401f52a1616744cd10790506DRC	for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
236cb6157be7a4506b2401f52a1616744cd10790506DRC		for samp in GRAY 444 422 420; do
237cb6157be7a4506b2401f52a1616744cd10790506DRC			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
238cb6157be7a4506b2401f52a1616744cd10790506DRC				scalearg=`echo $scale | sed s@_@/@g`
239823fbed414c2eaf2b929727cb23a3af85e08cf4fDRC				runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
240684ace1924f95d71caa31e68330405cdb8043729DRC				runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG
241cb6157be7a4506b2401f52a1616744cd10790506DRC				runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT}
242cb6157be7a4506b2401f52a1616744cd10790506DRC				rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}
243cb6157be7a4506b2401f52a1616744cd10790506DRC			done
244cb6157be7a4506b2401f52a1616744cd10790506DRC		done
245cb6157be7a4506b2401f52a1616744cd10790506DRC	done
246cb6157be7a4506b2401f52a1616744cd10790506DRC
247cb6157be7a4506b2401f52a1616744cd10790506DRCdone
248cb6157be7a4506b2401f52a1616744cd10790506DRC
249cb6157be7a4506b2401f52a1616744cd10790506DRCecho SUCCESS!
250