Merge branch 'master' into dev

This commit is contained in:
DRC
2017-11-17 19:00:53 -06:00
28 changed files with 399 additions and 334 deletions

View File

@@ -80,6 +80,28 @@ image planes and allocates memory for the image planes.
8. 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. testing BufferedImage encoding/decoding on big endian systems.
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.
10. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color
quantization was enabled.
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.
12. Fixed an access violation in tjbench.exe (Windows) that occurred when the
program was used to decompress an existing JPEG image.
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 1.5.2
===== =====

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code relevant * libjpeg-turbo Modifications:
* to libjpeg-turbo. * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -54,6 +54,14 @@ struct djpeg_dest_struct {
JDIMENSION rows_supplied); JDIMENSION rows_supplied);
/* Finish up at the end of the image. */ /* Finish up at the end of the image. */
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo); void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);
/* Re-calculate buffer dimensions based on output dimensions (for use with
partial image decompression.) If this is NULL, then the output format
does not support partial image decompression (BMP and RLE, in particular,
cannot support partial decompression because they use an inversion buffer
to write the image in bottom-up order.) */
void (*calc_buffer_dimensions) (j_decompress_ptr cinfo,
djpeg_dest_ptr dinfo);
/* Target file spec; filled in by djpeg.c after object is created. */ /* Target file spec; filled in by djpeg.c after object is created. */
FILE *output_file; FILE *output_file;

View File

@@ -29,7 +29,9 @@ file(GLOB FILES
*_411_*.png *_411_*.png
*_411_*.ppm *_411_*.ppm
*_411_*.jpg *_411_*.jpg
*_411.yuv) *_411.yuv
tjbenchtest*.log
tjexampletest*.log)
if(NOT FILES STREQUAL "") if(NOT FILES STREQUAL "")
message(STATUS "Removing test files") message(STATUS "Removing test files")

View File

@@ -1,4 +1,4 @@
TH DJPEG 1 "18 March 2017" .TH DJPEG 1 "13 November 2017"
.SH NAME .SH NAME
djpeg \- decompress a JPEG file to an image file djpeg \- decompress a JPEG file to an image file
.SH SYNOPSIS .SH SYNOPSIS
@@ -207,7 +207,8 @@ Decompress only a rectangular subregion of the image, starting at point X,Y
with width W and height H. If necessary, X will be shifted left to the nearest with width W and height H. If necessary, X will be shifted left to the nearest
iMCU boundary, and the width will be increased accordingly. Note that if iMCU boundary, and the width will be increased accordingly. Note that if
decompression scaling is being used, then X, Y, W, and H are relative to the decompression scaling is being used, then X, Y, W, and H are relative to the
scaled image dimensions. scaled image dimensions. Currently this option only works with the
PBMPLUS (PPM/PGM), GIF, and Targa output formats.
.TP .TP
.B \-verbose .B \-verbose
Enable debug printout. More Enable debug printout. More

View File

@@ -31,7 +31,6 @@
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "jconfigint.h" #include "jconfigint.h"
#include "wrppm.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare free() */ #ifndef HAVE_STDLIB_H /* <stdlib.h> should declare free() */
extern void free (void *ptr); extern void free (void *ptr);
@@ -179,6 +178,7 @@ usage (void)
fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n"); fprintf(stderr, " -skip Y0,Y1 Decompress all rows except those between Y0 and Y1 (inclusive)\n");
fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n"); fprintf(stderr, " -crop WxH+X+Y Decompress only a rectangular subregion of the image\n");
fprintf(stderr, " [requires PBMPLUS (PPM/PGM), GIF, or Targa output format]\n");
fprintf(stderr, " -verbose or -debug Emit debug output\n"); fprintf(stderr, " -verbose or -debug Emit debug output\n");
fprintf(stderr, " -version Print version information and exit\n"); fprintf(stderr, " -version Print version information and exit\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -727,9 +727,10 @@ main (int argc, char **argv)
} }
jpeg_crop_scanline(&cinfo, &crop_x, &crop_width); jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
((ppm_dest_ptr) dest_mgr)->buffer_width = cinfo.output_width * if (dest_mgr->calc_buffer_dimensions)
cinfo.out_color_components * (*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
sizeof(JSAMPLE); else
ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
/* Write output file header. This is a hack to ensure that the destination /* Write output file header. This is a hack to ensure that the destination
* manager creates an output image of the proper size. * manager creates an output image of the proper size.

View File

@@ -1132,7 +1132,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr> <tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegSubsamp</td><td>the level of chrominance subsampling to be used when generating the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr> <tr><td class="paramname">jpegSubsamp</td><td>the level of chrominance subsampling to be used when generating the JPEG image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.)</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr> <tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1229,7 +1229,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr> If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr> <tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr> <tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1326,7 +1326,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr> If you choose option 1, <code>*jpegSize</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>*jpegBuf</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr> <tr><td class="paramname">jpegSize</td><td>pointer to an unsigned long variable that holds the size of the JPEG image buffer. If <code>*jpegBuf</code> points to a pre-allocated buffer, then <code>*jpegSize</code> should be set to the size of the buffer. Upon return, <code>*jpegSize</code> will contain the size of the JPEG image (in bytes.) If <code>*jpegBuf</code> points to a JPEG image buffer that is being reused from a previous call to one of the JPEG compression functions, then <code>*jpegSize</code> is ignored.</td></tr>
<tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr> <tr><td class="paramname">jpegQual</td><td>the image quality of the generated JPEG image (1 = worst, 100 = best)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1419,7 +1419,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr> <tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr> <tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr> <tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1512,7 +1512,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr> <tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this should be <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the destination image is unpadded, or <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the destination image should be padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>width * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr> <tr><td class="paramname">height</td><td>height (in pixels) of the source and destination images</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr> <tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1597,7 +1597,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this is <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the decompressed image is unpadded, else <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the decompressed image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. (NOTE: <code>scaledWidth</code> can be determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df" title="Compute the scaled value of dimension using the given scaling factor.">TJSCALED()</a> with the JPEG image width and one of the scaling factors returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8" title="Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of Tur...">tjGetScalingFactors()</a>.) You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr> <tr><td class="paramname">pitch</td><td>bytes per line in the destination image. Normally, this is <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code> if the decompressed image is unpadded, else <code><a class="el" href="group___turbo_j_p_e_g.html#ga0aba955473315e405295d978f0c16511" title="Pad the given width to the nearest 32-bit boundary.">TJPAD</a>(scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat])</code> if each line of the decompressed image is padded to the nearest 32-bit boundary, as is the case for Windows bitmaps. (NOTE: <code>scaledWidth</code> can be determined by calling <a class="el" href="group___turbo_j_p_e_g.html#ga84878bb65404204743aa18cac02781df" title="Compute the scaled value of dimension using the given scaling factor.">TJSCALED()</a> with the JPEG image width and one of the scaling factors returned by <a class="el" href="group___turbo_j_p_e_g.html#ga6449044b9af402999ccf52f401333be8" title="Returns a list of fractional scaling factors that the JPEG decompressor in this implementation of Tur...">tjGetScalingFactors()</a>.) You can also be clever and use the pitch parameter to skip lines, etc. Setting this parameter to 0 is the equivalent of setting it to <code>scaledWidth * <a class="el" href="group___turbo_j_p_e_g.html#gad77cf8fe5b2bfd3cb3f53098146abb4c" title="Pixel size (in bytes) for a given pixel format.">tjPixelSize</a>[pixelFormat]</code>.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the destination image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size.</td></tr> <tr><td class="paramname">height</td><td>desired height (in pixels) of the destination image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size.</td></tr>
<tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr> <tr><td class="paramname">pixelFormat</td><td>pixel format of the destination image (see <a class="el" href="group___turbo_j_p_e_g.html#gac916144e26c3817ac514e64ae5d12e2a">Pixel formats</a>.)</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1747,7 +1747,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr> <tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr> <tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr> <tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1826,7 +1826,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr> <tr><td class="paramname">width</td><td>desired width (in pixels) of the YUV image. If this is different than the width of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired width. If <code>width</code> is set to 0, then only the height will be considered when determining the scaled image size. If the scaled width is not an even multiple of the MCU block width (see <a class="el" href="group___turbo_j_p_e_g.html#ga9e61e7cd47a15a173283ba94e781308c" title="MCU block width (in pixels) for a given level of chrominance subsampling.">tjMCUWidth</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image.</td></tr> <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to decompress the JPEG image into a subregion of a larger YUV planar image.</td></tr>
<tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr> <tr><td class="paramname">height</td><td>desired height (in pixels) of the YUV image. If this is different than the height of the JPEG image being decompressed, then TurboJPEG will use scaling in the JPEG decompressor to generate the largest possible image that will fit within the desired height. If <code>height</code> is set to 0, then only the width will be considered when determining the scaled image size. If the scaled height is not an even multiple of the MCU block height (see <a class="el" href="group___turbo_j_p_e_g.html#gabd247bb9fecb393eca57366feb8327bf" title="MCU block height (in pixels) for a given level of chrominance subsampling.">tjMCUHeight</a>), then an intermediate buffer copy will be performed within TurboJPEG.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -1944,7 +1944,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> to determine the appropriate size for this buffer based on the image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr> <tr><td class="paramname">dstBuf</td><td>pointer to an image buffer that will receive the YUV image. Use <a class="el" href="group___turbo_j_p_e_g.html#gaf451664a62c1f6c7cc5a6401f32908c9" title="The size of the buffer (in bytes) required to hold a YUV planar image with the given parameters...">tjBufSizeYUV2()</a> to determine the appropriate size for this buffer based on the image width, height, padding, and level of chrominance subsampling. The Y, U (Cb), and V (Cr) image planes will be stored sequentially in the buffer (refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.)</td></tr>
<tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr> <tr><td class="paramname">pad</td><td>the width of each line in each plane of the YUV image will be padded to the nearest multiple of this number of bytes (must be a power of 2.) To generate images suitable for X Video, <code>pad</code> should be set to 4.</td></tr>
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr> <tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -2037,7 +2037,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
<tr><td class="paramname">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Use <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> to determine the appropriate size for each plane based on the image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr> <tr><td class="paramname">dstPlanes</td><td>an array of pointers to Y, U (Cb), and V (Cr) image planes (or just a Y plane, if generating a grayscale image) that will receive the encoded image. These planes can be contiguous or non-contiguous in memory. Use <a class="el" href="group___turbo_j_p_e_g.html#ga6f98d977bfa9d167c97172e876ba61e2" title="The size of the buffer (in bytes) required to hold a YUV image plane with the given parameters...">tjPlaneSizeYUV()</a> to determine the appropriate size for each plane based on the image width, height, strides, and level of chrominance subsampling. Refer to <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a> for more details.</td></tr>
<tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image.</td></tr> <tr><td class="paramname">strides</td><td>an array of integers, each specifying the number of bytes per line in the corresponding plane of the output image. Setting the stride for any plane to 0 is the same as setting it to the plane width (see <a class="el" href="group___turbo_j_p_e_g.html#YUVnotes">YUV Image Format Notes</a>.) If <code>strides</code> is NULL, then the strides for all planes will be set to their respective plane widths. You can adjust the strides in order to add an arbitrary amount of line padding to each plane or to encode an RGB or grayscale image into a subregion of a larger YUV planar image.</td></tr>
<tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr> <tr><td class="paramname">subsamp</td><td>the level of chrominance subsampling to be used when generating the YUV image (see <a class="el" href="group___turbo_j_p_e_g.html#ga1d047060ea80bb9820d540bb928e9074">Chrominance subsampling options</a>.) To generate images suitable for X Video, <code>subsamp</code> should be set to <a class="el" href="group___turbo_j_p_e_g.html#gga1d047060ea80bb9820d540bb928e9074a63085dbf683cfe39e513cdb6343e3737">TJSAMP_420</a>. This produces an image compatible with the I420 (AKA "YUV420P") format.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -2425,7 +2425,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr> If you choose option 1, <code>dstSizes[i]</code> should be set to the size of your pre-allocated buffer. In any case, unless you have set <a class="el" href="group___turbo_j_p_e_g.html#ga8808d403c68b62aaa58a4c1e58e98963" title="Disable buffer (re)allocation.">TJFLAG_NOREALLOC</a>, you should always check <code>dstBufs[i]</code> upon return from this function, as it may have changed.</td></tr>
<tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr> <tr><td class="paramname">dstSizes</td><td>pointer to an array of n unsigned long variables that will receive the actual sizes (in bytes) of each transformed JPEG image. If <code>dstBufs[i]</code> points to a pre-allocated buffer, then <code>dstSizes[i]</code> should be set to the size of the buffer. Upon return, <code>dstSizes[i]</code> will contain the size of the JPEG image (in bytes.)</td></tr>
<tr><td class="paramname">transforms</td><td>pointer to an array of n <a class="el" href="structtjtransform.html" title="Lossless transform.">tjtransform</a> structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image.</td></tr> <tr><td class="paramname">transforms</td><td>pointer to an array of n <a class="el" href="structtjtransform.html" title="Lossless transform.">tjtransform</a> structures, each of which specifies the transform parameters and/or cropping region for the corresponding transformed output image.</td></tr>
<tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#ga72ecf4ebe6eb702d3c6f5ca27455e1ec">flags</a></td></tr> <tr><td class="paramname">flags</td><td>the bitwise OR of one or more of the <a class="el" href="group___turbo_j_p_e_g.html#gacb233cfd722d66d1ccbf48a7de81f0e0">flags</a></td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>

View File

@@ -755,41 +755,41 @@ class TJBench {
if (argv[i].equalsIgnoreCase("-tile")) { if (argv[i].equalsIgnoreCase("-tile")) {
doTile = true; xformOpt |= TJTransform.OPT_CROP; doTile = true; xformOpt |= TJTransform.OPT_CROP;
} }
if (argv[i].equalsIgnoreCase("-fastupsample")) { else if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code\n"); System.out.println("Using fast upsampling code\n");
flags |= TJ.FLAG_FASTUPSAMPLE; flags |= TJ.FLAG_FASTUPSAMPLE;
} }
if (argv[i].equalsIgnoreCase("-fastdct")) { else if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm\n"); System.out.println("Using fastest DCT/IDCT algorithm\n");
flags |= TJ.FLAG_FASTDCT; flags |= TJ.FLAG_FASTDCT;
} }
if (argv[i].equalsIgnoreCase("-accuratedct")) { else if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm\n"); System.out.println("Using most accurate DCT/IDCT algorithm\n");
flags |= TJ.FLAG_ACCURATEDCT; flags |= TJ.FLAG_ACCURATEDCT;
} }
if (argv[i].equalsIgnoreCase("-progressive")) { else if (argv[i].equalsIgnoreCase("-progressive")) {
System.out.println("Using progressive entropy coding\n"); System.out.println("Using progressive entropy coding\n");
flags |= TJ.FLAG_PROGRESSIVE; flags |= TJ.FLAG_PROGRESSIVE;
} }
if (argv[i].equalsIgnoreCase("-rgb")) else if (argv[i].equalsIgnoreCase("-rgb"))
pf = TJ.PF_RGB; pf = TJ.PF_RGB;
if (argv[i].equalsIgnoreCase("-rgbx")) else if (argv[i].equalsIgnoreCase("-rgbx"))
pf = TJ.PF_RGBX; pf = TJ.PF_RGBX;
if (argv[i].equalsIgnoreCase("-bgr")) else if (argv[i].equalsIgnoreCase("-bgr"))
pf = TJ.PF_BGR; pf = TJ.PF_BGR;
if (argv[i].equalsIgnoreCase("-bgrx")) else if (argv[i].equalsIgnoreCase("-bgrx"))
pf = TJ.PF_BGRX; pf = TJ.PF_BGRX;
if (argv[i].equalsIgnoreCase("-xbgr")) else if (argv[i].equalsIgnoreCase("-xbgr"))
pf = TJ.PF_XBGR; pf = TJ.PF_XBGR;
if (argv[i].equalsIgnoreCase("-xrgb")) else if (argv[i].equalsIgnoreCase("-xrgb"))
pf = TJ.PF_XRGB; pf = TJ.PF_XRGB;
if (argv[i].equalsIgnoreCase("-bottomup")) else if (argv[i].equalsIgnoreCase("-bottomup"))
flags |= TJ.FLAG_BOTTOMUP; flags |= TJ.FLAG_BOTTOMUP;
if (argv[i].equalsIgnoreCase("-quiet")) else if (argv[i].equalsIgnoreCase("-quiet"))
quiet = 1; quiet = 1;
if (argv[i].equalsIgnoreCase("-qq")) else if (argv[i].equalsIgnoreCase("-qq"))
quiet = 2; 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; int temp1 = 0, temp2 = 0;
boolean match = false, scanned = true; boolean match = false, scanned = true;
Scanner scanner = new Scanner(argv[++i]).useDelimiter("/"); Scanner scanner = new Scanner(argv[++i]).useDelimiter("/");
@@ -812,27 +812,27 @@ class TJBench {
} else } else
usage(); usage();
} }
if (argv[i].equalsIgnoreCase("-hflip")) else if (argv[i].equalsIgnoreCase("-hflip"))
xformOp = TJTransform.OP_HFLIP; xformOp = TJTransform.OP_HFLIP;
if (argv[i].equalsIgnoreCase("-vflip")) else if (argv[i].equalsIgnoreCase("-vflip"))
xformOp = TJTransform.OP_VFLIP; xformOp = TJTransform.OP_VFLIP;
if (argv[i].equalsIgnoreCase("-transpose")) else if (argv[i].equalsIgnoreCase("-transpose"))
xformOp = TJTransform.OP_TRANSPOSE; xformOp = TJTransform.OP_TRANSPOSE;
if (argv[i].equalsIgnoreCase("-transverse")) else if (argv[i].equalsIgnoreCase("-transverse"))
xformOp = TJTransform.OP_TRANSVERSE; xformOp = TJTransform.OP_TRANSVERSE;
if (argv[i].equalsIgnoreCase("-rot90")) else if (argv[i].equalsIgnoreCase("-rot90"))
xformOp = TJTransform.OP_ROT90; xformOp = TJTransform.OP_ROT90;
if (argv[i].equalsIgnoreCase("-rot180")) else if (argv[i].equalsIgnoreCase("-rot180"))
xformOp = TJTransform.OP_ROT180; xformOp = TJTransform.OP_ROT180;
if (argv[i].equalsIgnoreCase("-rot270")) else if (argv[i].equalsIgnoreCase("-rot270"))
xformOp = TJTransform.OP_ROT270; xformOp = TJTransform.OP_ROT270;
if (argv[i].equalsIgnoreCase("-grayscale")) else if (argv[i].equalsIgnoreCase("-grayscale"))
xformOpt |= TJTransform.OPT_GRAY; xformOpt |= TJTransform.OPT_GRAY;
if (argv[i].equalsIgnoreCase("-nooutput")) else if (argv[i].equalsIgnoreCase("-nooutput"))
xformOpt |= TJTransform.OPT_NOOUTPUT; xformOpt |= TJTransform.OPT_NOOUTPUT;
if (argv[i].equalsIgnoreCase("-copynone")) else if (argv[i].equalsIgnoreCase("-copynone"))
xformOpt |= TJTransform.OPT_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; double temp = -1;
try { try {
temp = Double.parseDouble(argv[++i]); temp = Double.parseDouble(argv[++i]);
@@ -842,11 +842,11 @@ class TJBench {
else else
usage(); usage();
} }
if (argv[i].equalsIgnoreCase("-yuv")) { else if (argv[i].equalsIgnoreCase("-yuv")) {
System.out.println("Testing YUV planar encoding/decoding\n"); System.out.println("Testing YUV planar encoding/decoding\n");
doYUV = true; doYUV = true;
} }
if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) { else if (argv[i].equalsIgnoreCase("-yuvpad") && i < argv.length - 1) {
int temp = 0; int temp = 0;
try { try {
temp = Integer.parseInt(argv[++i]); temp = Integer.parseInt(argv[++i]);
@@ -854,7 +854,7 @@ class TJBench {
if (temp >= 1) if (temp >= 1)
yuvpad = temp; yuvpad = temp;
} }
if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) { else if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
i++; i++;
if (argv[i].toUpperCase().startsWith("G")) if (argv[i].toUpperCase().startsWith("G"))
subsamp = TJ.SAMP_GRAY; subsamp = TJ.SAMP_GRAY;
@@ -869,11 +869,11 @@ class TJBench {
else if (argv[i].equals("411")) else if (argv[i].equals("411"))
subsamp = TJ.SAMP_411; subsamp = TJ.SAMP_411;
} }
if (argv[i].equalsIgnoreCase("-componly")) else if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true; compOnly = true;
if (argv[i].equalsIgnoreCase("-nowrite")) else if (argv[i].equalsIgnoreCase("-nowrite"))
write = false; write = false;
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) { else if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
double temp = -1; double temp = -1;
try { try {
temp = Double.parseDouble(argv[++i]); temp = Double.parseDouble(argv[++i]);
@@ -884,10 +884,9 @@ class TJBench {
} else } else
usage(); usage();
} }
if (argv[i].equalsIgnoreCase("-stoponwarning")) else if (argv[i].equalsIgnoreCase("-stoponwarning"))
flags |= TJ.FLAG_STOPONWARNING; flags |= TJ.FLAG_STOPONWARNING;
if (argv[i].equalsIgnoreCase("-?")) else usage();
usage();
} }
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (C)2011-2012, 2014-2015 D. R. Commander. All Rights Reserved. * Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
* All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -94,7 +95,7 @@ public class TJExample implements TJCustomFilter {
} }
private static final String[] sampName = { private static final String[] sampName = {
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0" "4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1"
}; };
public static void main(String[] argv) { public static void main(String[] argv) {
@@ -117,114 +118,114 @@ public class TJExample implements TJCustomFilter {
int outSubsamp = -1, outQual = 95; int outSubsamp = -1, outQual = 95;
boolean display = false; boolean display = false;
if (argv.length > 1) { if (argv[1].substring(0, 2).equalsIgnoreCase("-d"))
for (int i = 1; i < argv.length; i++) { display = true;
if (argv[i].length() < 2)
continue; for (int i = 2; i < argv.length; i++) {
if (argv[i].length() > 2 && if (argv[i].length() < 2)
argv[i].substring(0, 3).equalsIgnoreCase("-sc")) { continue;
int match = 0; else if (argv[i].length() > 2 &&
if (i < argv.length - 1) { argv[i].substring(0, 3).equalsIgnoreCase("-sc")) {
String[] scaleArg = argv[++i].split("/"); int match = 0;
if (scaleArg.length == 2) { if (i < argv.length - 1) {
TJScalingFactor tempsf = String[] scaleArg = argv[++i].split("/");
new TJScalingFactor(Integer.parseInt(scaleArg[0]), if (scaleArg.length == 2) {
Integer.parseInt(scaleArg[1])); TJScalingFactor tempsf =
for (int j = 0; j < sf.length; j++) { new TJScalingFactor(Integer.parseInt(scaleArg[0]),
if (tempsf.equals(sf[j])) { Integer.parseInt(scaleArg[1]));
scaleFactor = sf[j]; for (int j = 0; j < sf.length; j++) {
match = 1; if (tempsf.equals(sf[j])) {
break; scaleFactor = sf[j];
} match = 1;
break;
} }
} }
} }
if (match != 1) usage();
}
if (argv[i].equalsIgnoreCase("-h") || argv[i].equalsIgnoreCase("-?"))
usage();
if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
if (i < argv.length - 1) {
i++;
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
outSubsamp = TJ.SAMP_GRAY;
else if (argv[i].equals("444"))
outSubsamp = TJ.SAMP_444;
else if (argv[i].equals("422"))
outSubsamp = TJ.SAMP_422;
else if (argv[i].equals("420"))
outSubsamp = TJ.SAMP_420;
else
usage();
} else
usage();
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
if (i < argv.length - 1) {
int qual = Integer.parseInt(argv[++i]);
if (qual >= 1 && qual <= 100)
outQual = qual;
else
usage();
} else
usage();
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
xform.options |= TJTransform.OPT_GRAY;
if (argv[i].equalsIgnoreCase("-hflip"))
xform.op = TJTransform.OP_HFLIP;
if (argv[i].equalsIgnoreCase("-vflip"))
xform.op = TJTransform.OP_VFLIP;
if (argv[i].equalsIgnoreCase("-transpose"))
xform.op = TJTransform.OP_TRANSPOSE;
if (argv[i].equalsIgnoreCase("-transverse"))
xform.op = TJTransform.OP_TRANSVERSE;
if (argv[i].equalsIgnoreCase("-rot90"))
xform.op = TJTransform.OP_ROT90;
if (argv[i].equalsIgnoreCase("-rot180"))
xform.op = TJTransform.OP_ROT180;
if (argv[i].equalsIgnoreCase("-rot270"))
xform.op = TJTransform.OP_ROT270;
if (argv[i].equalsIgnoreCase("-custom"))
xform.cf = new TJExample();
else if (argv[i].length() > 2 &&
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
if (i >= argv.length - 1)
usage();
String[] cropArg = argv[++i].split(",");
if (cropArg.length != 3)
usage();
String[] dimArg = cropArg[2].split("[xX]");
if (dimArg.length != 2)
usage();
int tempx = Integer.parseInt(cropArg[0]);
int tempy = Integer.parseInt(cropArg[1]);
int tempw = Integer.parseInt(dimArg[0]);
int temph = Integer.parseInt(dimArg[1]);
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
usage();
xform.x = tempx;
xform.y = tempy;
xform.width = tempw;
xform.height = temph;
xform.options |= TJTransform.OPT_CROP;
}
if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
display = true;
if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code");
flags |= TJ.FLAG_FASTUPSAMPLE;
}
if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm");
flags |= TJ.FLAG_FASTDCT;
}
if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm");
flags |= TJ.FLAG_ACCURATEDCT;
} }
if (match != 1) usage();
} }
else if (argv[i].length() > 2 &&
argv[i].substring(0, 3).equalsIgnoreCase("-sa")) {
if (i < argv.length - 1) {
i++;
if (argv[i].substring(0, 1).equalsIgnoreCase("g"))
outSubsamp = TJ.SAMP_GRAY;
else if (argv[i].equals("444"))
outSubsamp = TJ.SAMP_444;
else if (argv[i].equals("422"))
outSubsamp = TJ.SAMP_422;
else if (argv[i].equals("420"))
outSubsamp = TJ.SAMP_420;
else
usage();
} else
usage();
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-q")) {
if (i < argv.length - 1) {
int qual = Integer.parseInt(argv[++i]);
if (qual >= 1 && qual <= 100)
outQual = qual;
else
usage();
} else
usage();
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-g"))
xform.options |= TJTransform.OPT_GRAY;
else if (argv[i].equalsIgnoreCase("-hflip"))
xform.op = TJTransform.OP_HFLIP;
else if (argv[i].equalsIgnoreCase("-vflip"))
xform.op = TJTransform.OP_VFLIP;
else if (argv[i].equalsIgnoreCase("-transpose"))
xform.op = TJTransform.OP_TRANSPOSE;
else if (argv[i].equalsIgnoreCase("-transverse"))
xform.op = TJTransform.OP_TRANSVERSE;
else if (argv[i].equalsIgnoreCase("-rot90"))
xform.op = TJTransform.OP_ROT90;
else if (argv[i].equalsIgnoreCase("-rot180"))
xform.op = TJTransform.OP_ROT180;
else if (argv[i].equalsIgnoreCase("-rot270"))
xform.op = TJTransform.OP_ROT270;
else if (argv[i].equalsIgnoreCase("-custom"))
xform.cf = new TJExample();
else if (argv[i].length() > 2 &&
argv[i].substring(0, 2).equalsIgnoreCase("-c")) {
if (i >= argv.length - 1)
usage();
String[] cropArg = argv[++i].split(",");
if (cropArg.length != 3)
usage();
String[] dimArg = cropArg[2].split("[xX]");
if (dimArg.length != 2)
usage();
int tempx = Integer.parseInt(cropArg[0]);
int tempy = Integer.parseInt(cropArg[1]);
int tempw = Integer.parseInt(dimArg[0]);
int temph = Integer.parseInt(dimArg[1]);
if (tempx < 0 || tempy < 0 || tempw < 0 || temph < 0)
usage();
xform.x = tempx;
xform.y = tempy;
xform.width = tempw;
xform.height = temph;
xform.options |= TJTransform.OPT_CROP;
}
else if (argv[i].substring(0, 2).equalsIgnoreCase("-d"))
display = true;
else if (argv[i].equalsIgnoreCase("-fastupsample")) {
System.out.println("Using fast upsampling code");
flags |= TJ.FLAG_FASTUPSAMPLE;
}
else if (argv[i].equalsIgnoreCase("-fastdct")) {
System.out.println("Using fastest DCT/IDCT algorithm");
flags |= TJ.FLAG_FASTDCT;
}
else if (argv[i].equalsIgnoreCase("-accuratedct")) {
System.out.println("Using most accurate DCT/IDCT algorithm");
flags |= TJ.FLAG_ACCURATEDCT;
}
else usage();
} }
String[] inFileTokens = argv[0].split("\\."); String[] inFileTokens = argv[0].split("\\.");
if (inFileTokens.length > 1) if (inFileTokens.length > 1)

View File

@@ -902,15 +902,13 @@ public class TJUnitTest {
for (int i = 0; i < argv.length; i++) { for (int i = 0; i < argv.length; i++) {
if (argv[i].equalsIgnoreCase("-yuv")) if (argv[i].equalsIgnoreCase("-yuv"))
doYUV = true; doYUV = true;
if (argv[i].equalsIgnoreCase("-noyuvpad")) else if (argv[i].equalsIgnoreCase("-noyuvpad"))
pad = 1; pad = 1;
if (argv[i].substring(0, 1).equalsIgnoreCase("-h") || else if (argv[i].equalsIgnoreCase("-bi")) {
argv[i].equalsIgnoreCase("-?"))
usage();
if (argv[i].equalsIgnoreCase("-bi")) {
bi = true; bi = true;
testName = "javabitest"; testName = "javabitest";
} } else
usage();
} }
if (doYUV) if (doYUV)
_4byteFormats[4] = -1; _4byteFormats[4] = -1;

View File

@@ -216,7 +216,7 @@ compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)
#endif #endif
dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */ dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */
if(r <= 16) return 0; if (r <= 16) return 0;
else return 1; else return 1;
} }

View File

@@ -77,7 +77,7 @@ int main(void)
jerr.pub.error_exit = my_error_exit; jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message; jerr.pub.output_message = my_output_message;
if(setjmp(jerr.jb)) { if (setjmp(jerr.jb)) {
/* this will execute if libjpeg has an error */ /* this will execute if libjpeg has an error */
jcs_valid = 0; jcs_valid = 0;
goto done; goto done;
@@ -104,7 +104,7 @@ int main(void)
printf(" Not present at compile time\n"); printf(" Not present at compile time\n");
#endif #endif
if(setjmp(jerr.jb)) { if (setjmp(jerr.jb)) {
/* this will execute if libjpeg has an error */ /* this will execute if libjpeg has an error */
jcs_alpha_valid = 0; jcs_alpha_valid = 0;
goto done2; goto done2;

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2015-2016, D. R. Commander. * Copyright (C) 2010, 2015-2017, D. R. Commander.
* Copyright (C) 2015, Google, Inc. * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
@@ -293,6 +293,14 @@ noop_convert (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
} }
/* Dummy quantize function used by jpeg_skip_scanlines() */
LOCAL(void)
noop_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows)
{
}
/* /*
* In some cases, it is best to call jpeg_read_scanlines() and discard the * In some cases, it is best to call jpeg_read_scanlines() and discard the
* output, rather than skipping the scanlines, because this allows us to * output, rather than skipping the scanlines, because this allows us to
@@ -308,14 +316,22 @@ read_and_discard_scanlines (j_decompress_ptr cinfo, JDIMENSION num_lines)
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf, void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION input_row, JSAMPARRAY output_buf, JDIMENSION input_row, JSAMPARRAY output_buf,
int num_rows); int num_rows);
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows) = NULL;
color_convert = cinfo->cconvert->color_convert; color_convert = cinfo->cconvert->color_convert;
cinfo->cconvert->color_convert = noop_convert; cinfo->cconvert->color_convert = noop_convert;
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
color_quantize = cinfo->cquantize->color_quantize;
cinfo->cquantize->color_quantize = noop_quantize;
}
for (n = 0; n < num_lines; n++) for (n = 0; n < num_lines; n++)
jpeg_read_scanlines(cinfo, NULL, 1); jpeg_read_scanlines(cinfo, NULL, 1);
cinfo->cconvert->color_convert = color_convert; cinfo->cconvert->color_convert = color_convert;
if (color_quantize)
cinfo->cquantize->color_quantize = color_quantize;
} }

View File

@@ -130,7 +130,7 @@ term_mem_destination (j_compress_ptr cinfo)
{ {
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest; my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
if(dest->alloc) *dest->outbuffer = dest->buffer; if (dest->alloc) *dest->outbuffer = dest->buffer;
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer); *dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
} }

View File

@@ -616,7 +616,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void) static INLINE boolean is_big_endian(void)
{ {
int test_value = 1; int test_value = 1;
if(*(char *)&test_value != 1) if (*(char *)&test_value != 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@@ -503,7 +503,7 @@ static const JLONG dither_matrix[4] = {
static INLINE boolean is_big_endian(void) static INLINE boolean is_big_endian(void)
{ {
int test_value = 1; int test_value = 1;
if(*(char *)&test_value != 1) if (*(char *)&test_value != 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@@ -535,7 +535,7 @@ int decompTest(char *filename)
char *temp=NULL, tempstr[80], tempstr2[80]; char *temp=NULL, tempstr[80], tempstr2[80];
int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0; int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0;
double start, elapsed; double start, elapsed;
int ps=tjPixelSize[pf], tile; int ps=tjPixelSize[pf], tile, decompsrc=0;
if((file=fopen(filename, "rb"))==NULL) if((file=fopen(filename, "rb"))==NULL)
_throwunix("opening file"); _throwunix("opening file");
@@ -715,18 +715,17 @@ int decompTest(char *filename)
else else
{ {
if(quiet==1) printf("N/A N/A "); if(quiet==1) printf("N/A N/A ");
jpegsize[0]=srcsize; tjFree(jpegbuf[0]);
free(jpegbuf[0]); jpegbuf[0]=NULL;
jpegbuf[0]=srcbuf; decompsrc=1;
srcbuf=NULL;
} }
if(w==tilew) _tilew=_w; if(w==tilew) _tilew=_w;
if(h==tileh) _tileh=_h; if(h==tileh) _tileh=_h;
if(!(xformopt&TJXOPT_NOOUTPUT)) if(!(xformopt&TJXOPT_NOOUTPUT))
{ {
if(decomp(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0, if(decomp(NULL, decompsrc? &srcbuf:jpegbuf, decompsrc? &srcsize:jpegsize,
filename, _tilew, _tileh)==-1) NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1)
goto bailout; goto bailout;
} }
else if(quiet==1) printf("N/A\n"); else if(quiet==1) printf("N/A\n");
@@ -875,37 +874,37 @@ int main(int argc, char *argv[])
{ {
dotile=1; xformopt|=TJXOPT_CROP; dotile=1; xformopt|=TJXOPT_CROP;
} }
if(!strcasecmp(argv[i], "-fastupsample")) else if(!strcasecmp(argv[i], "-fastupsample"))
{ {
printf("Using fast upsampling code\n\n"); printf("Using fast upsampling code\n\n");
flags|=TJFLAG_FASTUPSAMPLE; flags|=TJFLAG_FASTUPSAMPLE;
} }
if(!strcasecmp(argv[i], "-fastdct")) else if(!strcasecmp(argv[i], "-fastdct"))
{ {
printf("Using fastest DCT/IDCT algorithm\n\n"); printf("Using fastest DCT/IDCT algorithm\n\n");
flags|=TJFLAG_FASTDCT; flags|=TJFLAG_FASTDCT;
} }
if(!strcasecmp(argv[i], "-accuratedct")) else if(!strcasecmp(argv[i], "-accuratedct"))
{ {
printf("Using most accurate DCT/IDCT algorithm\n\n"); printf("Using most accurate DCT/IDCT algorithm\n\n");
flags|=TJFLAG_ACCURATEDCT; flags|=TJFLAG_ACCURATEDCT;
} }
if(!strcasecmp(argv[i], "-progressive")) else if(!strcasecmp(argv[i], "-progressive"))
{ {
printf("Using progressive entropy coding\n\n"); printf("Using progressive entropy coding\n\n");
flags|=TJFLAG_PROGRESSIVE; flags|=TJFLAG_PROGRESSIVE;
} }
if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB; else if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX; else if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR; else if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX; else if(!strcasecmp(argv[i], "-bgrx")) pf=TJPF_BGRX;
if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR; else if(!strcasecmp(argv[i], "-xbgr")) pf=TJPF_XBGR;
if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB; else if(!strcasecmp(argv[i], "-xrgb")) pf=TJPF_XRGB;
if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK; else if(!strcasecmp(argv[i], "-cmyk")) pf=TJPF_CMYK;
if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP; else if(!strcasecmp(argv[i], "-bottomup")) flags|=TJFLAG_BOTTOMUP;
if(!strcasecmp(argv[i], "-quiet")) quiet=1; else if(!strcasecmp(argv[i], "-quiet")) quiet=1;
if(!strcasecmp(argv[i], "-qq")) quiet=2; else if(!strcasecmp(argv[i], "-qq")) quiet=2;
if(!strcasecmp(argv[i], "-scale") && i<argc-1) else if(!strcasecmp(argv[i], "-scale") && i<argc-1)
{ {
int temp1=0, temp2=0, match=0; int temp1=0, temp2=0, match=0;
if(sscanf(argv[++i], "%d/%d", &temp1, &temp2)==2) if(sscanf(argv[++i], "%d/%d", &temp1, &temp2)==2)
@@ -923,44 +922,43 @@ int main(int argc, char *argv[])
} }
else usage(argv[0]); else usage(argv[0]);
} }
if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP; else if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP; else if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE; else if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRANSPOSE;
if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE; else if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TRANSVERSE;
if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90; else if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180; else if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180;
if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270; else if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270;
if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY; else if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_GRAY;
if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter; else if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDCTFilter;
if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT; else if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_NOOUTPUT;
if(!strcasecmp(argv[i], "-copynone")) xformopt|=TJXOPT_COPYNONE; else if(!strcasecmp(argv[i], "-copynone")) xformopt|=TJXOPT_COPYNONE;
if(!strcasecmp(argv[i], "-benchtime") && i<argc-1) else if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
{ {
double temp=atof(argv[++i]); double temp=atof(argv[++i]);
if(temp>0.0) benchtime=temp; if(temp>0.0) benchtime=temp;
else usage(argv[0]); else usage(argv[0]);
} }
if(!strcasecmp(argv[i], "-warmup") && i<argc-1) else if(!strcasecmp(argv[i], "-warmup") && i<argc-1)
{ {
double temp=atof(argv[++i]); double temp=atof(argv[++i]);
if(temp>=0.0) warmup=temp; if(temp>=0.0) warmup=temp;
else usage(argv[0]); else usage(argv[0]);
printf("Warmup time = %.1f seconds\n\n", warmup); printf("Warmup time = %.1f seconds\n\n", warmup);
} }
if(!strcmp(argv[i], "-?")) usage(argv[0]); else if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC); else if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
if(!strcasecmp(argv[i], "-bmp")) ext="bmp"; else if(!strcasecmp(argv[i], "-yuv"))
if(!strcasecmp(argv[i], "-yuv"))
{ {
printf("Testing YUV planar encoding/decoding\n\n"); printf("Testing YUV planar encoding/decoding\n\n");
doyuv=1; doyuv=1;
} }
if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1) else if(!strcasecmp(argv[i], "-yuvpad") && i<argc-1)
{ {
int temp=atoi(argv[++i]); int temp=atoi(argv[++i]);
if(temp>=1) yuvpad=temp; if(temp>=1) yuvpad=temp;
} }
if(!strcasecmp(argv[i], "-subsamp") && i<argc-1) else if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
{ {
i++; i++;
if(toupper(argv[i][0])=='G') subsamp=TJSAMP_GRAY; if(toupper(argv[i][0])=='G') subsamp=TJSAMP_GRAY;
@@ -977,9 +975,10 @@ int main(int argc, char *argv[])
} }
} }
} }
if(!strcasecmp(argv[i], "-componly")) componly=1; else if(!strcasecmp(argv[i], "-componly")) componly=1;
if(!strcasecmp(argv[i], "-nowrite")) dowrite=0; else if(!strcasecmp(argv[i], "-nowrite")) dowrite=0;
if(!strcasecmp(argv[i], "-stoponwarning")) flags|=TJFLAG_STOPONWARNING; else if(!strcasecmp(argv[i], "-stoponwarning")) flags|=TJFLAG_STOPONWARNING;
else usage(argv[0]);
} }
} }

View File

@@ -36,10 +36,9 @@ if [ -d $OUTDIR ]; then
fi fi
mkdir -p $OUTDIR mkdir -p $OUTDIR
exec >$EXEDIR/tjbenchtest.log while [ $# -gt 0 ]; do
case "$1" in
if [ $# -gt 0 ]; then -yuv)
if [ "$1" = "-yuv" ]; then
NSARG=-nosmooth NSARG=-nosmooth
YUVARG=-yuv YUVARG=-yuv
@@ -60,12 +59,16 @@ if [ $# -gt 0 ]; then
# phenomenon is not yet fully understood but is also believed to be some sort # phenomenon is not yet fully understood but is also believed to be some sort
# of round-off error.) # of round-off error.)
IMAGES="vgl_6548_0026a.${EXT}" IMAGES="vgl_6548_0026a.${EXT}"
fi ;;
if [ "$1" = "-alloc" ]; then -alloc)
ALLOCARG=-alloc ALLOCARG=-alloc
ALLOC=1 ALLOC=1
fi ;;
fi esac
shift
done
exec >$EXEDIR/tjbenchtest$YUVARG$ALLOCARG.log
# Standard tests # Standard tests
for image in $IMAGES; do for image in $IMAGES; do

View File

@@ -33,8 +33,6 @@ if [ -d $OUTDIR ]; then
fi fi
mkdir -p $OUTDIR mkdir -p $OUTDIR
exec >$EXEDIR/tjbenchtest-java.log
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
if [ "$1" = "-yuv" ]; then if [ "$1" = "-yuv" ]; then
NSARG=-nosmooth NSARG=-nosmooth
@@ -60,6 +58,8 @@ if [ $# -gt 0 ]; then
fi fi
fi fi
exec >$EXEDIR/tjbenchtest-java$YUVARG.log
# Standard tests # Standard tests
for image in $IMAGES; do for image in $IMAGES; do

View File

@@ -21,7 +21,7 @@ runme()
IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp" IMAGES="vgl_5674_0098.bmp vgl_6434_0018a.bmp vgl_6548_0026a.bmp nightshot_iso_100.bmp"
IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages
OUTDIR=__tjexampletest_output OUTDIR=`mktemp -d /tmp/__tjexampletest_output.XXXXXX`
EXEDIR=@CMAKE_CURRENT_BINARY_DIR@ EXEDIR=@CMAKE_CURRENT_BINARY_DIR@
JAVA="@Java_JAVA_EXECUTABLE@ -cp $EXEDIR/java/turbojpeg.jar -Djava.library.path=$EXEDIR" JAVA="@Java_JAVA_EXECUTABLE@ -cp $EXEDIR/java/turbojpeg.jar -Djava.library.path=$EXEDIR"
@@ -36,23 +36,23 @@ for image in $IMAGES; do
cp $IMGDIR/$image $OUTDIR cp $IMGDIR/$image $OUTDIR
basename=`basename $image .bmp` basename=`basename $image .bmp`
$EXEDIR/cjpeg -quality 95 -dct fast -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -grayscale -outfile $OUTDIR/${basename}_GRAY_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x2 -outfile $OUTDIR/${basename}_420_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 2x1 -outfile $OUTDIR/${basename}_422_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_fast_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct fast -sample 1x1 -outfile $OUTDIR/${basename}_444_fast_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -grayscale $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -grayscale -outfile $OUTDIR/${basename}_GRAY_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_420_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x2 -outfile $OUTDIR/${basename}_420_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_422_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 2x1 -outfile $OUTDIR/${basename}_422_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
$EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 $IMGDIR/${basename}.bmp >$OUTDIR/${basename}_444_accurate_cjpeg.jpg runme $EXEDIR/cjpeg -quality 95 -dct int -sample 1x1 -outfile $OUTDIR/${basename}_444_accurate_cjpeg.jpg $IMGDIR/${basename}.bmp
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
$EXEDIR/djpeg -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_djpeg.bmp runme $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_default_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct fast -rgb -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_djpeg.bmp runme $EXEDIR/djpeg -dct fast -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_fast_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct int -rgb -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_djpeg.bmp runme $EXEDIR/djpeg -dct int -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done done
for samp in 420 422; do for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_default_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct fast -nosmooth -bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg >$OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -dct fast -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_fast_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_fast_cjpeg.jpg
$EXEDIR/djpeg -dct int -nosmooth -bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg >$OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp runme $EXEDIR/djpeg -dct int -nosmooth -bmp -outfile $OUTDIR/${basename}_${samp}_accurate_nosmooth_djpeg.bmp $OUTDIR/${basename}_${samp}_accurate_cjpeg.jpg
done done
# Compression # Compression
@@ -87,7 +87,7 @@ for image in $IMAGES; 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 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 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 $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 runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${scale}.bmp $OUTDIR/${basename}_${samp}_${scale}_djpeg.bmp
rm $OUTDIR/${basename}_${samp}_${scale}.bmp rm $OUTDIR/${basename}_${samp}_${scale}.bmp
@@ -96,25 +96,25 @@ for image in $IMAGES; do
# Transforms # Transforms
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
$EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip horizontal -trim -outfile $OUTDIR/${basename}_${samp}_hflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -flip vertical -trim -outfile $OUTDIR/${basename}_${samp}_vflip_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -transpose -trim -outfile $OUTDIR/${basename}_${samp}_transpose_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -transverse -trim -outfile $OUTDIR/${basename}_${samp}_transverse_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 90 -trim -outfile $OUTDIR/${basename}_${samp}_rot90_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 180 -trim -outfile $OUTDIR/${basename}_${samp}_rot180_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
$EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim $OUTDIR/${basename}_${samp}_fast.jpg >$OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg runme $EXEDIR/jpegtran -crop 70x60+16+16 -rotate 270 -trim -outfile $OUTDIR/${basename}_${samp}_rot270_jpegtran.jpg $OUTDIR/${basename}_${samp}_fast.jpg
done done
for xform in hflip vflip transpose transverse rot90 rot180 rot270; do for xform in hflip vflip transpose transverse rot90 rot180 rot270; do
for samp in GRAY 420 422 444; do for samp in GRAY 420 422 444; do
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 16,16,70x60 runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.jpg -$xform -crop 16,16,70x60
runme cmp $OUTDIR/${basename}_${samp}_${xform}.jpg $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg 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 $EXEDIR/djpeg -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60 runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.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 runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_${xform}.bmp rm $OUTDIR/${basename}_${samp}_${xform}.bmp
done done
for samp in 420 422; do for samp in 420 422; do
$EXEDIR/djpeg -nosmooth -rgb -bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg >$OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme $EXEDIR/djpeg -nosmooth -rgb -bmp -outfile $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.jpg
runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60 -fastupsample runme $JAVA TJExample $OUTDIR/${basename}_${samp}_fast.jpg $OUTDIR/${basename}_${samp}_${xform}.bmp -$xform -crop 16,16,70x60 -fastupsample
runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp runme cmp -i 54:54 $OUTDIR/${basename}_${samp}_${xform}.bmp $OUTDIR/${basename}_${samp}_${xform}_jpegtran.bmp
rm $OUTDIR/${basename}_${samp}_${xform}.bmp rm $OUTDIR/${basename}_${samp}_${xform}.bmp
@@ -137,7 +137,7 @@ for image in $IMAGES; do
for samp in GRAY 444 422 420; 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 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 $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 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 rm $OUTDIR/${basename}_${samp}_${xform}_${scale}.bmp

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C)2009-2014 D. R. Commander. All Rights Reserved. * Copyright (C)2009-2014, 2017 D. R. Commander. All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@@ -697,10 +697,9 @@ int main(int argc, char *argv[])
for(i=1; i<argc; i++) for(i=1; i<argc; i++)
{ {
if(!strcasecmp(argv[i], "-yuv")) doyuv=1; if(!strcasecmp(argv[i], "-yuv")) doyuv=1;
if(!strcasecmp(argv[i], "-noyuvpad")) pad=1; else if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
if(!strcasecmp(argv[i], "-alloc")) alloc=1; else if(!strcasecmp(argv[i], "-alloc")) alloc=1;
if(!strncasecmp(argv[i], "-h", 2) || !strcasecmp(argv[i], "-?")) else usage(argv[0]);
usage(argv[0]);
} }
} }
if(alloc) printf("Testing automatic buffer allocation\n"); if(alloc) printf("Testing automatic buffer allocation\n");

View File

@@ -824,8 +824,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
cinfo->image_width=width; cinfo->image_width=width;
@@ -943,8 +942,7 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
cinfo->image_width=width; cinfo->image_width=width;
@@ -1026,8 +1024,7 @@ DLLEXPORT int DLLCALL tjEncodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
for(row=0; row<ph0; row+=cinfo->max_v_samp_factor) for(row=0; row<ph0; row+=cinfo->max_v_samp_factor)
@@ -1150,8 +1147,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
cinfo->image_width=width; cinfo->image_width=width;
@@ -1213,8 +1209,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
for(row=0; row<(int)cinfo->image_height; for(row=0; row<(int)cinfo->image_height;
@@ -1453,8 +1448,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize); jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);
@@ -1505,8 +1499,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
for(i=0; i<(int)dinfo->output_height; i++) for(i=0; i<(int)dinfo->output_height; i++)
{ {
@@ -1640,8 +1633,7 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
if(pixelFormat==TJPF_CMYK) if(pixelFormat==TJPF_CMYK)
@@ -1735,8 +1727,7 @@ DLLEXPORT int DLLCALL tjDecodeYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
for(row=0; row<ph0; row+=dinfo->max_v_samp_factor) for(row=0; row<ph0; row+=dinfo->max_v_samp_factor)
@@ -1846,8 +1837,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
if(!this->headerRead) if(!this->headerRead)
@@ -1928,8 +1918,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE; if(flags&TJFLAG_FASTUPSAMPLE) dinfo->do_fancy_upsampling=FALSE;
@@ -2122,8 +2111,7 @@ DLLEXPORT int DLLCALL tjTransform(tjhandle handle,
if(setjmp(this->jerr.setjmp_buffer)) if(setjmp(this->jerr.setjmp_buffer))
{ {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */
retval=-1; retval=-1; goto bailout;
goto bailout;
} }
jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize); jpeg_mem_src_tj(dinfo, jpegBuf, jpegSize);

View File

@@ -275,7 +275,6 @@ static const int tjGreenOffset[TJ_NUMPF] = {1, 1, 1, 1, 2, 2, 0, 1, 1, 2, 2, -1}
* then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>. * then the blue component will be <tt>pixel[tjBlueOffset[TJ_BGRX]]</tt>.
*/ */
static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1}; static const int tjBlueOffset[TJ_NUMPF] = {2, 0, 2, 0, 1, 3, 0, 2, 0, 1, 3, -1};
/** /**
* Pixel size (in bytes) for a given pixel format. * Pixel size (in bytes) for a given pixel format.
*/ */
@@ -717,7 +716,7 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void);
* @param jpegQual the image quality of the generated JPEG image (1 = worst, * @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best) * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -782,7 +781,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, const unsigned char *srcBuf,
* @param jpegQual the image quality of the generated JPEG image (1 = worst, * @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best) * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -853,7 +852,7 @@ DLLEXPORT int DLLCALL tjCompressFromYUV(tjhandle handle,
* @param jpegQual the image quality of the generated JPEG image (1 = worst, * @param jpegQual the image quality of the generated JPEG image (1 = worst,
* 100 = best) * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1014,7 +1013,7 @@ DLLEXPORT int tjPlaneHeight(int componentID, int height, int subsamp);
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
* image compatible with the I420 (AKA "YUV420P") format. * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1073,7 +1072,7 @@ DLLEXPORT int DLLCALL tjEncodeYUV3(tjhandle handle,
* Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an * Video, <tt>subsamp</tt> should be set to @ref TJSAMP_420. This produces an
* image compatible with the I420 (AKA "YUV420P") format. * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1182,7 +1181,7 @@ DLLEXPORT tjscalingfactor* DLLCALL tjGetScalingFactors(int *numscalingfactors);
* @param pixelFormat pixel format of the destination image (see @ref * @param pixelFormat pixel format of the destination image (see @ref
* TJPF "Pixel formats".) * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1233,7 +1232,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle,
* block height (see #tjMCUHeight), then an intermediate buffer copy will be * block height (see #tjMCUHeight), then an intermediate buffer copy will be
* performed within TurboJPEG. * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1290,7 +1289,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUV2(tjhandle handle,
* block height (see #tjMCUHeight), then an intermediate buffer copy will be * block height (see #tjMCUHeight), then an intermediate buffer copy will be
* performed within TurboJPEG. * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1343,7 +1342,7 @@ DLLEXPORT int DLLCALL tjDecompressToYUVPlanes(tjhandle handle,
* @param pixelFormat pixel format of the destination image (see @ref TJPF * @param pixelFormat pixel format of the destination image (see @ref TJPF
* "Pixel formats".) * "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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1401,7 +1400,7 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, const unsigned char *srcBuf,
* @param pixelFormat pixel format of the destination image (see @ref TJPF * @param pixelFormat pixel format of the destination image (see @ref TJPF
* "Pixel formats".) * "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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()
@@ -1476,7 +1475,7 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void);
* which specifies the transform parameters and/or cropping region for the * which specifies the transform parameters and/or cropping region for the
* corresponding transformed output image. * 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" * "flags"
* *
* @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2() * @return 0 if successful, or -1 if an error occurred (see #tjGetErrorStr2()

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited. * Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2014-2015, D. R. Commander. * Copyright (C) 2014-2015, 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -70,7 +70,7 @@ LOCAL(void) write_colormap
static INLINE boolean is_big_endian(void) static INLINE boolean is_big_endian(void)
{ {
int test_value = 1; int test_value = 1;
if(*(char *)&test_value != 1) if (*(char *)&test_value != 1)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
@@ -104,7 +104,7 @@ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
inptr = dest->pub.buffer[0]; inptr = dest->pub.buffer[0];
outptr = image_ptr[0]; outptr = image_ptr[0];
if(cinfo->out_color_space == JCS_RGB565) { if (cinfo->out_color_space == JCS_RGB565) {
boolean big_endian = is_big_endian(); boolean big_endian = is_big_endian();
unsigned short *inptr2 = (unsigned short *)inptr; unsigned short *inptr2 = (unsigned short *)inptr;
for (col = cinfo->output_width; col > 0; col--) { for (col = cinfo->output_width; col > 0; col--) {
@@ -437,6 +437,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
sizeof(bmp_dest_struct)); sizeof(bmp_dest_struct));
dest->pub.start_output = start_output_bmp; dest->pub.start_output = start_output_bmp;
dest->pub.finish_output = finish_output_bmp; dest->pub.finish_output = finish_output_bmp;
dest->pub.calc_buffer_dimensions = NULL;
dest->is_os2 = is_os2; dest->is_os2 = is_os2;
if (cinfo->out_color_space == JCS_GRAYSCALE) { if (cinfo->out_color_space == JCS_GRAYSCALE) {
@@ -446,7 +447,7 @@ jinit_write_bmp (j_decompress_ptr cinfo, boolean is_os2)
dest->pub.put_pixel_rows = put_gray_rows; dest->pub.put_pixel_rows = put_gray_rows;
else else
dest->pub.put_pixel_rows = put_pixel_rows; dest->pub.put_pixel_rows = put_pixel_rows;
} else if(cinfo->out_color_space == JCS_RGB565 ) { } else if (cinfo->out_color_space == JCS_RGB565) {
dest->pub.put_pixel_rows = put_pixel_rows; dest->pub.put_pixel_rows = put_pixel_rows;
} else { } else {
ERREXIT(cinfo, JERR_BMP_COLORSPACE); ERREXIT(cinfo, JERR_BMP_COLORSPACE);

13
wrgif.c
View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015, D. R. Commander. * Copyright (C) 2015, 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -355,6 +355,16 @@ finish_output_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
} }
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_gif (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
}
/* /*
* The module selection routine for GIF format output. * The module selection routine for GIF format output.
*/ */
@@ -372,6 +382,7 @@ jinit_write_gif (j_decompress_ptr cinfo)
dest->pub.start_output = start_output_gif; dest->pub.start_output = start_output_gif;
dest->pub.put_pixel_rows = put_pixel_rows; dest->pub.put_pixel_rows = put_pixel_rows;
dest->pub.finish_output = finish_output_gif; dest->pub.finish_output = finish_output_gif;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_gif;
if (cinfo->out_color_space != JCS_GRAYSCALE && if (cinfo->out_color_space != JCS_GRAYSCALE &&
cinfo->out_color_space != JCS_RGB) cinfo->out_color_space != JCS_RGB)

38
wrppm.c
View File

@@ -4,8 +4,8 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding. * Modified 2009 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only code and * libjpeg-turbo Modifications:
* information relevant to libjpeg-turbo. * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -20,7 +20,6 @@
*/ */
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "wrppm.h"
#ifdef PPM_SUPPORTED #ifdef PPM_SUPPORTED
@@ -63,6 +62,21 @@
*/ */
/* Private version of data destination object */
typedef struct {
struct djpeg_dest_struct pub; /* public fields */
/* Usually these two pointers point to the same place: */
char *iobuffer; /* fwrite's I/O buffer */
JSAMPROW pixrow; /* decompressor output buffer */
size_t buffer_width; /* width of I/O buffer */
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
} ppm_dest_struct;
typedef ppm_dest_struct *ppm_dest_ptr;
/* /*
* Write some pixel data. * Write some pixel data.
* In this module rows_supplied will always be 1. * In this module rows_supplied will always be 1.
@@ -196,6 +210,20 @@ finish_output_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
} }
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_ppm (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
ppm_dest_ptr dest = (ppm_dest_ptr) dinfo;
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components;
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
}
/* /*
* The module selection routine for PPM format output. * The module selection routine for PPM format output.
*/ */
@@ -211,13 +239,13 @@ jinit_write_ppm (j_decompress_ptr cinfo)
sizeof(ppm_dest_struct)); sizeof(ppm_dest_struct));
dest->pub.start_output = start_output_ppm; dest->pub.start_output = start_output_ppm;
dest->pub.finish_output = finish_output_ppm; dest->pub.finish_output = finish_output_ppm;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_ppm;
/* Calculate output image dimensions so we can allocate space */ /* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo); jpeg_calc_output_dimensions(cinfo);
/* Create physical I/O buffer */ /* Create physical I/O buffer */
dest->samples_per_row = cinfo->output_width * cinfo->out_color_components; dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
dest->buffer_width = dest->samples_per_row * (BYTESPERSAMPLE * sizeof(char));
dest->iobuffer = (char *) (*cinfo->mem->alloc_small) dest->iobuffer = (char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width); ((j_common_ptr) cinfo, JPOOL_IMAGE, dest->buffer_width);

26
wrppm.h
View File

@@ -1,26 +0,0 @@
/*
* wrppm.h
*
* This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994, Thomas G. Lane.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*/
#ifdef PPM_SUPPORTED
/* Private version of data destination object */
typedef struct {
struct djpeg_dest_struct pub; /* public fields */
/* Usually these two pointers point to the same place: */
char *iobuffer; /* fwrite's I/O buffer */
JSAMPROW pixrow; /* decompressor output buffer */
size_t buffer_width; /* width of I/O buffer */
JDIMENSION samples_per_row; /* JSAMPLEs per output row */
} ppm_dest_struct;
typedef ppm_dest_struct *ppm_dest_ptr;
#endif

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and * libjpeg-turbo Modifications:
* information relevant to libjpeg-turbo. * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -286,6 +286,7 @@ jinit_write_rle (j_decompress_ptr cinfo)
sizeof(rle_dest_struct)); sizeof(rle_dest_struct));
dest->pub.start_output = start_output_rle; dest->pub.start_output = start_output_rle;
dest->pub.finish_output = finish_output_rle; dest->pub.finish_output = finish_output_rle;
dest->pub.calc_buffer_dimensions = NULL;
/* Calculate output image dimensions so we can allocate space */ /* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo); jpeg_calc_output_dimensions(cinfo);

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code and * libjpeg-turbo Modifications:
* information relevant to libjpeg-turbo. * Copyright (C) 2017, D. R. Commander.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
* *
@@ -211,6 +211,19 @@ finish_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
} }
/*
* Re-calculate buffer dimensions based on output dimensions.
*/
METHODDEF(void)
calc_buffer_dimensions_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
{
tga_dest_ptr dest = (tga_dest_ptr) dinfo;
dest->buffer_width = cinfo->output_width * cinfo->output_components;
}
/* /*
* The module selection routine for Targa format output. * The module selection routine for Targa format output.
*/ */
@@ -226,12 +239,13 @@ jinit_write_targa (j_decompress_ptr cinfo)
sizeof(tga_dest_struct)); sizeof(tga_dest_struct));
dest->pub.start_output = start_output_tga; dest->pub.start_output = start_output_tga;
dest->pub.finish_output = finish_output_tga; dest->pub.finish_output = finish_output_tga;
dest->pub.calc_buffer_dimensions = calc_buffer_dimensions_tga;
/* Calculate output image dimensions so we can allocate space */ /* Calculate output image dimensions so we can allocate space */
jpeg_calc_output_dimensions(cinfo); jpeg_calc_output_dimensions(cinfo);
/* Create I/O buffer. */ /* Create I/O buffer. */
dest->buffer_width = cinfo->output_width * cinfo->output_components; dest->pub.calc_buffer_dimensions (cinfo, (djpeg_dest_ptr) dest);
dest->iobuffer = (char *) dest->iobuffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (dest->buffer_width * sizeof(char))); (size_t) (dest->buffer_width * sizeof(char)));