OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 set -u |
| 4 set -e |
| 5 trap onexit INT |
| 6 trap onexit TERM |
| 7 trap onexit EXIT |
| 8 |
| 9 onexit() |
| 10 { |
| 11 if [ -d $OUTDIR ]; then |
| 12 rm -rf $OUTDIR |
| 13 fi |
| 14 } |
| 15 |
| 16 runme() |
| 17 { |
| 18 echo \*\*\* $* |
| 19 $* |
| 20 } |
| 21 |
| 22 EXT=bmp |
| 23 IMAGES="vgl_5674_0098.${EXT} vgl_6434_0018a.${EXT} vgl_6548_0026a.${EXT} nightsh
ot_iso_100.${EXT}" |
| 24 IMGDIR=@srcdir@/testimages |
| 25 OUTDIR=`mktemp -d /tmp/__tjbenchtest_output.XXXXXX` |
| 26 EXEDIR=. |
| 27 BMPARG= |
| 28 NSARG= |
| 29 YUVARG= |
| 30 ALLOC=0 |
| 31 ALLOCARG= |
| 32 if [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi |
| 33 |
| 34 if [ -d $OUTDIR ]; then |
| 35 rm -rf $OUTDIR |
| 36 fi |
| 37 mkdir -p $OUTDIR |
| 38 |
| 39 exec >$EXEDIR/tjbenchtest.log |
| 40 |
| 41 if [ $# -gt 0 ]; then |
| 42 if [ "$1" = "-yuv" ]; then |
| 43 NSARG=-nosmooth |
| 44 YUVARG=-yuv |
| 45 |
| 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}" |
| 63 fi |
| 64 if [ "$1" = "-alloc" ]; then |
| 65 ALLOCARG=-alloc |
| 66 ALLOC=1 |
| 67 fi |
| 68 fi |
| 69 |
| 70 # Standard tests |
| 71 for image in $IMAGES; do |
| 72 |
| 73 cp $IMGDIR/$image $OUTDIR |
| 74 basename=`basename $image .${EXT}` |
| 75 runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${
basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 76 runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/$
{basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 77 runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/$
{basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 78 runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/$
{basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 79 runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${b
asename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 80 runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${
basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 81 runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${
basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 82 runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${
basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.${EXT} |
| 83 for samp in GRAY 420 422 444; do |
| 84 runme $EXEDIR/djpeg -rgb $NSARG $BMPARG -outfile $OUTDIR/${basen
ame}_${samp}_default_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg |
| 85 runme $EXEDIR/djpeg -dct fast -rgb $NSARG $BMPARG -outfile $OUTD
IR/${basename}_${samp}_fast_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.
jpg |
| 86 runme $EXEDIR/djpeg -dct int -rgb $NSARG $BMPARG -outfile $OUTDI
R/${basename}_${samp}_accurate_djpeg.${EXT} $OUTDIR/${basename}_${samp}_accurate
_cjpeg.jpg |
| 87 done |
| 88 for samp in 420 422; do |
| 89 runme $EXEDIR/djpeg -nosmooth $BMPARG -outfile $OUTDIR/${basenam
e}_${samp}_default_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast_cjpeg.
jpg |
| 90 runme $EXEDIR/djpeg -dct fast -nosmooth $BMPARG -outfile $OUTDIR
/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_fast
_cjpeg.jpg |
| 91 runme $EXEDIR/djpeg -dct int -nosmooth $BMPARG -outfile $OUTDIR/
${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} $OUTDIR/${basename}_${samp}_a
ccurate_cjpeg.jpg |
| 92 done |
| 93 |
| 94 # Compression |
| 95 for dct in accurate fast; do |
| 96 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0
.01 -warmup 0 -${dct}dct $YUVARG $ALLOCARG |
| 97 for samp in GRAY 420 422 444; do |
| 98 runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${
basename}_${samp}_${dct}_cjpeg.jpg |
| 99 done |
| 100 done |
| 101 |
| 102 for dct in fast accurate default; do |
| 103 dctarg=-${dct}dct |
| 104 if [ "${dct}" = "default" ]; then |
| 105 dctarg= |
| 106 fi |
| 107 |
| 108 # Tiled compression & decompression |
| 109 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -bench
time 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG |
| 110 for samp in GRAY 444; do |
| 111 if [ $ALLOC = 1 ]; then |
| 112 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT} |
| 113 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 114 else |
| 115 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 116 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 117 runme cmp $i $OUTDIR/${basename}_${samp}
_${dct}_djpeg.${EXT} |
| 118 rm $i |
| 119 done |
| 120 fi |
| 121 done |
| 122 runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -bench
time 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG $ALLOCARG |
| 123 for samp in 420 422; do |
| 124 if [ $ALLOC = 1 ]; then |
| 125 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT} |
| 126 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 127 else |
| 128 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 129 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 130 runme cmp $i $OUTDIR/${basename}_${samp}
_${dct}_nosmooth_djpeg.${EXT} |
| 131 rm $i |
| 132 done |
| 133 fi |
| 134 done |
| 135 |
| 136 # Tiled decompression |
| 137 for samp in GRAY 444; do |
| 138 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 ${dctarg} $YUVARG $ALLOCARG |
| 139 if [ $ALLOC = 1 ]; then |
| 140 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT} |
| 141 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 142 else |
| 143 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 144 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 145 runme cmp $i $OUTDIR/${basename}_${samp}
_${dct}_djpeg.${EXT} |
| 146 rm $i |
| 147 done |
| 148 fi |
| 149 done |
| 150 for samp in 420 422; do |
| 151 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample ${dctarg} $YUVARG
$ALLOCARG |
| 152 if [ $ALLOC = 1 ]; then |
| 153 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT} |
| 154 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 155 else |
| 156 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 157 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 158 runme cmp $i $OUTDIR/${basename}_${samp}
_${dct}_nosmooth_djpeg.${EXT} |
| 159 rm $i |
| 160 done |
| 161 fi |
| 162 done |
| 163 done |
| 164 |
| 165 # Scaled decompression |
| 166 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 |
| 167 scalearg=`echo $scale | sed s@_@/@g` |
| 168 for samp in GRAY 420 422 444; do |
| 169 runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSARG $BMPA
RG -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} $OUTDIR/${basename
}_${samp}_fast_cjpeg.jpg |
| 170 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG |
| 171 runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT
} $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT} |
| 172 rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} |
| 173 done |
| 174 done |
| 175 |
| 176 # Transforms |
| 177 for samp in GRAY 420 422 444; do |
| 178 runme $EXEDIR/jpegtran -flip horizontal -trim -outfile $OUTDIR/$
{basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 179 runme $EXEDIR/jpegtran -flip vertical -trim -outfile $OUTDIR/${b
asename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 180 runme $EXEDIR/jpegtran -transpose -trim -outfile $OUTDIR/${basen
ame}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 181 runme $EXEDIR/jpegtran -transverse -trim -outfile $OUTDIR/${base
name}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 182 runme $EXEDIR/jpegtran -rotate 90 -trim -outfile $OUTDIR/${basen
ame}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 183 runme $EXEDIR/jpegtran -rotate 180 -trim -outfile $OUTDIR/${base
name}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 184 runme $EXEDIR/jpegtran -rotate 270 -trim -outfile $OUTDIR/${base
name}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_Q95.jpg |
| 185 done |
| 186 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 187 for samp in GRAY 444; do |
| 188 runme $EXEDIR/djpeg -rgb $BMPARG -outfile $OUTDIR/${base
name}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${xform}_jpeg
tran.jpg |
| 189 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 $YUVARG $ALLOCARG |
| 190 if [ $ALLOC = 1 ]; then |
| 191 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 192 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 193 else |
| 194 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 195 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 196 runme cmp $i $OUTDIR/${basename}_${samp}
_${xform}_jpegtran.${EXT} |
| 197 rm $i |
| 198 done |
| 199 fi |
| 200 done |
| 201 for samp in 420 422; do |
| 202 runme $EXEDIR/djpeg -nosmooth -rgb $BMPARG -outfile $OUT
DIR/${basename}_${samp}_${xform}_jpegtran.${EXT} $OUTDIR/${basename}_${samp}_${x
form}_jpegtran.jpg |
| 203 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -fastupsample $YUVARG $
ALLOCARG |
| 204 if [ $ALLOC = 1 ]; then |
| 205 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 206 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 207 else |
| 208 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 209 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 210 runme cmp $i $OUTDIR/${basename}_${samp}
_${xform}_jpegtran.${EXT} |
| 211 rm $i |
| 212 done |
| 213 fi |
| 214 done |
| 215 done |
| 216 |
| 217 # Grayscale transform |
| 218 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 219 for samp in GRAY 444 422 420; do |
| 220 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jp
g $BMPARG -$xform -tile -quiet -benchtime 0.01 -warmup 0 -grayscale $YUVARG $ALL
OCARG |
| 221 if [ $ALLOC = 1 ]; then |
| 222 runme cmp $OUTDIR/${basename}_${samp}_Q95_full.$
{EXT} $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT} |
| 223 rm $OUTDIR/${basename}_${samp}_Q95_full.${EXT} |
| 224 else |
| 225 for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[
0-9]x[0-9]*[0-9].${EXT} \ |
| 226 $OUTDIR/${basename}_${samp}_Q95_full.${E
XT}; do |
| 227 runme cmp $i $OUTDIR/${basename}_GRAY_${
xform}_jpegtran.${EXT} |
| 228 rm $i |
| 229 done |
| 230 fi |
| 231 done |
| 232 done |
| 233 |
| 234 # Transforms with scaling |
| 235 for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 236 for samp in GRAY 444 422 420; do |
| 237 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 |
| 238 scalearg=`echo $scale | sed s@_@/@g` |
| 239 runme $EXEDIR/djpeg -rgb -scale ${scalearg} $NSA
RG $BMPARG -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT
} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg |
| 240 runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp
}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01 -warmup 0 $Y
UVARG $ALLOCARG |
| 241 runme cmp $OUTDIR/${basename}_${samp}_Q95_${scal
e}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT} |
| 242 rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EX
T} |
| 243 done |
| 244 done |
| 245 done |
| 246 |
| 247 done |
| 248 |
| 249 echo SUCCESS! |
OLD | NEW |