ReactOS 0.4.16-dev-336-gb667d82
jdmainct.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jdmainct.c:

Go to the source code of this file.

Classes

struct  my_main_controller
 

Macros

#define JPEG_INTERNALS
 
#define CTX_PREPARE_FOR_IMCU   0 /* need to prepare for MCU row */
 
#define CTX_PROCESS_IMCU   1 /* feeding iMCU to postprocessor */
 
#define CTX_POSTPONED_ROW   2 /* feeding postponed row group */
 

Typedefs

typedef my_main_controllermy_main_ptr
 

Functions

 METHODDEF (void)
 
 make_funny_pointers (j_decompress_ptr cinfo)
 
 set_wraparound_pointers (j_decompress_ptr cinfo)
 
 set_bottom_pointers (j_decompress_ptr cinfo)
 
 start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
 
 process_data_simple_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
 
 process_data_context_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
 
 jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
 

Macro Definition Documentation

◆ CTX_POSTPONED_ROW

#define CTX_POSTPONED_ROW   2 /* feeding postponed row group */

Definition at line 141 of file jdmainct.c.

◆ CTX_PREPARE_FOR_IMCU

#define CTX_PREPARE_FOR_IMCU   0 /* need to prepare for MCU row */

Definition at line 139 of file jdmainct.c.

◆ CTX_PROCESS_IMCU

#define CTX_PROCESS_IMCU   1 /* feeding iMCU to postprocessor */

Definition at line 140 of file jdmainct.c.

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 17 of file jdmainct.c.

Typedef Documentation

◆ my_main_ptr

Definition at line 136 of file jdmainct.c.

Function Documentation

◆ jinit_d_main_controller()

jinit_d_main_controller ( j_decompress_ptr  cinfo,
boolean  need_full_buffer 
)

Definition at line 469 of file jdmainct.c.

470{
471 my_main_ptr mainp;
472 int ci, rgroup, ngroups;
474
475 mainp = (my_main_ptr)
476 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
478 cinfo->main = &mainp->pub;
479 mainp->pub.start_pass = start_pass_main;
480
481 if (need_full_buffer) /* shouldn't happen */
482 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
483
484 /* Allocate the workspace.
485 * ngroups is the number of row groups we need.
486 */
487 if (cinfo->upsample->need_context_rows) {
488 if (cinfo->min_DCT_v_scaled_size < 2) /* unsupported, see comments above */
489 ERREXIT(cinfo, JERR_NOTIMPL);
490 alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
491 ngroups = cinfo->min_DCT_v_scaled_size + 2;
492 } else {
493 /* There are always min_DCT_v_scaled_size row groups in an iMCU row. */
494 ngroups = cinfo->min_DCT_v_scaled_size;
495 mainp->rowgroups_avail = (JDIMENSION) ngroups;
496 }
497
498 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
499 ci++, compptr++) {
501 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
502 mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
503 ((j_common_ptr) cinfo, JPOOL_IMAGE,
505 (JDIMENSION) (rgroup * ngroups));
506 }
507}
#define SIZEOF(_ar)
Definition: calc.h:97
jpeg_component_info * compptr
Definition: jdct.h:238
my_main_controller * my_main_ptr
Definition: jdmainct.c:136
start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
Definition: jdmainct.c:309
unsigned int JDIMENSION
Definition: jmorecfg.h:229
boolean need_full_buffer
Definition: jpegint.h:384
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define JPOOL_IMAGE
Definition: jpeglib.h:808
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
JDIMENSION width_in_blocks
Definition: jpeglib.h:148
struct jpeg_upsampler * upsample
Definition: jpeglib.h:686
struct jpeg_d_main_controller * main
Definition: jpeglib.h:679
jpeg_component_info * comp_info
Definition: jpeglib.h:583
JSAMPARRAY buffer[MAX_COMPONENTS]
Definition: jcmainct.c:41
JDIMENSION rowgroups_avail
Definition: jdmainct.c:122
struct jpeg_c_main_controller pub
Definition: jcmainct.c:30

Referenced by master_selection().

◆ make_funny_pointers()

make_funny_pointers ( j_decompress_ptr  cinfo)

Definition at line 197 of file jdmainct.c.

204{
205 my_main_ptr mainp = (my_main_ptr) cinfo->main;
206 int ci, i, rgroup;
207 int M = cinfo->min_DCT_v_scaled_size;
209 JSAMPARRAY buf, xbuf0, xbuf1;
210
211 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
212 ci++, compptr++) {
214 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
215 xbuf0 = mainp->xbuffer[0][ci];
216 xbuf1 = mainp->xbuffer[1][ci];
217 /* First copy the workspace pointers as-is */
218 buf = mainp->buffer[ci];
219 for (i = 0; i < rgroup * (M + 2); i++) {
220 xbuf0[i] = xbuf1[i] = buf[i];
221 }
222 /* In the second list, put the last four row groups in swapped order */
223 for (i = 0; i < rgroup * 2; i++) {
224 xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];
225 xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];
226 }
227 /* The wraparound pointers at top and bottom will be filled later
228 * (see set_wraparound_pointers, below). Initially we want the "above"
229 * pointers to duplicate the first actual data line. This only needs
230 * to happen in xbuffer[0].
231 */
232 for (i = 0; i < rgroup; i++) {
233 xbuf0[i - rgroup] = xbuf0[0];
234 }
235 }
236}
#define M(row, col)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:76
#define for
Definition: utility.h:88
JSAMPIMAGE xbuffer[2]
Definition: jdmainct.c:129

Referenced by start_pass_main().

◆ METHODDEF()

METHODDEF ( void  )

Definition at line 145 of file jdmainct.c.

163{
164 my_main_ptr mainp = (my_main_ptr) cinfo->main;
165 int ci, rgroup;
166 int M = cinfo->min_DCT_v_scaled_size;
168 JSAMPARRAY xbuf;
169
170 /* Get top-level space for component array pointers.
171 * We alloc both arrays with one call to save a few cycles.
172 */
173 mainp->xbuffer[0] = (JSAMPIMAGE)
174 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
175 cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
176 mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;
177
178 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
179 ci++, compptr++) {
181 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
182 /* Get space for pointer lists --- M+4 row groups in each list.
183 * We alloc both pointer lists with one call to save a few cycles.
184 */
185 xbuf = (JSAMPARRAY)
186 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
187 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
188 xbuf += rgroup; /* want one row group at negative offsets */
189 mainp->xbuffer[0][ci] = xbuf;
190 xbuf += rgroup * (M + 4);
191 mainp->xbuffer[1][ci] = xbuf;
192 }
193}
JSAMPARRAY * JSAMPIMAGE
Definition: jpeglib.h:77
JSAMPLE FAR * JSAMPROW
Definition: jpeglib.h:75

◆ process_data_context_main()

process_data_context_main ( j_decompress_ptr  cinfo,
JSAMPARRAY  output_buf,
JDIMENSION out_row_ctr,
JDIMENSION  out_rows_avail 
)

Definition at line 378 of file jdmainct.c.

381{
382 my_main_ptr mainp = (my_main_ptr) cinfo->main;
383
384 /* Read input data if we haven't filled the main buffer yet */
385 if (! mainp->buffer_full) {
386 if (! (*cinfo->coef->decompress_data) (cinfo,
387 mainp->xbuffer[mainp->whichptr]))
388 return; /* suspension forced, can do nothing more */
389 mainp->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
390 mainp->iMCU_row_ctr++; /* count rows received */
391 }
392
393 /* Postprocessor typically will not swallow all the input data it is handed
394 * in one call (due to filling the output buffer first). Must be prepared
395 * to exit and restart. This switch lets us keep track of how far we got.
396 * Note that each case falls through to the next on successful completion.
397 */
398 switch (mainp->context_state) {
400 /* Call postprocessor using previously set pointers for postponed row */
401 (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
402 &mainp->rowgroup_ctr, mainp->rowgroups_avail,
403 output_buf, out_row_ctr, out_rows_avail);
404 if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
405 return; /* Need to suspend */
407 if (*out_row_ctr >= out_rows_avail)
408 return; /* Postprocessor exactly filled output buf */
409 /*FALLTHROUGH*/
411 /* Prepare to process first M-1 row groups of this iMCU row */
412 mainp->rowgroup_ctr = 0;
413 mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1);
414 /* Check for bottom of image: if so, tweak pointers to "duplicate"
415 * the last sample row, and adjust rowgroups_avail to ignore padding rows.
416 */
417 if (mainp->iMCU_row_ctr == cinfo->total_iMCU_rows)
418 set_bottom_pointers(cinfo);
420 /*FALLTHROUGH*/
421 case CTX_PROCESS_IMCU:
422 /* Call postprocessor using previously set pointers */
423 (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
424 &mainp->rowgroup_ctr, mainp->rowgroups_avail,
425 output_buf, out_row_ctr, out_rows_avail);
426 if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
427 return; /* Need to suspend */
428 /* After the first iMCU, change wraparound pointers to normal state */
429 if (mainp->iMCU_row_ctr == 1)
431 /* Prepare to load new iMCU row using other xbuffer list */
432 mainp->whichptr ^= 1; /* 0=>1 or 1=>0 */
433 mainp->buffer_full = FALSE;
434 /* Still need to process last row group of this iMCU row, */
435 /* which is saved at index M+1 of the other xbuffer */
436 mainp->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1);
437 mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2);
439 }
440}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:239
set_bottom_pointers(j_decompress_ptr cinfo)
Definition: jdmainct.c:268
set_wraparound_pointers(j_decompress_ptr cinfo)
Definition: jdmainct.c:240
#define CTX_PREPARE_FOR_IMCU
Definition: jdmainct.c:139
#define CTX_PROCESS_IMCU
Definition: jdmainct.c:140
#define CTX_POSTPONED_ROW
Definition: jdmainct.c:141
if(dx< 0)
Definition: linetemp.h:194
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:680
struct jpeg_d_post_controller * post
Definition: jpeglib.h:681
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:633
JDIMENSION iMCU_row_ctr
Definition: jdmainct.c:133
JDIMENSION rowgroup_ctr
Definition: jcmainct.c:33
boolean buffer_full
Definition: jdmainct.c:126

Referenced by start_pass_main().

◆ process_data_simple_main()

process_data_simple_main ( j_decompress_ptr  cinfo,
JSAMPARRAY  output_buf,
JDIMENSION out_row_ctr,
JDIMENSION  out_rows_avail 
)

Definition at line 347 of file jdmainct.c.

350{
351 my_main_ptr mainp = (my_main_ptr) cinfo->main;
352
353 /* Read input data if we haven't filled the main buffer yet */
354 if (mainp->rowgroup_ctr >= mainp->rowgroups_avail) {
355 if (! (*cinfo->coef->decompress_data) (cinfo, mainp->buffer))
356 return; /* suspension forced, can do nothing more */
357 mainp->rowgroup_ctr = 0; /* OK, we have an iMCU row to work with */
358 }
359
360 /* Note: at the bottom of the image, we may pass extra garbage row groups
361 * to the postprocessor. The postprocessor has to check for bottom
362 * of image anyway (at row resolution), so no point in us doing it too.
363 */
364
365 /* Feed the postprocessor */
366 (*cinfo->post->post_process_data) (cinfo, mainp->buffer,
367 &mainp->rowgroup_ctr, mainp->rowgroups_avail,
368 output_buf, out_row_ctr, out_rows_avail);
369}

Referenced by start_pass_main().

◆ set_bottom_pointers()

set_bottom_pointers ( j_decompress_ptr  cinfo)

Definition at line 268 of file jdmainct.c.

273{
274 my_main_ptr mainp = (my_main_ptr) cinfo->main;
275 int ci, i, rgroup, iMCUheight, rows_left;
277 JSAMPARRAY xbuf;
278
279 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
280 ci++, compptr++) {
281 /* Count sample rows in one iMCU row and in one row group */
283 rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
284 /* Count nondummy sample rows remaining for this component */
285 rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
286 if (rows_left == 0) rows_left = iMCUheight;
287 /* Count nondummy row groups. Should get same answer for each component,
288 * so we need only do it once.
289 */
290 if (ci == 0) {
291 mainp->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
292 }
293 /* Duplicate the last real sample row rgroup*2 times; this pads out the
294 * last partial rowgroup and ensures at least one full rowgroup of context.
295 */
296 xbuf = mainp->xbuffer[mainp->whichptr][ci];
297 for (i = 0; i < rgroup * 2; i++) {
298 xbuf[rows_left + i] = xbuf[rows_left-1];
299 }
300 }
301}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
JDIMENSION downsampled_height
Definition: jpeglib.h:165

Referenced by process_data_context_main().

◆ set_wraparound_pointers()

set_wraparound_pointers ( j_decompress_ptr  cinfo)

Definition at line 240 of file jdmainct.c.

244{
245 my_main_ptr mainp = (my_main_ptr) cinfo->main;
246 int ci, i, rgroup;
247 int M = cinfo->min_DCT_v_scaled_size;
249 JSAMPARRAY xbuf0, xbuf1;
250
251 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
252 ci++, compptr++) {
254 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
255 xbuf0 = mainp->xbuffer[0][ci];
256 xbuf1 = mainp->xbuffer[1][ci];
257 for (i = 0; i < rgroup; i++) {
258 xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
259 xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
260 xbuf0[rgroup*(M+2) + i] = xbuf0[i];
261 xbuf1[rgroup*(M+2) + i] = xbuf1[i];
262 }
263 }
264}

Referenced by process_data_context_main().

◆ start_pass_main()

start_pass_main ( j_decompress_ptr  cinfo,
J_BUF_MODE  pass_mode 
)

Definition at line 309 of file jdmainct.c.

310{
311 my_main_ptr mainp = (my_main_ptr) cinfo->main;
312
313 switch (pass_mode) {
314 case JBUF_PASS_THRU:
315 if (cinfo->upsample->need_context_rows) {
316 mainp->pub.process_data = process_data_context_main;
317 make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
318 mainp->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
320 mainp->iMCU_row_ctr = 0;
321 mainp->buffer_full = FALSE; /* Mark buffer empty */
322 } else {
323 /* Simple case with no context needed */
324 mainp->pub.process_data = process_data_simple_main;
325 mainp->rowgroup_ctr = mainp->rowgroups_avail; /* Mark buffer empty */
326 }
327 break;
328#ifdef QUANT_2PASS_SUPPORTED
329 case JBUF_CRANK_DEST:
330 /* For last pass of 2-pass quantization, just crank the postprocessor */
331 mainp->pub.process_data = process_data_crank_post;
332 break;
333#endif
334 default:
335 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
336 break;
337 }
338}
switch(r->id)
Definition: btrfs.c:3046
process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
Definition: jdmainct.c:378
make_funny_pointers(j_decompress_ptr cinfo)
Definition: jdmainct.c:197
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
Definition: jdmainct.c:347
@ JBUF_PASS_THRU
Definition: jpegint.h:18
@ JBUF_CRANK_DEST
Definition: jpegint.h:21

Referenced by jinit_c_main_controller(), and jinit_d_main_controller().