Doxygen Source Code Documentation
jdmerge.c File Reference
#include "jinclude.h"#include "jpeglib.h"Go to the source code of this file.
Define Documentation
|
|
|
|
|
|
|
|
Definition at line 73 of file jdmerge.c. Referenced by build_ycc_rgb_table(). |
|
|
Definition at line 72 of file jdmerge.c. Referenced by build_ycc_rgb_table(), h2v1_merged_upsample(), and h2v2_merged_upsample(). |
Typedef Documentation
|
|
|
Function Documentation
|
|
Definition at line 83 of file jdmerge.c. References my_upsampler::Cb_b_tab, my_upsampler::Cb_g_tab, CENTERJSAMPLE, my_upsampler::Cr_g_tab, my_upsampler::Cr_r_tab, FIX, i, INT32, JPOOL_IMAGE, MAXJSAMPLE, ONE_HALF, RIGHT_SHIFT, SCALEBITS, SIZEOF, and jpeg_decompress_struct::upsample. Referenced by jinit_color_deconverter(), and jinit_merged_upsampler().
00084 {
00085 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
00086 int i;
00087 INT32 x;
00088 SHIFT_TEMPS
00089
00090 upsample->Cr_r_tab = (int *)
00091 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00092 (MAXJSAMPLE+1) * SIZEOF(int));
00093 upsample->Cb_b_tab = (int *)
00094 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00095 (MAXJSAMPLE+1) * SIZEOF(int));
00096 upsample->Cr_g_tab = (INT32 *)
00097 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00098 (MAXJSAMPLE+1) * SIZEOF(INT32));
00099 upsample->Cb_g_tab = (INT32 *)
00100 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00101 (MAXJSAMPLE+1) * SIZEOF(INT32));
00102
00103 for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
00104 /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
00105 /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
00106 /* Cr=>R value is nearest int to 1.40200 * x */
00107 upsample->Cr_r_tab[i] = (int)
00108 RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);
00109 /* Cb=>B value is nearest int to 1.77200 * x */
00110 upsample->Cb_b_tab[i] = (int)
00111 RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS);
00112 /* Cr=>G value is scaled-up -0.71414 * x */
00113 upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
00114 /* Cb=>G value is scaled-up -0.34414 * x */
00115 /* We also add in ONE_HALF so that need not do it in inner loop */
00116 upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF;
00117 }
00118 }
|
|
||||||||||||||||||||
|
Definition at line 226 of file jdmerge.c. References my_upsampler::Cb_b_tab, my_upsampler::Cb_g_tab, my_upsampler::Cr_g_tab, my_upsampler::Cr_r_tab, GETJSAMPLE, in_row_group_ctr, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPLE, JSAMPROW, jpeg_decompress_struct::output_width, RIGHT_SHIFT, jpeg_decompress_struct::sample_range_limit, SCALEBITS, and jpeg_decompress_struct::upsample. Referenced by jinit_merged_upsampler().
00229 {
00230 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
00231 register int y, cred, cgreen, cblue;
00232 int cb, cr;
00233 register JSAMPROW outptr;
00234 JSAMPROW inptr0, inptr1, inptr2;
00235 JDIMENSION col;
00236 /* copy these pointers into registers if possible */
00237 register JSAMPLE * range_limit = cinfo->sample_range_limit;
00238 int * Crrtab = upsample->Cr_r_tab;
00239 int * Cbbtab = upsample->Cb_b_tab;
00240 INT32 * Crgtab = upsample->Cr_g_tab;
00241 INT32 * Cbgtab = upsample->Cb_g_tab;
00242 SHIFT_TEMPS
00243
00244 inptr0 = input_buf[0][in_row_group_ctr];
00245 inptr1 = input_buf[1][in_row_group_ctr];
00246 inptr2 = input_buf[2][in_row_group_ctr];
00247 outptr = output_buf[0];
00248 /* Loop for each pair of output pixels */
00249 for (col = cinfo->output_width >> 1; col > 0; col--) {
00250 /* Do the chroma part of the calculation */
00251 cb = GETJSAMPLE(*inptr1++);
00252 cr = GETJSAMPLE(*inptr2++);
00253 cred = Crrtab[cr];
00254 cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
00255 cblue = Cbbtab[cb];
00256 /* Fetch 2 Y values and emit 2 pixels */
00257 y = GETJSAMPLE(*inptr0++);
00258 outptr[RGB_RED] = range_limit[y + cred];
00259 outptr[RGB_GREEN] = range_limit[y + cgreen];
00260 outptr[RGB_BLUE] = range_limit[y + cblue];
00261 outptr += RGB_PIXELSIZE;
00262 y = GETJSAMPLE(*inptr0++);
00263 outptr[RGB_RED] = range_limit[y + cred];
00264 outptr[RGB_GREEN] = range_limit[y + cgreen];
00265 outptr[RGB_BLUE] = range_limit[y + cblue];
00266 outptr += RGB_PIXELSIZE;
00267 }
00268 /* If image width is odd, do the last output column separately */
00269 if (cinfo->output_width & 1) {
00270 cb = GETJSAMPLE(*inptr1);
00271 cr = GETJSAMPLE(*inptr2);
00272 cred = Crrtab[cr];
00273 cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
00274 cblue = Cbbtab[cb];
00275 y = GETJSAMPLE(*inptr0);
00276 outptr[RGB_RED] = range_limit[y + cred];
00277 outptr[RGB_GREEN] = range_limit[y + cgreen];
00278 outptr[RGB_BLUE] = range_limit[y + cblue];
00279 }
00280 }
|
|
||||||||||||||||||||
|
Definition at line 288 of file jdmerge.c. References my_upsampler::Cb_b_tab, my_upsampler::Cb_g_tab, my_upsampler::Cr_g_tab, my_upsampler::Cr_r_tab, GETJSAMPLE, in_row_group_ctr, INT32, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPLE, JSAMPROW, jpeg_decompress_struct::output_width, RIGHT_SHIFT, jpeg_decompress_struct::sample_range_limit, SCALEBITS, and jpeg_decompress_struct::upsample. Referenced by jinit_merged_upsampler().
00291 {
00292 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
00293 register int y, cred, cgreen, cblue;
00294 int cb, cr;
00295 register JSAMPROW outptr0, outptr1;
00296 JSAMPROW inptr00, inptr01, inptr1, inptr2;
00297 JDIMENSION col;
00298 /* copy these pointers into registers if possible */
00299 register JSAMPLE * range_limit = cinfo->sample_range_limit;
00300 int * Crrtab = upsample->Cr_r_tab;
00301 int * Cbbtab = upsample->Cb_b_tab;
00302 INT32 * Crgtab = upsample->Cr_g_tab;
00303 INT32 * Cbgtab = upsample->Cb_g_tab;
00304 SHIFT_TEMPS
00305
00306 inptr00 = input_buf[0][in_row_group_ctr*2];
00307 inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
00308 inptr1 = input_buf[1][in_row_group_ctr];
00309 inptr2 = input_buf[2][in_row_group_ctr];
00310 outptr0 = output_buf[0];
00311 outptr1 = output_buf[1];
00312 /* Loop for each group of output pixels */
00313 for (col = cinfo->output_width >> 1; col > 0; col--) {
00314 /* Do the chroma part of the calculation */
00315 cb = GETJSAMPLE(*inptr1++);
00316 cr = GETJSAMPLE(*inptr2++);
00317 cred = Crrtab[cr];
00318 cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
00319 cblue = Cbbtab[cb];
00320 /* Fetch 4 Y values and emit 4 pixels */
00321 y = GETJSAMPLE(*inptr00++);
00322 outptr0[RGB_RED] = range_limit[y + cred];
00323 outptr0[RGB_GREEN] = range_limit[y + cgreen];
00324 outptr0[RGB_BLUE] = range_limit[y + cblue];
00325 outptr0 += RGB_PIXELSIZE;
00326 y = GETJSAMPLE(*inptr00++);
00327 outptr0[RGB_RED] = range_limit[y + cred];
00328 outptr0[RGB_GREEN] = range_limit[y + cgreen];
00329 outptr0[RGB_BLUE] = range_limit[y + cblue];
00330 outptr0 += RGB_PIXELSIZE;
00331 y = GETJSAMPLE(*inptr01++);
00332 outptr1[RGB_RED] = range_limit[y + cred];
00333 outptr1[RGB_GREEN] = range_limit[y + cgreen];
00334 outptr1[RGB_BLUE] = range_limit[y + cblue];
00335 outptr1 += RGB_PIXELSIZE;
00336 y = GETJSAMPLE(*inptr01++);
00337 outptr1[RGB_RED] = range_limit[y + cred];
00338 outptr1[RGB_GREEN] = range_limit[y + cgreen];
00339 outptr1[RGB_BLUE] = range_limit[y + cblue];
00340 outptr1 += RGB_PIXELSIZE;
00341 }
00342 /* If image width is odd, do the last output column separately */
00343 if (cinfo->output_width & 1) {
00344 cb = GETJSAMPLE(*inptr1);
00345 cr = GETJSAMPLE(*inptr2);
00346 cred = Crrtab[cr];
00347 cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
00348 cblue = Cbbtab[cb];
00349 y = GETJSAMPLE(*inptr00);
00350 outptr0[RGB_RED] = range_limit[y + cred];
00351 outptr0[RGB_GREEN] = range_limit[y + cgreen];
00352 outptr0[RGB_BLUE] = range_limit[y + cblue];
00353 y = GETJSAMPLE(*inptr01);
00354 outptr1[RGB_RED] = range_limit[y + cred];
00355 outptr1[RGB_GREEN] = range_limit[y + cgreen];
00356 outptr1[RGB_BLUE] = range_limit[y + cblue];
00357 }
00358 }
|
|
|
Definition at line 370 of file jdmerge.c. References build_ycc_rgb_table(), h2v1_merged_upsample(), h2v2_merged_upsample(), JPOOL_IMAGE, JSAMPLE, merged_1v_upsample(), merged_2v_upsample(), jpeg_upsampler::need_context_rows, SIZEOF, and start_pass_merged_upsample(). Referenced by master_selection().
00371 {
00372 my_upsample_ptr upsample;
00373
00374 upsample = (my_upsample_ptr)
00375 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00376 SIZEOF(my_upsampler));
00377 cinfo->upsample = (struct jpeg_upsampler *) upsample;
00378 upsample->pub.start_pass = start_pass_merged_upsample;
00379 upsample->pub.need_context_rows = FALSE;
00380
00381 upsample->out_row_width = cinfo->output_width * cinfo->out_color_components;
00382
00383 if (cinfo->max_v_samp_factor == 2) {
00384 upsample->pub.upsample = merged_2v_upsample;
00385 upsample->upmethod = h2v2_merged_upsample;
00386 /* Allocate a spare row buffer */
00387 upsample->spare_row = (JSAMPROW)
00388 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00389 (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE)));
00390 } else {
00391 upsample->pub.upsample = merged_1v_upsample;
00392 upsample->upmethod = h2v1_merged_upsample;
00393 /* No spare row needed */
00394 upsample->spare_row = NULL;
00395 }
00396
00397 build_ycc_rgb_table(cinfo);
00398 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 193 of file jdmerge.c. References in_row_group_ctr, in_row_groups_avail, JDIMENSION, JSAMPARRAY, JSAMPIMAGE, and jpeg_decompress_struct::upsample. Referenced by jinit_merged_upsampler().
00198 :1 vertical sampling case: much easier, never need a spare row. */ 00199 { 00200 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; 00201 00202 /* Just do the upsampling. */ 00203 (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, 00204 output_buf + *out_row_ctr); 00205 /* Adjust counts */ 00206 (*out_row_ctr)++; 00207 (*in_row_group_ctr)++; 00208 } |
|
||||||||||||||||||||||||||||||||
|
Definition at line 144 of file jdmerge.c. References in_row_group_ctr, in_row_groups_avail, jcopy_sample_rows(), JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JSAMPROW, num_rows, my_upsampler::out_row_width, my_upsampler::rows_to_go, my_upsampler::spare_full, my_upsampler::spare_row, and jpeg_decompress_struct::upsample. Referenced by jinit_merged_upsampler().
00149 :1 vertical sampling case: may need a spare row. */ 00150 { 00151 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; 00152 JSAMPROW work_ptrs[2]; 00153 JDIMENSION num_rows; /* number of rows returned to caller */ 00154 00155 if (upsample->spare_full) { 00156 /* If we have a spare row saved from a previous cycle, just return it. */ 00157 jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, 00158 1, upsample->out_row_width); 00159 num_rows = 1; 00160 upsample->spare_full = FALSE; 00161 } else { 00162 /* Figure number of rows to return to caller. */ 00163 num_rows = 2; 00164 /* Not more than the distance to the end of the image. */ 00165 if (num_rows > upsample->rows_to_go) 00166 num_rows = upsample->rows_to_go; 00167 /* And not more than what the client can accept: */ 00168 out_rows_avail -= *out_row_ctr; 00169 if (num_rows > out_rows_avail) 00170 num_rows = out_rows_avail; 00171 /* Create output pointer array for upsampler. */ 00172 work_ptrs[0] = output_buf[*out_row_ctr]; 00173 if (num_rows > 1) { 00174 work_ptrs[1] = output_buf[*out_row_ctr + 1]; 00175 } else { 00176 work_ptrs[1] = upsample->spare_row; 00177 upsample->spare_full = TRUE; 00178 } 00179 /* Now do the upsampling. */ 00180 (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); 00181 } 00182 00183 /* Adjust counts */ 00184 *out_row_ctr += num_rows; 00185 upsample->rows_to_go -= num_rows; 00186 /* When the buffer is emptied, declare this input row group consumed */ 00187 if (! upsample->spare_full) 00188 (*in_row_group_ctr)++; 00189 } |
|
|
Definition at line 126 of file jdmerge.c. References jpeg_decompress_struct::output_height, my_upsampler::rows_to_go, my_upsampler::spare_full, and jpeg_decompress_struct::upsample. Referenced by jinit_merged_upsampler().
00127 {
00128 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
00129
00130 /* Mark the spare buffer empty */
00131 upsample->spare_full = FALSE;
00132 /* Initialize total-height counter for detecting bottom of image */
00133 upsample->rows_to_go = cinfo->output_height;
00134 }
|