2018-05-10 20:50:35 +08:00
|
|
|
/*
|
|
|
|
* jdcol565.c
|
|
|
|
*
|
|
|
|
* This file was part of the Independent JPEG Group's software:
|
|
|
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
|
|
|
* Modifications:
|
|
|
|
* Copyright (C) 2013, Linaro Limited.
|
2024-05-25 18:03:12 +08:00
|
|
|
* Copyright (C) 2014-2015, 2022, D. R. Commander.
|
2018-05-10 20:50:35 +08:00
|
|
|
* For conditions of distribution and use, see the accompanying README.ijg
|
|
|
|
* file.
|
|
|
|
*
|
|
|
|
* This file contains output colorspace conversion routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file is included by jdcolor.c */
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
ycc_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
#if BITS_IN_JSAMPLE != 16
|
2019-02-24 00:30:49 +08:00
|
|
|
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
2018-05-10 20:50:35 +08:00
|
|
|
register int y, cb, cr;
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW outptr;
|
|
|
|
register _JSAMPROW inptr0, inptr1, inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
/* copy these pointers into registers if possible */
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
|
2019-02-24 00:30:49 +08:00
|
|
|
register int *Crrtab = cconvert->Cr_r_tab;
|
|
|
|
register int *Cbbtab = cconvert->Cb_b_tab;
|
|
|
|
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
|
|
|
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
2018-05-10 20:50:35 +08:00
|
|
|
SHIFT_TEMPS
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int r, g, b;
|
|
|
|
inptr0 = input_buf[0][input_row];
|
|
|
|
inptr1 = input_buf[1][input_row];
|
|
|
|
inptr2 = input_buf[2][input_row];
|
|
|
|
input_row++;
|
|
|
|
outptr = *output_buf++;
|
|
|
|
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[y + Crrtab[cr]];
|
|
|
|
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS))];
|
|
|
|
b = range_limit[y + Cbbtab[cb]];
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[y + Crrtab[cr]];
|
|
|
|
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS))];
|
|
|
|
b = range_limit[y + Cbbtab[cb]];
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
|
|
|
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[y + Crrtab[cr]];
|
|
|
|
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS))];
|
|
|
|
b = range_limit[y + Cbbtab[cb]];
|
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
|
|
|
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0;
|
|
|
|
cb = *inptr1;
|
|
|
|
cr = *inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[y + Crrtab[cr]];
|
|
|
|
g = range_limit[y + ((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS))];
|
|
|
|
b = range_limit[y + Cbbtab[cb]];
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
2024-05-25 18:03:12 +08:00
|
|
|
#else
|
|
|
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
|
|
|
#endif
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
ycc_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
#if BITS_IN_JSAMPLE != 16
|
2019-02-24 00:30:49 +08:00
|
|
|
my_cconvert_ptr cconvert = (my_cconvert_ptr)cinfo->cconvert;
|
2018-05-10 20:50:35 +08:00
|
|
|
register int y, cb, cr;
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW outptr;
|
|
|
|
register _JSAMPROW inptr0, inptr1, inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
/* copy these pointers into registers if possible */
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
|
2019-02-24 00:30:49 +08:00
|
|
|
register int *Crrtab = cconvert->Cr_r_tab;
|
|
|
|
register int *Cbbtab = cconvert->Cb_b_tab;
|
|
|
|
register JLONG *Crgtab = cconvert->Cr_g_tab;
|
|
|
|
register JLONG *Cbgtab = cconvert->Cb_g_tab;
|
2018-05-10 20:50:35 +08:00
|
|
|
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
|
|
|
SHIFT_TEMPS
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int r, g, b;
|
|
|
|
|
|
|
|
inptr0 = input_buf[0][input_row];
|
|
|
|
inptr1 = input_buf[1][input_row];
|
|
|
|
inptr2 = input_buf[2][input_row];
|
|
|
|
input_row++;
|
|
|
|
outptr = *output_buf++;
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
|
|
|
g = range_limit[DITHER_565_G(y +
|
|
|
|
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS)), d0)];
|
|
|
|
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
|
|
|
g = range_limit[DITHER_565_G(y +
|
|
|
|
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS)), d0)];
|
|
|
|
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
|
|
|
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0++;
|
|
|
|
cb = *inptr1++;
|
|
|
|
cr = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
|
|
|
g = range_limit[DITHER_565_G(y +
|
|
|
|
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS)), d0)];
|
|
|
|
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
|
|
|
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
2021-06-02 03:48:49 +08:00
|
|
|
y = *inptr0;
|
|
|
|
cb = *inptr1;
|
|
|
|
cr = *inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
r = range_limit[DITHER_565_R(y + Crrtab[cr], d0)];
|
|
|
|
g = range_limit[DITHER_565_G(y +
|
|
|
|
((int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
|
|
|
|
SCALEBITS)), d0)];
|
|
|
|
b = range_limit[DITHER_565_B(y + Cbbtab[cb], d0)];
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
2024-05-25 18:03:12 +08:00
|
|
|
#else
|
|
|
|
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
|
|
|
#endif
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
rgb_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW outptr;
|
|
|
|
register _JSAMPROW inptr0, inptr1, inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
SHIFT_TEMPS
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int r, g, b;
|
|
|
|
|
|
|
|
inptr0 = input_buf[0][input_row];
|
|
|
|
inptr1 = input_buf[1][input_row];
|
|
|
|
inptr2 = input_buf[2][input_row];
|
|
|
|
input_row++;
|
|
|
|
outptr = *output_buf++;
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = *inptr0++;
|
|
|
|
g = *inptr1++;
|
|
|
|
b = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = *inptr0++;
|
|
|
|
g = *inptr1++;
|
|
|
|
b = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
|
|
|
|
2021-06-02 03:48:49 +08:00
|
|
|
r = *inptr0++;
|
|
|
|
g = *inptr1++;
|
|
|
|
b = *inptr2++;
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
|
|
|
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = *inptr0;
|
|
|
|
g = *inptr1;
|
|
|
|
b = *inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
rgb_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW outptr;
|
|
|
|
register _JSAMPROW inptr0, inptr1, inptr2;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
|
2018-05-10 20:50:35 +08:00
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
|
|
|
SHIFT_TEMPS
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int r, g, b;
|
|
|
|
|
|
|
|
inptr0 = input_buf[0][input_row];
|
|
|
|
inptr1 = input_buf[1][input_row];
|
|
|
|
inptr2 = input_buf[2][input_row];
|
|
|
|
input_row++;
|
|
|
|
outptr = *output_buf++;
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = range_limit[DITHER_565_R(*inptr0++, d0)];
|
|
|
|
g = range_limit[DITHER_565_G(*inptr1++, d0)];
|
|
|
|
b = range_limit[DITHER_565_B(*inptr2++, d0)];
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = range_limit[DITHER_565_R(*inptr0++, d0)];
|
|
|
|
g = range_limit[DITHER_565_G(*inptr1++, d0)];
|
|
|
|
b = range_limit[DITHER_565_B(*inptr2++, d0)];
|
2018-05-10 20:50:35 +08:00
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
|
|
|
|
2021-06-02 03:48:49 +08:00
|
|
|
r = range_limit[DITHER_565_R(*inptr0++, d0)];
|
|
|
|
g = range_limit[DITHER_565_G(*inptr1++, d0)];
|
|
|
|
b = range_limit[DITHER_565_B(*inptr2++, d0)];
|
2018-05-10 20:50:35 +08:00
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
|
|
|
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
2021-06-02 03:48:49 +08:00
|
|
|
r = range_limit[DITHER_565_R(*inptr0, d0)];
|
|
|
|
g = range_limit[DITHER_565_G(*inptr1, d0)];
|
|
|
|
b = range_limit[DITHER_565_B(*inptr2, d0)];
|
2018-05-10 20:50:35 +08:00
|
|
|
rgb = PACK_SHORT_565(r, g, b);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
gray_rgb565_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW inptr, outptr;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int g;
|
|
|
|
|
|
|
|
inptr = input_buf[0][input_row++];
|
|
|
|
outptr = *output_buf++;
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
|
|
|
g = *inptr++;
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
|
|
|
g = *inptr++;
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
|
|
|
g = *inptr++;
|
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
|
|
|
g = *inptr;
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INLINE
|
|
|
|
LOCAL(void)
|
2024-05-25 18:03:12 +08:00
|
|
|
gray_rgb565D_convert_internal(j_decompress_ptr cinfo, _JSAMPIMAGE input_buf,
|
|
|
|
JDIMENSION input_row, _JSAMPARRAY output_buf,
|
2019-02-24 00:30:49 +08:00
|
|
|
int num_rows)
|
2018-05-10 20:50:35 +08:00
|
|
|
{
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPROW inptr, outptr;
|
2018-05-10 20:50:35 +08:00
|
|
|
register JDIMENSION col;
|
2024-05-25 18:03:12 +08:00
|
|
|
register _JSAMPLE *range_limit = (_JSAMPLE *)cinfo->sample_range_limit;
|
2018-05-10 20:50:35 +08:00
|
|
|
JDIMENSION num_cols = cinfo->output_width;
|
|
|
|
JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
|
|
|
|
|
|
|
while (--num_rows >= 0) {
|
|
|
|
JLONG rgb;
|
|
|
|
unsigned int g;
|
|
|
|
|
|
|
|
inptr = input_buf[0][input_row++];
|
|
|
|
outptr = *output_buf++;
|
|
|
|
if (PACK_NEED_ALIGNMENT(outptr)) {
|
|
|
|
g = *inptr++;
|
|
|
|
g = range_limit[DITHER_565_R(g, d0)];
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
outptr += 2;
|
|
|
|
num_cols--;
|
|
|
|
}
|
|
|
|
for (col = 0; col < (num_cols >> 1); col++) {
|
|
|
|
g = *inptr++;
|
|
|
|
g = range_limit[DITHER_565_R(g, d0)];
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
|
|
|
|
g = *inptr++;
|
|
|
|
g = range_limit[DITHER_565_R(g, d0)];
|
|
|
|
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(g, g, g));
|
|
|
|
d0 = DITHER_ROTATE(d0);
|
|
|
|
|
|
|
|
WRITE_TWO_ALIGNED_PIXELS(outptr, rgb);
|
|
|
|
outptr += 4;
|
|
|
|
}
|
|
|
|
if (num_cols & 1) {
|
|
|
|
g = *inptr;
|
|
|
|
g = range_limit[DITHER_565_R(g, d0)];
|
|
|
|
rgb = PACK_SHORT_565(g, g, g);
|
2019-02-24 00:30:49 +08:00
|
|
|
*(INT16 *)outptr = (INT16)rgb;
|
2018-05-10 20:50:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|