35 #define JPEG_INTERNALS
39 #ifdef UPSAMPLE_MERGING_SUPPORTED
73 #define ONE_HALF ((INT32) 1 << (SCALEBITS-1))
74 #define FIX(x) ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
90 upsample->Cr_r_tab = (
int *)
93 upsample->Cb_b_tab = (
int *)
94 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
96 upsample->Cr_g_tab = (
INT32 *)
97 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
99 upsample->Cb_g_tab = (
INT32 *)
100 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
107 upsample->Cr_r_tab[
i] = (
int)
110 upsample->Cb_b_tab[
i] = (
int)
113 upsample->Cr_g_tab[
i] = (-
FIX(0.71414)) *
x;
116 upsample->Cb_g_tab[
i] = (-
FIX(0.34414)) *
x + ONE_HALF;
131 upsample->spare_full =
FALSE;
155 if (upsample->spare_full) {
158 1, upsample->out_row_width);
160 upsample->spare_full =
FALSE;
168 out_rows_avail -= *out_row_ctr;
169 if (num_rows > out_rows_avail)
170 num_rows = out_rows_avail;
172 work_ptrs[0] = output_buf[*out_row_ctr];
174 work_ptrs[1] = output_buf[*out_row_ctr + 1];
176 work_ptrs[1] = upsample->spare_row;
177 upsample->spare_full =
TRUE;
180 (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs);
184 *out_row_ctr += num_rows;
187 if (! upsample->spare_full)
188 (*in_row_group_ctr)++;
203 (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr,
204 output_buf + *out_row_ctr);
207 (*in_row_group_ctr)++;
231 register int y, cred, cgreen, cblue;
238 int * Crrtab = upsample->Cr_r_tab;
239 int * Cbbtab = upsample->Cb_b_tab;
240 INT32 * Crgtab = upsample->Cr_g_tab;
241 INT32 * Cbgtab = upsample->Cb_g_tab;
244 inptr0 = input_buf[0][in_row_group_ctr];
245 inptr1 = input_buf[1][in_row_group_ctr];
246 inptr2 = input_buf[2][in_row_group_ctr];
247 outptr = output_buf[0];
258 outptr[RGB_RED] = range_limit[y + cred];
259 outptr[RGB_GREEN] = range_limit[y + cgreen];
260 outptr[RGB_BLUE] = range_limit[y + cblue];
261 outptr += RGB_PIXELSIZE;
263 outptr[RGB_RED] = range_limit[y + cred];
264 outptr[RGB_GREEN] = range_limit[y + cgreen];
265 outptr[RGB_BLUE] = range_limit[y + cblue];
266 outptr += RGB_PIXELSIZE;
276 outptr[RGB_RED] = range_limit[y + cred];
277 outptr[RGB_GREEN] = range_limit[y + cgreen];
278 outptr[RGB_BLUE] = range_limit[y + cblue];
293 register int y, cred, cgreen, cblue;
296 JSAMPROW inptr00, inptr01, inptr1, inptr2;
300 int * Crrtab = upsample->Cr_r_tab;
301 int * Cbbtab = upsample->Cb_b_tab;
302 INT32 * Crgtab = upsample->Cr_g_tab;
303 INT32 * Cbgtab = upsample->Cb_g_tab;
306 inptr00 = input_buf[0][in_row_group_ctr*2];
307 inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
308 inptr1 = input_buf[1][in_row_group_ctr];
309 inptr2 = input_buf[2][in_row_group_ctr];
310 outptr0 = output_buf[0];
311 outptr1 = output_buf[1];
322 outptr0[RGB_RED] = range_limit[y + cred];
323 outptr0[RGB_GREEN] = range_limit[y + cgreen];
324 outptr0[RGB_BLUE] = range_limit[y + cblue];
325 outptr0 += RGB_PIXELSIZE;
327 outptr0[RGB_RED] = range_limit[y + cred];
328 outptr0[RGB_GREEN] = range_limit[y + cgreen];
329 outptr0[RGB_BLUE] = range_limit[y + cblue];
330 outptr0 += RGB_PIXELSIZE;
332 outptr1[RGB_RED] = range_limit[y + cred];
333 outptr1[RGB_GREEN] = range_limit[y + cgreen];
334 outptr1[RGB_BLUE] = range_limit[y + cblue];
335 outptr1 += RGB_PIXELSIZE;
337 outptr1[RGB_RED] = range_limit[y + cred];
338 outptr1[RGB_GREEN] = range_limit[y + cgreen];
339 outptr1[RGB_BLUE] = range_limit[y + cblue];
340 outptr1 += RGB_PIXELSIZE;
350 outptr0[RGB_RED] = range_limit[y + cred];
351 outptr0[RGB_GREEN] = range_limit[y + cgreen];
352 outptr0[RGB_BLUE] = range_limit[y + cblue];
354 outptr1[RGB_RED] = range_limit[y + cred];
355 outptr1[RGB_GREEN] = range_limit[y + cgreen];
356 outptr1[RGB_BLUE] = range_limit[y + cblue];
375 (*cinfo->mem->alloc_small) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
378 upsample->
pub.start_pass = start_pass_merged_upsample;
384 upsample->
pub.upsample = merged_2v_upsample;
385 upsample->upmethod = h2v2_merged_upsample;
388 (*cinfo->mem->alloc_large) ((
j_common_ptr) cinfo, JPOOL_IMAGE,
391 upsample->
pub.upsample = merged_1v_upsample;
392 upsample->upmethod = h2v1_merged_upsample;
394 upsample->spare_row =
NULL;
GLOBAL void jcopy_sample_rows(JSAMPARRAY input_array, int source_row, JSAMPARRAY output_array, int dest_row, int num_rows, JDIMENSION num_cols)
struct jpeg_common_struct * j_common_ptr
#define GETJSAMPLE(value)
JMETHOD(void, prepare_for_output_pass,(j_decompress_ptr cinfo))
struct jpeg_upsampler pub
LOCAL void build_ycc_rgb_table(j_decompress_ptr cinfo)
JSAMPLE * sample_range_limit
my_upsampler * my_upsample_ptr
struct jpeg_upsampler * upsample
#define RIGHT_SHIFT(x, shft)
boolean need_context_rows
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID