summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/libjpeg/jdmerge.c
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 06:05:40 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 06:05:40 +1100
commit73751bcea9a5365e5f4d427986ba4f75fe0300ef (patch)
tree40f937b5d5e541a8ac68a80154bf30762e42c048 /3rdparty/libjpeg/jdmerge.c
parent8b2ea383f5f4dffd15c9684e94b7a0d6868d2711 (diff)
3rdparty/libjpeg: Updated to version 9e.
Diffstat (limited to '3rdparty/libjpeg/jdmerge.c')
-rw-r--r--3rdparty/libjpeg/jdmerge.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/3rdparty/libjpeg/jdmerge.c b/3rdparty/libjpeg/jdmerge.c
index 192da5829d0..8ff13143af2 100644
--- a/3rdparty/libjpeg/jdmerge.c
+++ b/3rdparty/libjpeg/jdmerge.c
@@ -2,7 +2,7 @@
* jdmerge.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
- * Modified 2013-2015 by Guido Vollbeding.
+ * Modified 2013-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -40,6 +40,12 @@
#ifdef UPSAMPLE_MERGING_SUPPORTED
+#if RANGE_BITS < 2
+ /* Deliberate syntax err */
+ Sorry, this code requires 2 or more range extension bits.
+#endif
+
+
/* Private subobject */
typedef struct {
@@ -89,28 +95,22 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
- upsample->Cr_r_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(int));
- upsample->Cb_b_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(int));
- upsample->Cr_g_tab = (INT32 *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(INT32));
- upsample->Cb_g_tab = (INT32 *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(INT32));
+ upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
+ upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.402 * x */
- upsample->Cr_r_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.402) * x + ONE_HALF, SCALEBITS);
+ upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
/* Cb=>B value is nearest int to 1.772 * x */
- upsample->Cb_b_tab[i] = (int)
- RIGHT_SHIFT(FIX(1.772) * x + ONE_HALF, SCALEBITS);
+ upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
/* Cr=>G value is scaled-up -0.714136286 * x */
upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
/* Cb=>G value is scaled-up -0.344136286 * x */
@@ -129,28 +129,22 @@ build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
INT32 x;
SHIFT_TEMPS
- upsample->Cr_r_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(int));
- upsample->Cb_b_tab = (int *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(int));
- upsample->Cr_g_tab = (INT32 *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(INT32));
- upsample->Cb_g_tab = (INT32 *)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (MAXJSAMPLE+1) * SIZEOF(INT32));
+ upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
+ upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
+ upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
- upsample->Cr_r_tab[i] = (int)
- RIGHT_SHIFT(FIX(2.804) * x + ONE_HALF, SCALEBITS);
+ upsample->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
- upsample->Cb_b_tab[i] = (int)
- RIGHT_SHIFT(FIX(3.544) * x + ONE_HALF, SCALEBITS);
+ upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
@@ -196,7 +190,7 @@ merged_2v_upsample (j_decompress_ptr cinfo,
if (upsample->spare_full) {
/* 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);
num_rows = 1;
upsample->spare_full = FALSE;
@@ -413,9 +407,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
{
my_upsample_ptr upsample;
- upsample = (my_upsample_ptr)
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- SIZEOF(my_upsampler));
+ upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
cinfo->upsample = &upsample->pub;
upsample->pub.start_pass = start_pass_merged_upsample;
upsample->pub.need_context_rows = FALSE;
@@ -426,9 +419,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
upsample->pub.upsample = merged_2v_upsample;
upsample->upmethod = h2v2_merged_upsample;
/* Allocate a spare row buffer */
- upsample->spare_row = (JSAMPROW)
- (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
- (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));
+ upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large)
+ ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ (size_t) upsample->out_row_width * SIZEOF(JSAMPLE));
} else {
upsample->pub.upsample = merged_1v_upsample;
upsample->upmethod = h2v1_merged_upsample;