mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #25092 from klatism:libjpeg-upgrade
libjpeg upgrade to version 9f #25092 Upgrade libjpeg dependency from version 9d to 9f. - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
1894426116
commit
f87e1efd2a
12
3rdparty/libjpeg/jcarith.c
vendored
12
3rdparty/libjpeg/jcarith.c
vendored
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jcarith.c
|
* jcarith.c
|
||||||
*
|
*
|
||||||
* Developed 1997-2019 by Guido Vollbeding.
|
* Developed 1997-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -361,7 +361,7 @@ emit_restart (j_compress_ptr cinfo, int restart_num)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
@ -450,7 +450,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
@ -557,7 +557,7 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
@ -592,7 +592,7 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
@ -691,7 +691,7 @@ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
|
146
3rdparty/libjpeg/jccoefct.c
vendored
146
3rdparty/libjpeg/jccoefct.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jccoefct.c
|
* jccoefct.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||||
* Modified 2003-2011 by Guido Vollbeding.
|
* Modified 2003-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -36,16 +36,14 @@ typedef struct {
|
|||||||
struct jpeg_c_coef_controller pub; /* public fields */
|
struct jpeg_c_coef_controller pub; /* public fields */
|
||||||
|
|
||||||
JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
||||||
JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
|
JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
|
||||||
int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
||||||
int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
||||||
|
|
||||||
/* For single-pass compression, it's sufficient to buffer just one MCU
|
/* For single-pass compression, it's sufficient to buffer just one MCU
|
||||||
* (although this may prove a bit slow in practice). We allocate a
|
* (although this may prove a bit slow in practice).
|
||||||
* workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each
|
* We append a workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks,
|
||||||
* MCU constructed and sent. (On 80x86, the workspace is FAR even though
|
* and reuse it for each MCU constructed and sent.
|
||||||
* it's not really very big; this is to keep the module interfaces unchanged
|
|
||||||
* when a large coefficient buffer is necessary.)
|
|
||||||
* In multi-pass modes, this array points to the current MCU's blocks
|
* In multi-pass modes, this array points to the current MCU's blocks
|
||||||
* within the virtual arrays.
|
* within the virtual arrays.
|
||||||
*/
|
*/
|
||||||
@ -53,6 +51,9 @@ typedef struct {
|
|||||||
|
|
||||||
/* In multi-pass modes, we need a virtual block array for each component. */
|
/* In multi-pass modes, we need a virtual block array for each component. */
|
||||||
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
|
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
|
||||||
|
|
||||||
|
/* Workspace for single-pass compression (omitted otherwise). */
|
||||||
|
JBLOCK blk_buffer[C_MAX_BLOCKS_IN_MCU];
|
||||||
} my_coef_controller;
|
} my_coef_controller;
|
||||||
|
|
||||||
typedef my_coef_controller * my_coef_ptr;
|
typedef my_coef_controller * my_coef_ptr;
|
||||||
@ -88,7 +89,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
|||||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
coef->mcu_ctr = 0;
|
coef->MCU_ctr = 0;
|
||||||
coef->MCU_vert_offset = 0;
|
coef->MCU_vert_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +126,6 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,59 +147,56 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||||
int blkn, bi, ci, yindex, yoffset, blockcnt;
|
int ci, xindex, yindex, yoffset, blockcnt;
|
||||||
JDIMENSION ypos, xpos;
|
JBLOCKROW blkp;
|
||||||
|
JSAMPARRAY input_ptr;
|
||||||
|
JDIMENSION xpos;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
forward_DCT_ptr forward_DCT;
|
forward_DCT_ptr forward_DCT;
|
||||||
|
|
||||||
/* Loop to write as much as one whole iMCU row */
|
/* Loop to write as much as one whole iMCU row */
|
||||||
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
||||||
yoffset++) {
|
yoffset++) {
|
||||||
for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
|
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||||
MCU_col_num++) {
|
MCU_col_num++) {
|
||||||
/* Determine where data comes from in input_buf and do the DCT thing.
|
/* Determine where data comes from in input_buf and do the DCT thing.
|
||||||
* Each call on forward_DCT processes a horizontal row of DCT blocks
|
* Each call on forward_DCT processes a horizontal row of DCT blocks as
|
||||||
* as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks
|
* wide as an MCU. Dummy blocks at the right or bottom edge are filled in
|
||||||
* sequentially. Dummy blocks at the right or bottom edge are filled in
|
|
||||||
* specially. The data in them does not matter for image reconstruction,
|
* specially. The data in them does not matter for image reconstruction,
|
||||||
* so we fill them with values that will encode to the smallest amount of
|
* so we fill them with values that will encode to the smallest amount of
|
||||||
* data, viz: all zeroes in the AC entries, DC entries equal to previous
|
* data, viz: all zeroes in the AC entries, DC entries equal to previous
|
||||||
* block's DC value. (Thanks to Thomas Kinsman for this idea.)
|
* block's DC value. (Thanks to Thomas Kinsman for this idea.)
|
||||||
*/
|
*/
|
||||||
blkn = 0;
|
blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index];
|
forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index];
|
||||||
|
input_ptr = input_buf[compptr->component_index] +
|
||||||
|
yoffset * compptr->DCT_v_scaled_size;
|
||||||
|
/* ypos == (yoffset + yindex) * compptr->DCT_v_scaled_size */
|
||||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||||
: compptr->last_col_width;
|
: compptr->last_col_width;
|
||||||
xpos = MCU_col_num * compptr->MCU_sample_width;
|
xpos = MCU_col_num * compptr->MCU_sample_width;
|
||||||
ypos = yoffset * compptr->DCT_v_scaled_size;
|
|
||||||
/* ypos == (yoffset+yindex) * DCTSIZE */
|
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||||
yoffset+yindex < compptr->last_row_height) {
|
yoffset + yindex < compptr->last_row_height) {
|
||||||
(*forward_DCT) (cinfo, compptr,
|
(*forward_DCT) (cinfo, compptr, input_ptr, blkp,
|
||||||
input_buf[compptr->component_index],
|
xpos, (JDIMENSION) blockcnt);
|
||||||
coef->MCU_buffer[blkn],
|
input_ptr += compptr->DCT_v_scaled_size;
|
||||||
ypos, xpos, (JDIMENSION) blockcnt);
|
blkp += blockcnt;
|
||||||
if (blockcnt < compptr->MCU_width) {
|
/* Dummy blocks at right edge */
|
||||||
/* Create some dummy blocks at the right edge of the image. */
|
if ((xindex = compptr->MCU_width - blockcnt) == 0)
|
||||||
FMEMZERO((void FAR *) coef->MCU_buffer[blkn + blockcnt],
|
continue;
|
||||||
(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
|
|
||||||
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
|
|
||||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* Create a row of dummy blocks at the bottom of the image. */
|
/* At bottom of image, need a whole row of dummy blocks */
|
||||||
FMEMZERO((void FAR *) coef->MCU_buffer[blkn],
|
xindex = compptr->MCU_width;
|
||||||
compptr->MCU_width * SIZEOF(JBLOCK));
|
|
||||||
for (bi = 0; bi < compptr->MCU_width; bi++) {
|
|
||||||
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
blkn += compptr->MCU_width;
|
/* Fill in any dummy blocks needed in this row */
|
||||||
ypos += compptr->DCT_v_scaled_size;
|
MEMZERO(blkp, xindex * SIZEOF(JBLOCK));
|
||||||
|
do {
|
||||||
|
blkp[0][0] = blkp[-1][0];
|
||||||
|
blkp++;
|
||||||
|
} while (--xindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Try to write the MCU. In event of a suspension failure, we will
|
/* Try to write the MCU. In event of a suspension failure, we will
|
||||||
@ -208,12 +205,12 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
coef->MCU_vert_offset = yoffset;
|
coef->MCU_vert_offset = yoffset;
|
||||||
coef->mcu_ctr = MCU_col_num;
|
coef->MCU_ctr = MCU_col_num;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Completed an MCU row, but perhaps not an iMCU row */
|
/* Completed an MCU row, but perhaps not an iMCU row */
|
||||||
coef->mcu_ctr = 0;
|
coef->MCU_ctr = 0;
|
||||||
}
|
}
|
||||||
/* Completed the iMCU row, advance counters for next one */
|
/* Completed the iMCU row, advance counters for next one */
|
||||||
coef->iMCU_row_num++;
|
coef->iMCU_row_num++;
|
||||||
@ -256,6 +253,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
JBLOCKARRAY buffer;
|
JBLOCKARRAY buffer;
|
||||||
JBLOCKROW thisblockrow, lastblockrow;
|
JBLOCKROW thisblockrow, lastblockrow;
|
||||||
|
JSAMPARRAY input_ptr;
|
||||||
forward_DCT_ptr forward_DCT;
|
forward_DCT_ptr forward_DCT;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
@ -280,14 +278,15 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
if (ndummy > 0)
|
if (ndummy > 0)
|
||||||
ndummy = h_samp_factor - ndummy;
|
ndummy = h_samp_factor - ndummy;
|
||||||
forward_DCT = cinfo->fdct->forward_DCT[ci];
|
forward_DCT = cinfo->fdct->forward_DCT[ci];
|
||||||
|
input_ptr = input_buf[ci];
|
||||||
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
|
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
|
||||||
* on forward_DCT processes a complete horizontal row of DCT blocks.
|
* on forward_DCT processes a complete horizontal row of DCT blocks.
|
||||||
*/
|
*/
|
||||||
for (block_row = 0; block_row < block_rows; block_row++) {
|
for (block_row = 0; block_row < block_rows; block_row++) {
|
||||||
thisblockrow = buffer[block_row];
|
thisblockrow = buffer[block_row];
|
||||||
(*forward_DCT) (cinfo, compptr, input_buf[ci], thisblockrow,
|
(*forward_DCT) (cinfo, compptr, input_ptr, thisblockrow,
|
||||||
(JDIMENSION) (block_row * compptr->DCT_v_scaled_size),
|
|
||||||
(JDIMENSION) 0, blocks_across);
|
(JDIMENSION) 0, blocks_across);
|
||||||
|
input_ptr += compptr->DCT_v_scaled_size;
|
||||||
if (ndummy > 0) {
|
if (ndummy > 0) {
|
||||||
/* Create dummy blocks at the right edge of the image. */
|
/* Create dummy blocks at the right edge of the image. */
|
||||||
thisblockrow += blocks_across; /* => first dummy block */
|
thisblockrow += blocks_across; /* => first dummy block */
|
||||||
@ -303,15 +302,14 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
* of the dummy blocks to match the last real block's DC value.
|
* of the dummy blocks to match the last real block's DC value.
|
||||||
* This squeezes a few more bytes out of the resulting file...
|
* This squeezes a few more bytes out of the resulting file...
|
||||||
*/
|
*/
|
||||||
if (coef->iMCU_row_num == last_iMCU_row) {
|
if (block_row < compptr->v_samp_factor) {
|
||||||
blocks_across += ndummy; /* include lower right corner */
|
blocks_across += ndummy; /* include lower right corner */
|
||||||
MCUs_across = blocks_across / h_samp_factor;
|
MCUs_across = blocks_across / h_samp_factor;
|
||||||
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
do {
|
||||||
block_row++) {
|
|
||||||
thisblockrow = buffer[block_row];
|
thisblockrow = buffer[block_row];
|
||||||
lastblockrow = buffer[block_row-1];
|
lastblockrow = buffer[block_row-1];
|
||||||
FMEMZERO((void FAR *) thisblockrow,
|
FMEMZERO((void FAR *) thisblockrow,
|
||||||
(size_t) (blocks_across * SIZEOF(JBLOCK)));
|
(size_t) blocks_across * SIZEOF(JBLOCK));
|
||||||
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||||
lastDC = lastblockrow[h_samp_factor-1][0];
|
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||||
for (bi = 0; bi < h_samp_factor; bi++) {
|
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||||
@ -320,7 +318,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
thisblockrow += h_samp_factor; /* advance to next MCU in row */
|
thisblockrow += h_samp_factor; /* advance to next MCU in row */
|
||||||
lastblockrow += h_samp_factor;
|
lastblockrow += h_samp_factor;
|
||||||
}
|
}
|
||||||
}
|
} while (++block_row < compptr->v_samp_factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* NB: compress_output will increment iMCU_row_num if successful.
|
/* NB: compress_output will increment iMCU_row_num if successful.
|
||||||
@ -347,8 +345,9 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
{
|
{
|
||||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||||
int blkn, ci, xindex, yindex, yoffset;
|
int ci, xindex, yindex, yoffset;
|
||||||
JDIMENSION start_col;
|
JDIMENSION start_col;
|
||||||
|
JBLOCKARRAY blkp;
|
||||||
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
||||||
JBLOCKROW buffer_ptr;
|
JBLOCKROW buffer_ptr;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
@ -368,30 +367,31 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
/* Loop to process one whole iMCU row */
|
/* Loop to process one whole iMCU row */
|
||||||
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
||||||
yoffset++) {
|
yoffset++) {
|
||||||
for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
||||||
MCU_col_num++) {
|
MCU_col_num++) {
|
||||||
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
||||||
blkn = 0; /* index of current DCT block within MCU */
|
blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
start_col = MCU_col_num * compptr->MCU_width;
|
start_col = MCU_col_num * compptr->MCU_width;
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
|
||||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
xindex = compptr->MCU_width;
|
||||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
do {
|
||||||
}
|
*blkp++ = buffer_ptr++;
|
||||||
|
} while (--xindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Try to write the MCU. */
|
/* Try to write the MCU. */
|
||||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
coef->MCU_vert_offset = yoffset;
|
coef->MCU_vert_offset = yoffset;
|
||||||
coef->mcu_ctr = MCU_col_num;
|
coef->MCU_ctr = MCU_col_num;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Completed an MCU row, but perhaps not an iMCU row */
|
/* Completed an MCU row, but perhaps not an iMCU row */
|
||||||
coef->mcu_ctr = 0;
|
coef->MCU_ctr = 0;
|
||||||
}
|
}
|
||||||
/* Completed the iMCU row, advance counters for next one */
|
/* Completed the iMCU row, advance counters for next one */
|
||||||
coef->iMCU_row_num++;
|
coef->iMCU_row_num++;
|
||||||
@ -411,13 +411,6 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
|||||||
{
|
{
|
||||||
my_coef_ptr coef;
|
my_coef_ptr coef;
|
||||||
|
|
||||||
coef = (my_coef_ptr)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
SIZEOF(my_coef_controller));
|
|
||||||
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
|
||||||
coef->pub.start_pass = start_pass_coef;
|
|
||||||
|
|
||||||
/* Create the coefficient buffer. */
|
|
||||||
if (need_full_buffer) {
|
if (need_full_buffer) {
|
||||||
#ifdef FULL_COEF_BUFFER_SUPPORTED
|
#ifdef FULL_COEF_BUFFER_SUPPORTED
|
||||||
/* Allocate a full-image virtual array for each component, */
|
/* Allocate a full-image virtual array for each component, */
|
||||||
@ -425,6 +418,9 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
|||||||
int ci;
|
int ci;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
|
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer));
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||||
@ -440,15 +436,21 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* We only need a single-MCU buffer. */
|
/* We only need a single-MCU buffer. */
|
||||||
JBLOCKROW buffer;
|
JBLOCKARRAY blkp;
|
||||||
int i;
|
JBLOCKROW buffer_ptr;
|
||||||
|
int bi;
|
||||||
|
|
||||||
buffer = (JBLOCKROW)
|
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
|
||||||
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
blkp = coef->MCU_buffer;
|
||||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
buffer_ptr = coef->blk_buffer;
|
||||||
coef->MCU_buffer[i] = buffer + i;
|
bi = C_MAX_BLOCKS_IN_MCU;
|
||||||
}
|
do {
|
||||||
|
*blkp++ = buffer_ptr++;
|
||||||
|
} while (--bi);
|
||||||
coef->whole_image[0] = NULL; /* flag for no virtual arrays */
|
coef->whole_image[0] = NULL; /* flag for no virtual arrays */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coef->pub.start_pass = start_pass_coef;
|
||||||
|
cinfo->coef = &coef->pub;
|
||||||
}
|
}
|
||||||
|
35
3rdparty/libjpeg/jccolor.c
vendored
35
3rdparty/libjpeg/jccolor.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jccolor.c
|
* jccolor.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2011-2019 by Guido Vollbeding.
|
* Modified 2011-2023 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -40,10 +40,10 @@ typedef my_color_converter * my_cconvert_ptr;
|
|||||||
* Note that the derived conversion coefficients given in some of these
|
* Note that the derived conversion coefficients given in some of these
|
||||||
* documents are imprecise. The general conversion equations are
|
* documents are imprecise. The general conversion equations are
|
||||||
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
|
||||||
* Cb = 0.5 * (B - Y) / (1 - Kb)
|
* Cb = (B - Y) / (1 - Kb) / K
|
||||||
* Cr = 0.5 * (R - Y) / (1 - Kr)
|
* Cr = (R - Y) / (1 - Kr) / K
|
||||||
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
|
||||||
* from the 1953 FCC NTSC primaries and CIE Illuminant C),
|
* from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC,
|
||||||
* the conversion equations to be implemented are therefore
|
* the conversion equations to be implemented are therefore
|
||||||
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
* Y = 0.299 * R + 0.587 * G + 0.114 * B
|
||||||
* Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE
|
* Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE
|
||||||
@ -62,8 +62,8 @@ typedef my_color_converter * my_cconvert_ptr;
|
|||||||
* by precalculating the constants times R,G,B for all possible values.
|
* by precalculating the constants times R,G,B for all possible values.
|
||||||
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
||||||
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||||
* reasonable for 16-bit samples, but if you want lossless storage you
|
* reasonable for 16-bit samples, but if you want lossless storage
|
||||||
* shouldn't be changing colorspace anyway.
|
* you shouldn't be changing colorspace anyway.
|
||||||
* The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
|
* The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
|
||||||
* in the tables to save adding them separately in the inner loop.
|
* in the tables to save adding them separately in the inner loop.
|
||||||
*/
|
*/
|
||||||
@ -110,16 +110,16 @@ rgb_ycc_start (j_compress_ptr cinfo)
|
|||||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||||
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
||||||
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
||||||
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
||||||
rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i;
|
rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i;
|
||||||
rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i;
|
rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i;
|
||||||
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
|
||||||
* This ensures that the maximum output will round to MAXJSAMPLE
|
* This ensures that the maximum output will round to MAXJSAMPLE
|
||||||
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
* not MAXJSAMPLE+1, and thus that we don't have to range-limit.
|
||||||
*/
|
*/
|
||||||
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
rgb_ycc_tab[i+B_CB_OFF] = (i << (SCALEBITS-1)) + CBCR_OFFSET + ONE_HALF-1;
|
||||||
/* B=>Cb and R=>Cr tables are the same
|
/* B=>Cb and R=>Cr tables are the same
|
||||||
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.5) * i + CBCR_OFFSET + ONE_HALF-1;
|
rgb_ycc_tab[i+R_CR_OFF] = (i << (SCALEBITS-1)) + CBCR_OFFSET + ONE_HALF-1;
|
||||||
*/
|
*/
|
||||||
rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
|
rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
|
||||||
rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
|
rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
|
||||||
@ -190,8 +190,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert some rows of samples to the JPEG colorspace.
|
* Convert some rows of samples to the JPEG colorspace.
|
||||||
* This version handles RGB->grayscale conversion, which is the same
|
* This version handles RGB->grayscale conversion,
|
||||||
* as the RGB->Y portion of RGB->YCbCr.
|
* which is the same as the RGB->Y portion of RGB->YCbCr.
|
||||||
* We assume rgb_ycc_start has been called (we only use the Y tables).
|
* We assume rgb_ycc_start has been called (we only use the Y tables).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
|||||||
JDIMENSION output_row, int num_rows)
|
JDIMENSION output_row, int num_rows)
|
||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
register int r, g, b;
|
register INT32 y;
|
||||||
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
register INT32 * ctab = cconvert->rgb_ycc_tab;
|
||||||
register JSAMPROW inptr;
|
register JSAMPROW inptr;
|
||||||
register JSAMPROW outptr;
|
register JSAMPROW outptr;
|
||||||
@ -212,14 +212,11 @@ rgb_gray_convert (j_compress_ptr cinfo,
|
|||||||
inptr = *input_buf++;
|
inptr = *input_buf++;
|
||||||
outptr = output_buf[0][output_row++];
|
outptr = output_buf[0][output_row++];
|
||||||
for (col = 0; col < num_cols; col++) {
|
for (col = 0; col < num_cols; col++) {
|
||||||
r = GETJSAMPLE(inptr[RGB_RED]);
|
y = ctab[R_Y_OFF + GETJSAMPLE(inptr[RGB_RED])];
|
||||||
g = GETJSAMPLE(inptr[RGB_GREEN]);
|
y += ctab[G_Y_OFF + GETJSAMPLE(inptr[RGB_GREEN])];
|
||||||
b = GETJSAMPLE(inptr[RGB_BLUE]);
|
y += ctab[B_Y_OFF + GETJSAMPLE(inptr[RGB_BLUE])];
|
||||||
inptr += RGB_PIXELSIZE;
|
inptr += RGB_PIXELSIZE;
|
||||||
/* Y */
|
outptr[col] = (JSAMPLE) (y >> SCALEBITS);
|
||||||
outptr[col] = (JSAMPLE)
|
|
||||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
|
||||||
>> SCALEBITS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
3rdparty/libjpeg/jcdctmgr.c
vendored
29
3rdparty/libjpeg/jcdctmgr.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jcdctmgr.c
|
* jcdctmgr.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2003-2013 by Guido Vollbeding.
|
* Modified 2003-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -66,15 +66,14 @@ typedef union {
|
|||||||
* Perform forward DCT on one or more blocks of a component.
|
* Perform forward DCT on one or more blocks of a component.
|
||||||
*
|
*
|
||||||
* The input samples are taken from the sample_data[] array starting at
|
* The input samples are taken from the sample_data[] array starting at
|
||||||
* position start_row/start_col, and moving to the right for any additional
|
* position start_col, and moving to the right for any additional blocks.
|
||||||
* blocks. The quantized coefficients are returned in coef_blocks[].
|
* The quantized coefficients are returned in coef_blocks[].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_col, JDIMENSION num_blocks)
|
||||||
JDIMENSION num_blocks)
|
|
||||||
/* This version is used for integer DCT implementations. */
|
/* This version is used for integer DCT implementations. */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
@ -84,8 +83,6 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||||
JDIMENSION bi;
|
JDIMENSION bi;
|
||||||
|
|
||||||
sample_data += start_row; /* fold in the vertical offset once */
|
|
||||||
|
|
||||||
for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
|
for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
|
||||||
/* Perform the DCT */
|
/* Perform the DCT */
|
||||||
(*do_dct) (workspace, sample_data, start_col);
|
(*do_dct) (workspace, sample_data, start_col);
|
||||||
@ -136,8 +133,7 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_col, JDIMENSION num_blocks)
|
||||||
JDIMENSION num_blocks)
|
|
||||||
/* This version is used for floating-point DCT implementations. */
|
/* This version is used for floating-point DCT implementations. */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding it tightly. */
|
/* This routine is heavily used, so it's worth coding it tightly. */
|
||||||
@ -147,8 +143,6 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
|
||||||
JDIMENSION bi;
|
JDIMENSION bi;
|
||||||
|
|
||||||
sample_data += start_row; /* fold in the vertical offset once */
|
|
||||||
|
|
||||||
for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
|
for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
|
||||||
/* Perform the DCT */
|
/* Perform the DCT */
|
||||||
(*do_dct) (workspace, sample_data, start_col);
|
(*do_dct) (workspace, sample_data, start_col);
|
||||||
@ -347,13 +341,11 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
|
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
|
||||||
compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size);
|
compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
qtblno = compptr->quant_tbl_no;
|
qtblno = compptr->quant_tbl_no;
|
||||||
/* Make sure specified quantization table is present */
|
/* Make sure specified quantization table is present */
|
||||||
@ -444,7 +436,6 @@ start_pass_fdctmgr (j_compress_ptr cinfo)
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,17 +452,15 @@ jinit_forward_dct (j_compress_ptr cinfo)
|
|||||||
int ci;
|
int ci;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
fdct = (my_fdct_ptr)
|
fdct = (my_fdct_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_fdct_controller));
|
||||||
SIZEOF(my_fdct_controller));
|
|
||||||
cinfo->fdct = &fdct->pub;
|
cinfo->fdct = &fdct->pub;
|
||||||
fdct->pub.start_pass = start_pass_fdctmgr;
|
fdct->pub.start_pass = start_pass_fdctmgr;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
/* Allocate a divisor table for each component */
|
/* Allocate a divisor table for each component */
|
||||||
compptr->dct_table =
|
compptr->dct_table = (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(divisor_table));
|
||||||
SIZEOF(divisor_table));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
296
3rdparty/libjpeg/jchuff.c
vendored
296
3rdparty/libjpeg/jchuff.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jchuff.c
|
* jchuff.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2006-2019 by Guido Vollbeding.
|
* Modified 2006-2023 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -26,17 +26,11 @@
|
|||||||
|
|
||||||
|
|
||||||
/* The legal range of a DCT coefficient is
|
/* The legal range of a DCT coefficient is
|
||||||
* -1024 .. +1023 for 8-bit data;
|
* -1024 .. +1023 for 8-bit sample data precision;
|
||||||
* -16384 .. +16383 for 12-bit data.
|
* -16384 .. +16383 for 12-bit sample data precision.
|
||||||
* Hence the magnitude should always fit in 10 or 14 bits respectively.
|
* Hence the magnitude should always fit in sample data precision + 2 bits.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if BITS_IN_JSAMPLE == 8
|
|
||||||
#define MAX_COEF_BITS 10
|
|
||||||
#else
|
|
||||||
#define MAX_COEF_BITS 14
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Derived data constructed for each Huffman table */
|
/* Derived data constructed for each Huffman table */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -542,11 +536,12 @@ emit_restart_e (huff_entropy_ptr entropy, int restart_num)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
|
int max_coef_bits;
|
||||||
int blkn, ci, tbl;
|
int blkn, ci, tbl;
|
||||||
ISHIFT_TEMPS
|
ISHIFT_TEMPS
|
||||||
|
|
||||||
@ -558,6 +553,9 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
if (entropy->restarts_to_go == 0)
|
if (entropy->restarts_to_go == 0)
|
||||||
emit_restart_e(entropy, entropy->next_restart_num);
|
emit_restart_e(entropy, entropy->next_restart_num);
|
||||||
|
|
||||||
|
/* Since we're encoding a difference, the range limit is twice as much. */
|
||||||
|
max_coef_bits = cinfo->data_precision + 3;
|
||||||
|
|
||||||
/* Encode the MCU data blocks */
|
/* Encode the MCU data blocks */
|
||||||
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
|
||||||
ci = cinfo->MCU_membership[blkn];
|
ci = cinfo->MCU_membership[blkn];
|
||||||
@ -569,12 +567,17 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
|
||||||
|
|
||||||
/* DC differences are figured on the point-transformed values. */
|
/* DC differences are figured on the point-transformed values. */
|
||||||
temp2 = temp - entropy->saved.last_dc_val[ci];
|
if ((temp2 = temp - entropy->saved.last_dc_val[ci]) == 0) {
|
||||||
|
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||||
|
emit_dc_symbol(entropy, tbl, 0);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
entropy->saved.last_dc_val[ci] = temp;
|
entropy->saved.last_dc_val[ci] = temp;
|
||||||
|
|
||||||
/* Encode the DC coefficient difference per section G.1.2.1 */
|
/* Encode the DC coefficient difference per section G.1.2.1 */
|
||||||
temp = temp2;
|
if ((temp = temp2) < 0) {
|
||||||
if (temp < 0) {
|
|
||||||
temp = -temp; /* temp is abs value of input */
|
temp = -temp; /* temp is abs value of input */
|
||||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||||
/* This code assumes we are on a two's complement machine */
|
/* This code assumes we are on a two's complement machine */
|
||||||
@ -583,14 +586,10 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
nbits = 0;
|
nbits = 0;
|
||||||
while (temp) {
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
nbits++;
|
while ((temp >>= 1));
|
||||||
temp >>= 1;
|
/* Check for out-of-range coefficient values */
|
||||||
}
|
if (nbits > max_coef_bits)
|
||||||
/* Check for out-of-range coefficient values.
|
|
||||||
* Since we're encoding a difference, the range limit is twice as much.
|
|
||||||
*/
|
|
||||||
if (nbits > MAX_COEF_BITS+1)
|
|
||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||||
@ -598,8 +597,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/* Emit that number of bits of the value, if positive, */
|
/* Emit that number of bits of the value, if positive, */
|
||||||
/* or the complement of its magnitude, if negative. */
|
/* or the complement of its magnitude, if negative. */
|
||||||
if (nbits) /* emit_bits rejects calls with size 0 */
|
emit_bits_e(entropy, (unsigned int) temp2, nbits);
|
||||||
emit_bits_e(entropy, (unsigned int) temp2, nbits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||||
@ -625,7 +623,7 @@ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
@ -633,7 +631,7 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
register int r, k;
|
register int r, k;
|
||||||
int Se, Al;
|
int Se, Al, max_coef_bits;
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||||
@ -646,6 +644,7 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
Se = cinfo->Se;
|
Se = cinfo->Se;
|
||||||
Al = cinfo->Al;
|
Al = cinfo->Al;
|
||||||
natural_order = cinfo->natural_order;
|
natural_order = cinfo->natural_order;
|
||||||
|
max_coef_bits = cinfo->data_precision + 2;
|
||||||
|
|
||||||
/* Encode the MCU data block */
|
/* Encode the MCU data block */
|
||||||
block = MCU_data[0];
|
block = MCU_data[0];
|
||||||
@ -666,18 +665,23 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
temp = -temp; /* temp is abs value of input */
|
temp = -temp; /* temp is abs value of input */
|
||||||
temp >>= Al; /* apply the point transform */
|
/* Apply the point transform, and watch out for case */
|
||||||
|
/* that nonzero coef is zero after point transform. */
|
||||||
|
if ((temp >>= Al) == 0) {
|
||||||
|
r++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
|
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
|
||||||
temp2 = ~temp;
|
temp2 = ~temp;
|
||||||
} else {
|
} else {
|
||||||
temp >>= Al; /* apply the point transform */
|
/* Apply the point transform, and watch out for case */
|
||||||
|
/* that nonzero coef is zero after point transform. */
|
||||||
|
if ((temp >>= Al) == 0) {
|
||||||
|
r++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
temp2 = temp;
|
temp2 = temp;
|
||||||
}
|
}
|
||||||
/* Watch out for case that nonzero coef is zero after point transform */
|
|
||||||
if (temp == 0) {
|
|
||||||
r++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Emit any pending EOBRUN */
|
/* Emit any pending EOBRUN */
|
||||||
if (entropy->EOBRUN > 0)
|
if (entropy->EOBRUN > 0)
|
||||||
@ -689,11 +693,11 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
nbits = 1; /* there must be at least one 1 bit */
|
nbits = 0;
|
||||||
while ((temp >>= 1))
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
nbits++;
|
while ((temp >>= 1));
|
||||||
/* Check for out-of-range coefficient values */
|
/* Check for out-of-range coefficient values */
|
||||||
if (nbits > MAX_COEF_BITS)
|
if (nbits > max_coef_bits)
|
||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Count/emit Huffman symbol for run length / number of bits */
|
/* Count/emit Huffman symbol for run length / number of bits */
|
||||||
@ -736,7 +740,7 @@ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int Al, blkn;
|
int Al, blkn;
|
||||||
@ -779,7 +783,7 @@ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
@ -916,83 +920,89 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
register int nbits;
|
register int nbits;
|
||||||
register int r, k;
|
register int r, k;
|
||||||
int Se = state->cinfo->lim_Se;
|
int Se = state->cinfo->lim_Se;
|
||||||
|
int max_coef_bits = state->cinfo->data_precision + 3;
|
||||||
const int * natural_order = state->cinfo->natural_order;
|
const int * natural_order = state->cinfo->natural_order;
|
||||||
|
|
||||||
/* Encode the DC coefficient difference per section F.1.2.1 */
|
/* Encode the DC coefficient difference per section F.1.2.1 */
|
||||||
|
|
||||||
temp = temp2 = block[0] - last_dc_val;
|
if ((temp = block[0] - last_dc_val) == 0) {
|
||||||
|
/* Emit the Huffman-coded symbol for the number of bits */
|
||||||
|
if (! emit_bits_s(state, dctbl->ehufco[0], dctbl->ehufsi[0]))
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
if ((temp2 = temp) < 0) {
|
||||||
|
temp = -temp; /* temp is abs value of input */
|
||||||
|
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||||
|
/* This code assumes we are on a two's complement machine */
|
||||||
|
temp2--;
|
||||||
|
}
|
||||||
|
|
||||||
if (temp < 0) {
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
temp = -temp; /* temp is abs value of input */
|
nbits = 0;
|
||||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
/* This code assumes we are on a two's complement machine */
|
while ((temp >>= 1));
|
||||||
temp2--;
|
/* Check for out-of-range coefficient values.
|
||||||
}
|
* Since we're encoding a difference, the range limit is twice as much.
|
||||||
|
*/
|
||||||
|
if (nbits > max_coef_bits)
|
||||||
|
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
/* Emit the Huffman-coded symbol for the number of bits */
|
||||||
nbits = 0;
|
if (! emit_bits_s(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits]))
|
||||||
while (temp) {
|
return FALSE;
|
||||||
nbits++;
|
|
||||||
temp >>= 1;
|
|
||||||
}
|
|
||||||
/* Check for out-of-range coefficient values.
|
|
||||||
* Since we're encoding a difference, the range limit is twice as much.
|
|
||||||
*/
|
|
||||||
if (nbits > MAX_COEF_BITS+1)
|
|
||||||
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
|
||||||
|
|
||||||
/* Emit the Huffman-coded symbol for the number of bits */
|
/* Emit that number of bits of the value, if positive, */
|
||||||
if (! emit_bits_s(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits]))
|
/* or the complement of its magnitude, if negative. */
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Emit that number of bits of the value, if positive, */
|
|
||||||
/* or the complement of its magnitude, if negative. */
|
|
||||||
if (nbits) /* emit_bits rejects calls with size 0 */
|
|
||||||
if (! emit_bits_s(state, (unsigned int) temp2, nbits))
|
if (! emit_bits_s(state, (unsigned int) temp2, nbits))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Encode the AC coefficients per section F.1.2.2 */
|
/* Encode the AC coefficients per section F.1.2.2 */
|
||||||
|
|
||||||
r = 0; /* r = run length of zeros */
|
r = 0; /* r = run length of zeros */
|
||||||
|
|
||||||
for (k = 1; k <= Se; k++) {
|
for (k = 1; k <= Se; k++) {
|
||||||
if ((temp2 = block[natural_order[k]]) == 0) {
|
if ((temp = block[natural_order[k]]) == 0) {
|
||||||
r++;
|
r++;
|
||||||
} else {
|
continue;
|
||||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
|
||||||
while (r > 15) {
|
|
||||||
if (! emit_bits_s(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0]))
|
|
||||||
return FALSE;
|
|
||||||
r -= 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = temp2;
|
|
||||||
if (temp < 0) {
|
|
||||||
temp = -temp; /* temp is abs value of input */
|
|
||||||
/* This code assumes we are on a two's complement machine */
|
|
||||||
temp2--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
|
||||||
nbits = 1; /* there must be at least one 1 bit */
|
|
||||||
while ((temp >>= 1))
|
|
||||||
nbits++;
|
|
||||||
/* Check for out-of-range coefficient values */
|
|
||||||
if (nbits > MAX_COEF_BITS)
|
|
||||||
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
|
||||||
|
|
||||||
/* Emit Huffman symbol for run length / number of bits */
|
|
||||||
temp = (r << 4) + nbits;
|
|
||||||
if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp]))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Emit that number of bits of the value, if positive, */
|
|
||||||
/* or the complement of its magnitude, if negative. */
|
|
||||||
if (! emit_bits_s(state, (unsigned int) temp2, nbits))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
r = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
||||||
|
while (r > 15) {
|
||||||
|
if (! emit_bits_s(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0]))
|
||||||
|
return FALSE;
|
||||||
|
r -= 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((temp2 = temp) < 0) {
|
||||||
|
temp = -temp; /* temp is abs value of input */
|
||||||
|
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
|
||||||
|
/* This code assumes we are on a two's complement machine */
|
||||||
|
temp2--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
|
nbits = 0;
|
||||||
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
|
while ((temp >>= 1));
|
||||||
|
/* Check for out-of-range coefficient values.
|
||||||
|
* Use ">=" instead of ">" so can use the
|
||||||
|
* same one larger limit from DC check here.
|
||||||
|
*/
|
||||||
|
if (nbits >= max_coef_bits)
|
||||||
|
ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
|
/* Emit Huffman symbol for run length / number of bits */
|
||||||
|
temp = (r << 4) + nbits;
|
||||||
|
if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp]))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* Emit that number of bits of the value, if positive, */
|
||||||
|
/* or the complement of its magnitude, if negative. */
|
||||||
|
if (! emit_bits_s(state, (unsigned int) temp2, nbits))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
r = 0; /* reset zero run length */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the last coef(s) were zero, emit an end-of-block code */
|
/* If the last coef(s) were zero, emit an end-of-block code */
|
||||||
@ -1009,7 +1019,7 @@ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_huff (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
working_state state;
|
working_state state;
|
||||||
@ -1122,28 +1132,31 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
|||||||
register int nbits;
|
register int nbits;
|
||||||
register int r, k;
|
register int r, k;
|
||||||
int Se = cinfo->lim_Se;
|
int Se = cinfo->lim_Se;
|
||||||
|
int max_coef_bits = cinfo->data_precision + 3;
|
||||||
const int * natural_order = cinfo->natural_order;
|
const int * natural_order = cinfo->natural_order;
|
||||||
|
|
||||||
/* Encode the DC coefficient difference per section F.1.2.1 */
|
/* Encode the DC coefficient difference per section F.1.2.1 */
|
||||||
|
|
||||||
temp = block[0] - last_dc_val;
|
if ((temp = block[0] - last_dc_val) == 0) {
|
||||||
if (temp < 0)
|
/* Count the Huffman symbol for the number of bits */
|
||||||
temp = -temp;
|
dc_counts[0]++;
|
||||||
|
} else {
|
||||||
|
if (temp < 0)
|
||||||
|
temp = -temp; /* temp is abs value of input */
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
nbits = 0;
|
nbits = 0;
|
||||||
while (temp) {
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
nbits++;
|
while ((temp >>= 1));
|
||||||
temp >>= 1;
|
/* Check for out-of-range coefficient values.
|
||||||
|
* Since we're encoding a difference, the range limit is twice as much.
|
||||||
|
*/
|
||||||
|
if (nbits > max_coef_bits)
|
||||||
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
|
/* Count the Huffman symbol for the number of bits */
|
||||||
|
dc_counts[nbits]++;
|
||||||
}
|
}
|
||||||
/* Check for out-of-range coefficient values.
|
|
||||||
* Since we're encoding a difference, the range limit is twice as much.
|
|
||||||
*/
|
|
||||||
if (nbits > MAX_COEF_BITS+1)
|
|
||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
|
||||||
|
|
||||||
/* Count the Huffman symbol for the number of bits */
|
|
||||||
dc_counts[nbits]++;
|
|
||||||
|
|
||||||
/* Encode the AC coefficients per section F.1.2.2 */
|
/* Encode the AC coefficients per section F.1.2.2 */
|
||||||
|
|
||||||
@ -1152,30 +1165,33 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
|||||||
for (k = 1; k <= Se; k++) {
|
for (k = 1; k <= Se; k++) {
|
||||||
if ((temp = block[natural_order[k]]) == 0) {
|
if ((temp = block[natural_order[k]]) == 0) {
|
||||||
r++;
|
r++;
|
||||||
} else {
|
continue;
|
||||||
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
|
||||||
while (r > 15) {
|
|
||||||
ac_counts[0xF0]++;
|
|
||||||
r -= 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
|
||||||
if (temp < 0)
|
|
||||||
temp = -temp;
|
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
|
||||||
nbits = 1; /* there must be at least one 1 bit */
|
|
||||||
while ((temp >>= 1))
|
|
||||||
nbits++;
|
|
||||||
/* Check for out-of-range coefficient values */
|
|
||||||
if (nbits > MAX_COEF_BITS)
|
|
||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
|
||||||
|
|
||||||
/* Count Huffman symbol for run length / number of bits */
|
|
||||||
ac_counts[(r << 4) + nbits]++;
|
|
||||||
|
|
||||||
r = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
|
||||||
|
while (r > 15) {
|
||||||
|
ac_counts[0xF0]++;
|
||||||
|
r -= 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp < 0)
|
||||||
|
temp = -temp; /* temp is abs value of input */
|
||||||
|
|
||||||
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
|
nbits = 0;
|
||||||
|
do nbits++; /* there must be at least one 1 bit */
|
||||||
|
while ((temp >>= 1));
|
||||||
|
/* Check for out-of-range coefficient values.
|
||||||
|
* Use ">=" instead of ">" so can use the
|
||||||
|
* same one larger limit from DC check here.
|
||||||
|
*/
|
||||||
|
if (nbits >= max_coef_bits)
|
||||||
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
|
/* Count Huffman symbol for run length / number of bits */
|
||||||
|
ac_counts[(r << 4) + nbits]++;
|
||||||
|
|
||||||
|
r = 0; /* reset zero run length */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the last coef(s) were zero, emit an end-of-block code */
|
/* If the last coef(s) were zero, emit an end-of-block code */
|
||||||
@ -1190,7 +1206,7 @@ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_gather (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int blkn, ci;
|
int blkn, ci;
|
||||||
|
28
3rdparty/libjpeg/jcmaster.c
vendored
28
3rdparty/libjpeg/jcmaster.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jcmaster.c
|
* jcmaster.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2003-2019 by Guido Vollbeding.
|
* Modified 2003-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -391,16 +391,16 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
int ci, mcublks, tmp;
|
int ci, mcublks, tmp;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
if (cinfo->comps_in_scan == 1) {
|
if (cinfo->comps_in_scan == 1) {
|
||||||
|
|
||||||
/* Noninterleaved (single-component) scan */
|
/* Noninterleaved (single-component) scan */
|
||||||
compptr = cinfo->cur_comp_info[0];
|
compptr = cinfo->cur_comp_info[0];
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
||||||
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
||||||
|
|
||||||
/* For noninterleaved scan, always one block per MCU */
|
/* For noninterleaved scan, always one block per MCU */
|
||||||
compptr->MCU_width = 1;
|
compptr->MCU_width = 1;
|
||||||
compptr->MCU_height = 1;
|
compptr->MCU_height = 1;
|
||||||
@ -413,28 +413,26 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||||
compptr->last_row_height = tmp;
|
compptr->last_row_height = tmp;
|
||||||
|
|
||||||
/* Prepare array describing MCU composition */
|
/* Prepare array describing MCU composition */
|
||||||
cinfo->blocks_in_MCU = 1;
|
cinfo->blocks_in_MCU = 1;
|
||||||
cinfo->MCU_membership[0] = 0;
|
cinfo->MCU_membership[0] = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Interleaved (multi-component) scan */
|
/* Interleaved (multi-component) scan */
|
||||||
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
||||||
MAX_COMPS_IN_SCAN);
|
MAX_COMPS_IN_SCAN);
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = (JDIMENSION)
|
cinfo->MCUs_per_row = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->jpeg_width,
|
jdiv_round_up((long) cinfo->jpeg_width,
|
||||||
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
|
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
|
||||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows;
|
||||||
jdiv_round_up((long) cinfo->jpeg_height,
|
|
||||||
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
|
|
||||||
|
|
||||||
cinfo->blocks_in_MCU = 0;
|
cinfo->blocks_in_MCU = 0;
|
||||||
|
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
/* Sampling factors give # of blocks of component in each MCU */
|
/* Sampling factors give # of blocks of component in each MCU */
|
||||||
@ -457,7 +455,7 @@ per_scan_setup (j_compress_ptr cinfo)
|
|||||||
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert restart specified in rows to actual MCU count. */
|
/* Convert restart specified in rows to actual MCU count. */
|
||||||
|
20
3rdparty/libjpeg/jconfig.h
vendored
20
3rdparty/libjpeg/jconfig.h
vendored
@ -1,6 +1,8 @@
|
|||||||
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT. */
|
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 9x or NT.
|
||||||
/* This file also works for Borland C++ 32-bit (bcc32) on Windows 9x or NT. */
|
* This file also works for Borland/Embarcadero C++ for Win32 or Win64
|
||||||
/* see jconfig.txt for explanations */
|
* (CLI: bcc32, bcc32c, bcc32x, bcc64; GUI IDE: C++Builder/RAD Studio).
|
||||||
|
* See jconfig.txt for explanations.
|
||||||
|
*/
|
||||||
|
|
||||||
#define HAVE_PROTOTYPES
|
#define HAVE_PROTOTYPES
|
||||||
#define HAVE_UNSIGNED_CHAR
|
#define HAVE_UNSIGNED_CHAR
|
||||||
@ -28,6 +30,16 @@ typedef unsigned char boolean;
|
|||||||
#endif
|
#endif
|
||||||
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||||
|
|
||||||
|
/* Define custom RGB color order, prevent jmorecfg.h from redefinition */
|
||||||
|
#undef JPEG_HAVE_RGB_CUSTOM
|
||||||
|
/* Use Windows custom BGR color order defined in jmorecfg.h */
|
||||||
|
#undef JPEG_USE_RGB_CUSTOM
|
||||||
|
|
||||||
|
/* Define custom file I/O functions, prevent jinclude.h from redefinition */
|
||||||
|
#undef JPEG_HAVE_FILE_IO_CUSTOM
|
||||||
|
/* Use Delphi custom file I/O functions defined in jinclude.h */
|
||||||
|
#undef JPEG_USE_FILE_IO_CUSTOM
|
||||||
|
|
||||||
|
|
||||||
#ifdef JPEG_INTERNALS
|
#ifdef JPEG_INTERNALS
|
||||||
|
|
||||||
@ -44,7 +56,7 @@ typedef unsigned char boolean;
|
|||||||
#define TARGA_SUPPORTED /* Targa image file format */
|
#define TARGA_SUPPORTED /* Targa image file format */
|
||||||
|
|
||||||
#define TWO_FILE_COMMANDLINE /* optional */
|
#define TWO_FILE_COMMANDLINE /* optional */
|
||||||
#define USE_SETMODE /* Microsoft has setmode() */
|
#define USE_SETMODE /* Microsoft/Borland/Embarcadero have setmode() */
|
||||||
#undef NEED_SIGNAL_CATCHER
|
#undef NEED_SIGNAL_CATCHER
|
||||||
#undef DONT_USE_B_MODE
|
#undef DONT_USE_B_MODE
|
||||||
#undef PROGRESS_REPORT /* optional */
|
#undef PROGRESS_REPORT /* optional */
|
||||||
|
21
3rdparty/libjpeg/jcparam.c
vendored
21
3rdparty/libjpeg/jcparam.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jcparam.c
|
* jcparam.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2019 by Guido Vollbeding.
|
* Modified 2003-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -62,8 +62,9 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
|||||||
|
|
||||||
|
|
||||||
/* These are the sample quantization tables given in JPEG spec section K.1.
|
/* These are the sample quantization tables given in JPEG spec section K.1.
|
||||||
* The spec says that the values given produce "good" quality, and
|
* NOTE: chrominance DC value is changed from 17 to 16 for lossless support.
|
||||||
* when divided by 2, "very good" quality.
|
* The spec says that the values given produce "good" quality,
|
||||||
|
* and when divided by 2, "very good" quality.
|
||||||
*/
|
*/
|
||||||
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
|
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
|
||||||
16, 11, 10, 16, 24, 40, 51, 61,
|
16, 11, 10, 16, 24, 40, 51, 61,
|
||||||
@ -76,7 +77,7 @@ static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
|
|||||||
72, 92, 95, 98, 112, 100, 103, 99
|
72, 92, 95, 98, 112, 100, 103, 99
|
||||||
};
|
};
|
||||||
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
||||||
17, 18, 24, 47, 99, 99, 99, 99,
|
16, 18, 24, 47, 99, 99, 99, 99,
|
||||||
18, 21, 26, 66, 99, 99, 99, 99,
|
18, 21, 26, 66, 99, 99, 99, 99,
|
||||||
24, 26, 56, 99, 99, 99, 99, 99,
|
24, 26, 56, 99, 99, 99, 99, 99,
|
||||||
47, 66, 99, 99, 99, 99, 99, 99,
|
47, 66, 99, 99, 99, 99, 99, 99,
|
||||||
@ -379,11 +380,13 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0,
|
SET_COMP(0, 0x52 /* 'R' */, 1,1,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0,
|
SET_COMP(2, 0x42 /* 'B' */, 1,1,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
@ -417,11 +420,13 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
/* Add offset 0x20 to the normal R/G/B component IDs */
|
/* Add offset 0x20 to the normal R/G/B component IDs */
|
||||||
SET_COMP(0, 0x72 /* 'r' */, 1,1, 0,
|
SET_COMP(0, 0x72 /* 'r' */, 1,1,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0);
|
SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(2, 0x62 /* 'b' */, 1,1, 0,
|
SET_COMP(2, 0x62 /* 'b' */, 1,1,
|
||||||
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
|
||||||
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
|
22
3rdparty/libjpeg/jcprepct.c
vendored
22
3rdparty/libjpeg/jcprepct.c
vendored
@ -2,6 +2,7 @@
|
|||||||
* jcprepct.c
|
* jcprepct.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
|
* Modified 2003-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -109,7 +110,8 @@ expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
|
|||||||
register int row;
|
register int row;
|
||||||
|
|
||||||
for (row = input_rows; row < output_rows; row++) {
|
for (row = input_rows; row < output_rows; row++) {
|
||||||
jcopy_sample_rows(image_data, input_rows-1, image_data, row,
|
jcopy_sample_rows(image_data + input_rows - 1,
|
||||||
|
image_data + row,
|
||||||
1, num_cols);
|
1, num_cols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,8 +222,8 @@ pre_process_context (j_compress_ptr cinfo,
|
|||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
int row;
|
int row;
|
||||||
for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
|
for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
|
||||||
jcopy_sample_rows(prep->color_buf[ci], 0,
|
jcopy_sample_rows(prep->color_buf[ci],
|
||||||
prep->color_buf[ci], -row,
|
prep->color_buf[ci] - row,
|
||||||
1, cinfo->image_width);
|
1, cinfo->image_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,10 +279,9 @@ create_context_buffer (j_compress_ptr cinfo)
|
|||||||
/* Grab enough space for fake row pointers for all the components;
|
/* Grab enough space for fake row pointers for all the components;
|
||||||
* we need five row groups' worth of pointers for each component.
|
* we need five row groups' worth of pointers for each component.
|
||||||
*/
|
*/
|
||||||
fake_buffer = (JSAMPARRAY)
|
fake_buffer = (JSAMPARRAY) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
(cinfo->num_components * 5 * rgroup_height) *
|
(cinfo->num_components * 5 * rgroup_height) * SIZEOF(JSAMPROW));
|
||||||
SIZEOF(JSAMPROW));
|
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
@ -324,10 +325,9 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
|||||||
if (need_full_buffer) /* safety check */
|
if (need_full_buffer) /* safety check */
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
|
|
||||||
prep = (my_prep_ptr)
|
prep = (my_prep_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_prep_controller));
|
||||||
SIZEOF(my_prep_controller));
|
cinfo->prep = &prep->pub;
|
||||||
cinfo->prep = (struct jpeg_c_prep_controller *) prep;
|
|
||||||
prep->pub.start_pass = start_pass_prep;
|
prep->pub.start_pass = start_pass_prep;
|
||||||
|
|
||||||
/* Allocate the color conversion buffer.
|
/* Allocate the color conversion buffer.
|
||||||
|
10
3rdparty/libjpeg/jcsample.c
vendored
10
3rdparty/libjpeg/jcsample.c
vendored
@ -2,6 +2,7 @@
|
|||||||
* jcsample.c
|
* jcsample.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
|
* Modified 2003-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -200,7 +201,7 @@ fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||||
{
|
{
|
||||||
/* Copy the data */
|
/* Copy the data */
|
||||||
jcopy_sample_rows(input_data, 0, output_data, 0,
|
jcopy_sample_rows(input_data, output_data,
|
||||||
cinfo->max_v_samp_factor, cinfo->image_width);
|
cinfo->max_v_samp_factor, cinfo->image_width);
|
||||||
/* Edge-expand */
|
/* Edge-expand */
|
||||||
expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
|
||||||
@ -483,10 +484,9 @@ jinit_downsampler (j_compress_ptr cinfo)
|
|||||||
boolean smoothok = TRUE;
|
boolean smoothok = TRUE;
|
||||||
int h_in_group, v_in_group, h_out_group, v_out_group;
|
int h_in_group, v_in_group, h_out_group, v_out_group;
|
||||||
|
|
||||||
downsample = (my_downsample_ptr)
|
downsample = (my_downsample_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_downsampler));
|
||||||
SIZEOF(my_downsampler));
|
cinfo->downsample = &downsample->pub;
|
||||||
cinfo->downsample = (struct jpeg_downsampler *) downsample;
|
|
||||||
downsample->pub.start_pass = start_pass_downsample;
|
downsample->pub.start_pass = start_pass_downsample;
|
||||||
downsample->pub.downsample = sep_downsample;
|
downsample->pub.downsample = sep_downsample;
|
||||||
downsample->pub.need_context_rows = FALSE;
|
downsample->pub.need_context_rows = FALSE;
|
||||||
|
56
3rdparty/libjpeg/jctrans.c
vendored
56
3rdparty/libjpeg/jctrans.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jctrans.c
|
* jctrans.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1995-1998, Thomas G. Lane.
|
* Copyright (C) 1995-1998, Thomas G. Lane.
|
||||||
* Modified 2000-2017 by Guido Vollbeding.
|
* Modified 2000-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -224,7 +224,7 @@ typedef struct {
|
|||||||
struct jpeg_c_coef_controller pub; /* public fields */
|
struct jpeg_c_coef_controller pub; /* public fields */
|
||||||
|
|
||||||
JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
||||||
JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
|
JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
|
||||||
int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
||||||
int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ typedef struct {
|
|||||||
jvirt_barray_ptr * whole_image;
|
jvirt_barray_ptr * whole_image;
|
||||||
|
|
||||||
/* Workspace for constructing dummy blocks at right/bottom edges. */
|
/* Workspace for constructing dummy blocks at right/bottom edges. */
|
||||||
JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];
|
JBLOCK dummy_buffer[C_MAX_BLOCKS_IN_MCU];
|
||||||
} my_coef_controller;
|
} my_coef_controller;
|
||||||
|
|
||||||
typedef my_coef_controller * my_coef_ptr;
|
typedef my_coef_controller * my_coef_ptr;
|
||||||
@ -257,7 +257,7 @@ start_iMCU_row (j_compress_ptr cinfo)
|
|||||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
coef->mcu_ctr = 0;
|
coef->MCU_ctr = 0;
|
||||||
coef->MCU_vert_offset = 0;
|
coef->MCU_vert_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,25 +315,30 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
/* Loop to process one whole iMCU row */
|
/* Loop to process one whole iMCU row */
|
||||||
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
||||||
yoffset++) {
|
yoffset++) {
|
||||||
for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||||
MCU_col_num++) {
|
MCU_col_num++) {
|
||||||
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
||||||
blkn = 0; /* index of current DCT block within MCU */
|
blkn = 0; /* index of current DCT block within MCU */
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
start_col = MCU_col_num * compptr->MCU_width;
|
|
||||||
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||||
: compptr->last_col_width;
|
: compptr->last_col_width;
|
||||||
|
start_col = MCU_col_num * compptr->MCU_width;
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||||
yindex+yoffset < compptr->last_row_height) {
|
yoffset + yindex < compptr->last_row_height) {
|
||||||
/* Fill in pointers to real blocks in this row */
|
/* Fill in pointers to real blocks in this row */
|
||||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
|
||||||
for (xindex = 0; xindex < blockcnt; xindex++)
|
xindex = blockcnt;
|
||||||
|
do {
|
||||||
MCU_buffer[blkn++] = buffer_ptr++;
|
MCU_buffer[blkn++] = buffer_ptr++;
|
||||||
|
} while (--xindex);
|
||||||
|
/* Dummy blocks at right edge */
|
||||||
|
if ((xindex = compptr->MCU_width - blockcnt) == 0)
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
/* At bottom of image, need a whole row of dummy blocks */
|
/* At bottom of image, need a whole row of dummy blocks */
|
||||||
xindex = 0;
|
xindex = compptr->MCU_width;
|
||||||
}
|
}
|
||||||
/* Fill in any dummy blocks needed in this row.
|
/* Fill in any dummy blocks needed in this row.
|
||||||
* Dummy blocks are filled in the same way as in jccoefct.c:
|
* Dummy blocks are filled in the same way as in jccoefct.c:
|
||||||
@ -341,23 +346,23 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
* block's DC value. The init routine has already zeroed the
|
* block's DC value. The init routine has already zeroed the
|
||||||
* AC entries, so we need only set the DC entries correctly.
|
* AC entries, so we need only set the DC entries correctly.
|
||||||
*/
|
*/
|
||||||
for (; xindex < compptr->MCU_width; xindex++) {
|
buffer_ptr = coef->dummy_buffer + blkn;
|
||||||
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
do {
|
||||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
buffer_ptr[0][0] = MCU_buffer[blkn-1][0][0];
|
||||||
blkn++;
|
MCU_buffer[blkn++] = buffer_ptr++;
|
||||||
}
|
} while (--xindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Try to write the MCU. */
|
/* Try to write the MCU. */
|
||||||
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
coef->MCU_vert_offset = yoffset;
|
coef->MCU_vert_offset = yoffset;
|
||||||
coef->mcu_ctr = MCU_col_num;
|
coef->MCU_ctr = MCU_col_num;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Completed an MCU row, but perhaps not an iMCU row */
|
/* Completed an MCU row, but perhaps not an iMCU row */
|
||||||
coef->mcu_ctr = 0;
|
coef->MCU_ctr = 0;
|
||||||
}
|
}
|
||||||
/* Completed the iMCU row, advance counters for next one */
|
/* Completed the iMCU row, advance counters for next one */
|
||||||
coef->iMCU_row_num++;
|
coef->iMCU_row_num++;
|
||||||
@ -379,12 +384,9 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
|||||||
jvirt_barray_ptr * coef_arrays)
|
jvirt_barray_ptr * coef_arrays)
|
||||||
{
|
{
|
||||||
my_coef_ptr coef;
|
my_coef_ptr coef;
|
||||||
JBLOCKROW buffer;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
coef = (my_coef_ptr)
|
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
|
||||||
SIZEOF(my_coef_controller));
|
|
||||||
cinfo->coef = &coef->pub;
|
cinfo->coef = &coef->pub;
|
||||||
coef->pub.start_pass = start_pass_coef;
|
coef->pub.start_pass = start_pass_coef;
|
||||||
coef->pub.compress_data = compress_output;
|
coef->pub.compress_data = compress_output;
|
||||||
@ -392,12 +394,6 @@ transencode_coef_controller (j_compress_ptr cinfo,
|
|||||||
/* Save pointer to virtual arrays */
|
/* Save pointer to virtual arrays */
|
||||||
coef->whole_image = coef_arrays;
|
coef->whole_image = coef_arrays;
|
||||||
|
|
||||||
/* Allocate and pre-zero space for dummy DCT blocks. */
|
/* Pre-zero space for dummy DCT blocks */
|
||||||
buffer = (JBLOCKROW)
|
MEMZERO(coef->dummy_buffer, SIZEOF(coef->dummy_buffer));
|
||||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
|
||||||
FMEMZERO((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
|
||||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
|
||||||
coef->dummy_buffer[i] = buffer + i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
35
3rdparty/libjpeg/jdapimin.c
vendored
35
3rdparty/libjpeg/jdapimin.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdapimin.c
|
* jdapimin.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* Modified 2009-2013 by Guido Vollbeding.
|
* Modified 2009-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -114,7 +114,7 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
|
|||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
default_decompress_parms (j_decompress_ptr cinfo)
|
default_decompress_parms (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
int cid0, cid1, cid2;
|
int cid0, cid1, cid2, cid3;
|
||||||
|
|
||||||
/* Guess the input colorspace, and set output colorspace accordingly. */
|
/* Guess the input colorspace, and set output colorspace accordingly. */
|
||||||
/* Note application may override our guesses. */
|
/* Note application may override our guesses. */
|
||||||
@ -123,13 +123,16 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
cinfo->jpeg_color_space = JCS_GRAYSCALE;
|
cinfo->jpeg_color_space = JCS_GRAYSCALE;
|
||||||
cinfo->out_color_space = JCS_GRAYSCALE;
|
cinfo->out_color_space = JCS_GRAYSCALE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
cid0 = cinfo->comp_info[0].component_id;
|
cid0 = cinfo->comp_info[0].component_id;
|
||||||
cid1 = cinfo->comp_info[1].component_id;
|
cid1 = cinfo->comp_info[1].component_id;
|
||||||
cid2 = cinfo->comp_info[2].component_id;
|
cid2 = cinfo->comp_info[2].component_id;
|
||||||
|
|
||||||
/* First try to guess from the component IDs */
|
/* For robust detection of standard colorspaces
|
||||||
|
* regardless of the presence of special markers,
|
||||||
|
* check component IDs from SOF marker first.
|
||||||
|
*/
|
||||||
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
|
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
|
||||||
cinfo->jpeg_color_space = JCS_YCbCr;
|
cinfo->jpeg_color_space = JCS_YCbCr;
|
||||||
else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
|
else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
|
||||||
@ -151,7 +154,6 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
default:
|
default:
|
||||||
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
||||||
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
||||||
@ -160,9 +162,22 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
/* Always guess RGB is proper output colorspace. */
|
/* Always guess RGB is proper output colorspace. */
|
||||||
cinfo->out_color_space = JCS_RGB;
|
cinfo->out_color_space = JCS_RGB;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if (cinfo->saw_Adobe_marker) {
|
cid0 = cinfo->comp_info[0].component_id;
|
||||||
|
cid1 = cinfo->comp_info[1].component_id;
|
||||||
|
cid2 = cinfo->comp_info[2].component_id;
|
||||||
|
cid3 = cinfo->comp_info[3].component_id;
|
||||||
|
|
||||||
|
/* For robust detection of standard colorspaces
|
||||||
|
* regardless of the presence of special markers,
|
||||||
|
* check component IDs from SOF marker first.
|
||||||
|
*/
|
||||||
|
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03 && cid3 == 0x04)
|
||||||
|
cinfo->jpeg_color_space = JCS_YCCK;
|
||||||
|
else if (cid0 == 0x43 && cid1 == 0x4D && cid2 == 0x59 && cid3 == 0x4B)
|
||||||
|
cinfo->jpeg_color_space = JCS_CMYK; /* ASCII 'C', 'M', 'Y', 'K' */
|
||||||
|
else if (cinfo->saw_Adobe_marker) {
|
||||||
switch (cinfo->Adobe_transform) {
|
switch (cinfo->Adobe_transform) {
|
||||||
case 0:
|
case 0:
|
||||||
cinfo->jpeg_color_space = JCS_CMYK;
|
cinfo->jpeg_color_space = JCS_CMYK;
|
||||||
@ -173,19 +188,17 @@ default_decompress_parms (j_decompress_ptr cinfo)
|
|||||||
default:
|
default:
|
||||||
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
||||||
cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
|
cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* No special markers, assume straight CMYK. */
|
/* Unknown IDs and no special markers, assume straight CMYK. */
|
||||||
cinfo->jpeg_color_space = JCS_CMYK;
|
cinfo->jpeg_color_space = JCS_CMYK;
|
||||||
}
|
}
|
||||||
cinfo->out_color_space = JCS_CMYK;
|
cinfo->out_color_space = JCS_CMYK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cinfo->jpeg_color_space = JCS_UNKNOWN;
|
cinfo->jpeg_color_space = JCS_UNKNOWN;
|
||||||
cinfo->out_color_space = JCS_UNKNOWN;
|
cinfo->out_color_space = JCS_UNKNOWN;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set defaults for other decompression parameters. */
|
/* Set defaults for other decompression parameters. */
|
||||||
|
12
3rdparty/libjpeg/jdarith.c
vendored
12
3rdparty/libjpeg/jdarith.c
vendored
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jdarith.c
|
* jdarith.c
|
||||||
*
|
*
|
||||||
* Developed 1997-2019 by Guido Vollbeding.
|
* Developed 1997-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -239,7 +239,7 @@ process_restart (j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
@ -318,7 +318,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
@ -400,7 +400,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
unsigned char *st;
|
unsigned char *st;
|
||||||
@ -434,7 +434,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
JBLOCKROW block;
|
JBLOCKROW block;
|
||||||
@ -509,7 +509,7 @@ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
jpeg_component_info * compptr;
|
jpeg_component_info * compptr;
|
||||||
|
16
3rdparty/libjpeg/jdatadst.c
vendored
16
3rdparty/libjpeg/jdatadst.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdatadst.c
|
* jdatadst.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2019 by Guido Vollbeding.
|
* Modified 2009-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -28,17 +28,17 @@ extern void free JPP((void *ptr));
|
|||||||
|
|
||||||
/* Expanded data destination object for stdio output */
|
/* Expanded data destination object for stdio output */
|
||||||
|
|
||||||
|
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct jpeg_destination_mgr pub; /* public fields */
|
struct jpeg_destination_mgr pub; /* public fields */
|
||||||
|
|
||||||
FILE * outfile; /* target stream */
|
FILE * outfile; /* target stream */
|
||||||
JOCTET * buffer; /* start of buffer */
|
JOCTET buffer[OUTPUT_BUF_SIZE]; /* output buffer */
|
||||||
} my_destination_mgr;
|
} my_destination_mgr;
|
||||||
|
|
||||||
typedef my_destination_mgr * my_dest_ptr;
|
typedef my_destination_mgr * my_dest_ptr;
|
||||||
|
|
||||||
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
|
||||||
|
|
||||||
|
|
||||||
/* Expanded data destination object for memory output */
|
/* Expanded data destination object for memory output */
|
||||||
|
|
||||||
@ -65,10 +65,6 @@ init_destination (j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||||
|
|
||||||
/* Allocate the output buffer --- it will be released when done with image */
|
|
||||||
dest->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE, OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
|
||||||
|
|
||||||
dest->pub.next_output_byte = dest->buffer;
|
dest->pub.next_output_byte = dest->buffer;
|
||||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||||
}
|
}
|
||||||
@ -187,8 +183,8 @@ term_mem_destination (j_compress_ptr cinfo)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for output to a stdio stream.
|
* Prepare for output to a stdio stream.
|
||||||
* The caller must have already opened the stream, and is responsible
|
* The caller must have already opened the stream,
|
||||||
* for closing it after finishing compression.
|
* and is responsible for closing it after finishing compression.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
|
23
3rdparty/libjpeg/jdatasrc.c
vendored
23
3rdparty/libjpeg/jdatasrc.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdatasrc.c
|
* jdatasrc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2019 by Guido Vollbeding.
|
* Modified 2009-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -23,18 +23,18 @@
|
|||||||
|
|
||||||
/* Expanded data source object for stdio input */
|
/* Expanded data source object for stdio input */
|
||||||
|
|
||||||
|
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct jpeg_source_mgr pub; /* public fields */
|
struct jpeg_source_mgr pub; /* public fields */
|
||||||
|
|
||||||
FILE * infile; /* source stream */
|
FILE * infile; /* source stream */
|
||||||
JOCTET * buffer; /* start of buffer */
|
JOCTET buffer[INPUT_BUF_SIZE]; /* input buffer */
|
||||||
boolean start_of_file; /* have we gotten any data yet? */
|
boolean start_of_file; /* have we gotten any data yet? */
|
||||||
} my_source_mgr;
|
} my_source_mgr;
|
||||||
|
|
||||||
typedef my_source_mgr * my_src_ptr;
|
typedef my_source_mgr * my_src_ptr;
|
||||||
|
|
||||||
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize source --- called by jpeg_read_header
|
* Initialize source --- called by jpeg_read_header
|
||||||
@ -204,8 +204,8 @@ term_source (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for input from a stdio stream.
|
* Prepare for input from a stdio stream.
|
||||||
* The caller must have already opened the stream, and is responsible
|
* The caller must have already opened the stream,
|
||||||
* for closing it after finishing decompression.
|
* and is responsible for closing it after finishing decompression.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
@ -213,19 +213,16 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
|
|||||||
{
|
{
|
||||||
my_src_ptr src;
|
my_src_ptr src;
|
||||||
|
|
||||||
/* The source object and input buffer are made permanent so that a series
|
/* The source object including the input buffer is made permanent so that
|
||||||
* of JPEG images can be read from the same file by calling jpeg_stdio_src
|
* a series of JPEG images can be read from the same file by calling
|
||||||
* only before the first one. (If we discarded the buffer at the end of
|
* jpeg_stdio_src only before the first one. (If we discarded the buffer
|
||||||
* one image, we'd likely lose the start of the next one.)
|
* at the end of one image, we'd likely lose the start of the next one.)
|
||||||
* This makes it unsafe to use this manager and a different source
|
* This makes it unsafe to use this manager and a different source
|
||||||
* manager serially with the same JPEG object. Caveat programmer.
|
* manager serially with the same JPEG object. Caveat programmer.
|
||||||
*/
|
*/
|
||||||
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
if (cinfo->src == NULL) { /* first time for this JPEG object? */
|
||||||
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
|
||||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
|
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
|
||||||
src = (my_src_ptr) cinfo->src;
|
|
||||||
src->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
|
|
||||||
((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
src = (my_src_ptr) cinfo->src;
|
src = (my_src_ptr) cinfo->src;
|
||||||
|
111
3rdparty/libjpeg/jdcoefct.c
vendored
111
3rdparty/libjpeg/jdcoefct.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdcoefct.c
|
* jdcoefct.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||||
* Modified 2002-2011 by Guido Vollbeding.
|
* Modified 2002-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -19,11 +19,13 @@
|
|||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
|
|
||||||
|
|
||||||
/* Block smoothing is only applicable for progressive JPEG, so: */
|
/* Block smoothing is only applicable for progressive JPEG, so: */
|
||||||
#ifndef D_PROGRESSIVE_SUPPORTED
|
#ifndef D_PROGRESSIVE_SUPPORTED
|
||||||
#undef BLOCK_SMOOTHING_SUPPORTED
|
#undef BLOCK_SMOOTHING_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Private buffer controller object */
|
/* Private buffer controller object */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -38,11 +40,8 @@ typedef struct {
|
|||||||
/* The output side's location is represented by cinfo->output_iMCU_row. */
|
/* The output side's location is represented by cinfo->output_iMCU_row. */
|
||||||
|
|
||||||
/* In single-pass modes, it's sufficient to buffer just one MCU.
|
/* In single-pass modes, it's sufficient to buffer just one MCU.
|
||||||
* We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
|
* We append a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
|
||||||
* and let the entropy decoder write into that workspace each time.
|
* and let the entropy decoder write into that workspace each time.
|
||||||
* (On 80x86, the workspace is FAR even though it's not really very big;
|
|
||||||
* this is to keep the module interfaces unchanged when a large coefficient
|
|
||||||
* buffer is necessary.)
|
|
||||||
* In multi-pass modes, this array points to the current MCU's blocks
|
* In multi-pass modes, this array points to the current MCU's blocks
|
||||||
* within the virtual arrays; it is used only by the input side.
|
* within the virtual arrays; it is used only by the input side.
|
||||||
*/
|
*/
|
||||||
@ -58,10 +57,14 @@ typedef struct {
|
|||||||
int * coef_bits_latch;
|
int * coef_bits_latch;
|
||||||
#define SAVED_COEFS 6 /* we save coef_bits[0..5] */
|
#define SAVED_COEFS 6 /* we save coef_bits[0..5] */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Workspace for single-pass modes (omitted otherwise). */
|
||||||
|
JBLOCK blk_buffer[D_MAX_BLOCKS_IN_MCU];
|
||||||
} my_coef_controller;
|
} my_coef_controller;
|
||||||
|
|
||||||
typedef my_coef_controller * my_coef_ptr;
|
typedef my_coef_controller * my_coef_ptr;
|
||||||
|
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
METHODDEF(int) decompress_onepass
|
METHODDEF(int) decompress_onepass
|
||||||
JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
|
||||||
@ -151,7 +154,8 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||||
int blkn, ci, xindex, yindex, yoffset, useful_width;
|
int ci, xindex, yindex, yoffset, useful_width;
|
||||||
|
JBLOCKROW blkp;
|
||||||
JSAMPARRAY output_ptr;
|
JSAMPARRAY output_ptr;
|
||||||
JDIMENSION start_col, output_col;
|
JDIMENSION start_col, output_col;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
@ -162,10 +166,10 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
yoffset++) {
|
yoffset++) {
|
||||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
|
||||||
MCU_col_num++) {
|
MCU_col_num++) {
|
||||||
|
blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */
|
||||||
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
|
||||||
if (cinfo->lim_Se) /* can bypass in DC only case */
|
if (cinfo->lim_Se) /* can bypass in DC only case */
|
||||||
FMEMZERO((void FAR *) coef->MCU_buffer[0],
|
MEMZERO(blkp, cinfo->blocks_in_MCU * SIZEOF(JBLOCK));
|
||||||
(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
|
|
||||||
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
coef->MCU_vert_offset = yoffset;
|
coef->MCU_vert_offset = yoffset;
|
||||||
@ -173,37 +177,34 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
return JPEG_SUSPENDED;
|
return JPEG_SUSPENDED;
|
||||||
}
|
}
|
||||||
/* Determine where data should go in output_buf and do the IDCT thing.
|
/* Determine where data should go in output_buf and do the IDCT thing.
|
||||||
* We skip dummy blocks at the right and bottom edges (but blkn gets
|
* We skip dummy blocks at the right and bottom edges (but blkp gets
|
||||||
* incremented past them!). Note the inner loop relies on having
|
* incremented past them!).
|
||||||
* allocated the MCU_buffer[] blocks sequentially.
|
|
||||||
*/
|
*/
|
||||||
blkn = 0; /* index of current DCT block within MCU */
|
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
/* Don't bother to IDCT an uninteresting component. */
|
/* Don't bother to IDCT an uninteresting component. */
|
||||||
if (! compptr->component_needed) {
|
if (! compptr->component_needed) {
|
||||||
blkn += compptr->MCU_blocks;
|
blkp += compptr->MCU_blocks;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
|
inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
|
||||||
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
|
||||||
: compptr->last_col_width;
|
|
||||||
output_ptr = output_buf[compptr->component_index] +
|
output_ptr = output_buf[compptr->component_index] +
|
||||||
yoffset * compptr->DCT_v_scaled_size;
|
yoffset * compptr->DCT_v_scaled_size;
|
||||||
|
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
||||||
|
: compptr->last_col_width;
|
||||||
start_col = MCU_col_num * compptr->MCU_sample_width;
|
start_col = MCU_col_num * compptr->MCU_sample_width;
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
if (cinfo->input_iMCU_row < last_iMCU_row ||
|
if (cinfo->input_iMCU_row < last_iMCU_row ||
|
||||||
yoffset+yindex < compptr->last_row_height) {
|
yoffset + yindex < compptr->last_row_height) {
|
||||||
output_col = start_col;
|
output_col = start_col;
|
||||||
for (xindex = 0; xindex < useful_width; xindex++) {
|
for (xindex = 0; xindex < useful_width; xindex++) {
|
||||||
(*inverse_DCT) (cinfo, compptr,
|
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) (blkp + xindex),
|
||||||
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
|
|
||||||
output_ptr, output_col);
|
output_ptr, output_col);
|
||||||
output_col += compptr->DCT_h_scaled_size;
|
output_col += compptr->DCT_h_scaled_size;
|
||||||
}
|
}
|
||||||
|
output_ptr += compptr->DCT_v_scaled_size;
|
||||||
}
|
}
|
||||||
blkn += compptr->MCU_width;
|
blkp += compptr->MCU_width;
|
||||||
output_ptr += compptr->DCT_v_scaled_size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +213,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
}
|
}
|
||||||
/* Completed the iMCU row, advance counters for next one */
|
/* Completed the iMCU row, advance counters for next one */
|
||||||
cinfo->output_iMCU_row++;
|
cinfo->output_iMCU_row++;
|
||||||
if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
|
if (++(cinfo->input_iMCU_row) <= last_iMCU_row) {
|
||||||
start_iMCU_row(cinfo);
|
start_iMCU_row(cinfo);
|
||||||
return JPEG_ROW_COMPLETED;
|
return JPEG_ROW_COMPLETED;
|
||||||
}
|
}
|
||||||
@ -247,8 +248,9 @@ consume_data (j_decompress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||||
int blkn, ci, xindex, yindex, yoffset;
|
int ci, xindex, yindex, yoffset;
|
||||||
JDIMENSION start_col;
|
JDIMENSION start_col;
|
||||||
|
JBLOCKARRAY blkp;
|
||||||
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
||||||
JBLOCKROW buffer_ptr;
|
JBLOCKROW buffer_ptr;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
@ -272,15 +274,16 @@ consume_data (j_decompress_ptr cinfo)
|
|||||||
for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
||||||
MCU_col_num++) {
|
MCU_col_num++) {
|
||||||
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
||||||
blkn = 0; /* index of current DCT block within MCU */
|
blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
start_col = MCU_col_num * compptr->MCU_width;
|
start_col = MCU_col_num * compptr->MCU_width;
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
|
||||||
for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
|
xindex = compptr->MCU_width;
|
||||||
coef->MCU_buffer[blkn++] = buffer_ptr++;
|
do {
|
||||||
}
|
*blkp++ = buffer_ptr++;
|
||||||
|
} while (--xindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Try to fetch the MCU. */
|
/* Try to fetch the MCU. */
|
||||||
@ -370,7 +373,7 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
|
if (++(cinfo->output_iMCU_row) <= last_iMCU_row)
|
||||||
return JPEG_ROW_COMPLETED;
|
return JPEG_ROW_COMPLETED;
|
||||||
return JPEG_SCAN_COMPLETED;
|
return JPEG_SCAN_COMPLETED;
|
||||||
}
|
}
|
||||||
@ -419,10 +422,9 @@ smoothing_ok (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
/* Allocate latch area if not already done */
|
/* Allocate latch area if not already done */
|
||||||
if (coef->coef_bits_latch == NULL)
|
if (coef->coef_bits_latch == NULL)
|
||||||
coef->coef_bits_latch = (int *)
|
coef->coef_bits_latch = (int *) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
cinfo->num_components *
|
cinfo->num_components * (SAVED_COEFS * SIZEOF(int)));
|
||||||
(SAVED_COEFS * SIZEOF(int)));
|
|
||||||
coef_bits_latch = coef->coef_bits_latch;
|
coef_bits_latch = coef->coef_bits_latch;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
@ -662,7 +664,7 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
|
if (++(cinfo->output_iMCU_row) <= last_iMCU_row)
|
||||||
return JPEG_ROW_COMPLETED;
|
return JPEG_ROW_COMPLETED;
|
||||||
return JPEG_SCAN_COMPLETED;
|
return JPEG_SCAN_COMPLETED;
|
||||||
}
|
}
|
||||||
@ -679,17 +681,6 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|||||||
{
|
{
|
||||||
my_coef_ptr coef;
|
my_coef_ptr coef;
|
||||||
|
|
||||||
coef = (my_coef_ptr)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
SIZEOF(my_coef_controller));
|
|
||||||
cinfo->coef = (struct jpeg_d_coef_controller *) coef;
|
|
||||||
coef->pub.start_input_pass = start_input_pass;
|
|
||||||
coef->pub.start_output_pass = start_output_pass;
|
|
||||||
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
|
||||||
coef->coef_bits_latch = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create the coefficient buffer. */
|
|
||||||
if (need_full_buffer) {
|
if (need_full_buffer) {
|
||||||
#ifdef D_MULTISCAN_FILES_SUPPORTED
|
#ifdef D_MULTISCAN_FILES_SUPPORTED
|
||||||
/* Allocate a full-image virtual array for each component, */
|
/* Allocate a full-image virtual array for each component, */
|
||||||
@ -698,6 +689,9 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|||||||
int ci, access_rows;
|
int ci, access_rows;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
|
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer));
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
access_rows = compptr->v_samp_factor;
|
access_rows = compptr->v_samp_factor;
|
||||||
@ -722,20 +716,29 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* We only need a single-MCU buffer. */
|
/* We only need a single-MCU buffer. */
|
||||||
JBLOCKROW buffer;
|
JBLOCKARRAY blkp;
|
||||||
int i;
|
JBLOCKROW buffer_ptr;
|
||||||
|
int bi;
|
||||||
|
|
||||||
buffer = (JBLOCKROW)
|
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
|
||||||
D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
buffer_ptr = coef->blk_buffer;
|
||||||
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
|
|
||||||
coef->MCU_buffer[i] = buffer + i;
|
|
||||||
}
|
|
||||||
if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */
|
if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */
|
||||||
FMEMZERO((void FAR *) buffer,
|
MEMZERO(buffer_ptr, SIZEOF(coef->blk_buffer));
|
||||||
(size_t) (D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)));
|
blkp = coef->MCU_buffer;
|
||||||
|
bi = D_MAX_BLOCKS_IN_MCU;
|
||||||
|
do {
|
||||||
|
*blkp++ = buffer_ptr++;
|
||||||
|
} while (--bi);
|
||||||
coef->pub.consume_data = dummy_consume_data;
|
coef->pub.consume_data = dummy_consume_data;
|
||||||
coef->pub.decompress_data = decompress_onepass;
|
coef->pub.decompress_data = decompress_onepass;
|
||||||
coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
|
coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coef->pub.start_input_pass = start_input_pass;
|
||||||
|
coef->pub.start_output_pass = start_output_pass;
|
||||||
|
#ifdef BLOCK_SMOOTHING_SUPPORTED
|
||||||
|
coef->coef_bits_latch = NULL;
|
||||||
|
#endif
|
||||||
|
cinfo->coef = &coef->pub;
|
||||||
}
|
}
|
||||||
|
180
3rdparty/libjpeg/jdcolor.c
vendored
180
3rdparty/libjpeg/jdcolor.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdcolor.c
|
* jdcolor.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2011-2019 by Guido Vollbeding.
|
* Modified 2011-2023 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -32,7 +32,9 @@ typedef struct {
|
|||||||
INT32 * Cb_g_tab; /* => table for Cb to G conversion */
|
INT32 * Cb_g_tab; /* => table for Cb to G conversion */
|
||||||
|
|
||||||
/* Private state for RGB->Y conversion */
|
/* Private state for RGB->Y conversion */
|
||||||
INT32 * rgb_y_tab; /* => table for RGB to Y conversion */
|
INT32 * R_y_tab; /* => table for R to Y conversion */
|
||||||
|
INT32 * G_y_tab; /* => table for G to Y conversion */
|
||||||
|
INT32 * B_y_tab; /* => table for B to Y conversion */
|
||||||
} my_color_deconverter;
|
} my_color_deconverter;
|
||||||
|
|
||||||
typedef my_color_deconverter * my_cconvert_ptr;
|
typedef my_color_deconverter * my_cconvert_ptr;
|
||||||
@ -87,29 +89,17 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
|||||||
* by precalculating the constants times Cb and Cr for all possible values.
|
* by precalculating the constants times Cb and Cr for all possible values.
|
||||||
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
|
||||||
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
* for 9-bit to 12-bit samples it is still acceptable. It's not very
|
||||||
* reasonable for 16-bit samples, but if you want lossless storage you
|
* reasonable for 16-bit samples, but if you want lossless storage
|
||||||
* shouldn't be changing colorspace anyway.
|
* you shouldn't be changing colorspace anyway.
|
||||||
* The Cr=>R and Cb=>B values can be rounded to integers in advance; the
|
* The Cr=>R and Cb=>B values can be rounded to integers in advance;
|
||||||
* values for the G calculation are left scaled up, since we must add them
|
* the values for the G calculation are left scaled up,
|
||||||
* together before rounding.
|
* since we must add them together before rounding.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||||
#define ONE_HALF ((INT32) 1 << (SCALEBITS-1))
|
#define ONE_HALF ((INT32) 1 << (SCALEBITS-1))
|
||||||
#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
|
#define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||||
|
|
||||||
/* We allocate one big table for RGB->Y conversion and divide it up into
|
|
||||||
* three parts, instead of doing three alloc_small requests. This lets us
|
|
||||||
* use a single table base address, which can be held in a register in the
|
|
||||||
* inner loops on many machines (more than can hold all three addresses,
|
|
||||||
* anyway).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define R_Y_OFF 0 /* offset to R => Y section */
|
|
||||||
#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */
|
|
||||||
#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */
|
|
||||||
#define TABLE_SIZE (3*(MAXJSAMPLE+1))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
|
* Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
|
||||||
@ -249,17 +239,19 @@ LOCAL(void)
|
|||||||
build_rgb_y_table (j_decompress_ptr cinfo)
|
build_rgb_y_table (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
INT32 * rgb_y_tab;
|
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
/* Allocate and fill in the conversion tables. */
|
cconvert->R_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||||
cconvert->rgb_y_tab = rgb_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE, TABLE_SIZE * SIZEOF(INT32));
|
cconvert->G_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
cconvert->B_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
|
||||||
|
|
||||||
for (i = 0; i <= MAXJSAMPLE; i++) {
|
for (i = 0; i <= MAXJSAMPLE; i++) {
|
||||||
rgb_y_tab[i+R_Y_OFF] = FIX(0.299) * i;
|
cconvert->R_y_tab[i] = FIX(0.299) * i;
|
||||||
rgb_y_tab[i+G_Y_OFF] = FIX(0.587) * i;
|
cconvert->G_y_tab[i] = FIX(0.587) * i;
|
||||||
rgb_y_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
|
cconvert->B_y_tab[i] = FIX(0.114) * i + ONE_HALF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,8 +266,10 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
|||||||
JSAMPARRAY output_buf, int num_rows)
|
JSAMPARRAY output_buf, int num_rows)
|
||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
register int r, g, b;
|
register INT32 y;
|
||||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
register INT32 * Rytab = cconvert->R_y_tab;
|
||||||
|
register INT32 * Gytab = cconvert->G_y_tab;
|
||||||
|
register INT32 * Bytab = cconvert->B_y_tab;
|
||||||
register JSAMPROW outptr;
|
register JSAMPROW outptr;
|
||||||
register JSAMPROW inptr0, inptr1, inptr2;
|
register JSAMPROW inptr0, inptr1, inptr2;
|
||||||
register JDIMENSION col;
|
register JDIMENSION col;
|
||||||
@ -288,13 +282,10 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
|||||||
input_row++;
|
input_row++;
|
||||||
outptr = *output_buf++;
|
outptr = *output_buf++;
|
||||||
for (col = 0; col < num_cols; col++) {
|
for (col = 0; col < num_cols; col++) {
|
||||||
r = GETJSAMPLE(inptr0[col]);
|
y = Rytab[GETJSAMPLE(inptr0[col])];
|
||||||
g = GETJSAMPLE(inptr1[col]);
|
y += Gytab[GETJSAMPLE(inptr1[col])];
|
||||||
b = GETJSAMPLE(inptr2[col]);
|
y += Bytab[GETJSAMPLE(inptr2[col])];
|
||||||
/* Y */
|
outptr[col] = (JSAMPLE) (y >> SCALEBITS);
|
||||||
outptr[col] = (JSAMPLE)
|
|
||||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
|
||||||
>> SCALEBITS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,7 +345,10 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
|
|||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
register int r, g, b;
|
register int r, g, b;
|
||||||
register INT32 * ctab = cconvert->rgb_y_tab;
|
register INT32 y;
|
||||||
|
register INT32 * Rytab = cconvert->R_y_tab;
|
||||||
|
register INT32 * Gytab = cconvert->G_y_tab;
|
||||||
|
register INT32 * Bytab = cconvert->B_y_tab;
|
||||||
register JSAMPROW outptr;
|
register JSAMPROW outptr;
|
||||||
register JSAMPROW inptr0, inptr1, inptr2;
|
register JSAMPROW inptr0, inptr1, inptr2;
|
||||||
register JDIMENSION col;
|
register JDIMENSION col;
|
||||||
@ -373,12 +367,10 @@ rgb1_gray_convert (j_decompress_ptr cinfo,
|
|||||||
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
|
||||||
* (modulo) operator is equivalent to the bitmask operator AND.
|
* (modulo) operator is equivalent to the bitmask operator AND.
|
||||||
*/
|
*/
|
||||||
r = (r + g - CENTERJSAMPLE) & MAXJSAMPLE;
|
y = Rytab[(r + g - CENTERJSAMPLE) & MAXJSAMPLE];
|
||||||
b = (b + g - CENTERJSAMPLE) & MAXJSAMPLE;
|
y += Gytab[g];
|
||||||
/* Y */
|
y += Bytab[(b + g - CENTERJSAMPLE) & MAXJSAMPLE];
|
||||||
outptr[col] = (JSAMPLE)
|
outptr[col] = (JSAMPLE) (y >> SCALEBITS);
|
||||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
|
||||||
>> SCALEBITS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,7 +412,7 @@ rgb_convert (j_decompress_ptr cinfo,
|
|||||||
/*
|
/*
|
||||||
* Color conversion for no colorspace change: just copy the data,
|
* Color conversion for no colorspace change: just copy the data,
|
||||||
* converting from separate-planes to interleaved representation.
|
* converting from separate-planes to interleaved representation.
|
||||||
* We assume out_color_components == num_components.
|
* Note: Omit uninteresting components in output buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@ -431,22 +423,27 @@ null_convert (j_decompress_ptr cinfo,
|
|||||||
register JSAMPROW outptr;
|
register JSAMPROW outptr;
|
||||||
register JSAMPROW inptr;
|
register JSAMPROW inptr;
|
||||||
register JDIMENSION count;
|
register JDIMENSION count;
|
||||||
register int num_comps = cinfo->num_components;
|
register int out_comps = cinfo->out_color_components;
|
||||||
JDIMENSION num_cols = cinfo->output_width;
|
JDIMENSION num_cols = cinfo->output_width;
|
||||||
|
JSAMPROW startptr;
|
||||||
int ci;
|
int ci;
|
||||||
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
while (--num_rows >= 0) {
|
while (--num_rows >= 0) {
|
||||||
/* It seems fastest to make a separate pass for each component. */
|
/* It seems fastest to make a separate pass for each component. */
|
||||||
for (ci = 0; ci < num_comps; ci++) {
|
startptr = *output_buf++;
|
||||||
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
inptr = input_buf[ci][input_row];
|
inptr = input_buf[ci][input_row];
|
||||||
outptr = output_buf[0] + ci;
|
outptr = startptr++;
|
||||||
for (count = num_cols; count > 0; count--) {
|
for (count = num_cols; count > 0; count--) {
|
||||||
*outptr = *inptr++; /* don't need GETJSAMPLE() here */
|
*outptr = *inptr++; /* don't need GETJSAMPLE() here */
|
||||||
outptr += num_comps;
|
outptr += out_comps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_row++;
|
input_row++;
|
||||||
output_buf++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +459,7 @@ grayscale_convert (j_decompress_ptr cinfo,
|
|||||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||||
JSAMPARRAY output_buf, int num_rows)
|
JSAMPARRAY output_buf, int num_rows)
|
||||||
{
|
{
|
||||||
jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0,
|
jcopy_sample_rows(input_buf[0] + input_row, output_buf,
|
||||||
num_rows, cinfo->output_width);
|
num_rows, cinfo->output_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,6 +546,46 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert CMYK to YK part of YCCK for colorless output.
|
||||||
|
* We assume build_rgb_y_table has been called.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
cmyk_yk_convert (j_decompress_ptr cinfo,
|
||||||
|
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||||
|
JSAMPARRAY output_buf, int num_rows)
|
||||||
|
{
|
||||||
|
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
|
||||||
|
register INT32 y;
|
||||||
|
register INT32 * Rytab = cconvert->R_y_tab;
|
||||||
|
register INT32 * Gytab = cconvert->G_y_tab;
|
||||||
|
register INT32 * Bytab = cconvert->B_y_tab;
|
||||||
|
register JSAMPROW outptr;
|
||||||
|
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||||
|
register JDIMENSION col;
|
||||||
|
JDIMENSION num_cols = cinfo->output_width;
|
||||||
|
|
||||||
|
while (--num_rows >= 0) {
|
||||||
|
inptr0 = input_buf[0][input_row];
|
||||||
|
inptr1 = input_buf[1][input_row];
|
||||||
|
inptr2 = input_buf[2][input_row];
|
||||||
|
inptr3 = input_buf[3][input_row];
|
||||||
|
input_row++;
|
||||||
|
outptr = *output_buf++;
|
||||||
|
for (col = 0; col < num_cols; col++) {
|
||||||
|
y = Rytab[MAXJSAMPLE - GETJSAMPLE(inptr0[col])];
|
||||||
|
y += Gytab[MAXJSAMPLE - GETJSAMPLE(inptr1[col])];
|
||||||
|
y += Bytab[MAXJSAMPLE - GETJSAMPLE(inptr2[col])];
|
||||||
|
outptr[0] = (JSAMPLE) (y >> SCALEBITS);
|
||||||
|
/* K passes through unchanged */
|
||||||
|
outptr[1] = inptr3[col]; /* don't need GETJSAMPLE here */
|
||||||
|
outptr += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Empty method for start_pass.
|
* Empty method for start_pass.
|
||||||
*/
|
*/
|
||||||
@ -568,7 +605,7 @@ GLOBAL(void)
|
|||||||
jinit_color_deconverter (j_decompress_ptr cinfo)
|
jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_cconvert_ptr cconvert;
|
my_cconvert_ptr cconvert;
|
||||||
int ci;
|
int ci, i;
|
||||||
|
|
||||||
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
|
||||||
@ -608,7 +645,7 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
|
||||||
/* Set out_color_components and conversion method based on requested space.
|
/* Set out_color_components and conversion method based on requested space.
|
||||||
* Also clear the component_needed flags for any unused components,
|
* Also adjust the component_needed flags for any unused components,
|
||||||
* so that earlier pipeline stages can avoid useless computation.
|
* so that earlier pipeline stages can avoid useless computation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -674,9 +711,9 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_BG_RGB:
|
case JCS_BG_RGB:
|
||||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
|
||||||
if (cinfo->jpeg_color_space != JCS_BG_RGB)
|
if (cinfo->jpeg_color_space != JCS_BG_RGB)
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
|
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||||
switch (cinfo->color_transform) {
|
switch (cinfo->color_transform) {
|
||||||
case JCT_NONE:
|
case JCT_NONE:
|
||||||
cconvert->pub.color_convert = rgb_convert;
|
cconvert->pub.color_convert = rgb_convert;
|
||||||
@ -690,25 +727,38 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
|
if (cinfo->jpeg_color_space != JCS_YCCK)
|
||||||
|
goto def_label;
|
||||||
cinfo->out_color_components = 4;
|
cinfo->out_color_components = 4;
|
||||||
switch (cinfo->jpeg_color_space) {
|
cconvert->pub.color_convert = ycck_cmyk_convert;
|
||||||
case JCS_YCCK:
|
build_ycc_rgb_table(cinfo);
|
||||||
cconvert->pub.color_convert = ycck_cmyk_convert;
|
|
||||||
build_ycc_rgb_table(cinfo);
|
|
||||||
break;
|
|
||||||
case JCS_CMYK:
|
|
||||||
cconvert->pub.color_convert = null_convert;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* permit null conversion to same output space */
|
case JCS_YCCK:
|
||||||
|
if (cinfo->jpeg_color_space != JCS_CMYK ||
|
||||||
|
/* Support only YK part of YCCK for colorless output */
|
||||||
|
! cinfo->comp_info[0].component_needed ||
|
||||||
|
cinfo->comp_info[1].component_needed ||
|
||||||
|
cinfo->comp_info[2].component_needed ||
|
||||||
|
! cinfo->comp_info[3].component_needed)
|
||||||
|
goto def_label;
|
||||||
|
cinfo->out_color_components = 2;
|
||||||
|
/* Need all components on input side */
|
||||||
|
cinfo->comp_info[1].component_needed = TRUE;
|
||||||
|
cinfo->comp_info[2].component_needed = TRUE;
|
||||||
|
cconvert->pub.color_convert = cmyk_yk_convert;
|
||||||
|
build_rgb_y_table(cinfo);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: def_label: /* permit null conversion to same output space */
|
||||||
if (cinfo->out_color_space != cinfo->jpeg_color_space)
|
if (cinfo->out_color_space != cinfo->jpeg_color_space)
|
||||||
/* unsupported non-null conversion */
|
/* unsupported non-null conversion */
|
||||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||||
cinfo->out_color_components = cinfo->num_components;
|
i = 0;
|
||||||
|
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||||
|
if (cinfo->comp_info[ci].component_needed)
|
||||||
|
i++; /* count output color components */
|
||||||
|
cinfo->out_color_components = i;
|
||||||
cconvert->pub.color_convert = null_convert;
|
cconvert->pub.color_convert = null_convert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
3rdparty/libjpeg/jdct.h
vendored
4
3rdparty/libjpeg/jdct.h
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdct.h
|
* jdct.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2002-2019 by Guido Vollbeding.
|
* Modified 2002-2023 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -158,7 +158,7 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
|
|||||||
#define jpeg_idct_6x12 jRD6x12
|
#define jpeg_idct_6x12 jRD6x12
|
||||||
#define jpeg_idct_5x10 jRD5x10
|
#define jpeg_idct_5x10 jRD5x10
|
||||||
#define jpeg_idct_4x8 jRD4x8
|
#define jpeg_idct_4x8 jRD4x8
|
||||||
#define jpeg_idct_3x6 jRD3x8
|
#define jpeg_idct_3x6 jRD3x6
|
||||||
#define jpeg_idct_2x4 jRD2x4
|
#define jpeg_idct_2x4 jRD2x4
|
||||||
#define jpeg_idct_1x2 jRD1x2
|
#define jpeg_idct_1x2 jRD1x2
|
||||||
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
#endif /* NEED_SHORT_EXTERNAL_NAMES */
|
||||||
|
14
3rdparty/libjpeg/jdhuff.c
vendored
14
3rdparty/libjpeg/jdhuff.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdhuff.c
|
* jdhuff.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2006-2019 by Guido Vollbeding.
|
* Modified 2006-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -704,7 +704,7 @@ process_restart (j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int Al = cinfo->Al;
|
int Al = cinfo->Al;
|
||||||
@ -776,7 +776,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
register int s, k, r;
|
register int s, k, r;
|
||||||
@ -864,7 +864,7 @@ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
JCOEF p1;
|
JCOEF p1;
|
||||||
@ -913,7 +913,7 @@ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
register int s, k, r;
|
register int s, k, r;
|
||||||
@ -1072,7 +1072,7 @@ undoit:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
const int * natural_order;
|
const int * natural_order;
|
||||||
@ -1201,7 +1201,7 @@ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
decode_mcu (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
|
||||||
{
|
{
|
||||||
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
|
||||||
int blkn;
|
int blkn;
|
||||||
|
39
3rdparty/libjpeg/jdinput.c
vendored
39
3rdparty/libjpeg/jdinput.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdinput.c
|
* jdinput.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2002-2013 by Guido Vollbeding.
|
* Modified 2002-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -330,7 +330,6 @@ initial_setup (j_decompress_ptr cinfo)
|
|||||||
default:
|
default:
|
||||||
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
|
||||||
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
|
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We initialize DCT_scaled_size and min_DCT_scaled_size to block_size.
|
/* We initialize DCT_scaled_size and min_DCT_scaled_size to block_size.
|
||||||
@ -391,16 +390,16 @@ per_scan_setup (j_decompress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
int ci, mcublks, tmp;
|
int ci, mcublks, tmp;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
if (cinfo->comps_in_scan == 1) {
|
if (cinfo->comps_in_scan == 1) {
|
||||||
|
|
||||||
/* Noninterleaved (single-component) scan */
|
/* Noninterleaved (single-component) scan */
|
||||||
compptr = cinfo->cur_comp_info[0];
|
compptr = cinfo->cur_comp_info[0];
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
cinfo->MCUs_per_row = compptr->width_in_blocks;
|
||||||
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
|
||||||
|
|
||||||
/* For noninterleaved scan, always one block per MCU */
|
/* For noninterleaved scan, always one block per MCU */
|
||||||
compptr->MCU_width = 1;
|
compptr->MCU_width = 1;
|
||||||
compptr->MCU_height = 1;
|
compptr->MCU_height = 1;
|
||||||
@ -413,28 +412,26 @@ per_scan_setup (j_decompress_ptr cinfo)
|
|||||||
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||||
compptr->last_row_height = tmp;
|
compptr->last_row_height = tmp;
|
||||||
|
|
||||||
/* Prepare array describing MCU composition */
|
/* Prepare array describing MCU composition */
|
||||||
cinfo->blocks_in_MCU = 1;
|
cinfo->blocks_in_MCU = 1;
|
||||||
cinfo->MCU_membership[0] = 0;
|
cinfo->MCU_membership[0] = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Interleaved (multi-component) scan */
|
/* Interleaved (multi-component) scan */
|
||||||
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
|
||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
|
||||||
MAX_COMPS_IN_SCAN);
|
MAX_COMPS_IN_SCAN);
|
||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = (JDIMENSION)
|
cinfo->MCUs_per_row = (JDIMENSION)
|
||||||
jdiv_round_up((long) cinfo->image_width,
|
jdiv_round_up((long) cinfo->image_width,
|
||||||
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
|
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
|
||||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows;
|
||||||
jdiv_round_up((long) cinfo->image_height,
|
|
||||||
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
|
|
||||||
|
|
||||||
cinfo->blocks_in_MCU = 0;
|
cinfo->blocks_in_MCU = 0;
|
||||||
|
|
||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
/* Sampling factors give # of blocks of component in each MCU */
|
/* Sampling factors give # of blocks of component in each MCU */
|
||||||
@ -457,7 +454,7 @@ per_scan_setup (j_decompress_ptr cinfo)
|
|||||||
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,9 +498,8 @@ latch_quant_tables (j_decompress_ptr cinfo)
|
|||||||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
cinfo->quant_tbl_ptrs[qtblno] == NULL)
|
||||||
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
|
||||||
/* OK, save away the quantization table */
|
/* OK, save away the quantization table */
|
||||||
qtbl = (JQUANT_TBL *)
|
qtbl = (JQUANT_TBL *) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(JQUANT_TBL));
|
||||||
SIZEOF(JQUANT_TBL));
|
|
||||||
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
|
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
|
||||||
compptr->quant_table = qtbl;
|
compptr->quant_table = qtbl;
|
||||||
}
|
}
|
||||||
@ -644,9 +640,8 @@ jinit_input_controller (j_decompress_ptr cinfo)
|
|||||||
my_inputctl_ptr inputctl;
|
my_inputctl_ptr inputctl;
|
||||||
|
|
||||||
/* Create subobject in permanent pool */
|
/* Create subobject in permanent pool */
|
||||||
inputctl = (my_inputctl_ptr)
|
inputctl = (my_inputctl_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_input_controller));
|
||||||
SIZEOF(my_input_controller));
|
|
||||||
cinfo->inputctl = &inputctl->pub;
|
cinfo->inputctl = &inputctl->pub;
|
||||||
/* Initialize method pointers */
|
/* Initialize method pointers */
|
||||||
inputctl->pub.consume_input = consume_markers;
|
inputctl->pub.consume_input = consume_markers;
|
||||||
|
48
3rdparty/libjpeg/jdmainct.c
vendored
48
3rdparty/libjpeg/jdmainct.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdmainct.c
|
* jdmainct.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2002-2016 by Guido Vollbeding.
|
* Modified 2002-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -170,21 +170,22 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
|
|||||||
/* Get top-level space for component array pointers.
|
/* Get top-level space for component array pointers.
|
||||||
* We alloc both arrays with one call to save a few cycles.
|
* We alloc both arrays with one call to save a few cycles.
|
||||||
*/
|
*/
|
||||||
mainp->xbuffer[0] = (JSAMPIMAGE)
|
mainp->xbuffer[0] = (JSAMPIMAGE) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
|
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
|
||||||
mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;
|
mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||||
/* Get space for pointer lists --- M+4 row groups in each list.
|
/* Get space for pointer lists --- M+4 row groups in each list.
|
||||||
* We alloc both pointer lists with one call to save a few cycles.
|
* We alloc both pointer lists with one call to save a few cycles.
|
||||||
*/
|
*/
|
||||||
xbuf = (JSAMPARRAY)
|
xbuf = (JSAMPARRAY) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
JPOOL_IMAGE, 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
|
||||||
2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
|
|
||||||
xbuf += rgroup; /* want one row group at negative offsets */
|
xbuf += rgroup; /* want one row group at negative offsets */
|
||||||
mainp->xbuffer[0][ci] = xbuf;
|
mainp->xbuffer[0][ci] = xbuf;
|
||||||
xbuf += rgroup * (M + 4);
|
xbuf += rgroup * (M + 4);
|
||||||
@ -210,6 +211,8 @@ make_funny_pointers (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||||
xbuf0 = mainp->xbuffer[0][ci];
|
xbuf0 = mainp->xbuffer[0][ci];
|
||||||
@ -250,6 +253,8 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||||
xbuf0 = mainp->xbuffer[0][ci];
|
xbuf0 = mainp->xbuffer[0][ci];
|
||||||
@ -278,6 +283,8 @@ set_bottom_pointers (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
/* Count sample rows in one iMCU row and in one row group */
|
/* Count sample rows in one iMCU row and in one row group */
|
||||||
iMCUheight = compptr->v_samp_factor * compptr->DCT_v_scaled_size;
|
iMCUheight = compptr->v_samp_factor * compptr->DCT_v_scaled_size;
|
||||||
rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
|
rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
|
||||||
@ -333,7 +340,6 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,9 +350,8 @@ start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
process_data_simple_main (j_decompress_ptr cinfo,
|
process_data_simple_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||||
JDIMENSION out_rows_avail)
|
|
||||||
{
|
{
|
||||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||||
|
|
||||||
@ -375,9 +380,8 @@ process_data_simple_main (j_decompress_ptr cinfo,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
process_data_context_main (j_decompress_ptr cinfo,
|
process_data_context_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||||
JDIMENSION out_rows_avail)
|
|
||||||
{
|
{
|
||||||
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
my_main_ptr mainp = (my_main_ptr) cinfo->main;
|
||||||
|
|
||||||
@ -449,13 +453,12 @@ process_data_context_main (j_decompress_ptr cinfo,
|
|||||||
#ifdef QUANT_2PASS_SUPPORTED
|
#ifdef QUANT_2PASS_SUPPORTED
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
process_data_crank_post (j_decompress_ptr cinfo,
|
process_data_crank_post (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||||
JDIMENSION out_rows_avail)
|
|
||||||
{
|
{
|
||||||
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
|
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
|
||||||
(JDIMENSION *) NULL, (JDIMENSION) 0,
|
(JDIMENSION *) NULL, (JDIMENSION) 0,
|
||||||
output_buf, out_row_ctr, out_rows_avail);
|
output_buf, out_row_ctr, out_rows_avail);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* QUANT_2PASS_SUPPORTED */
|
#endif /* QUANT_2PASS_SUPPORTED */
|
||||||
@ -472,9 +475,8 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|||||||
int ci, rgroup, ngroups;
|
int ci, rgroup, ngroups;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
|
||||||
mainp = (my_main_ptr)
|
mainp = (my_main_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller));
|
||||||
SIZEOF(my_main_controller));
|
|
||||||
cinfo->main = &mainp->pub;
|
cinfo->main = &mainp->pub;
|
||||||
mainp->pub.start_pass = start_pass_main;
|
mainp->pub.start_pass = start_pass_main;
|
||||||
|
|
||||||
@ -497,6 +499,8 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
|
|||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue; /* skip uninteresting component */
|
||||||
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
|
||||||
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
|
||||||
mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
||||||
|
29
3rdparty/libjpeg/jdmaster.c
vendored
29
3rdparty/libjpeg/jdmaster.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdmaster.c
|
* jdmaster.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2002-2019 by Guido Vollbeding.
|
* Modified 2002-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -103,10 +103,8 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
* This function is used for full decompression.
|
* This function is used for full decompression.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
#ifdef IDCT_SCALING_SUPPORTED
|
int ci, i;
|
||||||
int ci, ssize;
|
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Prevent application from calling me at wrong times */
|
/* Prevent application from calling me at wrong times */
|
||||||
if (cinfo->global_state != DSTATE_READY)
|
if (cinfo->global_state != DSTATE_READY)
|
||||||
@ -124,7 +122,7 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
ssize = 1;
|
int ssize = 1;
|
||||||
if (! cinfo->raw_data_out)
|
if (! cinfo->raw_data_out)
|
||||||
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
while (cinfo->min_DCT_h_scaled_size * ssize <=
|
||||||
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
|
||||||
@ -166,27 +164,22 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
|
|||||||
#endif /* IDCT_SCALING_SUPPORTED */
|
#endif /* IDCT_SCALING_SUPPORTED */
|
||||||
|
|
||||||
/* Report number of components in selected colorspace. */
|
/* Report number of components in selected colorspace. */
|
||||||
/* Probably this should be in the color conversion module... */
|
/* This should correspond to the actual code in the color conversion module. */
|
||||||
switch (cinfo->out_color_space) {
|
switch (cinfo->out_color_space) {
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
cinfo->out_color_components = 1;
|
cinfo->out_color_components = 1;
|
||||||
break;
|
break;
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
case JCS_BG_RGB:
|
case JCS_BG_RGB:
|
||||||
#if RGB_PIXELSIZE != 3
|
|
||||||
cinfo->out_color_components = RGB_PIXELSIZE;
|
cinfo->out_color_components = RGB_PIXELSIZE;
|
||||||
break;
|
break;
|
||||||
#endif /* else share code with YCbCr */
|
default: /* YCCK <=> CMYK conversion or same colorspace as in file */
|
||||||
case JCS_YCbCr:
|
i = 0;
|
||||||
case JCS_BG_YCC:
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
cinfo->out_color_components = 3;
|
ci++, compptr++)
|
||||||
break;
|
if (compptr->component_needed)
|
||||||
case JCS_CMYK:
|
i++; /* count output color components */
|
||||||
case JCS_YCCK:
|
cinfo->out_color_components = i;
|
||||||
cinfo->out_color_components = 4;
|
|
||||||
break;
|
|
||||||
default: /* else must be same colorspace as in file */
|
|
||||||
cinfo->out_color_components = cinfo->num_components;
|
|
||||||
}
|
}
|
||||||
cinfo->output_components = (cinfo->quantize_colors ? 1 :
|
cinfo->output_components = (cinfo->quantize_colors ? 1 :
|
||||||
cinfo->out_color_components);
|
cinfo->out_color_components);
|
||||||
|
33
3rdparty/libjpeg/jdmerge.c
vendored
33
3rdparty/libjpeg/jdmerge.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdmerge.c
|
* jdmerge.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2013-2019 by Guido Vollbeding.
|
* Modified 2013-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -20,17 +20,17 @@
|
|||||||
* B = Y + K4 * Cb
|
* B = Y + K4 * Cb
|
||||||
* only the Y term varies among the group of pixels corresponding to a pair
|
* only the Y term varies among the group of pixels corresponding to a pair
|
||||||
* of chroma samples, so the rest of the terms can be calculated just once.
|
* of chroma samples, so the rest of the terms can be calculated just once.
|
||||||
* At typical sampling ratios, this eliminates half or three-quarters of the
|
* At typical sampling ratios, this eliminates half or three-quarters
|
||||||
* multiplications needed for color conversion.
|
* of the multiplications needed for color conversion.
|
||||||
*
|
*
|
||||||
* This file currently provides implementations for the following cases:
|
* This file currently provides implementations for the following cases:
|
||||||
* YCC => RGB color conversion only (YCbCr or BG_YCC).
|
* YCC => RGB color conversion only (YCbCr or BG_YCC).
|
||||||
* Sampling ratios of 2h1v or 2h2v.
|
* Sampling ratios of 2h1v or 2h2v.
|
||||||
* No scaling needed at upsample time.
|
* No scaling needed at upsample time.
|
||||||
* Corner-aligned (non-CCIR601) sampling alignment.
|
* Corner-aligned (non-CCIR601) sampling alignment.
|
||||||
* Other special cases could be added, but in most applications these are
|
* Other special cases could be added, but in most applications these
|
||||||
* the only common cases. (For uncommon cases we fall back on the more
|
* are the only common cases. (For uncommon cases we fall back on
|
||||||
* general code in jdsample.c and jdcolor.c.)
|
* the more general code in jdsample.c and jdcolor.c.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
@ -190,7 +190,7 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
|||||||
|
|
||||||
if (upsample->spare_full) {
|
if (upsample->spare_full) {
|
||||||
/* If we have a spare row saved from a previous cycle, just return it. */
|
/* If we have a spare row saved from a previous cycle, just return it. */
|
||||||
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
|
jcopy_sample_rows(& upsample->spare_row, output_buf + *out_row_ctr,
|
||||||
1, upsample->out_row_width);
|
1, upsample->out_row_width);
|
||||||
num_rows = 1;
|
num_rows = 1;
|
||||||
upsample->spare_full = FALSE;
|
upsample->spare_full = FALSE;
|
||||||
@ -286,9 +286,9 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
|
|||||||
/* Do the chroma part of the calculation */
|
/* Do the chroma part of the calculation */
|
||||||
cb = GETJSAMPLE(*inptr1++);
|
cb = GETJSAMPLE(*inptr1++);
|
||||||
cr = GETJSAMPLE(*inptr2++);
|
cr = GETJSAMPLE(*inptr2++);
|
||||||
cred = Crrtab[cr];
|
|
||||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||||
cblue = Cbbtab[cb];
|
cblue = Cbbtab[cb];
|
||||||
|
cred = Crrtab[cr];
|
||||||
/* Fetch 2 Y values and emit 2 pixels */
|
/* Fetch 2 Y values and emit 2 pixels */
|
||||||
y = GETJSAMPLE(*inptr0++);
|
y = GETJSAMPLE(*inptr0++);
|
||||||
outptr[RGB_RED] = range_limit[y + cred];
|
outptr[RGB_RED] = range_limit[y + cred];
|
||||||
@ -303,15 +303,14 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
|
|||||||
}
|
}
|
||||||
/* If image width is odd, do the last output column separately */
|
/* If image width is odd, do the last output column separately */
|
||||||
if (cinfo->output_width & 1) {
|
if (cinfo->output_width & 1) {
|
||||||
|
y = GETJSAMPLE(*inptr0);
|
||||||
cb = GETJSAMPLE(*inptr1);
|
cb = GETJSAMPLE(*inptr1);
|
||||||
cr = GETJSAMPLE(*inptr2);
|
cr = GETJSAMPLE(*inptr2);
|
||||||
cred = Crrtab[cr];
|
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
|
||||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
outptr[RGB_GREEN] = range_limit[y +
|
||||||
cblue = Cbbtab[cb];
|
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
||||||
y = GETJSAMPLE(*inptr0);
|
SCALEBITS))];
|
||||||
outptr[RGB_RED] = range_limit[y + cred];
|
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
|
||||||
outptr[RGB_GREEN] = range_limit[y + cgreen];
|
|
||||||
outptr[RGB_BLUE] = range_limit[y + cblue];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,9 +349,9 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
|||||||
/* Do the chroma part of the calculation */
|
/* Do the chroma part of the calculation */
|
||||||
cb = GETJSAMPLE(*inptr1++);
|
cb = GETJSAMPLE(*inptr1++);
|
||||||
cr = GETJSAMPLE(*inptr2++);
|
cr = GETJSAMPLE(*inptr2++);
|
||||||
cred = Crrtab[cr];
|
|
||||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||||
cblue = Cbbtab[cb];
|
cblue = Cbbtab[cb];
|
||||||
|
cred = Crrtab[cr];
|
||||||
/* Fetch 4 Y values and emit 4 pixels */
|
/* Fetch 4 Y values and emit 4 pixels */
|
||||||
y = GETJSAMPLE(*inptr00++);
|
y = GETJSAMPLE(*inptr00++);
|
||||||
outptr0[RGB_RED] = range_limit[y + cred];
|
outptr0[RGB_RED] = range_limit[y + cred];
|
||||||
@ -379,9 +378,9 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
|||||||
if (cinfo->output_width & 1) {
|
if (cinfo->output_width & 1) {
|
||||||
cb = GETJSAMPLE(*inptr1);
|
cb = GETJSAMPLE(*inptr1);
|
||||||
cr = GETJSAMPLE(*inptr2);
|
cr = GETJSAMPLE(*inptr2);
|
||||||
cred = Crrtab[cr];
|
|
||||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||||
cblue = Cbbtab[cb];
|
cblue = Cbbtab[cb];
|
||||||
|
cred = Crrtab[cr];
|
||||||
y = GETJSAMPLE(*inptr00);
|
y = GETJSAMPLE(*inptr00);
|
||||||
outptr0[RGB_RED] = range_limit[y + cred];
|
outptr0[RGB_RED] = range_limit[y + cred];
|
||||||
outptr0[RGB_GREEN] = range_limit[y + cgreen];
|
outptr0[RGB_GREEN] = range_limit[y + cgreen];
|
||||||
|
75
3rdparty/libjpeg/jdsample.c
vendored
75
3rdparty/libjpeg/jdsample.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jdsample.c
|
* jdsample.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2002-2015 by Guido Vollbeding.
|
* Modified 2002-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -27,7 +27,7 @@
|
|||||||
/* Pointer to routine to upsample a single component */
|
/* Pointer to routine to upsample a single component */
|
||||||
typedef JMETHOD(void, upsample1_ptr,
|
typedef JMETHOD(void, upsample1_ptr,
|
||||||
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
(j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
|
JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr));
|
||||||
|
|
||||||
/* Private subobject */
|
/* Private subobject */
|
||||||
|
|
||||||
@ -102,6 +102,9 @@ sep_upsample (j_decompress_ptr cinfo,
|
|||||||
if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
|
if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
/* Don't bother to upsample an uninteresting component. */
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue;
|
||||||
/* Invoke per-component upsample method. Notice we pass a POINTER
|
/* Invoke per-component upsample method. Notice we pass a POINTER
|
||||||
* to color_buf[ci], so that fullsize_upsample can change it.
|
* to color_buf[ci], so that fullsize_upsample can change it.
|
||||||
*/
|
*/
|
||||||
@ -156,25 +159,12 @@ sep_upsample (j_decompress_ptr cinfo,
|
|||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
|
||||||
{
|
{
|
||||||
*output_data_ptr = input_data;
|
*output_data_ptr = input_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a no-op version used for "uninteresting" components.
|
|
||||||
* These components will not be referenced by color conversion.
|
|
||||||
*/
|
|
||||||
|
|
||||||
METHODDEF(void)
|
|
||||||
noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
|
||||||
{
|
|
||||||
*output_data_ptr = NULL; /* safety check */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This version handles any integral sampling ratios.
|
* This version handles any integral sampling ratios.
|
||||||
* This is not used for typical JPEG files, so it need not be fast.
|
* This is not used for typical JPEG files, so it need not be fast.
|
||||||
@ -188,25 +178,25 @@ noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
|
||||||
{
|
{
|
||||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||||
JSAMPARRAY output_data = *output_data_ptr;
|
JSAMPARRAY output_data, output_end;
|
||||||
register JSAMPROW inptr, outptr;
|
register JSAMPROW inptr, outptr;
|
||||||
register JSAMPLE invalue;
|
register JSAMPLE invalue;
|
||||||
register int h;
|
register int h;
|
||||||
JSAMPROW outend;
|
JSAMPROW outend;
|
||||||
int h_expand, v_expand;
|
int h_expand, v_expand;
|
||||||
int inrow, outrow;
|
|
||||||
|
|
||||||
h_expand = upsample->h_expand[compptr->component_index];
|
h_expand = upsample->h_expand[compptr->component_index];
|
||||||
v_expand = upsample->v_expand[compptr->component_index];
|
v_expand = upsample->v_expand[compptr->component_index];
|
||||||
|
|
||||||
inrow = outrow = 0;
|
output_data = *output_data_ptr;
|
||||||
while (outrow < cinfo->max_v_samp_factor) {
|
output_end = output_data + cinfo->max_v_samp_factor;
|
||||||
|
for (; output_data < output_end; output_data += v_expand) {
|
||||||
/* Generate one output row with proper horizontal expansion */
|
/* Generate one output row with proper horizontal expansion */
|
||||||
inptr = input_data[inrow];
|
inptr = *input_data++;
|
||||||
outptr = output_data[outrow];
|
outptr = *output_data;
|
||||||
outend = outptr + cinfo->output_width;
|
outend = outptr + cinfo->output_width;
|
||||||
while (outptr < outend) {
|
while (outptr < outend) {
|
||||||
invalue = *inptr++; /* don't need GETJSAMPLE() here */
|
invalue = *inptr++; /* don't need GETJSAMPLE() here */
|
||||||
@ -216,11 +206,9 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
}
|
}
|
||||||
/* Generate any additional output rows by duplicating the first one */
|
/* Generate any additional output rows by duplicating the first one */
|
||||||
if (v_expand > 1) {
|
if (v_expand > 1) {
|
||||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
jcopy_sample_rows(output_data, output_data + 1,
|
||||||
v_expand-1, cinfo->output_width);
|
v_expand - 1, cinfo->output_width);
|
||||||
}
|
}
|
||||||
inrow++;
|
|
||||||
outrow += v_expand;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +220,7 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
|
||||||
{
|
{
|
||||||
JSAMPARRAY output_data = *output_data_ptr;
|
JSAMPARRAY output_data = *output_data_ptr;
|
||||||
register JSAMPROW inptr, outptr;
|
register JSAMPROW inptr, outptr;
|
||||||
@ -260,28 +248,26 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
|||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
|
JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
|
||||||
{
|
{
|
||||||
JSAMPARRAY output_data = *output_data_ptr;
|
JSAMPARRAY output_data, output_end;
|
||||||
register JSAMPROW inptr, outptr;
|
register JSAMPROW inptr, outptr;
|
||||||
register JSAMPLE invalue;
|
register JSAMPLE invalue;
|
||||||
JSAMPROW outend;
|
JSAMPROW outend;
|
||||||
int inrow, outrow;
|
|
||||||
|
|
||||||
inrow = outrow = 0;
|
output_data = *output_data_ptr;
|
||||||
while (outrow < cinfo->max_v_samp_factor) {
|
output_end = output_data + cinfo->max_v_samp_factor;
|
||||||
inptr = input_data[inrow];
|
for (; output_data < output_end; output_data += 2) {
|
||||||
outptr = output_data[outrow];
|
inptr = *input_data++;
|
||||||
|
outptr = *output_data;
|
||||||
outend = outptr + cinfo->output_width;
|
outend = outptr + cinfo->output_width;
|
||||||
while (outptr < outend) {
|
while (outptr < outend) {
|
||||||
invalue = *inptr++; /* don't need GETJSAMPLE() here */
|
invalue = *inptr++; /* don't need GETJSAMPLE() here */
|
||||||
*outptr++ = invalue;
|
*outptr++ = invalue;
|
||||||
*outptr++ = invalue;
|
*outptr++ = invalue;
|
||||||
}
|
}
|
||||||
jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
|
jcopy_sample_rows(output_data, output_data + 1,
|
||||||
1, cinfo->output_width);
|
1, cinfo->output_width);
|
||||||
inrow++;
|
|
||||||
outrow += 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,9 +284,8 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
jpeg_component_info * compptr;
|
jpeg_component_info * compptr;
|
||||||
int h_in_group, v_in_group, h_out_group, v_out_group;
|
int h_in_group, v_in_group, h_out_group, v_out_group;
|
||||||
|
|
||||||
upsample = (my_upsample_ptr)
|
upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
|
||||||
SIZEOF(my_upsampler));
|
|
||||||
cinfo->upsample = &upsample->pub;
|
cinfo->upsample = &upsample->pub;
|
||||||
upsample->pub.start_pass = start_pass_upsample;
|
upsample->pub.start_pass = start_pass_upsample;
|
||||||
upsample->pub.upsample = sep_upsample;
|
upsample->pub.upsample = sep_upsample;
|
||||||
@ -314,6 +299,9 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
|
/* Don't bother to upsample an uninteresting component. */
|
||||||
|
if (! compptr->component_needed)
|
||||||
|
continue;
|
||||||
/* Compute size of an "input group" after IDCT scaling. This many samples
|
/* Compute size of an "input group" after IDCT scaling. This many samples
|
||||||
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
|
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
|
||||||
*/
|
*/
|
||||||
@ -324,11 +312,6 @@ jinit_upsampler (j_decompress_ptr cinfo)
|
|||||||
h_out_group = cinfo->max_h_samp_factor;
|
h_out_group = cinfo->max_h_samp_factor;
|
||||||
v_out_group = cinfo->max_v_samp_factor;
|
v_out_group = cinfo->max_v_samp_factor;
|
||||||
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
|
||||||
if (! compptr->component_needed) {
|
|
||||||
/* Don't bother to upsample an uninteresting component. */
|
|
||||||
upsample->methods[ci] = noop_upsample;
|
|
||||||
continue; /* don't need to allocate buffer */
|
|
||||||
}
|
|
||||||
if (h_in_group == h_out_group && v_in_group == v_out_group) {
|
if (h_in_group == h_out_group && v_in_group == v_out_group) {
|
||||||
/* Fullsize components can be processed without any work. */
|
/* Fullsize components can be processed without any work. */
|
||||||
upsample->methods[ci] = fullsize_upsample;
|
upsample->methods[ci] = fullsize_upsample;
|
||||||
|
66
3rdparty/libjpeg/jinclude.h
vendored
66
3rdparty/libjpeg/jinclude.h
vendored
@ -2,7 +2,7 @@
|
|||||||
* jinclude.h
|
* jinclude.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||||
* Modified 2017 by Guido Vollbeding.
|
* Modified 2017-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -11,8 +11,8 @@
|
|||||||
* care of by the standard jconfig symbols, but on really weird systems
|
* care of by the standard jconfig symbols, but on really weird systems
|
||||||
* you may have to edit this file.)
|
* you may have to edit this file.)
|
||||||
*
|
*
|
||||||
* NOTE: this file is NOT intended to be included by applications using the
|
* NOTE: this file is NOT intended to be included by applications using
|
||||||
* JPEG library. Most applications need only include jpeglib.h.
|
* the JPEG library. Most applications need only include jpeglib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -87,11 +87,71 @@
|
|||||||
*
|
*
|
||||||
* Furthermore, macros are provided for fflush() and ferror() in order
|
* Furthermore, macros are provided for fflush() and ferror() in order
|
||||||
* to facilitate adaption by applications using an own FILE class.
|
* to facilitate adaption by applications using an own FILE class.
|
||||||
|
*
|
||||||
|
* You can define your own custom file I/O functions in jconfig.h and
|
||||||
|
* #define JPEG_HAVE_FILE_IO_CUSTOM there to prevent redefinition here.
|
||||||
|
*
|
||||||
|
* You can #define JPEG_USE_FILE_IO_CUSTOM in jconfig.h to use custom file
|
||||||
|
* I/O functions implemented in Delphi VCL (Visual Component Library)
|
||||||
|
* in Vcl.Imaging.jpeg.pas for the TJPEGImage component utilizing
|
||||||
|
* the Delphi RTL (Run-Time Library) TMemoryStream component:
|
||||||
|
*
|
||||||
|
* procedure jpeg_stdio_src(var cinfo: jpeg_decompress_struct;
|
||||||
|
* input_file: TStream); external;
|
||||||
|
*
|
||||||
|
* procedure jpeg_stdio_dest(var cinfo: jpeg_compress_struct;
|
||||||
|
* output_file: TStream); external;
|
||||||
|
*
|
||||||
|
* function jfread(var buf; recsize, reccount: Integer; S: TStream): Integer;
|
||||||
|
* begin
|
||||||
|
* Result := S.Read(buf, recsize * reccount);
|
||||||
|
* end;
|
||||||
|
*
|
||||||
|
* function jfwrite(const buf; recsize, reccount: Integer; S: TStream): Integer;
|
||||||
|
* begin
|
||||||
|
* Result := S.Write(buf, recsize * reccount);
|
||||||
|
* end;
|
||||||
|
*
|
||||||
|
* function jfflush(S: TStream): Integer;
|
||||||
|
* begin
|
||||||
|
* Result := 0;
|
||||||
|
* end;
|
||||||
|
*
|
||||||
|
* function jferror(S: TStream): Integer;
|
||||||
|
* begin
|
||||||
|
* Result := 0;
|
||||||
|
* end;
|
||||||
|
*
|
||||||
|
* TMemoryStream of Delphi RTL has the distinctive feature to provide dynamic
|
||||||
|
* memory buffer management with a file/stream-based interface, particularly for
|
||||||
|
* the write (output) operation, which is easier to apply compared with direct
|
||||||
|
* implementations as given in jdatadst.c for memory destination. Those direct
|
||||||
|
* implementations of dynamic memory write tend to be more difficult to use,
|
||||||
|
* so providing an option like TMemoryStream may be a useful alternative.
|
||||||
|
*
|
||||||
|
* The CFile/CMemFile classes of the Microsoft Foundation Class (MFC) Library
|
||||||
|
* may be used in a similar fashion.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef JPEG_HAVE_FILE_IO_CUSTOM
|
||||||
|
#ifdef JPEG_USE_FILE_IO_CUSTOM
|
||||||
|
extern size_t jfread(void * __ptr, size_t __size, size_t __n, FILE * __stream);
|
||||||
|
extern size_t jfwrite(const void * __ptr, size_t __size, size_t __n, FILE * __stream);
|
||||||
|
extern int jfflush(FILE * __stream);
|
||||||
|
extern int jferror(FILE * __fp);
|
||||||
|
|
||||||
|
#define JFREAD(file,buf,sizeofbuf) \
|
||||||
|
((size_t) jfread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||||
|
#define JFWRITE(file,buf,sizeofbuf) \
|
||||||
|
((size_t) jfwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||||
|
#define JFFLUSH(file) jfflush(file)
|
||||||
|
#define JFERROR(file) jferror(file)
|
||||||
|
#else
|
||||||
#define JFREAD(file,buf,sizeofbuf) \
|
#define JFREAD(file,buf,sizeofbuf) \
|
||||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||||
#define JFWRITE(file,buf,sizeofbuf) \
|
#define JFWRITE(file,buf,sizeofbuf) \
|
||||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||||
#define JFFLUSH(file) fflush(file)
|
#define JFFLUSH(file) fflush(file)
|
||||||
#define JFERROR(file) ferror(file)
|
#define JFERROR(file) ferror(file)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
31
3rdparty/libjpeg/jmorecfg.h
vendored
31
3rdparty/libjpeg/jmorecfg.h
vendored
@ -2,7 +2,7 @@
|
|||||||
* jmorecfg.h
|
* jmorecfg.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 1997-2013 by Guido Vollbeding.
|
* Modified 1997-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -351,8 +351,8 @@ typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
|||||||
|
|
||||||
#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||||
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
|
||||||
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
|
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW) */
|
||||||
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
||||||
/* Note: if you selected more than 8-bit data precision, it is dangerous to
|
/* Note: if you selected more than 8-bit data precision, it is dangerous to
|
||||||
* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
|
* turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
|
||||||
@ -369,8 +369,8 @@ typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
|||||||
|
|
||||||
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||||
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
|
||||||
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
|
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW) */
|
||||||
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
||||||
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
||||||
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
||||||
@ -384,20 +384,31 @@ typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
|||||||
/*
|
/*
|
||||||
* Ordering of RGB data in scanlines passed to or from the application.
|
* Ordering of RGB data in scanlines passed to or from the application.
|
||||||
* If your application wants to deal with data in the order B,G,R, just
|
* If your application wants to deal with data in the order B,G,R, just
|
||||||
* change these macros. You can also deal with formats such as R,G,B,X
|
* #define JPEG_USE_RGB_CUSTOM in jconfig.h, or define your own custom
|
||||||
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
|
* order in jconfig.h and #define JPEG_HAVE_RGB_CUSTOM.
|
||||||
* the offsets will also change the order in which colormap data is organized.
|
* You can also deal with formats such as R,G,B,X (one extra byte per pixel)
|
||||||
|
* by changing RGB_PIXELSIZE.
|
||||||
|
* Note that changing the offsets will also change
|
||||||
|
* the order in which colormap data is organized.
|
||||||
* RESTRICTIONS:
|
* RESTRICTIONS:
|
||||||
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
|
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
|
||||||
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
||||||
* is not 3 (they don't understand about dummy color components!). So you
|
* is not 3 (they don't understand about dummy color components!).
|
||||||
* can't use color quantization if you change that value.
|
* So you can't use color quantization if you change that value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef JPEG_HAVE_RGB_CUSTOM
|
||||||
|
#ifdef JPEG_USE_RGB_CUSTOM
|
||||||
|
#define RGB_RED 2 /* Offset of Red in an RGB scanline element */
|
||||||
|
#define RGB_GREEN 1 /* Offset of Green */
|
||||||
|
#define RGB_BLUE 0 /* Offset of Blue */
|
||||||
|
#else
|
||||||
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
|
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
|
||||||
#define RGB_GREEN 1 /* Offset of Green */
|
#define RGB_GREEN 1 /* Offset of Green */
|
||||||
#define RGB_BLUE 2 /* Offset of Blue */
|
#define RGB_BLUE 2 /* Offset of Blue */
|
||||||
|
#endif
|
||||||
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
|
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Definitions for speed-related optimizations. */
|
/* Definitions for speed-related optimizations. */
|
||||||
|
13
3rdparty/libjpeg/jpegint.h
vendored
13
3rdparty/libjpeg/jpegint.h
vendored
@ -2,7 +2,7 @@
|
|||||||
* jpegint.h
|
* jpegint.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 1997-2019 by Guido Vollbeding.
|
* Modified 1997-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -103,8 +103,7 @@ struct jpeg_downsampler {
|
|||||||
typedef JMETHOD(void, forward_DCT_ptr,
|
typedef JMETHOD(void, forward_DCT_ptr,
|
||||||
(j_compress_ptr cinfo, jpeg_component_info * compptr,
|
(j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_col, JDIMENSION num_blocks));
|
||||||
JDIMENSION num_blocks));
|
|
||||||
|
|
||||||
struct jpeg_forward_dct {
|
struct jpeg_forward_dct {
|
||||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
|
JMETHOD(void, start_pass, (j_compress_ptr cinfo));
|
||||||
@ -115,7 +114,7 @@ struct jpeg_forward_dct {
|
|||||||
/* Entropy encoding */
|
/* Entropy encoding */
|
||||||
struct jpeg_entropy_encoder {
|
struct jpeg_entropy_encoder {
|
||||||
JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
|
JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
|
||||||
JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data));
|
JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKARRAY MCU_data));
|
||||||
JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
|
JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -211,7 +210,7 @@ struct jpeg_marker_reader {
|
|||||||
/* Entropy decoding */
|
/* Entropy decoding */
|
||||||
struct jpeg_entropy_decoder {
|
struct jpeg_entropy_decoder {
|
||||||
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
|
||||||
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKROW *MCU_data));
|
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data));
|
||||||
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
|
JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -416,8 +415,8 @@ EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
|
|||||||
/* Utility routines in jutils.c */
|
/* Utility routines in jutils.c */
|
||||||
EXTERN(long) jdiv_round_up JPP((long a, long b));
|
EXTERN(long) jdiv_round_up JPP((long a, long b));
|
||||||
EXTERN(long) jround_up JPP((long a, long b));
|
EXTERN(long) jround_up JPP((long a, long b));
|
||||||
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row,
|
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array,
|
||||||
JSAMPARRAY output_array, int dest_row,
|
JSAMPARRAY output_array,
|
||||||
int num_rows, JDIMENSION num_cols));
|
int num_rows, JDIMENSION num_cols));
|
||||||
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
|
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
|
||||||
JDIMENSION num_blocks));
|
JDIMENSION num_blocks));
|
||||||
|
4
3rdparty/libjpeg/jpeglib.h
vendored
4
3rdparty/libjpeg/jpeglib.h
vendored
@ -2,7 +2,7 @@
|
|||||||
* jpeglib.h
|
* jpeglib.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2002-2019 by Guido Vollbeding.
|
* Modified 2002-2022 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -39,7 +39,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
|
||||||
#define JPEG_LIB_VERSION_MAJOR 9
|
#define JPEG_LIB_VERSION_MAJOR 9
|
||||||
#define JPEG_LIB_VERSION_MINOR 4
|
#define JPEG_LIB_VERSION_MINOR 6
|
||||||
|
|
||||||
|
|
||||||
/* Various constants determining the sizes of things.
|
/* Various constants determining the sizes of things.
|
||||||
|
32
3rdparty/libjpeg/jquant1.c
vendored
32
3rdparty/libjpeg/jquant1.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jquant1.c
|
* jquant1.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2011 by Guido Vollbeding.
|
* Modified 2011-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -293,8 +293,7 @@ create_colormap (j_decompress_ptr cinfo)
|
|||||||
/* The colors are ordered in the map in standard row-major order, */
|
/* The colors are ordered in the map in standard row-major order, */
|
||||||
/* i.e. rightmost (highest-indexed) color changes most rapidly. */
|
/* i.e. rightmost (highest-indexed) color changes most rapidly. */
|
||||||
|
|
||||||
colormap = (*cinfo->mem->alloc_sarray)
|
colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
||||||
(JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);
|
(JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);
|
||||||
|
|
||||||
/* blksize is number of adjacent repeated entries for a component */
|
/* blksize is number of adjacent repeated entries for a component */
|
||||||
@ -400,9 +399,8 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
|
|||||||
int j,k;
|
int j,k;
|
||||||
INT32 num,den;
|
INT32 num,den;
|
||||||
|
|
||||||
odither = (ODITHER_MATRIX_PTR)
|
odither = (ODITHER_MATRIX_PTR) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ODITHER_MATRIX));
|
||||||
SIZEOF(ODITHER_MATRIX));
|
|
||||||
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
|
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
|
||||||
* Hence the dither value for the matrix cell with fill order f
|
* Hence the dither value for the matrix cell with fill order f
|
||||||
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
|
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
|
||||||
@ -531,8 +529,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
|||||||
|
|
||||||
for (row = 0; row < num_rows; row++) {
|
for (row = 0; row < num_rows; row++) {
|
||||||
/* Initialize output values to 0 so can process components separately */
|
/* Initialize output values to 0 so can process components separately */
|
||||||
FMEMZERO((void FAR *) output_buf[row],
|
FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE));
|
||||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
|
||||||
row_index = cquantize->row_index;
|
row_index = cquantize->row_index;
|
||||||
for (ci = 0; ci < nc; ci++) {
|
for (ci = 0; ci < nc; ci++) {
|
||||||
input_ptr = input_buf[row] + ci;
|
input_ptr = input_buf[row] + ci;
|
||||||
@ -636,8 +633,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
|||||||
|
|
||||||
for (row = 0; row < num_rows; row++) {
|
for (row = 0; row < num_rows; row++) {
|
||||||
/* Initialize output values to 0 so can process components separately */
|
/* Initialize output values to 0 so can process components separately */
|
||||||
FMEMZERO((void FAR *) output_buf[row],
|
FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE));
|
||||||
(size_t) (width * SIZEOF(JSAMPLE)));
|
|
||||||
for (ci = 0; ci < nc; ci++) {
|
for (ci = 0; ci < nc; ci++) {
|
||||||
input_ptr = input_buf[row] + ci;
|
input_ptr = input_buf[row] + ci;
|
||||||
output_ptr = output_buf[row];
|
output_ptr = output_buf[row];
|
||||||
@ -726,10 +722,10 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
|
|||||||
size_t arraysize;
|
size_t arraysize;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));
|
arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR);
|
||||||
for (i = 0; i < cinfo->out_color_components; i++) {
|
for (i = 0; i < cinfo->out_color_components; i++) {
|
||||||
cquantize->fserrors[i] = (FSERRPTR)
|
cquantize->fserrors[i] = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||||
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,13 +776,12 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
|||||||
if (cquantize->fserrors[0] == NULL)
|
if (cquantize->fserrors[0] == NULL)
|
||||||
alloc_fs_workspace(cinfo);
|
alloc_fs_workspace(cinfo);
|
||||||
/* Initialize the propagated errors to zero. */
|
/* Initialize the propagated errors to zero. */
|
||||||
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR));
|
arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR);
|
||||||
for (i = 0; i < cinfo->out_color_components; i++)
|
for (i = 0; i < cinfo->out_color_components; i++)
|
||||||
FMEMZERO((void FAR *) cquantize->fserrors[i], arraysize);
|
FMEMZERO((void FAR *) cquantize->fserrors[i], arraysize);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,10 +818,9 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
my_cquantize_ptr cquantize;
|
my_cquantize_ptr cquantize;
|
||||||
|
|
||||||
cquantize = (my_cquantize_ptr)
|
cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer));
|
||||||
SIZEOF(my_cquantizer));
|
cinfo->cquantize = &cquantize->pub;
|
||||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
|
||||||
cquantize->pub.start_pass = start_pass_1_quant;
|
cquantize->pub.start_pass = start_pass_1_quant;
|
||||||
cquantize->pub.finish_pass = finish_pass_1_quant;
|
cquantize->pub.finish_pass = finish_pass_1_quant;
|
||||||
cquantize->pub.new_color_map = new_color_map_1_quant;
|
cquantize->pub.new_color_map = new_color_map_1_quant;
|
||||||
|
18
3rdparty/libjpeg/jquant2.c
vendored
18
3rdparty/libjpeg/jquant2.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jquant2.c
|
* jquant2.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2011 by Guido Vollbeding.
|
* Modified 2011-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -1197,8 +1197,8 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
|
|||||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||||
|
|
||||||
if (cinfo->dither_mode == JDITHER_FS) {
|
if (cinfo->dither_mode == JDITHER_FS) {
|
||||||
size_t arraysize = (size_t) ((cinfo->output_width + 2) *
|
size_t arraysize = ((size_t) cinfo->output_width + (size_t) 2)
|
||||||
(3 * SIZEOF(FSERROR)));
|
* (3 * SIZEOF(FSERROR));
|
||||||
/* Allocate Floyd-Steinberg workspace if we didn't already. */
|
/* Allocate Floyd-Steinberg workspace if we didn't already. */
|
||||||
if (cquantize->fserrors == NULL)
|
if (cquantize->fserrors == NULL)
|
||||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||||
@ -1247,10 +1247,9 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
|||||||
my_cquantize_ptr cquantize;
|
my_cquantize_ptr cquantize;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
cquantize = (my_cquantize_ptr)
|
cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer));
|
||||||
SIZEOF(my_cquantizer));
|
cinfo->cquantize = &cquantize->pub;
|
||||||
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
|
|
||||||
cquantize->pub.start_pass = start_pass_2_quant;
|
cquantize->pub.start_pass = start_pass_2_quant;
|
||||||
cquantize->pub.new_color_map = new_color_map_2_quant;
|
cquantize->pub.new_color_map = new_color_map_2_quant;
|
||||||
cquantize->fserrors = NULL; /* flag optional arrays not allocated */
|
cquantize->fserrors = NULL; /* flag optional arrays not allocated */
|
||||||
@ -1284,7 +1283,8 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
|||||||
if (desired > MAXNUMCOLORS)
|
if (desired > MAXNUMCOLORS)
|
||||||
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
|
||||||
cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
|
cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3);
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(JDIMENSION) desired, (JDIMENSION) 3);
|
||||||
cquantize->desired = desired;
|
cquantize->desired = desired;
|
||||||
} else
|
} else
|
||||||
cquantize->sv_colormap = NULL;
|
cquantize->sv_colormap = NULL;
|
||||||
@ -1302,7 +1302,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
|
|||||||
if (cinfo->dither_mode == JDITHER_FS) {
|
if (cinfo->dither_mode == JDITHER_FS) {
|
||||||
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
|
||||||
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
(size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR))));
|
((size_t) cinfo->output_width + (size_t) 2) * (3 * SIZEOF(FSERROR)));
|
||||||
/* Might as well create the error-limiting table too. */
|
/* Might as well create the error-limiting table too. */
|
||||||
init_error_limit(cinfo);
|
init_error_limit(cinfo);
|
||||||
}
|
}
|
||||||
|
99
3rdparty/libjpeg/jutils.c
vendored
99
3rdparty/libjpeg/jutils.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* jutils.c
|
* jutils.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2019 by Guido Vollbeding.
|
* Modified 2009-2020 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -52,67 +52,67 @@ const int jpeg_zigzag_order[DCTSIZE2] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const int jpeg_natural_order[DCTSIZE2+16] = {
|
const int jpeg_natural_order[DCTSIZE2+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 3, 10,
|
0, 1, 8, 16, 9, 2, 3, 10,
|
||||||
17, 24, 32, 25, 18, 11, 4, 5,
|
17, 24, 32, 25, 18, 11, 4, 5,
|
||||||
12, 19, 26, 33, 40, 48, 41, 34,
|
12, 19, 26, 33, 40, 48, 41, 34,
|
||||||
27, 20, 13, 6, 7, 14, 21, 28,
|
27, 20, 13, 6, 7, 14, 21, 28,
|
||||||
35, 42, 49, 56, 57, 50, 43, 36,
|
35, 42, 49, 56, 57, 50, 43, 36,
|
||||||
29, 22, 15, 23, 30, 37, 44, 51,
|
29, 22, 15, 23, 30, 37, 44, 51,
|
||||||
58, 59, 52, 45, 38, 31, 39, 46,
|
58, 59, 52, 45, 38, 31, 39, 46,
|
||||||
53, 60, 61, 54, 47, 55, 62, 63,
|
53, 60, 61, 54, 47, 55, 62, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order7[7*7+16] = {
|
const int jpeg_natural_order7[7*7+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 3, 10,
|
0, 1, 8, 16, 9, 2, 3, 10,
|
||||||
17, 24, 32, 25, 18, 11, 4, 5,
|
17, 24, 32, 25, 18, 11, 4, 5,
|
||||||
12, 19, 26, 33, 40, 48, 41, 34,
|
12, 19, 26, 33, 40, 48, 41, 34,
|
||||||
27, 20, 13, 6, 14, 21, 28, 35,
|
27, 20, 13, 6, 14, 21, 28, 35,
|
||||||
42, 49, 50, 43, 36, 29, 22, 30,
|
42, 49, 50, 43, 36, 29, 22, 30,
|
||||||
37, 44, 51, 52, 45, 38, 46, 53,
|
37, 44, 51, 52, 45, 38, 46, 53,
|
||||||
54,
|
54,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order6[6*6+16] = {
|
const int jpeg_natural_order6[6*6+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 3, 10,
|
0, 1, 8, 16, 9, 2, 3, 10,
|
||||||
17, 24, 32, 25, 18, 11, 4, 5,
|
17, 24, 32, 25, 18, 11, 4, 5,
|
||||||
12, 19, 26, 33, 40, 41, 34, 27,
|
12, 19, 26, 33, 40, 41, 34, 27,
|
||||||
20, 13, 21, 28, 35, 42, 43, 36,
|
20, 13, 21, 28, 35, 42, 43, 36,
|
||||||
29, 37, 44, 45,
|
29, 37, 44, 45,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order5[5*5+16] = {
|
const int jpeg_natural_order5[5*5+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 3, 10,
|
0, 1, 8, 16, 9, 2, 3, 10,
|
||||||
17, 24, 32, 25, 18, 11, 4, 12,
|
17, 24, 32, 25, 18, 11, 4, 12,
|
||||||
19, 26, 33, 34, 27, 20, 28, 35,
|
19, 26, 33, 34, 27, 20, 28, 35,
|
||||||
36,
|
36,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order4[4*4+16] = {
|
const int jpeg_natural_order4[4*4+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 3, 10,
|
0, 1, 8, 16, 9, 2, 3, 10,
|
||||||
17, 24, 25, 18, 11, 19, 26, 27,
|
17, 24, 25, 18, 11, 19, 26, 27,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order3[3*3+16] = {
|
const int jpeg_natural_order3[3*3+16] = {
|
||||||
0, 1, 8, 16, 9, 2, 10, 17,
|
0, 1, 8, 16, 9, 2, 10, 17,
|
||||||
18,
|
18,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
const int jpeg_natural_order2[2*2+16] = {
|
const int jpeg_natural_order2[2*2+16] = {
|
||||||
0, 1, 8, 9,
|
0, 1, 8, 9,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
|
||||||
63, 63, 63, 63, 63, 63, 63, 63
|
63, 63, 63, 63, 63, 63, 63, 63
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -174,12 +174,12 @@ jzero_far (void FAR * target, size_t bytestozero)
|
|||||||
|
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
jcopy_sample_rows (JSAMPARRAY input_array,
|
||||||
JSAMPARRAY output_array, int dest_row,
|
JSAMPARRAY output_array,
|
||||||
int num_rows, JDIMENSION num_cols)
|
int num_rows, JDIMENSION num_cols)
|
||||||
/* Copy some rows of samples from one place to another.
|
/* Copy some rows of samples from one place to another.
|
||||||
* num_rows rows are copied from input_array[source_row++]
|
* num_rows rows are copied from *input_array++ to *output_array++;
|
||||||
* to output_array[dest_row++]; these areas may overlap for duplication.
|
* these areas may overlap for duplication.
|
||||||
* The source and destination arrays must be at least as wide as num_cols.
|
* The source and destination arrays must be at least as wide as num_cols.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
@ -191,9 +191,6 @@ jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
|||||||
#endif
|
#endif
|
||||||
register int row;
|
register int row;
|
||||||
|
|
||||||
input_array += source_row;
|
|
||||||
output_array += dest_row;
|
|
||||||
|
|
||||||
for (row = num_rows; row > 0; row--) {
|
for (row = num_rows; row > 0; row--) {
|
||||||
inptr = *input_array++;
|
inptr = *input_array++;
|
||||||
outptr = *output_array++;
|
outptr = *output_array++;
|
||||||
|
6
3rdparty/libjpeg/jversion.h
vendored
6
3rdparty/libjpeg/jversion.h
vendored
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jversion.h
|
* jversion.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1991-2024, Thomas G. Lane, Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README file.
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
@ -9,6 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define JVERSION "9d 12-Jan-2020"
|
#define JVERSION "9f 14-Jan-2024"
|
||||||
|
|
||||||
#define JCOPYRIGHT "Copyright (C) 2020, Thomas G. Lane, Guido Vollbeding"
|
#define JCOPYRIGHT "Copyright (C) 2024, Thomas G. Lane, Guido Vollbeding"
|
||||||
|
@ -166,7 +166,9 @@ TEST(vittrack, accuracy_vittrack)
|
|||||||
cv::TrackerVit::Params params;
|
cv::TrackerVit::Params params;
|
||||||
params.net = model;
|
params.net = model;
|
||||||
cv::Ptr<Tracker> tracker = TrackerVit::create(params);
|
cv::Ptr<Tracker> tracker = TrackerVit::create(params);
|
||||||
checkTrackingAccuracy(tracker, 0.67);
|
// NOTE: Test threshold was reduced from 0.67 (libjpeg-turbo) to 0.66 (libjpeg 9f),
|
||||||
|
// becase libjpeg and libjpeg-turbo produce slightly different images
|
||||||
|
checkTrackingAccuracy(tracker, 0.66);
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // namespace opencv_test::
|
}} // namespace opencv_test::
|
||||||
|
Loading…
Reference in New Issue
Block a user