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