-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduce a partial image decompression regression test script that validates the correctness of jpeg_skip_scanlines() and jpeg_crop_scanlines() for a variety of cropping regions and libjpeg settings. This regression test catches the following issues: #182, fixed in 5bc43c7 #237, fixed in 6e95c08649794f5018608f37250026a45ead2db8 #244, fixed in 398c1e9 #441, fully fixed in this commit It does not catch the following issues: #194, fixed in 773040f #244 (additional segfault), fixed in 9120a24 - Modify the libjpeg-turbo regression test suite (make test) so that it checks for the issue reported in #441 (segfault in jpeg_skip_scanlines() when used with 4:2:0 merged upsampling/color conversion.) - Fix issues in jpeg_skip_scanlines() that caused incorrect output with h2v2 (4:2:0) merged upsampling/color conversion. The previous commit fixed the segfault reported in #441, but that was a symptom of a larger problem. Because merged 4:2:0 upsampling uses a "spare row" buffer, it is necessary to allow the upsampler to run when skipping rows (fancy 4:2:0 upsampling, which uses context rows, also requires this.) Otherwise, if skipping starts at an odd-numbered row, the output image will be incorrect. - Throw an error if jpeg_skip_scanlines() is called with two-pass color quantization enabled. With two-pass color quantization, the first pass occurs within jpeg_start_decompress(), so subsequent calls to jpeg_skip_scanlines() interfere with the multipass state and prevent the second pass from occurring during subsequent calls to jpeg_read_scanlines().
- Loading branch information
1 parent
9120a24
commit a46c111
Showing
5 changed files
with
136 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
set -u | ||
set -e | ||
trap onexit INT | ||
trap onexit TERM | ||
trap onexit EXIT | ||
|
||
onexit() | ||
{ | ||
if [ -d $OUTDIR ]; then | ||
rm -rf $OUTDIR | ||
fi | ||
} | ||
|
||
runme() | ||
{ | ||
echo \*\*\* $* | ||
$* | ||
} | ||
|
||
IMAGE=vgl_6548_0026a.bmp | ||
WIDTH=128 | ||
HEIGHT=95 | ||
IMGDIR=@CMAKE_CURRENT_SOURCE_DIR@/testimages | ||
OUTDIR=`mktemp -d /tmp/__croptest_output.XXXXXX` | ||
EXEDIR=@CMAKE_CURRENT_BINARY_DIR@ | ||
|
||
if [ -d $OUTDIR ]; then | ||
rm -rf $OUTDIR | ||
fi | ||
mkdir -p $OUTDIR | ||
|
||
exec >$EXEDIR/croptest.log | ||
|
||
echo "============================================================" | ||
echo "$IMAGE ($WIDTH x $HEIGHT)" | ||
echo "============================================================" | ||
echo | ||
|
||
for PROGARG in "" -progressive; do | ||
|
||
cp $IMGDIR/$IMAGE $OUTDIR | ||
basename=`basename $IMAGE .bmp` | ||
echo "------------------------------------------------------------" | ||
echo "Generating test images" | ||
echo "------------------------------------------------------------" | ||
echo | ||
runme $EXEDIR/cjpeg $PROGARG -grayscale -outfile $OUTDIR/${basename}_GRAY.jpg $IMGDIR/${basename}.bmp | ||
runme $EXEDIR/cjpeg $PROGARG -sample 2x2 -outfile $OUTDIR/${basename}_420.jpg $IMGDIR/${basename}.bmp | ||
runme $EXEDIR/cjpeg $PROGARG -sample 2x1 -outfile $OUTDIR/${basename}_422.jpg $IMGDIR/${basename}.bmp | ||
runme $EXEDIR/cjpeg $PROGARG -sample 1x2 -outfile $OUTDIR/${basename}_440.jpg $IMGDIR/${basename}.bmp | ||
runme $EXEDIR/cjpeg $PROGARG -sample 1x1 -outfile $OUTDIR/${basename}_444.jpg $IMGDIR/${basename}.bmp | ||
echo | ||
|
||
for NSARG in "" -nosmooth; do | ||
|
||
for COLORSARG in "" "-colors 256 -dither none -onepass"; do | ||
|
||
for Y in {0..16}; do | ||
|
||
for H in {1..16}; do | ||
|
||
X=$(( (Y*16)%128 )) | ||
W=$(( WIDTH-X-7 )) | ||
if [ $Y -le 15 ]; then | ||
CROPSPEC="${W}x${H}+${X}+${Y}" | ||
else | ||
Y2=$(( HEIGHT-H )); | ||
CROPSPEC="${W}x${H}+${X}+${Y2}" | ||
fi | ||
|
||
echo "------------------------------------------------------------" | ||
echo $PROGARG $NSARG $COLORSARG -crop $CROPSPEC | ||
echo "------------------------------------------------------------" | ||
echo | ||
for samp in GRAY 420 422 440 444; do | ||
$EXEDIR/djpeg $NSARG $COLORSARG -rgb -outfile $OUTDIR/${basename}_${samp}_full.ppm $OUTDIR/${basename}_${samp}.jpg | ||
convert -crop $CROPSPEC $OUTDIR/${basename}_${samp}_full.ppm $OUTDIR/${basename}_${samp}_ref.ppm | ||
runme $EXEDIR/djpeg $NSARG $COLORSARG -crop $CROPSPEC -rgb -outfile $OUTDIR/${basename}_${samp}.ppm $OUTDIR/${basename}_${samp}.jpg | ||
runme cmp $OUTDIR/${basename}_${samp}.ppm $OUTDIR/${basename}_${samp}_ref.ppm | ||
done | ||
echo | ||
|
||
done | ||
|
||
done | ||
|
||
done | ||
|
||
done | ||
|
||
done | ||
|
||
echo SUCCESS! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters