ReactOS 0.4.16-dev-2613-g9533ad7
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 472 of file jdmainct.c.

473{
474 my_main_ptr mainp;
475 int ci, rgroup, ngroups;
477
478 mainp = (my_main_ptr) (*cinfo->mem->alloc_small)
480 cinfo->main = &mainp->pub;
481 mainp->pub.start_pass = start_pass_main;
482
483 if (need_full_buffer) /* shouldn't happen */
484 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
485
486 /* Allocate the workspace.
487 * ngroups is the number of row groups we need.
488 */
489 if (cinfo->upsample->need_context_rows) {
490 if (cinfo->min_DCT_v_scaled_size < 2) /* unsupported, see comments above */
491 ERREXIT(cinfo, JERR_NOTIMPL);
492 alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
493 ngroups = cinfo->min_DCT_v_scaled_size + 2;
494 } else {
495 /* There are always min_DCT_v_scaled_size row groups in an iMCU row. */
496 ngroups = cinfo->min_DCT_v_scaled_size;
497 mainp->rowgroups_avail = (JDIMENSION) ngroups;
498 }
499
500 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
501 ci++, compptr++) {
503 continue; /* skip uninteresting component */
505 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
506 mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
507 ((j_common_ptr) cinfo, JPOOL_IMAGE,
509 (JDIMENSION) (rgroup * ngroups));
510 }
511}
#define SIZEOF(_ar)
Definition: calc.h:97
jpeg_component_info * compptr
Definition: jdct.h:252
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:316
unsigned int JDIMENSION
Definition: jmorecfg.h:265
boolean need_full_buffer
Definition: jpegint.h:383
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define JPOOL_IMAGE
Definition: jpeglib.h:810
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
JDIMENSION width_in_blocks
Definition: jpeglib.h:148
boolean component_needed
Definition: jpeglib.h:174
struct jpeg_upsampler * upsample
Definition: jpeglib.h:688
struct jpeg_d_main_controller * main
Definition: jpeglib.h:681
jpeg_component_info * comp_info
Definition: jpeglib.h:584
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 198 of file jdmainct.c.

205{
206 my_main_ptr mainp = (my_main_ptr) cinfo->main;
207 int ci, i, rgroup;
208 int M = cinfo->min_DCT_v_scaled_size;
210 JSAMPARRAY buf, xbuf0, xbuf1;
211
212 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
213 ci++, compptr++) {
215 continue; /* skip uninteresting component */
217 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
218 xbuf0 = mainp->xbuffer[0][ci];
219 xbuf1 = mainp->xbuffer[1][ci];
220 /* First copy the workspace pointers as-is */
221 buf = mainp->buffer[ci];
222 for (i = 0; i < rgroup * (M + 2); i++) {
223 xbuf0[i] = xbuf1[i] = buf[i];
224 }
225 /* In the second list, put the last four row groups in swapped order */
226 for (i = 0; i < rgroup * 2; i++) {
227 xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i];
228 xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i];
229 }
230 /* The wraparound pointers at top and bottom will be filled later
231 * (see set_wraparound_pointers, below). Initially we want the "above"
232 * pointers to duplicate the first actual data line. This only needs
233 * to happen in xbuffer[0].
234 */
235 for (i = 0; i < rgroup; i++) {
236 xbuf0[i - rgroup] = xbuf0[0];
237 }
238 }
239}
#define M(row, col)
for(i=0;i< ARRAY_SIZE(offsets);i++)
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
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) (*cinfo->mem->alloc_small)
174 ((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 continue; /* skip uninteresting component */
183 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
184 /* Get space for pointer lists --- M+4 row groups in each list.
185 * We alloc both pointer lists with one call to save a few cycles.
186 */
187 xbuf = (JSAMPARRAY) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
188 JPOOL_IMAGE, 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
189 xbuf += rgroup; /* want one row group at negative offsets */
190 mainp->xbuffer[0][ci] = xbuf;
191 xbuf += rgroup * (M + 4);
192 mainp->xbuffer[1][ci] = xbuf;
193 }
194}
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 383 of file jdmainct.c.

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

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

Referenced by start_pass_main().

◆ set_bottom_pointers()

set_bottom_pointers ( j_decompress_ptr  cinfo)

Definition at line 273 of file jdmainct.c.

278{
279 my_main_ptr mainp = (my_main_ptr) cinfo->main;
280 int ci, i, rgroup, iMCUheight, rows_left;
282 JSAMPARRAY xbuf;
283
284 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
285 ci++, compptr++) {
287 continue; /* skip uninteresting component */
288 /* Count sample rows in one iMCU row and in one row group */
290 rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
291 /* Count nondummy sample rows remaining for this component */
292 rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
293 if (rows_left == 0) rows_left = iMCUheight;
294 /* Count nondummy row groups. Should get same answer for each component,
295 * so we need only do it once.
296 */
297 if (ci == 0) {
298 mainp->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
299 }
300 /* Duplicate the last real sample row rgroup*2 times; this pads out the
301 * last partial rowgroup and ensures at least one full rowgroup of context.
302 */
303 xbuf = mainp->xbuffer[mainp->whichptr][ci];
304 for (i = 0; i < rgroup * 2; i++) {
305 xbuf[rows_left + i] = xbuf[rows_left-1];
306 }
307 }
308}
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 243 of file jdmainct.c.

247{
248 my_main_ptr mainp = (my_main_ptr) cinfo->main;
249 int ci, i, rgroup;
250 int M = cinfo->min_DCT_v_scaled_size;
252 JSAMPARRAY xbuf0, xbuf1;
253
254 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
255 ci++, compptr++) {
257 continue; /* skip uninteresting component */
259 cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
260 xbuf0 = mainp->xbuffer[0][ci];
261 xbuf1 = mainp->xbuffer[1][ci];
262 for (i = 0; i < rgroup; i++) {
263 xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
264 xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
265 xbuf0[rgroup*(M+2) + i] = xbuf0[i];
266 xbuf1[rgroup*(M+2) + i] = xbuf1[i];
267 }
268 }
269}

Referenced by process_data_context_main().

◆ start_pass_main()

start_pass_main ( j_decompress_ptr  cinfo,
J_BUF_MODE  pass_mode 
)

Definition at line 316 of file jdmainct.c.

317{
318 my_main_ptr mainp = (my_main_ptr) cinfo->main;
319
320 switch (pass_mode) {
321 case JBUF_PASS_THRU:
322 if (cinfo->upsample->need_context_rows) {
323 mainp->pub.process_data = process_data_context_main;
324 make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
325 mainp->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
327 mainp->iMCU_row_ctr = 0;
328 mainp->buffer_full = FALSE; /* Mark buffer empty */
329 } else {
330 /* Simple case with no context needed */
331 mainp->pub.process_data = process_data_simple_main;
332 mainp->rowgroup_ctr = mainp->rowgroups_avail; /* Mark buffer empty */
333 }
334 break;
335#ifdef QUANT_2PASS_SUPPORTED
336 case JBUF_CRANK_DEST:
337 /* For last pass of 2-pass quantization, just crank the postprocessor */
338 mainp->pub.process_data = process_data_crank_post;
339 break;
340#endif
341 default:
342 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
343 }
344}
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:383
make_funny_pointers(j_decompress_ptr cinfo)
Definition: jdmainct.c:198
process_data_simple_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
Definition: jdmainct.c:353
@ 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().