11 if [ -d $OUTDIR ]; then
23 IMAGES="vgl_5674_0098.${EXT} vgl_6434_0018a.${EXT} vgl_6548_0026a.${EXT} nightshot_iso_100.${EXT}"
24 IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages
25 OUTDIR=`mktemp -d /tmp/__tjbenchtest_output.XXXXXX`
26 EXEDIR=@CMAKE_CURRENT_BINARY_DIR@
33 if [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi
35 if [ -d $OUTDIR ]; then
40 while [ $# -gt 0 ]; do
46 # NOTE: The combination of tjEncodeYUV*() and tjCompressFromYUV*() does not
47 # always produce bitwise-identical results to tjCompress*() if subsampling is
48 # enabled. In both cases, if the image width or height are not evenly
49 # divisible by the MCU width/height, then the bottom and/or right edge are
50 # expanded. However, the libjpeg code performs this expansion prior to
51 # downsampling, and TurboJPEG performs it in tjCompressFromYUV*(), which is
52 # after downsampling. Thus, the two will agree only if the width/height along
53 # each downsampled dimension is an odd number or is evenly divisible by the MCU
54 # width/height. This disagreement basically amounts to a round-off error, but
55 # there is no easy way around it, so for now, we just test the only image that
56 # works. (NOTE: nightshot_iso_100 does not suffer from the above issue, but
57 # it suffers from an unrelated problem whereby the combination of
58 # tjDecompressToYUV*() and tjDecodeYUV*() do not produce bitwise-identical
59 # results to tjDecompress*() if decompression scaling is enabled. This latter
60 # phenomenon is not yet fully understood but is also believed to be some sort
61 # of round-off error.)
62 IMAGES="vgl_6548_0026a.${EXT}"
75 exec >$EXEDIR/tjbenchtest$YUVARG$ALLOCARG$PROGARG.log
78 for image in $IMAGES; do
80 cp $IMGDIR/$image $OUTDIR
81 basename=`basename $image .${EXT}`
82 runme $EXEDIR/cjpeg -quality 95 -dct fast $PROGARG -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
83 runme $EXEDIR/cjpeg -quality 95 -dct fast $PROGARG -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
84 runme $EXEDIR/cjpeg -quality 95 -dct fast $PROGARG -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
85 runme $EXEDIR/cjpeg -quality 95 -dct fast $PROGARG -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT}
86 runme $EXEDIR/cjpeg -quality 95 -dct int $PROGARG -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
87 runme $EXEDIR/cjpeg -quality 95 -dct int $PROGARG -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
88 runme $EXEDIR/cjpeg -quality 95 -dct int $PROGARG -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
89 runme $EXEDIR/cjpeg -quality 95 -dct int $PROGARG -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT}
90 for samp in GRAY 420 422 444; do
91 runme $EXEDIR/djpeg -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
92 runme $EXEDIR/djpeg -dct fast -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
93 runme $EXEDIR/djpeg -dct int -rgb $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
95 for samp in 420 422; do
96 runme $EXEDIR/djpeg -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
97 runme $EXEDIR/djpeg -dct fast -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
98 runme $EXEDIR/djpeg -dct int -nosmooth $BMPARG -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
102 for dct in accurate fast; do
103 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -warmup 0 -${dct}dct $YUVARG $ALLOCARG $PROGARG
104 for samp in GRAY 420 422 444; do
105 runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg
109 for dct in fast accurate default; do
111 if [ "${dct}" = "default" ]; then
115 # Tiled compression & decompression
116 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG $PROGARG
117 for samp in GRAY 444; do
118 if [ $ALLOC = 1 ]; then
119 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
120 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
122 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
123 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
124 runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
129 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG $ALLOCARG $PROGARG
130 for samp in 420 422; do
131 if [ $ALLOC = 1 ]; then
132 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
133 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
135 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
136 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
137 runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
143 # Tiled decompression
144 for samp in GRAY 444; do
145 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG $PROGARG
146 if [ $ALLOC = 1 ]; then
147 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
148 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
150 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
151 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
152 runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT}
157 for samp in 420 422; do
158 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG $ALLOCARG $PROGARG
159 if [ $ALLOC = 1 ]; then
160 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
161 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
163 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
164 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
165 runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT}
172 # Scaled decompression
173 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
174 scalearg=`echo $scale | sed 's/\_/\//g'`
175 for samp in GRAY 420 422 444; do
176 runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
177 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG $PROGARG
178 runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT}
179 rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}
184 for samp in GRAY 420 422 444; do
185 runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
186 runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
187 runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
188 runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
189 runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
190 runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
191 runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg
193 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
194 for samp in GRAY 444; do
195 runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
196 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG $PROGARG
197 if [ $ALLOC = 1 ]; then
198 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
199 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
201 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
202 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
203 runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
208 for samp in 420 422; do
209 runme $EXEDIR/djpeg -nosmooth -rgb $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
210 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG $ALLOCARG $PROGARG
211 if [ $ALLOC = 1 ]; then
212 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
213 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
215 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
216 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
217 runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
224 # Grayscale transform
225 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
226 for samp in GRAY 444 422 420; do
227 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG $ALLOCARG $PROGARG
228 if [ $ALLOC = 1 ]; then
229 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.${EXT} $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT}
230 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT}
232 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
233 $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
234 runme cmp $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT}
241 # Transforms with scaling
242 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
243 for samp in GRAY 444 422 420; do
244 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
245 scalearg=`echo $scale | sed 's/\_/\//g'`
246 runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
247 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG $PROGARG
248 runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT}
249 rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}