OJPEG: fix broken sanity check added in 4.1.0, and add two OJPEG test files
This commit is contained in:
parent
f417f056c5
commit
0356ea76ba
@ -837,36 +837,6 @@ OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc)
|
|||||||
{
|
{
|
||||||
if (sp->subsampling_convert_state==0)
|
if (sp->subsampling_convert_state==0)
|
||||||
{
|
{
|
||||||
const jpeg_decompress_struct* cinfo = &sp->libjpeg_jpeg_decompress_struct;
|
|
||||||
int width = 0;
|
|
||||||
int last_col_width = 0;
|
|
||||||
int jpeg_bytes;
|
|
||||||
int expected_bytes;
|
|
||||||
int i;
|
|
||||||
if (cinfo->MCUs_per_row == 0)
|
|
||||||
{
|
|
||||||
sp->error_in_raw_data_decoding = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
for (i = 0; i < cinfo->comps_in_scan; ++i)
|
|
||||||
{
|
|
||||||
const jpeg_component_info* info = cinfo->cur_comp_info[i];
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
|
||||||
width += info->MCU_width * info->DCT_h_scaled_size;
|
|
||||||
last_col_width += info->last_col_width * info->DCT_h_scaled_size;
|
|
||||||
#else
|
|
||||||
width += info->MCU_width * info->DCT_scaled_size;
|
|
||||||
last_col_width += info->last_col_width * info->DCT_scaled_size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
jpeg_bytes = (cinfo->MCUs_per_row - 1) * width + last_col_width;
|
|
||||||
expected_bytes = sp->subsampling_convert_clinelenout * sp->subsampling_ver * sp->subsampling_hor;
|
|
||||||
if (jpeg_bytes != expected_bytes)
|
|
||||||
{
|
|
||||||
TIFFErrorExt(tif->tif_clientdata,module,"Inconsistent number of MCU in codestream");
|
|
||||||
sp->error_in_raw_data_decoding = 1;
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
||||||
{
|
{
|
||||||
sp->error_in_raw_data_decoding = 1;
|
sp->error_in_raw_data_decoding = 1;
|
||||||
@ -1291,6 +1261,29 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
|||||||
}
|
}
|
||||||
if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0)
|
if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0)
|
||||||
return(0);
|
return(0);
|
||||||
|
if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ||
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.image_height < sp->strile_length) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,
|
||||||
|
"jpeg_start_decompress() returned image_width = %d "
|
||||||
|
"and image_height = %d, expected %d and %d",
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.image_width,
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.image_height,
|
||||||
|
sp->strile_width,
|
||||||
|
sp->strile_length);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if(sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor != sp->subsampling_hor ||
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) {
|
||||||
|
TIFFErrorExt(tif->tif_clientdata,module,
|
||||||
|
"jpeg_start_decompress() returned max_h_samp_factor = %d "
|
||||||
|
"and max_v_samp_factor = %d, expected %d and %d",
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
|
||||||
|
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
|
||||||
|
sp->subsampling_hor,
|
||||||
|
sp->subsampling_ver);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sp->writeheader_done=1;
|
sp->writeheader_done=1;
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,9 @@ set(TESTSCRIPTS
|
|||||||
tiff2rgba-palette-1c-8b.sh
|
tiff2rgba-palette-1c-8b.sh
|
||||||
tiff2rgba-rgb-3c-16b.sh
|
tiff2rgba-rgb-3c-16b.sh
|
||||||
tiff2rgba-rgb-3c-8b.sh
|
tiff2rgba-rgb-3c-8b.sh
|
||||||
tiff2rgba-quad-tile.jpg.sh)
|
tiff2rgba-quad-tile.jpg.sh
|
||||||
|
tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh
|
||||||
|
tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh)
|
||||||
|
|
||||||
# This list should contain all of the TIFF files in the 'images'
|
# This list should contain all of the TIFF files in the 'images'
|
||||||
# subdirectory which are intended to be used as input images for
|
# subdirectory which are intended to be used as input images for
|
||||||
@ -123,7 +125,9 @@ set(TIFFIMAGES
|
|||||||
images/rgb-3c-8b.tiff
|
images/rgb-3c-8b.tiff
|
||||||
images/quad-tile.jpg.tiff
|
images/quad-tile.jpg.tiff
|
||||||
images/quad-lzw-compat.tiff
|
images/quad-lzw-compat.tiff
|
||||||
images/lzw-single-strip.tiff)
|
images/lzw-single-strip.tiff
|
||||||
|
images/ojpeg_zackthecat_subsamp22_single_strip.tiff
|
||||||
|
images/ojpeg_chewey_subsamp21_multi_strip.tiff)
|
||||||
|
|
||||||
set(BMPIMAGES
|
set(BMPIMAGES
|
||||||
images/palette-1c-8b.bmp
|
images/palette-1c-8b.bmp
|
||||||
|
@ -55,7 +55,10 @@ CLEANFILES = test_packbits.tif o-*
|
|||||||
if HAVE_JPEG
|
if HAVE_JPEG
|
||||||
JPEG_DEPENDENT_CHECK_PROG=raw_decode
|
JPEG_DEPENDENT_CHECK_PROG=raw_decode
|
||||||
JPEG_DEPENDENT_TESTSCRIPTS=\
|
JPEG_DEPENDENT_TESTSCRIPTS=\
|
||||||
tiff2rgba-quad-tile.jpg.sh
|
tiff2rgba-quad-tile.jpg.sh \
|
||||||
|
tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh \
|
||||||
|
tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh
|
||||||
|
|
||||||
else
|
else
|
||||||
JPEG_DEPENDENT_CHECK_PROG=
|
JPEG_DEPENDENT_CHECK_PROG=
|
||||||
JPEG_DEPENDENT_TESTSCRIPTS=
|
JPEG_DEPENDENT_TESTSCRIPTS=
|
||||||
@ -171,7 +174,9 @@ TIFFIMAGES = \
|
|||||||
images/rgb-3c-8b.tiff \
|
images/rgb-3c-8b.tiff \
|
||||||
images/quad-tile.jpg.tiff \
|
images/quad-tile.jpg.tiff \
|
||||||
images/quad-lzw-compat.tiff \
|
images/quad-lzw-compat.tiff \
|
||||||
images/lzw-single-strip.tiff
|
images/lzw-single-strip.tiff \
|
||||||
|
images/ojpeg_zackthecat_subsamp22_single_strip.tiff \
|
||||||
|
images/ojpeg_chewey_subsamp21_multi_strip.tiff
|
||||||
|
|
||||||
PNMIMAGES = \
|
PNMIMAGES = \
|
||||||
images/minisblack-1c-8b.pgm \
|
images/minisblack-1c-8b.pgm \
|
||||||
|
BIN
test/images/ojpeg_chewey_subsamp21_multi_strip.tiff
Normal file
BIN
test/images/ojpeg_chewey_subsamp21_multi_strip.tiff
Normal file
Binary file not shown.
BIN
test/images/ojpeg_zackthecat_subsamp22_single_strip.tiff
Normal file
BIN
test/images/ojpeg_zackthecat_subsamp22_single_strip.tiff
Normal file
Binary file not shown.
7
test/tiff2bw-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiff2bw-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiff2bw-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFF2BW" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiff2bw-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiff2bw-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiff2bw-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFF2BW" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFF2RGBA" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFF2RGBA" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-R90-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiffcrop-R90-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-R90-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -R90" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-R90-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiffcrop-R90-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-R90-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -R90" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-doubleflip-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiffcrop-doubleflip-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-doubleflip-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -F both" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-doubleflip-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiffcrop-doubleflip-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-doubleflip-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -F both" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-extract-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiffcrop-extract-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-extract-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-extract-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiffcrop-extract-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-extract-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -U px -E top -X 60 -Y 60" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-extractz14-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
7
test/tiffcrop-extractz14-ojpeg_chewey_subsamp21_multi_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-extractz14-ojpeg_chewey_subsamp21_multi_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
7
test/tiffcrop-extractz14-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
7
test/tiffcrop-extractz14-ojpeg_zackthecat_subsamp22_single_strip.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generated file, master is Makefile.am
|
||||||
|
. ${srcdir:-.}/common.sh
|
||||||
|
infile="$srcdir/images/ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
outfile="o-tiffcrop-extractz14-ojpeg_zackthecat_subsamp22_single_strip.tiff"
|
||||||
|
f_test_convert "$TIFFCROP -E left -Z1:4,2:4" $infile $outfile
|
||||||
|
f_tiffinfo_validate $outfile
|
Loading…
Reference in New Issue
Block a user