Don't allow 12-bit JPEG support to be disabled

In libjpeg-turbo 2.1.x and prior, the WITH_12BIT CMake variable was used
to enable 12-bit JPEG support at compile time, because the libjpeg API
library could not handle multiple JPEG data precisions at run time.  The
initial approach to handling multiple JPEG data precisions at run time
(7fec5074f9) created a whole new API,
library, and applications for 12-bit data precision, so it made sense to
repurpose WITH_12BIT to allow 12-bit data precision to be disabled.
e8b40f3c2b made it so that the libjpeg API
library can handle multiple JPEG data precisions at run time via a
handful of straightforward API extensions.  Referring to
6c2bc901e2, it hasn't been possible to
build libjpeg-turbo with both forward and backward libjpeg API/ABI
compatibility since libjpeg-turbo 1.4.x.  Thus, whereas we retain full
backward API/ABI compatibility with libjpeg v6b-v8, forward libjpeg
API/ABI compatibility ceased being realistic years ago, so it no longer
makes sense to provide compile-time options that give a false sense of
forward API/ABI compatibility by allowing some (but not all) of our
libjpeg API extensions to be disabled.  Such options are difficult to
maintain and clutter the code with #ifdefs.
This commit is contained in:
DRC
2022-11-13 13:00:26 -06:00
parent 9ca7919a40
commit b5a9ef64ea
21 changed files with 113 additions and 338 deletions

View File

@@ -109,24 +109,6 @@ jobs:
cmake -DFLOATTEST8=no-fp-contract ..
JSIMD_FORCENONE=1 make test
popd
linux-no12bit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Build
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
mkdir build
pushd build
cmake -G"Unix Makefiles" -DWITH_12BIT=0 \
-DCMAKE_C_FLAGS='--std=gnu90 -Wall -Werror -Wextra -Wpedantic -pedantic-errors -Wdouble-promotion -Wformat-overflow=2 -Wformat-security -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k -Wmissing-include-dirs -Wshift-overflow=2 -Wswitch-bool -Wno-unused-parameter -Wuninitialized -Wstrict-overflow=2 -Wstringop-overflow=4 -Wstringop-truncation -Wduplicated-branches -Wduplicated-cond -Wdeclaration-after-statement -Wshadow -Wunsafe-loop-optimizations -Wundef -Wcast-align -Wno-clobbered -Wjump-misses-init -Wno-sign-compare -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wno-long-long -Wdisabled-optimization -Wno-overlength-strings' \
..
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
make -j$NUMCPUS --load-average=$NUMCPUS
make test
popd
linux-jpeg7-x32:
runs-on: ubuntu-latest
steps:

View File

@@ -196,8 +196,6 @@ option(ENABLE_STATIC "Build static libraries" TRUE)
boolean_number(ENABLE_STATIC)
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
boolean_number(REQUIRE_SIMD)
option(WITH_12BIT "Include 12-bit JPEG support" TRUE)
boolean_number(WITH_12BIT)
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
boolean_number(WITH_ARITH_DEC)
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
@@ -252,8 +250,6 @@ if(WITH_JPEG8 OR WITH_JPEG7)
set(WITH_ARITH_DEC 1)
endif()
report_option(WITH_12BIT "12-bit JPEG support")
if(WITH_ARITH_DEC)
set(D_ARITH_CODING_SUPPORTED 1)
endif()
@@ -283,16 +279,9 @@ endif()
# 1: + Partial image decompression functions (libjpeg-turbo 1.5.x)
# 2: + ICC functions (libjpeg-turbo 2.0.x)
# 3: + 12-bit-per-component functions (libjpeg-turbo 2.2.x)
if(WITH_12BIT)
set(SO_AGE 3)
if(NOT WITH_JPEG8)
set(SO_AGE 4)
endif()
else()
set(SO_AGE 2)
if(NOT WITH_JPEG8)
set(SO_AGE 3)
endif()
set(SO_AGE 3)
if(NOT WITH_JPEG8)
set(SO_AGE 4)
endif()
if(WITH_JPEG8)
@@ -566,16 +555,13 @@ if(WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
endif()
if(WITH_12BIT)
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(jpeg12 OBJECT jcapistd.c jccoefct.c jccolor.c jcdctmgr.c
jcmainct.c jcprepct.c jcsample.c jdapistd.c jdcoefct.c jdcolor.c jddctmgr.c
jdmainct.c jdmerge.c jdpostct.c jdsample.c jfdctfst.c jfdctint.c jidctflt.c
jidctfst.c jidctint.c jidctred.c jquant1.c jquant2.c jutils.c)
set_property(TARGET jpeg12 PROPERTY COMPILE_FLAGS "-DBITS_IN_JSAMPLE=12")
set(JPEG12_OBJS $<TARGET_OBJECTS:jpeg12>)
endif()
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(jpeg12 OBJECT jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jcmainct.c
jcprepct.c jcsample.c jdapistd.c jdcoefct.c jdcolor.c jddctmgr.c jdmainct.c
jdmerge.c jdpostct.c jdsample.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
jidctint.c jidctred.c jquant1.c jquant2.c jutils.c)
set_property(TARGET jpeg12 PROPERTY COMPILE_FLAGS "-DBITS_IN_JSAMPLE=12")
if(WITH_SIMD)
add_subdirectory(simd)
@@ -609,7 +595,7 @@ endif()
if(ENABLE_STATIC)
add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS}
${SIMD_OBJS} ${JPEG12_OBJS})
${SIMD_OBJS} $<TARGET_OBJECTS:jpeg12>)
if(NOT MSVC)
set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
endif()
@@ -619,7 +605,7 @@ if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
set(TURBOJPEG_SOURCES ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS} ${SIMD_OBJS}
turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c
wrbmp.c wrppm.c ${JPEG12_OBJS})
wrbmp.c wrppm.c $<TARGET_OBJECTS:jpeg12>)
set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile)
if(WITH_JAVA)
set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
@@ -671,7 +657,7 @@ if(WITH_TURBOJPEG)
if(ENABLE_STATIC)
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_TARGET_OBJECTS}
${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c
rdppm.c wrbmp.c wrppm.c ${JPEG12_OBJS})
rdppm.c wrbmp.c wrppm.c $<TARGET_OBJECTS:jpeg12>)
set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
if(NOT MSVC)
@@ -697,30 +683,24 @@ set(CDJPEG_COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
if(ENABLE_STATIC)
if(WITH_12BIT)
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(cjpeg12-static OBJECT rdgif.c rdppm.c)
set_property(TARGET cjpeg12-static PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
set(CJPEG12_OBJS $<TARGET_OBJECTS:cjpeg12-static>)
endif()
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(cjpeg12-static OBJECT rdgif.c rdppm.c)
set_property(TARGET cjpeg12-static PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c
rdswitch.c rdtarga.c ${CJPEG12_OBJS})
rdswitch.c rdtarga.c $<TARGET_OBJECTS:cjpeg12-static>)
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
${CDJPEG_COMPILE_FLAGS})
target_link_libraries(cjpeg-static jpeg-static)
if(WITH_12BIT)
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(djpeg12-static OBJECT rdcolmap.c wrgif.c wrppm.c)
set_property(TARGET djpeg12-static PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
set(DJPEG12_OBJS $<TARGET_OBJECTS:djpeg12-static>)
endif()
# Compile a separate version of these source files with 12-bit data
# precision.
add_library(djpeg12-static OBJECT rdcolmap.c wrgif.c wrppm.c)
set_property(TARGET djpeg12-static PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c
wrgif.c wrppm.c wrtarga.c ${DJPEG12_OBJS})
wrgif.c wrppm.c wrtarga.c $<TARGET_OBJECTS:djpeg12-static>)
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
${CDJPEG_COMPILE_FLAGS})
target_link_libraries(djpeg-static jpeg-static)
@@ -793,11 +773,6 @@ if(ENABLE_STATIC)
set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
endif()
set(TEST_SAMPLE_BITS 8)
if(WITH_12BIT)
set(TEST_SAMPLE_BITS ${TEST_SAMPLE_BITS} 12)
endif()
set(TESTIMAGES ${CMAKE_CURRENT_SOURCE_DIR}/testimages)
set(MD5CMP ${CMAKE_CURRENT_BINARY_DIR}/md5/md5cmp)
if(CMAKE_CROSSCOMPILING)
@@ -870,33 +845,31 @@ if(FLOATTEST8)
endif()
endif()
if(WITH_12BIT)
if(CPU_TYPE STREQUAL "x86_64")
if(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST12 no-fp-contract)
elseif(NOT CPU_TYPE STREQUAL "i386")
if((CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64") AND
NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
set(DEFAULT_FLOATTEST12 fp-contract)
else()
set(DEFAULT_FLOATTEST12 no-fp-contract)
elseif(NOT CPU_TYPE STREQUAL "i386")
if((CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64") AND
NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT MSVC)
set(DEFAULT_FLOATTEST12 fp-contract)
else()
set(DEFAULT_FLOATTEST12 no-fp-contract)
endif()
endif()
endif()
set(FLOATTEST12 ${DEFAULT_FLOATTEST12} CACHE STRING
"The type of floating point math used by the 12-bit-per-sample floating point DCT/IDCT algorithms. This tells the testing system which numerical results it should expect from those tests. [sse = libjpeg-turbo x86/x86-64 SIMD extensions, no-fp-contract = generic FPU with floating point expression contraction disabled, fp-contract = generic FPU with floating point expression contraction enabled, 387 = 387 FPU, msvc = 32-bit Visual Studio] (default = ${DEFAULT_FLOATTEST12})")
message(STATUS "FLOATTEST12 = ${FLOATTEST12}")
set(FLOATTEST12 ${DEFAULT_FLOATTEST12} CACHE STRING
"The type of floating point math used by the 12-bit-per-sample floating point DCT/IDCT algorithms. This tells the testing system which numerical results it should expect from those tests. [sse = libjpeg-turbo x86/x86-64 SIMD extensions, no-fp-contract = generic FPU with floating point expression contraction disabled, fp-contract = generic FPU with floating point expression contraction enabled, 387 = 387 FPU, msvc = 32-bit Visual Studio] (default = ${DEFAULT_FLOATTEST12})")
message(STATUS "FLOATTEST12 = ${FLOATTEST12}")
if(FLOATTEST12)
string(TOUPPER ${FLOATTEST12} FLOATTEST12_UC)
string(REGEX REPLACE "-" "_" FLOATTEST12_UC ${FLOATTEST12_UC})
string(TOLOWER ${FLOATTEST12} FLOATTEST12)
if(NOT FLOATTEST12 STREQUAL "sse" AND
NOT FLOATTEST12 STREQUAL "no-fp-contract" AND
NOT FLOATTEST12 STREQUAL "fp-contract" AND
NOT FLOATTEST12 STREQUAL "387" AND
NOT FLOATTEST12 STREQUAL "msvc")
message(FATAL_ERROR "\"${FLOATTEST12}\" is not a valid value for FLOATTEST12.")
endif()
if(FLOATTEST12)
string(TOUPPER ${FLOATTEST12} FLOATTEST12_UC)
string(REGEX REPLACE "-" "_" FLOATTEST12_UC ${FLOATTEST12_UC})
string(TOLOWER ${FLOATTEST12} FLOATTEST12)
if(NOT FLOATTEST12 STREQUAL "sse" AND
NOT FLOATTEST12 STREQUAL "no-fp-contract" AND
NOT FLOATTEST12 STREQUAL "fp-contract" AND
NOT FLOATTEST12 STREQUAL "387" AND
NOT FLOATTEST12 STREQUAL "msvc")
message(FATAL_ERROR "\"${FLOATTEST12}\" is not a valid value for FLOATTEST12.")
endif()
endif()
@@ -1021,7 +994,7 @@ foreach(libtype ${TEST_LIBTYPES})
endif()
endmacro()
foreach(sample_bits ${TEST_SAMPLE_BITS})
foreach(sample_bits 8 12)
if(sample_bits EQUAL 12)
set(cjpeg cjpeg12)

View File

@@ -20,8 +20,7 @@ the creation of 12-bit-per-component JPEG images. (djpeg and jpegtran handle
12-bit-per-component JPEG images automatically.)
Refer to [libjpeg.txt](libjpeg.txt) and [usage.txt](usage.txt) for more
details. The `WITH_12BIT` CMake variable can be used to disable
12-bit-per-component JPEG support.
details.
2. Significantly sped up the computation of optimal Huffman tables. This
speeds up the compression of tiny images by as much as 2x and provides a

View File

@@ -35,9 +35,7 @@ struct cjpeg_source_struct {
FILE *input_file;
JSAMPARRAY buffer;
#ifdef WITH_12BIT
J12SAMPARRAY buffer12;
#endif
JDIMENSION buffer_height;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
JDIMENSION max_pixels;
@@ -78,9 +76,7 @@ struct djpeg_dest_struct {
* height is buffer_height.
*/
JSAMPARRAY buffer;
#ifdef WITH_12BIT
J12SAMPARRAY buffer12;
#endif
JDIMENSION buffer_height;
};
@@ -114,18 +110,14 @@ EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
boolean use_inversion_array);
EXTERN(cjpeg_source_ptr) jinit_read_gif(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
#ifdef WITH_12BIT
EXTERN(cjpeg_source_ptr) j12init_read_gif(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_gif(j_decompress_ptr cinfo, boolean is_lzw);
EXTERN(djpeg_dest_ptr) j12init_write_gif(j_decompress_ptr cinfo,
boolean is_lzw);
#endif
EXTERN(cjpeg_source_ptr) jinit_read_ppm(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
#ifdef WITH_12BIT
EXTERN(cjpeg_source_ptr) j12init_read_ppm(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_ppm(j_decompress_ptr cinfo);
EXTERN(djpeg_dest_ptr) j12init_write_ppm(j_decompress_ptr cinfo);
#endif
EXTERN(cjpeg_source_ptr) jinit_read_targa(j_compress_ptr cinfo);
EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
@@ -142,9 +134,7 @@ EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
/* djpeg support routines (in rdcolmap.c) */
EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
#ifdef WITH_12BIT
EXTERN(void) read_color_map_12(j_decompress_ptr cinfo, FILE *infile);
#endif
/* common support routines (in cdjpeg.c) */

View File

@@ -103,20 +103,16 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
#endif
#ifdef GIF_SUPPORTED
case 'G':
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
return j12init_read_gif(cinfo);
else
#endif
return jinit_read_gif(cinfo);
#endif
#ifdef PPM_SUPPORTED
case 'P':
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
return j12init_read_ppm(cinfo);
else
#endif
return jinit_read_ppm(cinfo);
#endif
#ifdef TARGA_SUPPORTED
@@ -743,15 +739,12 @@ main(int argc, char **argv)
jpeg_write_icc_profile(&cinfo, icc_profile, (unsigned int)icc_len);
/* Process data */
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
while (cinfo.next_scanline < cinfo.image_height) {
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
(void)jpeg12_write_scanlines(&cinfo, src_mgr->buffer12, num_scanlines);
}
} else
#endif
{
} else {
while (cinfo.next_scanline < cinfo.image_height) {
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
(void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);

21
djpeg.c
View File

@@ -660,11 +660,9 @@ main(int argc, char **argv)
#endif
#ifdef GIF_SUPPORTED
case FMT_GIF:
#ifdef WITH_12BIT
if (cinfo.data_precision == 12)
dest_mgr = j12init_write_gif(&cinfo, TRUE);
else
#endif
dest_mgr = jinit_write_gif(&cinfo, TRUE);
break;
case FMT_GIF0:
@@ -673,11 +671,9 @@ main(int argc, char **argv)
#endif
#ifdef PPM_SUPPORTED
case FMT_PPM:
#ifdef WITH_12BIT
if (cinfo.data_precision == 12)
dest_mgr = j12init_write_ppm(&cinfo);
else
#endif
dest_mgr = jinit_write_ppm(&cinfo);
break;
#endif
@@ -717,7 +713,6 @@ main(int argc, char **argv)
(*dest_mgr->start_output) (&cinfo, dest_mgr);
cinfo.output_height = tmp;
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
/* Process data */
while (cinfo.output_scanline < skip_start) {
@@ -736,9 +731,7 @@ main(int argc, char **argv)
dest_mgr->buffer_height);
(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
}
} else
#endif
{
} else {
/* Process data */
while (cinfo.output_scanline < skip_start) {
num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
@@ -772,11 +765,9 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}
#ifdef WITH_12BIT
if (cinfo.data_precision == 12)
jpeg12_crop_scanline(&cinfo, &crop_x, &crop_width);
else
#endif
jpeg_crop_scanline(&cinfo, &crop_x, &crop_width);
if (dest_mgr->calc_buffer_dimensions)
(*dest_mgr->calc_buffer_dimensions) (&cinfo, dest_mgr);
@@ -791,7 +782,6 @@ main(int argc, char **argv)
(*dest_mgr->start_output) (&cinfo, dest_mgr);
cinfo.output_height = tmp;
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
/* Process data */
if ((tmp = jpeg12_skip_scanlines(&cinfo, crop_y)) != crop_y) {
@@ -812,9 +802,7 @@ main(int argc, char **argv)
progname, tmp, cinfo.output_height - crop_y - crop_height);
exit(EXIT_FAILURE);
}
} else
#endif
{
} else {
/* Process data */
if ((tmp = jpeg_skip_scanlines(&cinfo, crop_y)) != crop_y) {
fprintf(stderr, "%s: jpeg_skip_scanlines() returned %u rather than %u\n",
@@ -841,7 +829,6 @@ main(int argc, char **argv)
/* Write output file header */
(*dest_mgr->start_output) (&cinfo, dest_mgr);
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
/* Process data */
while (cinfo.output_scanline < cinfo.output_height) {
@@ -849,9 +836,7 @@ main(int argc, char **argv)
dest_mgr->buffer_height);
(*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
}
} else
#endif
{
} else {
/* Process data */
while (cinfo.output_scanline < cinfo.output_height) {
num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,

View File

@@ -114,12 +114,10 @@ write_JPEG_file(char *filename, int quality, int data_precision)
JSAMPARRAY image_buffer = NULL;
/* Points to large array of R,G,B-order data */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
#ifdef WITH_12BIT
J12SAMPARRAY image_buffer12 = NULL;
/* Points to large array of R,G,B-order 12-bit
data */
J12SAMPROW row_pointer12[1]; /* pointer to J12SAMPLE row[s] */
#endif
int row_stride; /* physical row width in image buffer */
int row, col;
@@ -183,7 +181,6 @@ write_JPEG_file(char *filename, int quality, int data_precision)
* sample array and initialize it for each successive scanline written in the
* scanline loop below.
*/
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
image_buffer12 = (J12SAMPARRAY)(*cinfo.mem->alloc_sarray)
((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, HEIGHT);
@@ -200,9 +197,7 @@ write_JPEG_file(char *filename, int quality, int data_precision)
col * (MAXJ12SAMPLE + 1) / WIDTH) % (MAXJ12SAMPLE + 1);
}
}
} else
#endif
{
} else {
image_buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, HEIGHT);
@@ -227,7 +222,6 @@ write_JPEG_file(char *filename, int quality, int data_precision)
* To keep things simple, we pass one scanline per call; you can pass
* more if you wish, though.
*/
#ifdef WITH_12BIT
if (cinfo.data_precision == 12) {
while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg12_write_scanlines expects an array of pointers to scanlines.
@@ -237,9 +231,7 @@ write_JPEG_file(char *filename, int quality, int data_precision)
row_pointer12[0] = image_buffer12[cinfo.next_scanline];
(void)jpeg12_write_scanlines(&cinfo, row_pointer12, 1);
}
} else
#endif
{
} else {
while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg_write_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could pass
@@ -403,10 +395,8 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
FILE *infile; /* source file */
FILE *outfile; /* output file */
JSAMPARRAY buffer; /* Output row buffer */
#ifdef WITH_12BIT
J12SAMPARRAY buffer12; /* 12-bit output row buffer */
int col;
#endif
int row_stride; /* physical row width in output buffer */
/* In this example we want to open the input and output files before doing
@@ -459,12 +449,8 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
*/
/* emit header for raw PPM format */
#ifdef WITH_12BIT
fprintf(outfile, "P6\n%d %d\n%d\n", WIDTH, HEIGHT,
cinfo->data_precision == 12 ? MAXJ12SAMPLE : MAXJSAMPLE);
#else
fprintf(outfile, "P6\n%d %d\n%d\n", WIDTH, HEIGHT, MAXJSAMPLE);
#endif
/* Step 4: set parameters for decompression */
@@ -488,12 +474,10 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
/* Samples per row in output buffer */
row_stride = cinfo->output_width * cinfo->output_components;
/* Make a one-row-high sample array that will go away when done with image */
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
buffer12 = (J12SAMPARRAY)(*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE, row_stride, 1);
else
#endif
buffer = (*cinfo->mem->alloc_sarray)
((j_common_ptr)cinfo, JPOOL_IMAGE, row_stride, 1);
@@ -503,7 +487,6 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
/* Here we use the library's state variable cinfo->output_scanline as the
* loop counter, so that we don't have to keep track ourselves.
*/
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
while (cinfo->output_scanline < cinfo->output_height) {
/* jpeg12_read_scanlines expects an array of pointers to scanlines.
@@ -517,9 +500,7 @@ do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *infilename,
((buffer12[0][col] >> 8) & 0xFF);
fwrite(buffer12[0], 1, row_stride * sizeof(J12SAMPLE), outfile);
}
} else
#endif
{
} else {
while (cinfo->output_scanline < cinfo->output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could ask for
@@ -593,10 +574,8 @@ usage(const char *progname)
fprintf(stderr, " %s decompress inputfile[.jpg] outputfile[.ppm]\n",
progname);
fprintf(stderr, "Switches (names may be abbreviated):\n");
#ifdef WITH_12BIT
fprintf(stderr, " -precision N Create JPEG file with N-bit data precision\n");
fprintf(stderr, " (N is 8 or 12; default is 8)\n");
#endif
fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is most useful range,\n");
fprintf(stderr, " default is 75)\n");
@@ -637,7 +616,6 @@ main(int argc, char **argv)
}
arg++; /* advance past switch marker character */
#ifdef WITH_12BIT
if (!strncasecmp(arg, "p", 1)) {
/* Set data precision. */
if (++argn >= argc) /* advance to next argument */
@@ -645,9 +623,7 @@ main(int argc, char **argv)
if (sscanf(argv[argn], "%d", &data_precision) < 1 ||
(data_precision != 8 && data_precision != 12))
usage(argv[0]);
} else
#endif
if (!strncasecmp(arg, "q", 1)) {
} else if (!strncasecmp(arg, "q", 1)) {
/* Quality rating (quantization table scaling factor). */
if (++argn >= argc) /* advance to next argument */
usage(argv[0]);

View File

@@ -33,16 +33,14 @@ target_link_libraries(cjpeg_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY} jpeg-static)
install(TARGETS cjpeg_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
${FUZZ_BINDIR})
if(WITH_12BIT)
add_executable(cjpeg12_fuzzer${FUZZER_SUFFIX} cjpeg12.cc ../cdjpeg.c
../rdbmp.c ../rdgif.c ../rdppm.c ../rdswitch.c ../rdtarga.c)
set_property(TARGET cjpeg12_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
${COMPILE_FLAGS})
target_link_libraries(cjpeg12_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
jpeg-static)
install(TARGETS cjpeg12_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
${FUZZ_BINDIR})
endif()
add_executable(cjpeg12_fuzzer${FUZZER_SUFFIX} cjpeg12.cc ../cdjpeg.c ../rdbmp.c
../rdgif.c ../rdppm.c ../rdswitch.c ../rdtarga.c)
set_property(TARGET cjpeg12_fuzzer${FUZZER_SUFFIX} PROPERTY COMPILE_FLAGS
${COMPILE_FLAGS})
target_link_libraries(cjpeg12_fuzzer${FUZZER_SUFFIX} ${FUZZ_LIBRARY}
jpeg-static)
install(TARGETS cjpeg12_fuzzer${FUZZER_SUFFIX} RUNTIME DESTINATION
${FUZZ_BINDIR})
macro(add_fuzz_target target source_file)
add_executable(${target}_fuzzer${FUZZER_SUFFIX} ${source_file})

View File

@@ -185,13 +185,10 @@ jpeg_finish_compress(j_compress_ptr cinfo)
/* We bypass the main controller and invoke coef controller directly;
* all work is being done from the coefficient buffer.
*/
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
if (!(*cinfo->coef->compress_data_12) (cinfo, (J12SAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
} else
#endif
{
} else {
if (!(*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE)NULL))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
}

View File

@@ -36,29 +36,24 @@ jinit_compress_master(j_compress_ptr cinfo)
/* Initialize master control (includes parameter checking/processing) */
jinit_c_master_control(cinfo, FALSE /* full compression */);
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
/* Preprocessing */
if (!cinfo->raw_data_in) {
/* Preprocessing */
if (!cinfo->raw_data_in) {
if (cinfo->data_precision == 12) {
j12init_color_converter(cinfo);
j12init_downsampler(cinfo);
j12init_c_prep_controller(cinfo,
FALSE /* never need full buffer here */);
}
/* Forward DCT */
j12init_forward_dct(cinfo);
} else
#endif
{
/* Preprocessing */
if (!cinfo->raw_data_in) {
} else {
jinit_color_converter(cinfo);
jinit_downsampler(cinfo);
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
}
/* Forward DCT */
jinit_forward_dct(cinfo);
}
/* Forward DCT */
if (cinfo->data_precision == 12)
j12init_forward_dct(cinfo);
else
jinit_forward_dct(cinfo);
/* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) {
#ifdef C_ARITH_CODING_SUPPORTED
@@ -78,14 +73,11 @@ jinit_compress_master(j_compress_ptr cinfo)
}
/* Need a full-image coefficient buffer in any multi-pass mode. */
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
j12init_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
j12init_c_main_controller(cinfo, FALSE /* never need full buffer here */);
} else
#endif
{
} else {
jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
cinfo->optimize_coding));
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);

View File

@@ -18,9 +18,6 @@
/* Use accelerated SIMD routines when using 8-bit samples */
#cmakedefine WITH_SIMD 1
/* Include 12-bit JPEG support */
#cmakedefine WITH_12BIT 1
#ifdef _WIN32
#undef RIGHT_SHIFT_IS_UNSIGNED

View File

@@ -364,16 +364,12 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
}
#ifdef WITH_12BIT
METHODDEF(boolean)
compress_output_12(j_compress_ptr cinfo, J12SAMPIMAGE input_buf)
{
return compress_output(cinfo, (JSAMPIMAGE)input_buf);
}
#endif
/*
* Initialize coefficient buffer controller.
@@ -397,9 +393,7 @@ transencode_coef_controller(j_compress_ptr cinfo,
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
coef->pub.start_pass = start_pass_coef;
coef->pub.compress_data = compress_output;
#ifdef WITH_12BIT
coef->pub.compress_data_12 = compress_output_12;
#endif
/* Save pointer to virtual arrays */
coef->whole_image = coef_arrays;

View File

@@ -123,13 +123,11 @@ output_pass_setup(j_decompress_ptr cinfo)
}
/* Process some data */
last_scanline = cinfo->output_scanline;
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
(*cinfo->main->process_data_12) (cinfo, (J12SAMPARRAY)NULL,
&cinfo->output_scanline,
(JDIMENSION)0);
else
#endif
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY)NULL,
&cinfo->output_scanline, (JDIMENSION)0);
if (cinfo->output_scanline == last_scanline)

View File

@@ -409,12 +409,9 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
/* Allocate and fill in the sample_range_limit table */
{
JSAMPLE *table;
#ifdef WITH_12BIT
J12SAMPLE *table12;
#endif
int i;
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
table12 = (J12SAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
@@ -438,9 +435,7 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
(2 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE) * sizeof(J12SAMPLE));
memcpy(table12 + (4 * (MAXJ12SAMPLE + 1) - CENTERJ12SAMPLE),
cinfo->sample_range_limit, CENTERJ12SAMPLE * sizeof(J12SAMPLE));
} else
#endif
{
} else {
table = (JSAMPLE *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(5 * (MAXJSAMPLE + 1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
@@ -526,11 +521,9 @@ master_selection(j_decompress_ptr cinfo)
if (cinfo->enable_1pass_quant) {
#ifdef QUANT_1PASS_SUPPORTED
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
j12init_1pass_quantizer(cinfo);
else
#endif
jinit_1pass_quantizer(cinfo);
master->quantizer_1pass = cinfo->cquantize;
#else
@@ -541,11 +534,9 @@ master_selection(j_decompress_ptr cinfo)
/* We use the 2-pass code to map to external colormaps. */
if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
#ifdef QUANT_2PASS_SUPPORTED
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
j12init_2pass_quantizer(cinfo);
else
#endif
jinit_2pass_quantizer(cinfo);
master->quantizer_2pass = cinfo->cquantize;
#else
@@ -557,7 +548,6 @@ master_selection(j_decompress_ptr cinfo)
*/
}
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
/* Post-processing: in particular, color conversion first */
if (!cinfo->raw_data_out) {
@@ -575,9 +565,7 @@ master_selection(j_decompress_ptr cinfo)
}
/* Inverse DCT */
j12init_inverse_dct(cinfo);
} else
#endif
{
} else {
/* Post-processing: in particular, color conversion first */
if (!cinfo->raw_data_out) {
if (master->using_merged_upsample) {
@@ -615,16 +603,13 @@ master_selection(j_decompress_ptr cinfo)
/* Initialize principal buffer controllers. */
use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
#ifdef WITH_12BIT
if (cinfo->data_precision == 12) {
j12init_d_coef_controller(cinfo, use_c_buffer);
if (!cinfo->raw_data_out)
j12init_d_main_controller(cinfo,
FALSE /* never need full buffer here */);
} else
#endif
{
} else {
jinit_d_coef_controller(cinfo, use_c_buffer);
if (!cinfo->raw_data_out)

View File

@@ -127,11 +127,9 @@ transdecode_master_selection(j_decompress_ptr cinfo)
}
/* Always get a full-image coefficient buffer. */
#ifdef WITH_12BIT
if (cinfo->data_precision == 12)
j12init_d_coef_controller(cinfo, TRUE);
else
#endif
jinit_d_coef_controller(cinfo, TRUE);
/* We can now tell the memory manager to allocate virtual arrays. */

View File

@@ -439,7 +439,6 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
JSAMPROW workspace;
JDIMENSION rowsperchunk, currow, i;
long ltemp;
#ifdef WITH_12BIT
J12SAMPARRAY result12;
J12SAMPROW workspace12;
int data_precision = cinfo->is_decompressor ?
@@ -447,9 +446,6 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 12 ?
sizeof(J12SAMPLE) : sizeof(JSAMPLE);
#else
size_t sample_size = sizeof(JSAMPLE);
#endif
/* Make sure each row is properly aligned */
if ((ALIGN_SIZE % sample_size) != 0)
@@ -474,7 +470,6 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
rowsperchunk = numrows;
mem->last_rowsperchunk = rowsperchunk;
#ifdef WITH_12BIT
if (data_precision == 12) {
/* Get space for row pointers (small object) */
result12 = (J12SAMPARRAY)alloc_small(cinfo, pool_id,
@@ -494,9 +489,7 @@ alloc_sarray(j_common_ptr cinfo, int pool_id, JDIMENSION samplesperrow,
}
return (JSAMPARRAY)result12;
} else
#endif
{
} else {
/* Get space for row pointers (small object) */
result = (JSAMPARRAY)alloc_small(cinfo, pool_id,
(size_t)(numrows * sizeof(JSAMPROW)));
@@ -676,15 +669,11 @@ realize_virt_arrays(j_common_ptr cinfo)
size_t minheights, max_minheights;
jvirt_sarray_ptr sptr;
jvirt_barray_ptr bptr;
#ifdef WITH_12BIT
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 12 ?
sizeof(J12SAMPLE) : sizeof(JSAMPLE);
#else
size_t sample_size = sizeof(JSAMPLE);
#endif
/* Compute the minimum space needed (maxaccess rows in each buffer)
* and the maximum space needed (full image height in each buffer).
@@ -796,15 +785,11 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
/* Do backing store read or write of a virtual sample array */
{
long bytesperrow, file_offset, byte_count, rows, thisrow, i;
#ifdef WITH_12BIT
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 12 ?
sizeof(J12SAMPLE) : sizeof(JSAMPLE);
#else
size_t sample_size = sizeof(JSAMPLE);
#endif
bytesperrow = (long)ptr->samplesperrow * (long)sample_size;
file_offset = ptr->cur_start_row * bytesperrow;
@@ -820,7 +805,6 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
if (rows <= 0) /* this chunk might be past end of file! */
break;
byte_count = rows * bytesperrow;
#ifdef WITH_12BIT
if (data_precision == 12) {
J12SAMPARRAY mem_buffer12 = (J12SAMPARRAY)ptr->mem_buffer;
@@ -832,9 +816,7 @@ do_sarray_io(j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
(*ptr->b_s_info.read_backing_store) (cinfo, &ptr->b_s_info,
(void *)mem_buffer12[i],
file_offset, byte_count);
} else
#endif
{
} else {
if (writing)
(*ptr->b_s_info.write_backing_store) (cinfo, &ptr->b_s_info,
(void *)ptr->mem_buffer[i],
@@ -891,15 +873,11 @@ access_virt_sarray(j_common_ptr cinfo, jvirt_sarray_ptr ptr,
{
JDIMENSION end_row = start_row + num_rows;
JDIMENSION undef_row;
#ifdef WITH_12BIT
int data_precision = cinfo->is_decompressor ?
((j_decompress_ptr)cinfo)->data_precision :
((j_compress_ptr)cinfo)->data_precision;
size_t sample_size = data_precision == 12 ?
sizeof(J12SAMPLE) : sizeof(JSAMPLE);
#else
size_t sample_size = sizeof(JSAMPLE);
#endif
/* debugging check */
if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess ||

View File

@@ -50,8 +50,6 @@ typedef unsigned char JSAMPLE;
#define CENTERJSAMPLE 128
#ifdef WITH_12BIT
/* J12SAMPLE should be the smallest type that will hold the values 0..4095. */
typedef short J12SAMPLE;
@@ -59,8 +57,6 @@ typedef short J12SAMPLE;
#define MAXJ12SAMPLE 4095
#define CENTERJ12SAMPLE 2048
#endif
/* Representation of a DCT frequency coefficient.
* This should be a signed value of at least 16 bits; "short" is usually OK.

View File

@@ -87,10 +87,8 @@ struct jpeg_c_main_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
void (*process_data) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
#ifdef WITH_12BIT
void (*process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail);
#endif
};
/* Compression preprocessing (downsampling input buffer control) */
@@ -101,23 +99,19 @@ struct jpeg_c_prep_controller {
JSAMPIMAGE output_buf,
JDIMENSION *out_row_group_ctr,
JDIMENSION out_row_groups_avail);
#ifdef WITH_12BIT
void (*pre_process_data_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
JDIMENSION *in_row_ctr,
JDIMENSION in_rows_avail,
J12SAMPIMAGE output_buf,
JDIMENSION *out_row_group_ctr,
JDIMENSION out_row_groups_avail);
#endif
};
/* Coefficient buffer control */
struct jpeg_c_coef_controller {
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
boolean (*compress_data) (j_compress_ptr cinfo, JSAMPIMAGE input_buf);
#ifdef WITH_12BIT
boolean (*compress_data_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf);
#endif
};
/* Colorspace conversion */
@@ -126,11 +120,9 @@ struct jpeg_color_converter {
void (*color_convert) (j_compress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows);
#ifdef WITH_12BIT
void (*color_convert_12) (j_compress_ptr cinfo, J12SAMPARRAY input_buf,
J12SAMPIMAGE output_buf, JDIMENSION output_row,
int num_rows);
#endif
};
/* Downsampling */
@@ -139,11 +131,9 @@ struct jpeg_downsampler {
void (*downsample) (j_compress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION in_row_index, JSAMPIMAGE output_buf,
JDIMENSION out_row_group_index);
#ifdef WITH_12BIT
void (*downsample_12) (j_compress_ptr cinfo, J12SAMPIMAGE input_buf,
JDIMENSION in_row_index, J12SAMPIMAGE output_buf,
JDIMENSION out_row_group_index);
#endif
boolean need_context_rows; /* TRUE if need rows above & below */
};
@@ -156,12 +146,10 @@ struct jpeg_forward_dct {
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks);
#ifdef WITH_12BIT
void (*forward_DCT_12) (j_compress_ptr cinfo, jpeg_component_info *compptr,
J12SAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks);
#endif
};
/* Entropy encoding */
@@ -224,10 +212,8 @@ struct jpeg_d_main_controller {
void (*start_pass) (j_decompress_ptr cinfo, J_BUF_MODE pass_mode);
void (*process_data) (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
#ifdef WITH_12BIT
void (*process_data_12) (j_decompress_ptr cinfo, J12SAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
#endif
};
/* Coefficient buffer control */
@@ -236,9 +222,7 @@ struct jpeg_d_coef_controller {
int (*consume_data) (j_decompress_ptr cinfo);
void (*start_output_pass) (j_decompress_ptr cinfo);
int (*decompress_data) (j_decompress_ptr cinfo, JSAMPIMAGE output_buf);
#ifdef WITH_12BIT
int (*decompress_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE output_buf);
#endif
/* Pointer to array of coefficient virtual arrays, or NULL if none */
jvirt_barray_ptr *coef_arrays;
};
@@ -251,14 +235,12 @@ struct jpeg_d_post_controller {
JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
#ifdef WITH_12BIT
void (*post_process_data_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
J12SAMPARRAY output_buf,
JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail);
#endif
};
/* Marker reading & parsing */
@@ -297,21 +279,17 @@ typedef void (*inverse_DCT_method_ptr) (j_decompress_ptr cinfo,
JCOEFPTR coef_block,
JSAMPARRAY output_buf,
JDIMENSION output_col);
#ifdef WITH_12BIT
typedef void (*inverse_DCT_12_method_ptr) (j_decompress_ptr cinfo,
jpeg_component_info *compptr,
JCOEFPTR coef_block,
J12SAMPARRAY output_buf,
JDIMENSION output_col);
#endif
struct jpeg_inverse_dct {
void (*start_pass) (j_decompress_ptr cinfo);
/* It is useful to allow each component to have a separate IDCT method. */
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
#ifdef WITH_12BIT
inverse_DCT_12_method_ptr inverse_DCT_12[MAX_COMPONENTS];
#endif
};
/* Upsampling (note that upsampler must also call color converter) */
@@ -321,12 +299,10 @@ struct jpeg_upsampler {
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
#ifdef WITH_12BIT
void (*upsample_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail, J12SAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail);
#endif
boolean need_context_rows; /* TRUE if need rows above & below */
};
@@ -337,11 +313,9 @@ struct jpeg_color_deconverter {
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
JDIMENSION input_row, JSAMPARRAY output_buf,
int num_rows);
#ifdef WITH_12BIT
void (*color_convert_12) (j_decompress_ptr cinfo, J12SAMPIMAGE input_buf,
JDIMENSION input_row, J12SAMPARRAY output_buf,
int num_rows);
#endif
};
/* Color quantization or color precision reduction */
@@ -349,10 +323,8 @@ struct jpeg_color_quantizer {
void (*start_pass) (j_decompress_ptr cinfo, boolean is_pre_scan);
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY output_buf, int num_rows);
#ifdef WITH_12BIT
void (*color_quantize_12) (j_decompress_ptr cinfo, J12SAMPARRAY input_buf,
J12SAMPARRAY output_buf, int num_rows);
#endif
void (*finish_pass) (j_decompress_ptr cinfo);
void (*new_color_map) (j_decompress_ptr cinfo);
};
@@ -394,64 +366,58 @@ EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
boolean transcode_only);
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_c_main_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_c_prep_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_c_coef_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
EXTERN(void) j12init_color_converter(j_compress_ptr cinfo);
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
EXTERN(void) j12init_downsampler(j_compress_ptr cinfo);
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
EXTERN(void) j12init_forward_dct(j_compress_ptr cinfo);
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
#ifdef WITH_12BIT
EXTERN(void) j12init_c_main_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_c_prep_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_c_coef_controller(j_compress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_color_converter(j_compress_ptr cinfo);
EXTERN(void) j12init_downsampler(j_compress_ptr cinfo);
EXTERN(void) j12init_forward_dct(j_compress_ptr cinfo);
#endif
/* Decompression module initialization routines */
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_d_main_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_d_coef_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_d_post_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
#ifdef WITH_12BIT
EXTERN(void) j12init_d_main_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_d_coef_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_d_post_controller(j_decompress_ptr cinfo,
boolean need_full_buffer);
EXTERN(void) j12init_inverse_dct(j_decompress_ptr cinfo);
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
EXTERN(void) j12init_upsampler(j_decompress_ptr cinfo);
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
EXTERN(void) j12init_color_deconverter(j_decompress_ptr cinfo);
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) j12init_1pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) j12init_2pass_quantizer(j_decompress_ptr cinfo);
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
EXTERN(void) j12init_merged_upsampler(j_decompress_ptr cinfo);
#endif
/* Memory manager initialization */
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
@@ -462,11 +428,9 @@ EXTERN(long) jround_up(long a, long b);
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
JSAMPARRAY output_array, int dest_row,
int num_rows, JDIMENSION num_cols);
#ifdef WITH_12BIT
EXTERN(void) j12copy_sample_rows(J12SAMPARRAY input_array, int source_row,
J12SAMPARRAY output_array, int dest_row,
int num_rows, JDIMENSION num_cols);
#endif
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks);
EXTERN(void) jzero_far(void *target, size_t bytestozero);

View File

@@ -70,14 +70,12 @@ typedef JSAMPLE *JSAMPROW; /* ptr to one image row of pixel samples. */
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */
#ifdef WITH_12BIT
typedef J12SAMPLE *J12SAMPROW; /* ptr to one image row of 12-bit pixel
samples. */
typedef J12SAMPROW *J12SAMPARRAY; /* ptr to some 12-bit sample rows (a 2-D
12-bit sample array) */
typedef J12SAMPARRAY *J12SAMPIMAGE; /* a 3-D 12-bit sample array: top index is
color */
#endif
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */
typedef JBLOCK *JBLOCKROW; /* pointer to one row of coefficient blocks */
@@ -973,11 +971,9 @@ EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
JSAMPARRAY scanlines,
JDIMENSION num_lines);
#ifdef WITH_12BIT
EXTERN(JDIMENSION) jpeg12_write_scanlines(j_compress_ptr cinfo,
J12SAMPARRAY scanlines,
JDIMENSION num_lines);
#endif
EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
#if JPEG_LIB_VERSION >= 70
@@ -988,11 +984,9 @@ EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
JDIMENSION num_lines);
#ifdef WITH_12BIT
EXTERN(JDIMENSION) jpeg12_write_raw_data(j_compress_ptr cinfo,
J12SAMPIMAGE data,
JDIMENSION num_lines);
#endif
/* Write a special marker. See libjpeg.txt concerning safe usage. */
EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
@@ -1028,33 +1022,25 @@ EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
JSAMPARRAY scanlines,
JDIMENSION max_lines);
#ifdef WITH_12BIT
EXTERN(JDIMENSION) jpeg12_read_scanlines(j_decompress_ptr cinfo,
J12SAMPARRAY scanlines,
JDIMENSION max_lines);
#endif
EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
JDIMENSION num_lines);
#ifdef WITH_12BIT
EXTERN(JDIMENSION) jpeg12_skip_scanlines(j_decompress_ptr cinfo,
JDIMENSION num_lines);
#endif
EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
JDIMENSION *width);
#ifdef WITH_12BIT
EXTERN(void) jpeg12_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
JDIMENSION *width);
#endif
EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
JDIMENSION max_lines);
#ifdef WITH_12BIT
EXTERN(JDIMENSION) jpeg12_read_raw_data(j_decompress_ptr cinfo,
J12SAMPIMAGE data,
JDIMENSION max_lines);
#endif
/* Additional entry points for buffered-image mode. */
EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);

View File

@@ -99,8 +99,8 @@ broader range of users and developers.
#--> -DSO_MINOR_VERSION=@SO_MINOR_VERSION@ \
#--> -DJPEG_LIB_VERSION=@JPEG_LIB_VERSION@ \
#--> -DREQUIRE_SIMD=@REQUIRE_SIMD@ \
#--> -DWITH_12BIT=@WITH_12BIT@ -DWITH_ARITH_DEC=@WITH_ARITH_DEC@ \
#--> -DWITH_ARITH_ENC=@WITH_ARITH_ENC@ -DWITH_JAVA=@WITH_JAVA@ \
#--> -DWITH_ARITH_DEC=@WITH_ARITH_DEC@ -DWITH_ARITH_ENC=@WITH_ARITH_ENC@ \
#--> -DWITH_JAVA=@WITH_JAVA@ \
#--> -DWITH_JPEG7=@WITH_JPEG7@ -DWITH_JPEG8=@WITH_JPEG8@ \
#--> -DWITH_SIMD=@WITH_SIMD@ -DWITH_TURBOJPEG=@WITH_TURBOJPEG@ .
#-->make DESTDIR=$RPM_BUILD_ROOT

View File

@@ -37,7 +37,7 @@ if(MSVC)
set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_BINARY_DIR}/win/jpeg.rc)
endif()
add_library(jpeg SHARED ${JPEG_SRCS} ${DEFFILE} ${SIMD_TARGET_OBJECTS}
${SIMD_OBJS} ${JPEG12_OBJS})
${SIMD_OBJS} $<TARGET_OBJECTS:jpeg12>)
set_target_properties(jpeg PROPERTIES SOVERSION ${SO_MAJOR_VERSION}
VERSION ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION})
@@ -69,26 +69,20 @@ set(CDJPEG_COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
# Compile a separate version of these source files with 12-bit data precision.
if(WITH_12BIT)
add_library(cjpeg12 OBJECT ../rdgif.c ../rdppm.c)
set_property(TARGET cjpeg12 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
set(CJPEG12_OBJS $<TARGET_OBJECTS:cjpeg12>)
endif()
add_library(cjpeg12 OBJECT ../rdgif.c ../rdppm.c)
set_property(TARGET cjpeg12 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdbmp.c ../rdgif.c ../rdppm.c
../rdswitch.c ../rdtarga.c ${CJPEG12_OBJS})
../rdswitch.c ../rdtarga.c $<TARGET_OBJECTS:cjpeg12>)
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${CDJPEG_COMPILE_FLAGS})
target_link_libraries(cjpeg jpeg)
# Compile a separate version of these source files with 12-bit data precision.
if(WITH_12BIT)
add_library(djpeg12 OBJECT ../rdcolmap.c ../wrgif.c ../wrppm.c)
set_property(TARGET djpeg12 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
set(DJPEG12_OBJS $<TARGET_OBJECTS:djpeg12>)
endif()
add_library(djpeg12 OBJECT ../rdcolmap.c ../wrgif.c ../wrppm.c)
set_property(TARGET djpeg12 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c
../wrbmp.c ../wrgif.c ../wrppm.c ../wrtarga.c ${DJPEG12_OBJS})
../wrbmp.c ../wrgif.c ../wrppm.c ../wrtarga.c $<TARGET_OBJECTS:djpeg12>)
set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${CDJPEG_COMPILE_FLAGS})
target_link_libraries(djpeg jpeg)