tjexample.c: Fix error when recompressing
(regression introduced by fc01f4673b)
Because of the TurboJPEG 3 API overhaul, the pure compression code path
in tjexample.c now creates a TurboJPEG compression instance prior to
calling tj3LoadImage(). However, due to an oversight, a compression
instance was no longer created in the recompression code path. Thus,
that code path attempted to reuse the TurboJPEG decompression instance,
which caused an error ("tj3Set(): TJPARAM_QUALITY is not applicable to
decompression instances.") This commit modifies tjexample.c so that the
recompression code path creates a new TurboJPEG compression instance if
one has not already been created.
Fixes #716
This commit is contained in:
@@ -350,6 +350,7 @@ int main(int argc, char **argv)
|
||||
pixelFormat) < 0)
|
||||
THROW_TJ("decompressing JPEG image");
|
||||
tj3Free(jpegBuf); jpegBuf = NULL;
|
||||
tj3Destroy(tjInstance); tjInstance = NULL;
|
||||
} else {
|
||||
/* Input image is not a JPEG image. Load it into memory. */
|
||||
if ((tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
|
||||
@@ -379,6 +380,8 @@ int main(int argc, char **argv)
|
||||
printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],
|
||||
outQual);
|
||||
|
||||
if (!tjInstance && (tjInstance = tj3Init(TJINIT_COMPRESS)) == NULL)
|
||||
THROW_TJ("initializing compressor");
|
||||
if (tj3Set(tjInstance, TJPARAM_SUBSAMP, outSubsamp) < 0)
|
||||
THROW_TJ("setting TJPARAM_SUBSAMP");
|
||||
if (tj3Set(tjInstance, TJPARAM_QUALITY, outQual) < 0)
|
||||
|
||||
Reference in New Issue
Block a user