diff --git a/java/TJComp.java b/java/TJComp.java index 393174b3..31aa0a2b 100644 --- a/java/TJComp.java +++ b/java/TJComp.java @@ -145,7 +145,7 @@ final class TJComp { int i; int arithmetic = -1, colorspace = -1, fastDCT = -1, losslessPSV = -1, losslessPt = -1, maxMemory = -1, optimize = -1, - pixelFormat = TJ.PF_UNKNOWN, precision = -1, progressive = -1, + pixelFormat = TJ.PF_UNKNOWN, precision = 8, progressive = -1, quality = DEFAULT_QUALITY, restartIntervalBlocks = -1, restartIntervalRows = -1, subsamp = DEFAULT_SUBSAMP; String iccFilename = null; @@ -247,16 +247,14 @@ final class TJComp { if (i != argv.length - 2) usage(); - if (losslessPSV == -1 && precision != -1 && precision != 8 && - precision != 12) + if (losslessPSV == -1 && precision != 8 && precision != 12) usage(); tjc = new TJCompressor(); tjc.set(TJ.PARAM_QUALITY, quality); tjc.set(TJ.PARAM_SUBSAMP, subsamp); - if (precision >= 0) - tjc.set(TJ.PARAM_PRECISION, precision); + tjc.set(TJ.PARAM_PRECISION, precision); if (fastDCT >= 0) tjc.set(TJ.PARAM_FASTDCT, fastDCT); if (optimize >= 0) diff --git a/src/tjcomp.c b/src/tjcomp.c index a7136876..2c1c48ce 100644 --- a/src/tjcomp.c +++ b/src/tjcomp.c @@ -151,7 +151,7 @@ int main(int argc, char **argv) int i, retval = 0; int arithmetic = -1, colorspace = -1, fastDCT = -1, losslessPSV = -1, losslessPt = -1, maxMemory = -1, optimize = -1, pixelFormat = TJPF_UNKNOWN, - precision = -1, progressive = -1, quality = DEFAULT_QUALITY, + precision = 8, progressive = -1, quality = DEFAULT_QUALITY, restartIntervalBlocks = -1, restartIntervalRows = -1, subsamp = DEFAULT_SUBSAMP; char *iccFilename = NULL; @@ -238,8 +238,7 @@ int main(int argc, char **argv) if (i != argc - 2) usage(argv[0]); - if (losslessPSV == -1 && precision != -1 && precision != 8 && - precision != 12) + if (losslessPSV == -1 && precision != 8 && precision != 12) usage(argv[0]); if ((tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL) @@ -249,7 +248,7 @@ int main(int argc, char **argv) THROW_TJ("setting TJPARAM_QUALITY"); if (tj3Set(tjInstance, TJPARAM_SUBSAMP, subsamp) < 0) THROW_TJ("setting TJPARAM_SUBSAMP"); - if (precision >= 0 && tj3Set(tjInstance, TJPARAM_PRECISION, precision) < 0) + if (tj3Set(tjInstance, TJPARAM_PRECISION, precision) < 0) THROW_TJ("setting TJPARAM_PRECISION"); if (fastDCT >= 0 && tj3Set(tjInstance, TJPARAM_FASTDCT, fastDCT) < 0) THROW_TJ("setting TJPARAM_FASTDCT"); diff --git a/test/tjcomptest.in b/test/tjcomptest.in index 3b063da4..3ad9cda8 100755 --- a/test/tjcomptest.in +++ b/test/tjcomptest.in @@ -61,6 +61,11 @@ for precision in 8 12; do RGBIMG=$IMGDIR/monkey16.ppm GRAYIMG=$IMGDIR/monkey16.pgm fi + if [ $precision -eq 8 ]; then + prearg= + else + prearg="-pre $precision" + fi for restartarg in "" "-r 1 -icc $IMGDIR/test3.icc" "-r 1b"; do for ariarg in "" "-a"; do for dctarg in "" "-dc fa"; do @@ -81,12 +86,11 @@ for precision in 8 12; do fi for sampi in {0..5}; do basename=`basename $RGBIMG .ppm` - runme $TJCOMP -pre $precision $restartarg $ariarg $dctarg \ + runme $TJCOMP $prearg $restartarg $ariarg $dctarg \ $optarg $progarg $qualarg -s ${SUBSAMPOPT[$sampi]} \ $RGBIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision $restartarg $ariarg \ - $dctarg $optarg $progarg $qualarg $blarg \ - -sa ${SAMPOPT[$sampi]} \ + runme $EXEDIR/cjpeg $prearg $restartarg $ariarg $dctarg \ + $optarg $progarg $qualarg $blarg -sa ${SAMPOPT[$sampi]} \ -outf $OUTDIR/${basename}-cjpeg.jpg $RGBIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g" @@ -95,12 +99,11 @@ for precision in 8 12; do rm $OUTDIR/${basename}-tjcomp.jpg $OUTDIR/${basename}-cjpeg.jpg echo - runme $TJCOMP -pre $precision $restartarg $ariarg $dctarg \ + runme $TJCOMP $prearg $restartarg $ariarg $dctarg \ $optarg $progarg $qualarg -s ${SUBSAMPOPT[$sampi]} \ -g $RGBIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision $restartarg $ariarg \ - $dctarg $optarg $progarg $qualarg $blarg \ - -sa ${SAMPOPT[$sampi]} \ + runme $EXEDIR/cjpeg $prearg $restartarg $ariarg $dctarg \ + $optarg $progarg $qualarg $blarg -sa ${SAMPOPT[$sampi]} \ -gr -outf $OUTDIR/${basename}-cjpeg.jpg $RGBIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g" @@ -109,12 +112,11 @@ for precision in 8 12; do rm $OUTDIR/${basename}-tjcomp.jpg $OUTDIR/${basename}-cjpeg.jpg echo - runme $TJCOMP -pre $precision $restartarg $ariarg $dctarg \ + runme $TJCOMP $prearg $restartarg $ariarg $dctarg \ $optarg $progarg $qualarg -s ${SUBSAMPOPT[$sampi]} \ -rg $RGBIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision $restartarg $ariarg \ - $dctarg $optarg $progarg $qualarg $blarg \ - -sa ${SAMPOPT[$sampi]} \ + runme $EXEDIR/cjpeg $prearg $restartarg $ariarg $dctarg \ + $optarg $progarg $qualarg $blarg -sa ${SAMPOPT[$sampi]} \ -rgb -outf $OUTDIR/${basename}-cjpeg.jpg $RGBIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g" @@ -124,12 +126,11 @@ for precision in 8 12; do echo basename=`basename $GRAYIMG .pgm` - runme $TJCOMP -pre $precision $restartarg $ariarg $dctarg \ + runme $TJCOMP $prearg $restartarg $ariarg $dctarg \ $optarg $progarg $qualarg -s ${SUBSAMPOPT[$sampi]} \ $GRAYIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision $restartarg $ariarg \ - $dctarg $optarg $progarg $qualarg $blarg \ - -sa ${SAMPOPT[$sampi]} \ + runme $EXEDIR/cjpeg $prearg $restartarg $ariarg $dctarg \ + $optarg $progarg $qualarg $blarg -sa ${SAMPOPT[$sampi]} \ -outf $OUTDIR/${basename}-cjpeg.jpg $GRAYIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g" @@ -154,6 +155,11 @@ for precision in {2..16}; do RGBIMG=$IMGDIR/monkey16.ppm GRAYIMG=$IMGDIR/monkey16.pgm fi + if [ $precision -eq 8 ]; then + prearg= + else + prearg="-pre $precision" + fi for psv in {1..7}; do for pt in {0..15}; do if [ $pt -ge $precision ]; then @@ -161,9 +167,9 @@ for precision in {2..16}; do fi for restartarg in "" "-r 1 -icc $IMGDIR/test3.icc"; do basename=`basename $RGBIMG .ppm` - runme $TJCOMP -pre $precision -l $psv,$pt $restartarg \ + runme $TJCOMP $prearg -l $psv,$pt $restartarg \ $RGBIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision -l $psv,$pt $restartarg \ + runme $EXEDIR/cjpeg $prearg -l $psv,$pt $restartarg \ -outf $OUTDIR/${basename}-cjpeg.jpg $RGBIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g" @@ -172,9 +178,9 @@ for precision in {2..16}; do echo basename=`basename $GRAYIMG .pgm` - runme $TJCOMP -pre $precision -l $psv,$pt $restartarg \ + runme $TJCOMP $prearg -l $psv,$pt $restartarg \ $GRAYIMG $OUTDIR/${basename}-tjcomp.jpg - runme $EXEDIR/cjpeg -pre $precision -l $psv,$pt $restartarg \ + runme $EXEDIR/cjpeg $prearg -l $psv,$pt $restartarg \ -outf $OUTDIR/${basename}-cjpeg.jpg $GRAYIMG $EXEDIR/test/md5sum $OUTDIR/${basename}-tjcomp.jpg \ $OUTDIR/${basename}-cjpeg.jpg | sed "s@$OUTDIR@\$OUTDIR@g"