mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-01-18 21:41:20 +01:00
12-bit: Set alpha channel to 4095 rather than 255
This commit is contained in:
@@ -37,6 +37,10 @@ strides to pass to `tjDecompressToYUVPlanes()`. This caused a buffer overrun
|
||||
and subsequent segfault if the desired image dimensions exceeded the scaled
|
||||
image dimensions.
|
||||
|
||||
6. Fixed an issue whereby, when decompressing a 12-bit-per-component JPEG image
|
||||
(`-DWITH_12BIT=1`) using an alpha-enabled output color space such as
|
||||
`JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095.
|
||||
|
||||
|
||||
2.0.8 ESR
|
||||
=========
|
||||
|
||||
14
jdcolext.c
14
jdcolext.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, 2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2015, 2023, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -62,10 +62,10 @@ ycc_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||
SCALEBITS))];
|
||||
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
/* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
|
||||
/* alpha channel value */
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
@@ -95,10 +95,10 @@ gray_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
for (col = 0; col < num_cols; col++) {
|
||||
/* We can dispense with GETJSAMPLE() here */
|
||||
outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col];
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
/* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
|
||||
/* alpha channel value */
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
@@ -132,10 +132,10 @@ rgb_rgb_convert_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr[RGB_RED] = inptr0[col];
|
||||
outptr[RGB_GREEN] = inptr1[col];
|
||||
outptr[RGB_BLUE] = inptr2[col];
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
/* Set unused byte to MAXJSAMPLE so it can be interpreted as an opaque */
|
||||
/* alpha channel value */
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
|
||||
20
jdmrgext.c
20
jdmrgext.c
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2011, 2015, 2020, D. R. Commander.
|
||||
* Copyright (C) 2011, 2015, 2020, 2023, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -57,7 +57,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
@@ -65,7 +65,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
outptr[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr0[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr0[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr0[RGB_ALPHA] = 0xFF;
|
||||
outptr0[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr0 += RGB_PIXELSIZE;
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
@@ -139,7 +139,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr0[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr0[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr0[RGB_ALPHA] = 0xFF;
|
||||
outptr0[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr0 += RGB_PIXELSIZE;
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
@@ -147,7 +147,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr1[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr1[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr1[RGB_ALPHA] = 0xFF;
|
||||
outptr1[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr1 += RGB_PIXELSIZE;
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
@@ -155,7 +155,7 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr1[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr1[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr1[RGB_ALPHA] = 0xFF;
|
||||
outptr1[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
outptr1 += RGB_PIXELSIZE;
|
||||
}
|
||||
@@ -171,14 +171,14 @@ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
outptr0[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr0[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr0[RGB_ALPHA] = 0xFF;
|
||||
outptr0[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
outptr1[RGB_RED] = range_limit[y + cred];
|
||||
outptr1[RGB_GREEN] = range_limit[y + cgreen];
|
||||
outptr1[RGB_BLUE] = range_limit[y + cblue];
|
||||
#ifdef RGB_ALPHA
|
||||
outptr1[RGB_ALPHA] = 0xFF;
|
||||
outptr1[RGB_ALPHA] = MAXJSAMPLE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
20
rdppm.c
20
rdppm.c
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015-2017, 2020-2022, D. R. Commander.
|
||||
* Copyright (C) 2015-2017, 2020-2023, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -189,13 +189,13 @@ get_text_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
if (maxval == MAXJSAMPLE) {
|
||||
if (aindex >= 0)
|
||||
GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
|
||||
ptr[aindex] = 0xFF;)
|
||||
ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
GRAY_RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
|
||||
} else {
|
||||
if (aindex >= 0)
|
||||
GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
|
||||
ptr[aindex] = 0xFF;)
|
||||
ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
GRAY_RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
|
||||
}
|
||||
@@ -263,13 +263,13 @@ get_text_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
if (maxval == MAXJSAMPLE) {
|
||||
if (aindex >= 0)
|
||||
RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval),
|
||||
ptr[aindex] = 0xFF;)
|
||||
ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
RGB_READ_LOOP((JSAMPLE)read_pbm_integer(cinfo, infile, maxval), {})
|
||||
} else {
|
||||
if (aindex >= 0)
|
||||
RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)],
|
||||
ptr[aindex] = 0xFF;)
|
||||
ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
RGB_READ_LOOP(rescale[read_pbm_integer(cinfo, infile, maxval)], {})
|
||||
}
|
||||
@@ -355,12 +355,12 @@ get_gray_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
bufferptr = source->iobuffer;
|
||||
if (maxval == MAXJSAMPLE) {
|
||||
if (aindex >= 0)
|
||||
GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
|
||||
GRAY_RGB_READ_LOOP(*bufferptr++, ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
GRAY_RGB_READ_LOOP(*bufferptr++, {})
|
||||
} else {
|
||||
if (aindex >= 0)
|
||||
GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
|
||||
GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
GRAY_RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
|
||||
}
|
||||
@@ -423,12 +423,12 @@ get_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
bufferptr = source->iobuffer;
|
||||
if (maxval == MAXJSAMPLE) {
|
||||
if (aindex >= 0)
|
||||
RGB_READ_LOOP(*bufferptr++, ptr[aindex] = 0xFF;)
|
||||
RGB_READ_LOOP(*bufferptr++, ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
RGB_READ_LOOP(*bufferptr++, {})
|
||||
} else {
|
||||
if (aindex >= 0)
|
||||
RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = 0xFF;)
|
||||
RGB_READ_LOOP(rescale[UCH(*bufferptr++)], ptr[aindex] = MAXJSAMPLE;)
|
||||
else
|
||||
RGB_READ_LOOP(rescale[UCH(*bufferptr++)], {})
|
||||
}
|
||||
@@ -553,7 +553,7 @@ get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||
ptr[bindex] = rescale[temp];
|
||||
if (aindex >= 0)
|
||||
ptr[aindex] = 0xFF;
|
||||
ptr[aindex] = MAXJSAMPLE;
|
||||
ptr += ps;
|
||||
}
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user