DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 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} nightshot_iso_100.${EXT}" |
| 24 | IMGDIR=@srcdir@/testimages |
| 25 | OUTDIR=__tjbenchtest_output |
| 26 | EXEDIR=. |
| 27 | BMPARG= |
| 28 | if [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi |
| 29 | |
| 30 | if [ -d $OUTDIR ]; then |
| 31 | rm -rf $OUTDIR |
| 32 | fi |
| 33 | mkdir -p $OUTDIR |
| 34 | |
| 35 | exec >$EXEDIR/tjbenchtest.log |
| 36 | |
| 37 | # Standard tests |
| 38 | for image in $IMAGES; do |
| 39 | |
| 40 | cp $IMGDIR/$image $OUTDIR |
| 41 | basename=`basename $image .${EXT}` |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 42 | $EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg |
| 43 | $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_420_fast_cjpeg.jpg |
| 44 | $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_422_fast_cjpeg.jpg |
| 45 | $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_444_fast_cjpeg.jpg |
| 46 | $EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg |
| 47 | $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_420_accurate_cjpeg.jpg |
| 48 | $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_422_accurate_cjpeg.jpg |
| 49 | $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_444_accurate_cjpeg.jpg |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 50 | for samp in GRAY 420 422 444; do |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 51 | $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.${EXT} |
| 52 | $EXEDIR/djpeg -dct fast -rgb $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.${EXT} |
| 53 | $EXEDIR/djpeg -dct int -rgb $BMPARG $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.${EXT} |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 54 | done |
| 55 | for samp in 420 422; do |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 56 | $EXEDIR/djpeg -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.${EXT} |
| 57 | $EXEDIR/djpeg -dct fast -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.${EXT} |
| 58 | $EXEDIR/djpeg -dct int -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.${EXT} |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 59 | done |
| 60 | |
| 61 | # Compression |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 62 | for dct in accurate fast; do |
| 63 | runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01 -${dct}dct |
| 64 | for samp in GRAY 420 422 444; do |
| 65 | runme cmp $OUTDIR/${basename}_${samp}_Q95.jpg $OUTDIR/${basename}_${samp}_${dct}_cjpeg.jpg |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 66 | done |
| 67 | done |
| 68 | |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 69 | for dct in fast accurate default; do |
| 70 | dctarg=-${dct}dct |
| 71 | if [ "${dct}" = "default" ]; then |
| 72 | dctarg= |
| 73 | fi |
| 74 | |
| 75 | # Tiled compression & decompression |
| 76 | runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 ${dctarg} |
| 77 | for samp in GRAY 444; do |
| 78 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 79 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 80 | runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT} |
| 81 | rm $i |
| 82 | done |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 83 | done |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 84 | runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} |
| 85 | for samp in 420 422; do |
| 86 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 87 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 88 | runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT} |
| 89 | rm $i |
| 90 | done |
| 91 | done |
| 92 | |
| 93 | # Tiled decompression |
| 94 | for samp in GRAY 444; do |
| 95 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 ${dctarg} |
| 96 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 97 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 98 | runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_djpeg.${EXT} |
| 99 | rm $i |
| 100 | done |
| 101 | done |
| 102 | for samp in 420 422; do |
| 103 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -fastupsample ${dctarg} |
| 104 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 105 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 106 | runme cmp $i $OUTDIR/${basename}_${samp}_${dct}_nosmooth_djpeg.${EXT} |
| 107 | rm $i |
| 108 | done |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 109 | done |
| 110 | done |
| 111 | |
| 112 | # Scaled decompression |
| 113 | for scale in 2 4 8; do |
| 114 | for samp in GRAY 420 422 444; do |
DRC | fd3aba3 | 2012-06-29 23:14:48 +0000 | [diff] [blame] | 115 | $EXEDIR/djpeg -rgb -scale 1/${scale} $BMPARG $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_1_${scale}_djpeg.${EXT} |
DRC | 9cd4e4b | 2012-01-31 07:56:44 +0000 | [diff] [blame] | 116 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale 1/${scale} -quiet -benchtime 0.01 |
| 117 | runme cmp $OUTDIR/${basename}_${samp}_Q95_1_${scale}.${EXT} $OUTDIR/${basename}_${samp}_1_${scale}_djpeg.${EXT} |
| 118 | rm $OUTDIR/${basename}_${samp}_Q95_1_${scale}.${EXT} |
| 119 | done |
| 120 | done |
| 121 | |
| 122 | # Transforms |
| 123 | for samp in GRAY 420 422 444; do |
| 124 | $EXEDIR/jpegtran -flip horizontal -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg |
| 125 | $EXEDIR/jpegtran -flip vertical -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg |
| 126 | $EXEDIR/jpegtran -transpose -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg |
| 127 | $EXEDIR/jpegtran -transverse -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg |
| 128 | $EXEDIR/jpegtran -rotate 90 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg |
| 129 | $EXEDIR/jpegtran -rotate 180 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg |
| 130 | $EXEDIR/jpegtran -rotate 270 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg |
| 131 | done |
| 132 | for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 133 | for samp in GRAY 444; do |
| 134 | $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 135 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 |
| 136 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 137 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 138 | runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 139 | rm $i |
| 140 | done |
| 141 | done |
| 142 | for samp in 420 422; do |
| 143 | $EXEDIR/djpeg -nosmooth -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 144 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -fastupsample |
| 145 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 146 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 147 | runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT} |
| 148 | rm $i |
| 149 | done |
| 150 | done |
| 151 | done |
| 152 | |
| 153 | # Grayscale transform |
| 154 | for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 155 | for samp in GRAY 444 422 420; do |
| 156 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -grayscale |
| 157 | for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \ |
| 158 | $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do |
| 159 | runme cmp $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT} |
| 160 | rm $i |
| 161 | done |
| 162 | done |
| 163 | done |
| 164 | |
| 165 | # Transforms with scaling |
| 166 | for xform in hflip vflip transpose transverse rot90 rot180 rot270; do |
| 167 | for samp in GRAY 444 422 420; do |
| 168 | for scale in 2 4 8; do |
| 169 | $EXEDIR/djpeg -rgb -scale 1/${scale} $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_1_${scale}_jpegtran.${EXT} |
| 170 | runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale 1/${scale} -quiet -benchtime 0.01 |
| 171 | runme cmp $OUTDIR/${basename}_${samp}_Q95_1_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_1_${scale}_jpegtran.${EXT} |
| 172 | rm $OUTDIR/${basename}_${samp}_Q95_1_${scale}.${EXT} |
| 173 | done |
| 174 | done |
| 175 | done |
| 176 | |
| 177 | done |
| 178 | |
| 179 | echo SUCCESS! |