Allow disabling prog/opt/lossless if prev. enabled
- Due to an oversight, a113506d17
(libjpeg-turbo 1.4 beta1) effectively made the call to
std_huff_tables() in jpeg_set_defaults() a no-op if the Huffman tables
were previously defined, which made it impossible to disable Huffman
table optimization or progressive mode if they were previously enabled
in the same API instance. std_huff_tables() retains its previous
behavior for decompression instances, but it now force-enables the
standard (baseline) Huffman tables for compression instances.
- Due to another oversight, there was no way to disable lossless mode
if it was previously enabled in a particular API instance.
jpeg_set_defaults() now accomplishes this, which makes
TJ*PARAM_LOSSLESS behave as intended/documented.
- Due to yet another oversight, setCompDefaults() in the TurboJPEG API
library permanently modified the value of TJ*PARAM_SUBSAMP when
generating a lossless JPEG image, which affected subsequent lossy
compression operations. This issue was hidden by the issue above and
thus does not need to be publicly documented.
Fixes #792
This commit is contained in:
11
ChangeLog.md
11
ChangeLog.md
@@ -8,6 +8,17 @@
|
|||||||
transform value greater than 7 resulted in an error ("Parameter value out of
|
transform value greater than 7 resulted in an error ("Parameter value out of
|
||||||
range".)
|
range".)
|
||||||
|
|
||||||
|
2. Fixed a regression introduced by 1.4 beta1[3] that prevented
|
||||||
|
`jpeg_set_defaults()` from resetting the Huffman tables to default (baseline)
|
||||||
|
values if Huffman table optimization or progressive mode was previously enabled
|
||||||
|
in the same libjpeg instance.
|
||||||
|
|
||||||
|
3. Fixed an issue whereby lossless JPEG compression could not be disabled if it
|
||||||
|
was previously enabled in a libjpeg or TurboJPEG instance.
|
||||||
|
`jpeg_set_defaults()` now disables lossless JPEG compression in a libjpeg
|
||||||
|
instance, and setting `TJPARAM_LOSSLESS`/`TJ.PARAM_LOSSLESS` to `0` now
|
||||||
|
disables lossless JPEG compression in a TurboJPEG instance.
|
||||||
|
|
||||||
|
|
||||||
3.0.4
|
3.0.4
|
||||||
=====
|
=====
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* Lossless JPEG Modifications:
|
* Lossless JPEG Modifications:
|
||||||
* Copyright (C) 1999, Ken Murchison.
|
* Copyright (C) 1999, Ken Murchison.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, 2018, 2023, D. R. Commander.
|
* Copyright (C) 2009-2011, 2018, 2023-2024, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -220,6 +220,9 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
cinfo->scan_info = NULL;
|
cinfo->scan_info = NULL;
|
||||||
cinfo->num_scans = 0;
|
cinfo->num_scans = 0;
|
||||||
|
|
||||||
|
/* Default is lossy output */
|
||||||
|
cinfo->master->lossless = FALSE;
|
||||||
|
|
||||||
/* Expect normal source image, not raw downsampled data */
|
/* Expect normal source image, not raw downsampled data */
|
||||||
cinfo->raw_data_in = FALSE;
|
cinfo->raw_data_in = FALSE;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2013, 2022, D. R. Commander.
|
* Copyright (C) 2013, 2022, 2024, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -25,7 +25,7 @@ add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
|
|||||||
|
|
||||||
if (*htblptr == NULL)
|
if (*htblptr == NULL)
|
||||||
*htblptr = jpeg_alloc_huff_table(cinfo);
|
*htblptr = jpeg_alloc_huff_table(cinfo);
|
||||||
else
|
else if (cinfo->is_decompressor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Copy the number-of-symbols-of-each-code-length counts */
|
/* Copy the number-of-symbols-of-each-code-length counts */
|
||||||
|
|||||||
18
turbojpeg.c
18
turbojpeg.c
@@ -328,6 +328,8 @@ static int getPixelFormat(int pixelSize, int flags)
|
|||||||
|
|
||||||
static void setCompDefaults(tjinstance *this, int pixelFormat)
|
static void setCompDefaults(tjinstance *this, int pixelFormat)
|
||||||
{
|
{
|
||||||
|
int subsamp = this->subsamp;
|
||||||
|
|
||||||
this->cinfo.in_color_space = pf2cs[pixelFormat];
|
this->cinfo.in_color_space = pf2cs[pixelFormat];
|
||||||
this->cinfo.input_components = tjPixelSize[pixelFormat];
|
this->cinfo.input_components = tjPixelSize[pixelFormat];
|
||||||
jpeg_set_defaults(&this->cinfo);
|
jpeg_set_defaults(&this->cinfo);
|
||||||
@@ -344,9 +346,9 @@ static void setCompDefaults(tjinstance *this, int pixelFormat)
|
|||||||
jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
|
jpeg_enable_lossless(&this->cinfo, this->losslessPSV, this->losslessPt);
|
||||||
#endif
|
#endif
|
||||||
if (pixelFormat == TJPF_GRAY)
|
if (pixelFormat == TJPF_GRAY)
|
||||||
this->subsamp = TJSAMP_GRAY;
|
subsamp = TJSAMP_GRAY;
|
||||||
else if (this->subsamp != TJSAMP_GRAY)
|
else if (subsamp != TJSAMP_GRAY)
|
||||||
this->subsamp = TJSAMP_444;
|
subsamp = TJSAMP_444;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +367,7 @@ static void setCompDefaults(tjinstance *this, int pixelFormat)
|
|||||||
case TJCS_YCCK:
|
case TJCS_YCCK:
|
||||||
jpeg_set_colorspace(&this->cinfo, JCS_YCCK); break;
|
jpeg_set_colorspace(&this->cinfo, JCS_YCCK); break;
|
||||||
default:
|
default:
|
||||||
if (this->subsamp == TJSAMP_GRAY)
|
if (subsamp == TJSAMP_GRAY)
|
||||||
jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
|
jpeg_set_colorspace(&this->cinfo, JCS_GRAYSCALE);
|
||||||
else if (pixelFormat == TJPF_CMYK)
|
else if (pixelFormat == TJPF_CMYK)
|
||||||
jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
|
jpeg_set_colorspace(&this->cinfo, JCS_YCCK);
|
||||||
@@ -380,16 +382,16 @@ static void setCompDefaults(tjinstance *this, int pixelFormat)
|
|||||||
#endif
|
#endif
|
||||||
this->cinfo.arith_code = this->arithmetic;
|
this->cinfo.arith_code = this->arithmetic;
|
||||||
|
|
||||||
this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
|
this->cinfo.comp_info[0].h_samp_factor = tjMCUWidth[subsamp] / 8;
|
||||||
this->cinfo.comp_info[1].h_samp_factor = 1;
|
this->cinfo.comp_info[1].h_samp_factor = 1;
|
||||||
this->cinfo.comp_info[2].h_samp_factor = 1;
|
this->cinfo.comp_info[2].h_samp_factor = 1;
|
||||||
if (this->cinfo.num_components > 3)
|
if (this->cinfo.num_components > 3)
|
||||||
this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[this->subsamp] / 8;
|
this->cinfo.comp_info[3].h_samp_factor = tjMCUWidth[subsamp] / 8;
|
||||||
this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
|
this->cinfo.comp_info[0].v_samp_factor = tjMCUHeight[subsamp] / 8;
|
||||||
this->cinfo.comp_info[1].v_samp_factor = 1;
|
this->cinfo.comp_info[1].v_samp_factor = 1;
|
||||||
this->cinfo.comp_info[2].v_samp_factor = 1;
|
this->cinfo.comp_info[2].v_samp_factor = 1;
|
||||||
if (this->cinfo.num_components > 3)
|
if (this->cinfo.num_components > 3)
|
||||||
this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[this->subsamp] / 8;
|
this->cinfo.comp_info[3].v_samp_factor = tjMCUHeight[subsamp] / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user