ReactOS  0.4.15-dev-509-g96a357b
jcmainct.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jcmainct.c:

Go to the source code of this file.

Classes

struct  my_main_controller
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_main_controllermy_main_ptr
 

Functions

 METHODDEF (void)
 
 process_data_simple_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
 
 jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
 

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 14 of file jcmainct.c.

Typedef Documentation

◆ my_main_ptr

Definition at line 51 of file jcmainct.c.

Function Documentation

◆ jinit_c_main_controller()

jinit_c_main_controller ( j_compress_ptr  cinfo,
boolean  need_full_buffer 
)

Definition at line 248 of file jcmainct.c.

249 {
250  my_main_ptr mainp;
251  int ci;
253 
254  mainp = (my_main_ptr)
255  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257  cinfo->main = &mainp->pub;
258  mainp->pub.start_pass = start_pass_main;
259 
260  /* We don't need to create a buffer in raw-data mode. */
261  if (cinfo->raw_data_in)
262  return;
263 
264  /* Create the buffer. It holds downsampled data, so each component
265  * may be of a different size.
266  */
267  if (need_full_buffer) {
268 #ifdef FULL_MAIN_BUFFER_SUPPORTED
269  /* Allocate a full-image virtual array for each component */
270  /* Note we pad the bottom to a multiple of the iMCU height */
271  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
272  ci++, compptr++) {
273  mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
274  ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
277  (long) compptr->v_samp_factor)) *
280  }
281 #else
282  ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
283 #endif
284  } else {
285 #ifdef FULL_MAIN_BUFFER_SUPPORTED
286  mainp->whole_image[0] = NULL; /* flag for no virtual arrays */
287 #endif
288  /* Allocate a strip buffer for each component */
289  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
290  ci++, compptr++) {
291  mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
292  ((j_common_ptr) cinfo, JPOOL_IMAGE,
295  }
296  }
297 }
struct jpeg_c_main_controller pub
Definition: jcmainct.c:30
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
boolean need_full_buffer
Definition: jpegint.h:384
start_pass_main(j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
Definition: jdmainct.c:309
jpeg_component_info * compptr
Definition: jdct.h:238
JDIMENSION width_in_blocks
Definition: jpeglib.h:148
#define SIZEOF(_ar)
Definition: calc.h:97
#define JPOOL_IMAGE
Definition: jpeglib.h:808
jround_up(long a, long b)
Definition: jutils.c:133
JSAMPARRAY buffer[MAX_COMPONENTS]
Definition: jcmainct.c:41
smooth NULL
Definition: ftsmooth.c:416
JDIMENSION height_in_blocks
Definition: jpeglib.h:149
struct jpeg_c_main_controller * main
Definition: jpeglib.h:444
#define long
Definition: qsort.c:33
unsigned int JDIMENSION
Definition: jmorecfg.h:229
boolean raw_data_in
Definition: jpeglib.h:357
jpeg_component_info * comp_info
Definition: jpeglib.h:333
my_main_controller * my_main_ptr
Definition: jcmainct.c:51

Referenced by jinit_compress_master().

◆ METHODDEF()

METHODDEF ( void  )

Definition at line 55 of file jcmainct.c.

71 {
72  my_main_ptr mainp = (my_main_ptr) cinfo->main;
73 
74  /* Do nothing in raw-data mode. */
75  if (cinfo->raw_data_in)
76  return;
77 
78  mainp->cur_iMCU_row = 0; /* initialize counters */
79  mainp->rowgroup_ctr = 0;
80  mainp->suspended = FALSE;
81  mainp->pass_mode = pass_mode; /* save mode for use by process_data */
82 
83  switch (pass_mode) {
84  case JBUF_PASS_THRU:
85 #ifdef FULL_MAIN_BUFFER_SUPPORTED
86  if (mainp->whole_image[0] != NULL)
87  ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
88 #endif
89  mainp->pub.process_data = process_data_simple_main;
90  break;
91 #ifdef FULL_MAIN_BUFFER_SUPPORTED
92  case JBUF_SAVE_SOURCE:
93  case JBUF_CRANK_DEST:
94  case JBUF_SAVE_AND_PASS:
95  if (mainp->whole_image[0] == NULL)
96  ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
97  mainp->pub.process_data = process_data_buffer_main;
98  break;
99 #endif
100  default:
101  ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
102  break;
103  }
104 }
struct jpeg_c_main_controller pub
Definition: jcmainct.c:30
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
Definition: jcmainct.c:114
J_BUF_MODE pass_mode
Definition: jcmainct.c:35
JDIMENSION rowgroup_ctr
Definition: jcmainct.c:33
boolean suspended
Definition: jcmainct.c:34
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
JDIMENSION cur_iMCU_row
Definition: jcmainct.c:32
my_main_controller * my_main_ptr
Definition: jcmainct.c:51

◆ process_data_simple_main()

process_data_simple_main ( j_compress_ptr  cinfo,
JSAMPARRAY  input_buf,
JDIMENSION in_row_ctr,
JDIMENSION  in_rows_avail 
)

Definition at line 114 of file jcmainct.c.

117 {
118  my_main_ptr mainp = (my_main_ptr) cinfo->main;
119 
120  while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
121  /* Read input data if we haven't filled the main buffer yet */
122  if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
123  (*cinfo->prep->pre_process_data) (cinfo,
124  input_buf, in_row_ctr, in_rows_avail,
125  mainp->buffer, &mainp->rowgroup_ctr,
127 
128  /* If we don't have a full iMCU row buffered, return to application for
129  * more data. Note that preprocessor will always pad to fill the iMCU row
130  * at the bottom of the image.
131  */
132  if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
133  return;
134 
135  /* Send the completed row to the compressor */
136  if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
137  /* If compressor did not consume the whole row, then we must need to
138  * suspend processing and return to the application. In this situation
139  * we pretend we didn't yet consume the last input row; otherwise, if
140  * it happened to be the last row of the image, the application would
141  * think we were done.
142  */
143  if (! mainp->suspended) {
144  (*in_row_ctr)--;
145  mainp->suspended = TRUE;
146  }
147  return;
148  }
149  /* We did finish the row. Undo our little suspension hack if a previous
150  * call suspended; then mark the main buffer empty.
151  */
152  if (mainp->suspended) {
153  (*in_row_ctr)++;
154  mainp->suspended = FALSE;
155  }
156  mainp->rowgroup_ctr = 0;
157  mainp->cur_iMCU_row++;
158  }
159 }
struct jpeg_c_prep_controller * prep
Definition: jpeglib.h:445
#define TRUE
Definition: types.h:120
JDIMENSION rowgroup_ctr
Definition: jcmainct.c:33
boolean suspended
Definition: jcmainct.c:34
while(1)
Definition: macro.lex.yy.c:740
JSAMPARRAY buffer[MAX_COMPONENTS]
Definition: jcmainct.c:41
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:446
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:411
struct jpeg_c_main_controller * main
Definition: jpeglib.h:444
JDIMENSION cur_iMCU_row
Definition: jcmainct.c:32
unsigned int JDIMENSION
Definition: jmorecfg.h:229
my_main_controller * my_main_ptr
Definition: jcmainct.c:51