mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-21 07:47:32 +09:00
Issue #1933 - Part 2: Update libjpeg-turbo source.
This commit is contained in:
parent
75e223e3bf
commit
fc2133f4d1
321 changed files with 73829 additions and 50995 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2020, D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
|
|
@ -40,44 +40,16 @@
|
|||
#define JPEG_INTERNALS
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jdmerge.h"
|
||||
#include "jsimd.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_upsampler pub; /* public fields */
|
||||
|
||||
/* Pointer to routine to do actual upsampling/conversion of one row group */
|
||||
void (*upmethod) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf);
|
||||
|
||||
/* Private state for YCC->RGB conversion */
|
||||
int *Cr_r_tab; /* => table for Cr to R conversion */
|
||||
int *Cb_b_tab; /* => table for Cb to B conversion */
|
||||
JLONG *Cr_g_tab; /* => table for Cr to G conversion */
|
||||
JLONG *Cb_g_tab; /* => table for Cb to G conversion */
|
||||
|
||||
/* For 2:1 vertical sampling, we produce two output rows at a time.
|
||||
* We need a "spare" row buffer to hold the second output row if the
|
||||
* application provides just a one-row buffer; we also use the spare
|
||||
* to discard the dummy last row if the image height is odd.
|
||||
*/
|
||||
JSAMPROW spare_row;
|
||||
boolean spare_full; /* T if spare buffer is occupied */
|
||||
|
||||
JDIMENSION out_row_width; /* samples per output row */
|
||||
JDIMENSION rows_to_go; /* counts rows remaining in image */
|
||||
} my_upsampler;
|
||||
|
||||
typedef my_upsampler *my_upsample_ptr;
|
||||
|
||||
#define SCALEBITS 16 /* speediest right-shift on some machines */
|
||||
#define ONE_HALF ((JLONG) 1 << (SCALEBITS-1))
|
||||
#define FIX(x) ((JLONG) ((x) * (1L<<SCALEBITS) + 0.5))
|
||||
#define ONE_HALF ((JLONG)1 << (SCALEBITS - 1))
|
||||
#define FIX(x) ((JLONG)((x) * (1L << SCALEBITS) + 0.5))
|
||||
|
||||
|
||||
/* Include inline routines for colorspace extensions */
|
||||
|
|
@ -88,12 +60,12 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef RGB_BLUE
|
||||
#undef RGB_PIXELSIZE
|
||||
|
||||
#define RGB_RED EXT_RGB_RED
|
||||
#define RGB_GREEN EXT_RGB_GREEN
|
||||
#define RGB_BLUE EXT_RGB_BLUE
|
||||
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extrgb_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extrgb_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_RGB_RED
|
||||
#define RGB_GREEN EXT_RGB_GREEN
|
||||
#define RGB_BLUE EXT_RGB_BLUE
|
||||
#define RGB_PIXELSIZE EXT_RGB_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extrgb_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extrgb_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -102,13 +74,13 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef h2v1_merged_upsample_internal
|
||||
#undef h2v2_merged_upsample_internal
|
||||
|
||||
#define RGB_RED EXT_RGBX_RED
|
||||
#define RGB_GREEN EXT_RGBX_GREEN
|
||||
#define RGB_BLUE EXT_RGBX_BLUE
|
||||
#define RGB_ALPHA 3
|
||||
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extrgbx_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extrgbx_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_RGBX_RED
|
||||
#define RGB_GREEN EXT_RGBX_GREEN
|
||||
#define RGB_BLUE EXT_RGBX_BLUE
|
||||
#define RGB_ALPHA 3
|
||||
#define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extrgbx_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extrgbx_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -118,12 +90,12 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef h2v1_merged_upsample_internal
|
||||
#undef h2v2_merged_upsample_internal
|
||||
|
||||
#define RGB_RED EXT_BGR_RED
|
||||
#define RGB_GREEN EXT_BGR_GREEN
|
||||
#define RGB_BLUE EXT_BGR_BLUE
|
||||
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extbgr_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extbgr_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_BGR_RED
|
||||
#define RGB_GREEN EXT_BGR_GREEN
|
||||
#define RGB_BLUE EXT_BGR_BLUE
|
||||
#define RGB_PIXELSIZE EXT_BGR_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extbgr_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extbgr_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -132,13 +104,13 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef h2v1_merged_upsample_internal
|
||||
#undef h2v2_merged_upsample_internal
|
||||
|
||||
#define RGB_RED EXT_BGRX_RED
|
||||
#define RGB_GREEN EXT_BGRX_GREEN
|
||||
#define RGB_BLUE EXT_BGRX_BLUE
|
||||
#define RGB_ALPHA 3
|
||||
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extbgrx_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extbgrx_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_BGRX_RED
|
||||
#define RGB_GREEN EXT_BGRX_GREEN
|
||||
#define RGB_BLUE EXT_BGRX_BLUE
|
||||
#define RGB_ALPHA 3
|
||||
#define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extbgrx_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extbgrx_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -148,13 +120,13 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef h2v1_merged_upsample_internal
|
||||
#undef h2v2_merged_upsample_internal
|
||||
|
||||
#define RGB_RED EXT_XBGR_RED
|
||||
#define RGB_GREEN EXT_XBGR_GREEN
|
||||
#define RGB_BLUE EXT_XBGR_BLUE
|
||||
#define RGB_ALPHA 0
|
||||
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extxbgr_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extxbgr_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_XBGR_RED
|
||||
#define RGB_GREEN EXT_XBGR_GREEN
|
||||
#define RGB_BLUE EXT_XBGR_BLUE
|
||||
#define RGB_ALPHA 0
|
||||
#define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extxbgr_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extxbgr_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -164,13 +136,13 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
#undef h2v1_merged_upsample_internal
|
||||
#undef h2v2_merged_upsample_internal
|
||||
|
||||
#define RGB_RED EXT_XRGB_RED
|
||||
#define RGB_GREEN EXT_XRGB_GREEN
|
||||
#define RGB_BLUE EXT_XRGB_BLUE
|
||||
#define RGB_ALPHA 0
|
||||
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extxrgb_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extxrgb_h2v2_merged_upsample_internal
|
||||
#define RGB_RED EXT_XRGB_RED
|
||||
#define RGB_GREEN EXT_XRGB_GREEN
|
||||
#define RGB_BLUE EXT_XRGB_BLUE
|
||||
#define RGB_ALPHA 0
|
||||
#define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE
|
||||
#define h2v1_merged_upsample_internal extxrgb_h2v1_merged_upsample_internal
|
||||
#define h2v2_merged_upsample_internal extxrgb_h2v2_merged_upsample_internal
|
||||
#include "jdmrgext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
|
|
@ -187,25 +159,25 @@ typedef my_upsampler *my_upsample_ptr;
|
|||
*/
|
||||
|
||||
LOCAL(void)
|
||||
build_ycc_rgb_table (j_decompress_ptr cinfo)
|
||||
build_ycc_rgb_table(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
int i;
|
||||
JLONG x;
|
||||
SHIFT_TEMPS
|
||||
|
||||
upsample->Cr_r_tab = (int *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(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));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(int));
|
||||
upsample->Cr_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
upsample->Cb_g_tab = (JLONG *)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE+1) * sizeof(JLONG));
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
(MAXJSAMPLE + 1) * sizeof(JLONG));
|
||||
|
||||
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
|
||||
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
|
||||
|
|
@ -217,10 +189,10 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
|||
upsample->Cb_b_tab[i] = (int)
|
||||
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
|
||||
/* Cr=>G value is scaled-up -0.71414 * x */
|
||||
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
|
||||
upsample->Cr_g_tab[i] = (-FIX(0.71414)) * x;
|
||||
/* Cb=>G value is scaled-up -0.34414 * x */
|
||||
/* We also add in ONE_HALF so that need not do it in inner loop */
|
||||
upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
|
||||
upsample->Cb_g_tab[i] = (-FIX(0.34414)) * x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,9 +202,9 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
start_pass_merged_upsample (j_decompress_ptr cinfo)
|
||||
start_pass_merged_upsample(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Mark the spare buffer empty */
|
||||
upsample->spare_full = FALSE;
|
||||
|
|
@ -248,14 +220,13 @@ start_pass_merged_upsample (j_decompress_ptr cinfo)
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
merged_2v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_2v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 2:1 vertical sampling case: may need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
JSAMPROW work_ptrs[2];
|
||||
JDIMENSION num_rows; /* number of rows returned to caller */
|
||||
|
||||
|
|
@ -264,8 +235,8 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
|||
JDIMENSION size = upsample->out_row_width;
|
||||
if (cinfo->out_color_space == JCS_RGB565)
|
||||
size = cinfo->output_width * 2;
|
||||
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0,
|
||||
1, size);
|
||||
jcopy_sample_rows(&upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 1,
|
||||
size);
|
||||
num_rows = 1;
|
||||
upsample->spare_full = FALSE;
|
||||
} else {
|
||||
|
|
@ -294,20 +265,19 @@ merged_2v_upsample (j_decompress_ptr cinfo,
|
|||
*out_row_ctr += num_rows;
|
||||
upsample->rows_to_go -= num_rows;
|
||||
/* When the buffer is emptied, declare this input row group consumed */
|
||||
if (! upsample->spare_full)
|
||||
if (!upsample->spare_full)
|
||||
(*in_row_group_ctr)++;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
merged_1v_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail,
|
||||
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
|
||||
JDIMENSION out_rows_avail)
|
||||
merged_1v_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION *in_row_group_ctr,
|
||||
JDIMENSION in_row_groups_avail, JSAMPARRAY output_buf,
|
||||
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
|
||||
/* 1:1 vertical sampling case: much easier, never need a spare row. */
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
my_merged_upsample_ptr upsample = (my_merged_upsample_ptr)cinfo->upsample;
|
||||
|
||||
/* Just do the upsampling. */
|
||||
(*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
|
||||
|
|
@ -333,43 +303,42 @@ merged_1v_upsample (j_decompress_ptr cinfo,
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
extrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
extrgbx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
extbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
extbgrx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
extxbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
extxrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
default:
|
||||
h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGB:
|
||||
extrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
extrgbx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
extbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
extbgrx_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
extxbgr_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
extxrgb_h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
default:
|
||||
h2v1_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -379,43 +348,42 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
|
|||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
extrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
extrgbx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
extbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
extbgrx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
extxbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
extxrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
default:
|
||||
h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGB:
|
||||
extrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
extrgbx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
extbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
extbgrx_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
extxbgr_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
extxrgb_h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
default:
|
||||
h2v2_merged_upsample_internal(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -424,24 +392,21 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
|||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
#define PACK_SHORT_565_LE(r, g, b) \
|
||||
((((r) << 8) & 0xF800) | (((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) \
|
||||
(((r) & 0xF8) | ((g) >> 5) | (((g) << 11) & 0xE000) | (((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||
((INT16 *)(addr))[0] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
|
||||
((INT16*)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16*)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
|
||||
((INT16 *)(addr))[1] = (INT16)(pixels); \
|
||||
((INT16 *)(addr))[0] = (INT16)((pixels) >> 16); \
|
||||
}
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
|
|
@ -452,7 +417,7 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
|||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
* sufficient for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
|
|
@ -467,13 +432,13 @@ static const JLONG dither_matrix[4] = {
|
|||
|
||||
/* Include inline routines for RGB565 conversion */
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_LE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_LE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_le
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_le
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_le
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_le
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_LE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_LE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_le
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_le
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_le
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_le
|
||||
#include "jdmrg565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
|
|
@ -483,13 +448,13 @@ static const JLONG dither_matrix[4] = {
|
|||
#undef h2v2_merged_upsample_565_internal
|
||||
#undef h2v2_merged_upsample_565D_internal
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_BE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_BE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_be
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_be
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_be
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_be
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_BE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_BE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_be
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_be
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_be
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_be
|
||||
#include "jdmrg565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
|
|
@ -503,16 +468,15 @@ static const JLONG dither_matrix[4] = {
|
|||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
if (*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
|
|
@ -520,13 +484,12 @@ h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
|||
else
|
||||
h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v1_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
|
|
@ -538,9 +501,8 @@ h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
|||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
|
|
@ -552,9 +514,8 @@ h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
|||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
h2v2_merged_upsample_565D(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf)
|
||||
{
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
|
|
@ -574,14 +535,14 @@ h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
|||
*/
|
||||
|
||||
GLOBAL(void)
|
||||
jinit_merged_upsampler (j_decompress_ptr cinfo)
|
||||
jinit_merged_upsampler(j_decompress_ptr cinfo)
|
||||
{
|
||||
my_upsample_ptr upsample;
|
||||
my_merged_upsample_ptr upsample;
|
||||
|
||||
upsample = (my_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *) upsample;
|
||||
upsample = (my_merged_upsample_ptr)
|
||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
sizeof(my_merged_upsampler));
|
||||
cinfo->upsample = (struct jpeg_upsampler *)upsample;
|
||||
upsample->pub.start_pass = start_pass_merged_upsample;
|
||||
upsample->pub.need_context_rows = FALSE;
|
||||
|
||||
|
|
@ -602,8 +563,8 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
|
|||
}
|
||||
/* 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)));
|
||||
(*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;
|
||||
if (jsimd_can_h2v1_merged_upsample())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue