Add more extensive TurboJPEG regression tests
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@771 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/BUILDING.txt b/BUILDING.txt
index 730eaf7..0b3e055 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -694,3 +694,30 @@
Building a Windows installer requires the Nullsoft Install System
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.
+
+
+*******************************************************************************
+** Regression testing
+*******************************************************************************
+
+The most common way to test libjpeg-turbo is by invoking 'make test' on
+Unix/Linux platforms or 'ctest' on Windows platforms, once the build has
+completed. This runs a series of tests to ensure that mathematical
+compatibility has been maintained between libjpeg-turbo and libjpeg v6b. This
+also invokes the TurboJPEG unit tests, which ensure that the colorspace
+extensions, YUV encoding, decompression scaling, and other features of the
+TurboJPEG C and Java APIs are working properly (and, by extension, that the
+equivalent features of the underlying libjpeg API are also working.)
+
+Invoking 'make testclean' or 'nmake testclean' (if using NMake) or building
+the 'testclean' target (if using the Visual Studio IDE) will clean up the
+output images generated by 'make test'.
+
+On Unix/Linux platforms, more extensive tests of the TurboJPEG/OSS C and Java
+wrappers can be run by invoking 'make tjtest'. These extended TurboJPEG tests
+essentially iterate through all of the available features of the TurboJPEG APIs
+that are not covered by the TurboJPEG unit tests (this includes the lossless
+transform options) and compare the images generated by each feature to images
+generated using the equivalent feature in the libjpeg API. The extended
+TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
+not in the underlying libjpeg-turbo library.
diff --git a/Makefile.am b/Makefile.am
index 32e578e..131f802 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -224,6 +224,14 @@
rm -f *_440_*.jpg
rm -f *_440.yuv
+
+tjtest:
+ sh ./tjbenchtest
+if WITH_JAVA
+ sh ./tjexampletest
+endif
+
+
if X86_64
install-exec-hook:
diff --git a/configure.ac b/configure.ac
index 81fc6ec..634c575 100644
--- a/configure.ac
+++ b/configure.ac
@@ -368,6 +368,8 @@
AC_CONFIG_FILES([pkgscripts/uninstall:release/uninstall.in])
AC_CONFIG_FILES([pkgscripts/makesunpkg:release/makesunpkg.in])
AC_CONFIG_FILES([pkgscripts/pkginfo:release/pkginfo.in])
+AC_CONFIG_FILES([tjbenchtest])
+AC_CONFIG_FILES([tjexampletest])
AC_CONFIG_FILES([libjpeg.map])
AC_CONFIG_FILES([Makefile simd/Makefile])
AC_CONFIG_FILES([java/Makefile])
diff --git a/testimages/nightshot_iso_100.bmp b/testimages/nightshot_iso_100.bmp
new file mode 100644
index 0000000..5a27151
--- /dev/null
+++ b/testimages/nightshot_iso_100.bmp
Binary files differ
diff --git a/testimages/vgl_5674_0098.bmp b/testimages/vgl_5674_0098.bmp
new file mode 100644
index 0000000..d74ea64
--- /dev/null
+++ b/testimages/vgl_5674_0098.bmp
Binary files differ
diff --git a/testimages/vgl_6434_0018a.bmp b/testimages/vgl_6434_0018a.bmp
new file mode 100644
index 0000000..25e77b7
--- /dev/null
+++ b/testimages/vgl_6434_0018a.bmp
Binary files differ
diff --git a/testimages/vgl_6548_0026a.bmp b/testimages/vgl_6548_0026a.bmp
new file mode 100644
index 0000000..41e35b5
--- /dev/null
+++ b/testimages/vgl_6548_0026a.bmp
Binary files differ
diff --git a/tjbenchtest.in b/tjbenchtest.in
new file mode 100755
index 0000000..390b044
--- /dev/null
+++ b/tjbenchtest.in
@@ -0,0 +1,164 @@
+#!/bin/bash
+
+set -u
+set -e
+trap onexit INT
+trap onexit TERM
+trap onexit EXIT
+
+onexit()
+{
+ if [ -d $OUTDIR ]; then
+ rm -rf $OUTDIR
+ fi
+}
+
+runme()
+{
+ echo \*\*\* $*
+ $*
+}
+
+EXT=bmp
+IMAGES="vgl_5674_0098.${EXT} vgl_6434_0018a.${EXT} vgl_6548_0026a.${EXT} nightshot_iso_100.${EXT}"
+IMGDIR=@srcdir@/testimages
+OUTDIR=__tjbenchtest_output
+EXEDIR=.
+BMPARG=
+if [ "$EXT" = "bmp" ]; then BMPARG=-bmp; fi
+
+if [ -d $OUTDIR ]; then
+ rm -rf $OUTDIR
+fi
+mkdir -p $OUTDIR
+
+exec >$EXEDIR/tjbenchtest.log
+
+# Standard tests
+for image in $IMAGES; do
+
+ cp $IMGDIR/$image $OUTDIR
+ basename=`basename $image .${EXT}`
+ $EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_GRAY_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_420_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_422_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.${EXT} >$OUTDIR/${basename}_444_cjpeg.jpg
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_cjpeg.jpg >$OUTDIR/${basename}_${samp}_djpeg.${EXT}
+ done
+ for samp in 420 422; do
+ $EXEDIR/djpeg -nosmooth $BMPARG $OUTDIR/${basename}_${samp}_cjpeg.jpg >$OUTDIR/${basename}_${samp}_djpeg_nosmooth.${EXT}
+ done
+
+ # Compression
+ runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -quiet -benchtime 0.01
+ for s in GRAY 420 422 444; do
+ runme cmp $OUTDIR/${basename}_${s}_Q95.jpg $OUTDIR/${basename}_${s}_cjpeg.jpg
+ done
+
+ # Tiled compression & decompression
+ runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01
+ for samp in GRAY 444; do
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_djpeg.${EXT}
+ rm $i
+ done
+ done
+ runme $EXEDIR/tjbench $OUTDIR/$image 95 -rgb -tile -quiet -benchtime 0.01 -fastupsample
+ for samp in 420 422; do
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_djpeg_nosmooth.${EXT}
+ rm $i
+ done
+ done
+
+ # Tiled decompression
+ for samp in GRAY 444; do
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_djpeg.${EXT}
+ rm $i
+ done
+ done
+ for samp in 420 422; do
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -tile -quiet -benchtime 0.01 -fastupsample
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_djpeg_nosmooth.${EXT}
+ rm $i
+ done
+ done
+
+ # Scaled decompression
+ 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
+ scalearg=`echo $scale | sed s@_@/@g`
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/djpeg -rgb -scale ${scalearg} $BMPARG $OUTDIR/${basename}_${samp}_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT}
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -scale ${scalearg} -quiet -benchtime 0.01
+ runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${scale}_djpeg.${EXT}
+ rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}
+ done
+ done
+
+ # Transforms
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/jpegtran -flip horizontal -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg
+ $EXEDIR/jpegtran -flip vertical -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg
+ $EXEDIR/jpegtran -transpose -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg
+ $EXEDIR/jpegtran -transverse -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg
+ $EXEDIR/jpegtran -rotate 90 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg
+ $EXEDIR/jpegtran -rotate 180 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg
+ $EXEDIR/jpegtran -rotate 270 -trim $OUTDIR/${basename}_${samp}_Q95.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg
+ done
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 444; do
+ $EXEDIR/djpeg -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
+ rm $i
+ done
+ done
+ for samp in 420 422; do
+ $EXEDIR/djpeg -nosmooth -rgb $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -fastupsample
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_${samp}_${xform}_jpegtran.${EXT}
+ rm $i
+ done
+ done
+ done
+
+ # Grayscale transform
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 444 422 420; do
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -tile -quiet -benchtime 0.01 -grayscale
+ for i in $OUTDIR/${basename}_${samp}_Q95_[0-9]*[0-9]x[0-9]*[0-9].${EXT} \
+ $OUTDIR/${basename}_${samp}_Q95_full.${EXT}; do
+ runme cmp $i $OUTDIR/${basename}_GRAY_${xform}_jpegtran.${EXT}
+ rm $i
+ done
+ done
+ done
+
+ # Transforms with scaling
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 444 422 420; do
+ 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
+ scalearg=`echo $scale | sed s@_@/@g`
+ $EXEDIR/djpeg -rgb -scale ${scalearg} $BMPARG $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT}
+ runme $EXEDIR/tjbench $OUTDIR/${basename}_${samp}_Q95.jpg $BMPARG -$xform -scale ${scalearg} -quiet -benchtime 0.01
+ runme cmp $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT} $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.${EXT}
+ rm $OUTDIR/${basename}_${samp}_Q95_${scale}.${EXT}
+ done
+ done
+ done
+
+done
+
+echo SUCCESS!
diff --git a/tjexampletest.in b/tjexampletest.in
new file mode 100755
index 0000000..fb7b4c5
--- /dev/null
+++ b/tjexampletest.in
@@ -0,0 +1,118 @@
+#!/bin/bash
+
+set -u
+set -e
+trap onexit INT
+trap onexit TERM
+trap onexit EXIT
+
+onexit()
+{
+ if [ -d $OUTDIR ]; then
+ rm -rf $OUTDIR
+ fi
+}
+
+runme()
+{
+ echo \*\*\* $*
+ $*
+}
+
+IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
+IMGDIR=@srcdir@/testimages
+OUTDIR=__tjexampletest_output
+EXEDIR=.
+JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs"
+
+if [ -d $OUTDIR ]; then
+ rm -rf $OUTDIR
+fi
+mkdir -p $OUTDIR
+
+exec >$EXEDIR/tjexampletest.log
+
+for image in $IMAGES; do
+
+ cp $IMGDIR/$image $OUTDIR
+ basename=`basename $image .bmp`
+ $EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_cjpeg.jpg
+ $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_cjpeg.jpg
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_cjpeg.jpg >$OUTDIR/${basename}_${samp}_djpeg.bmp
+ done
+
+ # Compression
+ for samp in GRAY 420 422 444; do
+ runme $JAVA TJExample $OUTDIR/$image $OUTDIR/${basename}_${samp}.jpg -q 95 -samp ${samp}
+ runme cmp $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_cjpeg.jpg
+ done
+
+ # Decompression
+ for samp in 420 GRAY 420 422 444; do
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}.bmp
+ runme cmp -i 54:54 $OUTDIR/${basename}_${samp}.bmp $OUTDIR/${basename}_${samp}_djpeg.bmp
+ rm $OUTDIR/${basename}_${samp}.bmp
+ done
+
+ # Scaled decompression
+ 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
+ scalearg=`echo $scale | sed s@_@/@g`
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${scale}.bmp -scale ${scalearg}
+ runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
+ rm $OUTDIR/${basename}_${samp}_${scale}.bmp
+ done
+ done
+
+ # Transforms
+ for samp in GRAY 420 422 444; do
+ $EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg
+ $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim $OUTDIR/${basename}_${samp}.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg
+ done
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 420 422 444; do
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 16,16,70x60
+ runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
+ $EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60
+ runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
+ rm $OUTDIR/${basename}_${samp}_${xform}.bmp
+ done
+ done
+
+ # Grayscale transform
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 444 422 420; do
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -grayscale -crop 16,16,70x60
+ runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_GRAY_${xform}_jpegtran.jpg
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -grayscale -crop 16,16,70x60
+ runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_GRAY_${xform}_jpegtran.bmp
+ rm $OUTDIR/${basename}_${samp}_${xform}.bmp
+ done
+ done
+
+ # Transforms with scaling
+ for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
+ for samp in GRAY 444 422 420; do
+ 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
+ scalearg=`echo $scale | sed s@_@/@g`
+ $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
+ runme $JAVA TJExample $OUTDIR/${basename}_${samp}.jpg $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp -$xform -scale ${scalearg} -crop 16,16,70x60
+ runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp
+ rm $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp
+ done
+ done
+ done
+
+done
+
+echo SUCCESS!