tjDecodeYUV*: Fix err if TJ inst used for prog dec
If the TurboJPEG instance passed to tjDecodeYUV[Planes]() was previously
used to decompress a progressive JPEG image, then we need to disable the
progressive decompression parameters in the underlying libjpeg instance
before calling jinit_master_decompress().
This commit also modifies the build system so that the "tjtest" target
will test for this issue, and it corrects a previous oversight in the
build system whereby tjbenchtest did not test progressive
compression/decompression unless WITH_JAVA was true.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ccd3f08..28fd443 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1290,6 +1290,8 @@
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
COMMAND echo tjbenchtest -progressive
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
+ COMMAND echo tjbenchtest -progressive -yuv
+ COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
COMMAND echo tjexampletest
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
COMMAND echo tjbenchtest.java
@@ -1298,6 +1300,9 @@
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
COMMAND echo tjbenchtest.java -progressive
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
+ COMMAND echo tjexampletest.java -progressive -yuv
+ COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
+ -progressive -yuv
COMMAND echo tjexampletest.java
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
@@ -1313,6 +1318,10 @@
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
COMMAND echo tjbenchtest -yuv -alloc
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
+ COMMAND echo tjbenchtest -progressive
+ COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
+ COMMAND echo tjbenchtest -progressive -yuv
+ COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
COMMAND echo tjexampletest
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
diff --git a/ChangeLog.md b/ChangeLog.md
index 0033f27..3667d12 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -30,6 +30,11 @@
containing one or more scans with lengths divisible by 16 would result in an
error ("Missing Huffman code table entry") and an invalid JPEG image.
+6. Fixed an issue whereby `tjDecodeYUV()` and `tjDecodeYUVPlanes()` would throw
+an error ("Invalid progressive parameters") or a warning ("Inconsistent
+progression sequence") if passed a TurboJPEG instance that was previously used
+to decompress a progressive JPEG image.
+
2.0.2
=====
diff --git a/turbojpeg.c b/turbojpeg.c
index b6a1f20..3a1e3a9 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1432,6 +1432,9 @@
else if (flags & TJFLAG_FORCESSE2) putenv("JSIMD_FORCESSE2=1");
#endif
+ dinfo->progressive_mode = dinfo->inputctl->has_multiple_scans = FALSE;
+ dinfo->Ss = dinfo->Ah = dinfo->Al = 0;
+ dinfo->Se = DCTSIZE2 - 1;
if (setDecodeDefaults(dinfo, pixelFormat, subsamp, flags) == -1) {
retval = -1; goto bailout;
}