From: DRC Date: Sat, 18 Nov 2017 01:00:53 +0000 (-0600) Subject: Merge branch 'master' into dev X-Git-Tag: 1.5.90~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4893e5d8b82931e384816cac2d54b10bf324f64f;p=libjpeg-turbo Merge branch 'master' into dev --- 4893e5d8b82931e384816cac2d54b10bf324f64f diff --cc ChangeLog.md index f9b8bd7,d6299f1..2ac91e2 --- a/ChangeLog.md +++ b/ChangeLog.md @@@ -77,9 -7,31 +77,31 @@@ particular transform when using the YUVImage constructor that creates an instance backed by separate image planes and allocates memory for the image planes. -2. Fixed an issue whereby the Java version of TJUnitTest would fail when +8. Fixed an issue whereby the Java version of TJUnitTest would fail when testing BufferedImage encoding/decoding on big endian systems. -3. Fixed a segfault in djpeg that would occur if an output format other than ++9. Fixed a segfault in djpeg that would occur if an output format other than + PPM/PGM was selected along with the `-crop` option. The `-crop` option now + works with the GIF and Targa formats as well (unfortunately, it cannot be made + to work with the BMP and RLE formats due to the fact that those output engines + write scanlines in bottom-up order.) djpeg will now exit gracefully if an + output format other than PPM/PGM, GIF, or Targa is selected along with the + `-crop` option. + -4. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color ++10. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color + quantization was enabled. + -5. TJBench (both C and Java versions) will now display usage information if any -command-line argument is unrecognized. This prevents the program from silently -ignoring typos. ++11. TJBench (both C and Java versions) will now display usage information if ++any command-line argument is unrecognized. This prevents the program from ++silently ignoring typos. + -6. Fixed an access violation in tjbench.exe (Windows) that occurred when the ++12. Fixed an access violation in tjbench.exe (Windows) that occurred when the + program was used to decompress an existing JPEG image. + -7. Fixed an ArrayIndexOutOfBoundsException in the TJExample Java program that ++13. Fixed an ArrayIndexOutOfBoundsException in the TJExample Java program that + occurred when attempting to decompress a JPEG image that had been compressed + with 4:1:1 chrominance subsampling. + 1.5.2 ===== diff --cc cmakescripts/testclean.cmake index 38bb03b,38bb03b..fc3fc25 --- a/cmakescripts/testclean.cmake +++ b/cmakescripts/testclean.cmake @@@ -29,7 -29,7 +29,9 @@@ file(GLOB FILE *_411_*.png *_411_*.ppm *_411_*.jpg -- *_411.yuv) ++ *_411.yuv ++ tjbenchtest*.log ++ tjexampletest*.log) if(NOT FILES STREQUAL "") message(STATUS "Removing test files") diff --cc djpeg.c index 53a8009,96db401..2fbb0b7 --- a/djpeg.c +++ b/djpeg.c @@@ -31,12 -31,7 +31,11 @@@ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "jversion.h" /* for version message */ #include "jconfigint.h" - #include "wrppm.h" +#ifndef HAVE_STDLIB_H /* should declare free() */ +extern void free (void *ptr); +#endif + #include /* to declare isprint() */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ diff --cc java/TJBench.java index 0733816,ddc414c..16dfb98 --- a/java/TJBench.java +++ b/java/TJBench.java @@@ -767,29 -733,25 +767,29 @@@ class TJBench System.out.println("Using most accurate DCT/IDCT algorithm\n"); flags |= TJ.FLAG_ACCURATEDCT; } - if (argv[i].equalsIgnoreCase("-progressive")) { ++ else if (argv[i].equalsIgnoreCase("-progressive")) { + System.out.println("Using progressive entropy coding\n"); + flags |= TJ.FLAG_PROGRESSIVE; + } - if (argv[i].equalsIgnoreCase("-rgb")) + else if (argv[i].equalsIgnoreCase("-rgb")) pf = TJ.PF_RGB; - if (argv[i].equalsIgnoreCase("-rgbx")) + else if (argv[i].equalsIgnoreCase("-rgbx")) pf = TJ.PF_RGBX; - if (argv[i].equalsIgnoreCase("-bgr")) + else if (argv[i].equalsIgnoreCase("-bgr")) pf = TJ.PF_BGR; - if (argv[i].equalsIgnoreCase("-bgrx")) + else if (argv[i].equalsIgnoreCase("-bgrx")) pf = TJ.PF_BGRX; - if (argv[i].equalsIgnoreCase("-xbgr")) + else if (argv[i].equalsIgnoreCase("-xbgr")) pf = TJ.PF_XBGR; - if (argv[i].equalsIgnoreCase("-xrgb")) + else if (argv[i].equalsIgnoreCase("-xrgb")) pf = TJ.PF_XRGB; - if (argv[i].equalsIgnoreCase("-bottomup")) + else if (argv[i].equalsIgnoreCase("-bottomup")) flags |= TJ.FLAG_BOTTOMUP; - if (argv[i].equalsIgnoreCase("-quiet")) + else if (argv[i].equalsIgnoreCase("-quiet")) quiet = 1; - if (argv[i].equalsIgnoreCase("-qq")) + else if (argv[i].equalsIgnoreCase("-qq")) quiet = 2; - if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) { + else if (argv[i].equalsIgnoreCase("-scale") && i < argv.length - 1) { int temp1 = 0, temp2 = 0; boolean match = false, scanned = true; Scanner scanner = new Scanner(argv[++i]).useDelimiter("/"); @@@ -812,27 -774,25 +812,27 @@@ } else usage(); } - if (argv[i].equalsIgnoreCase("-hflip")) + else if (argv[i].equalsIgnoreCase("-hflip")) xformOp = TJTransform.OP_HFLIP; - if (argv[i].equalsIgnoreCase("-vflip")) + else if (argv[i].equalsIgnoreCase("-vflip")) xformOp = TJTransform.OP_VFLIP; - if (argv[i].equalsIgnoreCase("-transpose")) + else if (argv[i].equalsIgnoreCase("-transpose")) xformOp = TJTransform.OP_TRANSPOSE; - if (argv[i].equalsIgnoreCase("-transverse")) + else if (argv[i].equalsIgnoreCase("-transverse")) xformOp = TJTransform.OP_TRANSVERSE; - if (argv[i].equalsIgnoreCase("-rot90")) + else if (argv[i].equalsIgnoreCase("-rot90")) xformOp = TJTransform.OP_ROT90; - if (argv[i].equalsIgnoreCase("-rot180")) + else if (argv[i].equalsIgnoreCase("-rot180")) xformOp = TJTransform.OP_ROT180; - if (argv[i].equalsIgnoreCase("-rot270")) + else if (argv[i].equalsIgnoreCase("-rot270")) xformOp = TJTransform.OP_ROT270; - if (argv[i].equalsIgnoreCase("-grayscale")) + else if (argv[i].equalsIgnoreCase("-grayscale")) xformOpt |= TJTransform.OPT_GRAY; - if (argv[i].equalsIgnoreCase("-nooutput")) + else if (argv[i].equalsIgnoreCase("-nooutput")) xformOpt |= TJTransform.OPT_NOOUTPUT; - if (argv[i].equalsIgnoreCase("-copynone")) ++ else if (argv[i].equalsIgnoreCase("-copynone")) + xformOpt |= TJTransform.OPT_COPYNONE; - if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) { + else if (argv[i].equalsIgnoreCase("-benchtime") && i < argv.length - 1) { double temp = -1; try { temp = Double.parseDouble(argv[++i]); @@@ -884,10 -844,7 +884,9 @@@ } else usage(); } - if (argv[i].equalsIgnoreCase("-stoponwarning")) ++ else if (argv[i].equalsIgnoreCase("-stoponwarning")) + flags |= TJ.FLAG_STOPONWARNING; - if (argv[i].equalsIgnoreCase("-?")) - usage(); + else usage(); } } diff --cc tjbench.c index a627510,76b61cd..9b7a48b --- a/tjbench.c +++ b/tjbench.c @@@ -890,22 -849,17 +889,22 @@@ int main(int argc, char *argv[] printf("Using most accurate DCT/IDCT algorithm\n\n"); flags|=TJFLAG_ACCURATEDCT; } - if(!strcasecmp(argv[i], "-progressive")) ++ else if(!strcasecmp(argv[i], "-progressive")) + { + printf("Using progressive entropy coding\n\n"); + flags|=TJFLAG_PROGRESSIVE; + } - if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB; - if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX; - if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR; - if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX; - if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR; - if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB; - if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK; - if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP; - if(!strcasecmp(argv[i], "-quiet")) quiet=1; - if(!strcasecmp(argv[i], "-qq")) quiet=2; - if(!strcasecmp(argv[i], "-scale") && i0.0) benchtime=temp; @@@ -977,9 -929,9 +975,10 @@@ } } } - if(!strcasecmp(argv[i], "-componly")) componly=1; - if(!strcasecmp(argv[i], "-nowrite")) dowrite=0; - if(!strcasecmp(argv[i], "-stoponwarning")) flags|=TJFLAG_STOPONWARNING; + else if(!strcasecmp(argv[i], "-componly")) componly=1; + else if(!strcasecmp(argv[i], "-nowrite")) dowrite=0; ++ else if(!strcasecmp(argv[i], "-stoponwarning")) flags|=TJFLAG_STOPONWARNING; + else usage(argv[0]); } } diff --cc tjexampletest.in index 619d04f,4cb9e9d..d251977 --- a/tjexampletest.in +++ b/tjexampletest.in @@@ -20,10 -20,10 +20,10 @@@ runme( } IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp" -IMGDIR=@srcdir@/testimages +IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages - OUTDIR=__tjexampletest_output + OUTDIR=`mktemp -d /tmp/__tjexampletest_output.XXXXXX` -EXEDIR=. -JAVA="@JAVA@ -cp java/turbojpeg.jar -Djava.library.path=.libs" +EXEDIR=@CMAKE_CURRENT_BINARY_DIR@ +JAVA="@Java_JAVA_EXECUTABLE@ -cp $EXEDIR/java/turbojpeg.jar -Djava.library.path=$EXEDIR" if [ -d $OUTDIR ]; then rm -rf $OUTDIR @@@ -85,9 -85,9 +85,9 @@@ for image in $IMAGES; d # 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` + scalearg=`echo $scale | sed 's/\_/\//g'` for samp in GRAY 420 422 444; do - $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp + runme $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.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 @@@ -136,8 -136,8 +136,8 @@@ 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` + 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 $EXEDIR/djpeg -rgb -bmp -scale ${scalearg} -outfile $OUTDIR/${basename}_${samp}_${xform}_${scale}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.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 diff --cc turbojpeg.h index c4e48cc,307dc6f..f7fef7b --- a/turbojpeg.h +++ b/turbojpeg.h @@@ -717,11 -666,10 +716,11 @@@ DLLEXPORT tjhandle DLLCALL tjInitCompre * @param jpegQual the image quality of the generated JPEG image (1 = worst, * 100 = best) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, int pixelFormat, unsigned char **jpegBuf, @@@ -782,11 -730,10 +781,11 @@@ * @param jpegQual the image quality of the generated JPEG image (1 = worst, * 100 = best) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle, const unsigned char *srcBuf, int width, int pad, int height, int subsamp, @@@ -853,11 -800,10 +852,11 @@@ * @param jpegQual the image quality of the generated JPEG image (1 = worst, * 100 = best) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle, const unsigned char **srcPlanes, int width, const int *strides, int height, @@@ -1014,11 -960,10 +1013,11 @@@ DLLEXPORT int tjPlaneHeight(int compone * Video, subsamp should be set to @ref TJSAMP_420. This produces an * image compatible with the I420 (AKA "YUV420P") format. * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, @@@ -1073,11 -1018,10 +1072,11 @@@ * Video, subsamp should be set to @ref TJSAMP_420. This produces an * image compatible with the I420 (AKA "YUV420P") format. * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle, const unsigned char *srcBuf, int width, int pitch, int height, @@@ -1182,11 -1125,10 +1181,11 @@@ DLLEXPORT tjscalingfactor* DLLCALL tjGe * @param pixelFormat pixel format of the destination image (see @ref * TJPF "Pixel formats".) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, const unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, @@@ -1233,11 -1175,10 +1232,11 @@@ * block height (see #tjMCUHeight), then an intermediate buffer copy will be * performed within TurboJPEG. * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle, const unsigned char *jpegBuf, unsigned long jpegSize, unsigned char *dstBuf, @@@ -1290,11 -1231,10 +1289,11 @@@ * block height (see #tjMCUHeight), then an intermediate buffer copy will be * performed within TurboJPEG. * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle, const unsigned char *jpegBuf, unsigned long jpegSize, @@@ -1343,11 -1283,10 +1342,11 @@@ * @param pixelFormat pixel format of the destination image (see @ref TJPF * "Pixel formats".) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf, int pad, int subsamp, unsigned char *dstBuf, int width, int pitch, @@@ -1401,11 -1340,10 +1400,11 @@@ * @param pixelFormat pixel format of the destination image (see @ref TJPF * "Pixel formats".) * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle, const unsigned char **srcPlanes, const int *strides, int subsamp, @@@ -1476,11 -1414,10 +1475,11 @@@ DLLEXPORT tjhandle DLLCALL tjInitTransf * which specifies the transform parameters and/or cropping region for the * corresponding transformed output image. * - * @param flags the bitwise OR of one or more of the @ref TJFLAG_BOTTOMUP + * @param flags the bitwise OR of one or more of the @ref TJFLAG_ACCURATEDCT * "flags" * - * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr().) + * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() + * and #tjGetErrorCode().) */ DLLEXPORT int DLLCALL tjTransform(tjhandle handle, const unsigned char *jpegBuf, unsigned long jpegSize, int n,