COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jcmainct.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jcmainct.cpp:

Classes

struct  my_main_controller
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_main_controllermy_main_ptr
 

Functions

static void process_data_simple_main (j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
 
static void start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
 
void jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
 

Macro Definition Documentation

#define JPEG_INTERNALS

Typedef Documentation

Function Documentation

static void process_data_simple_main ( j_compress_ptr  cinfo,
JSAMPARRAY  input_buf,
JDIMENSION in_row_ctr,
JDIMENSION  in_rows_avail 
)
static
116 {
117  my_main_ptr main = (my_main_ptr) cinfo->main;
118 
119  while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
120  /* Read input data if we haven't filled the main buffer yet */
121  if (main->rowgroup_ctr < DCTSIZE)
122  (*cinfo->prep->pre_process_data) (cinfo,
123  input_buf, in_row_ctr, in_rows_avail,
124  main->buffer, &main->rowgroup_ctr,
125  (JDIMENSION) DCTSIZE);
126 
127  /* If we don't have a full iMCU row buffered, return to application for
128  * more data. Note that preprocessor will always pad to fill the iMCU row
129  * at the bottom of the image.
130  */
131  if (main->rowgroup_ctr != DCTSIZE)
132  return;
133 
134  /* Send the completed row to the compressor */
135  if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
136  /* If compressor did not consume the whole row, then we must need to
137  * suspend processing and return to the application. In this situation
138  * we pretend we didn't yet consume the last input row; otherwise, if
139  * it happened to be the last row of the image, the application would
140  * think we were done.
141  */
142  if (! main->suspended) {
143  (*in_row_ctr)--;
144  main->suspended = TRUE;
145  }
146  return;
147  }
148  /* We did finish the row. Undo our little suspension hack if a previous
149  * call suspended; then mark the main buffer empty.
150  */
151  if (main->suspended) {
152  (*in_row_ctr)++;
153  main->suspended = FALSE;
154  }
155  main->rowgroup_ctr = 0;
156  main->cur_iMCU_row++;
157  }
158 }
struct jpeg_c_prep_controller * prep
Definition: jpeglib.h:402
Definition: jcmainct.cpp:28
JDIMENSION rowgroup_ctr
Definition: jcmainct.cpp:32
my_main_controller * my_main_ptr
Definition: jcmainct.cpp:50
boolean suspended
Definition: jcmainct.cpp:33
#define FALSE
Definition: jpleph.cpp:69
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:403
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:372
int main(int argc, char **argv)
Definition: agent_001.cpp:50
struct jpeg_c_main_controller * main
Definition: jpeglib.h:401
#define TRUE
Definition: jpleph.cpp:68
JDIMENSION cur_iMCU_row
Definition: jcmainct.cpp:31
JSAMPARRAY buffer[10]
Definition: jcmainct.cpp:40
#define DCTSIZE
Definition: jpeglib.h:46
unsigned int JDIMENSION
Definition: jmorecfg.h:171
static void start_pass_main ( j_compress_ptr  cinfo,
J_BUF_MODE  pass_mode 
)
static
70 {
71  my_main_ptr main = (my_main_ptr) cinfo->main;
72 
73  /* Do nothing in raw-data mode. */
74  if (cinfo->raw_data_in)
75  return;
76 
77  main->cur_iMCU_row = 0; /* initialize counters */
78  main->rowgroup_ctr = 0;
79  main->suspended = FALSE;
80  main->pass_mode = pass_mode; /* save mode for use by process_data */
81 
82  switch (pass_mode) {
83  case JBUF_PASS_THRU:
84 #ifdef FULL_MAIN_BUFFER_SUPPORTED
85  if (main->whole_image[0] != NULL)
87 #endif
88  main->pub.process_data = process_data_simple_main;
89  break;
90 #ifdef FULL_MAIN_BUFFER_SUPPORTED
91  case JBUF_SAVE_SOURCE:
92  case JBUF_CRANK_DEST:
93  case JBUF_SAVE_AND_PASS:
94  if (main->whole_image[0] == NULL)
96  main->pub.process_data = process_data_buffer_main;
97  break;
98 #endif
99  default:
101  break;
102  }
103 }
struct jpeg_c_main_controller pub
Definition: jcmainct.cpp:29
Definition: jerror.h:46
Definition: jpegint.h:20
Definition: jcmainct.cpp:28
Definition: jpegint.h:21
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
J_BUF_MODE pass_mode
Definition: jcmainct.cpp:34
JDIMENSION rowgroup_ctr
Definition: jcmainct.cpp:32
my_main_controller * my_main_ptr
Definition: jcmainct.cpp:50
boolean suspended
Definition: jcmainct.cpp:33
#define FALSE
Definition: jpleph.cpp:69
int main(int argc, char **argv)
Definition: agent_001.cpp:50
Definition: jpegint.h:19
struct jpeg_c_main_controller * main
Definition: jpeglib.h:401
static void process_data_simple_main(j_compress_ptr cinfo, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
Definition: jcmainct.cpp:113
JDIMENSION cur_iMCU_row
Definition: jcmainct.cpp:31
Definition: jpegint.h:17
boolean raw_data_in
Definition: jpeglib.h:325
void jinit_c_main_controller ( j_compress_ptr  cinfo,
boolean  need_full_buffer 
)
246 {
248  int ci;
250 
251  main = (my_main_ptr)
252  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
254  cinfo->main = (struct jpeg_c_main_controller *) main;
255  main->pub.start_pass = start_pass_main;
256 
257  /* We don't need to create a buffer in raw-data mode. */
258  if (cinfo->raw_data_in)
259  return;
260 
261  /* Create the buffer. It holds downsampled data, so each component
262  * may be of a different size.
263  */
264  if (need_full_buffer) {
265 #ifdef FULL_MAIN_BUFFER_SUPPORTED
266  /* Allocate a full-image virtual array for each component */
267  /* Note we pad the bottom to a multiple of the iMCU height */
268  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
269  ci++, compptr++) {
270  main->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
271  ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
272  compptr->width_in_blocks * DCTSIZE,
273  (JDIMENSION) jround_up((long) compptr->height_in_blocks,
274  (long) compptr->v_samp_factor) * DCTSIZE,
275  (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
276  }
277 #else
279 #endif
280  } else {
281 #ifdef FULL_MAIN_BUFFER_SUPPORTED
282  main->whole_image[0] = NULL; /* flag for no virtual arrays */
283 #endif
284  /* Allocate a strip buffer for each component */
285  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
286  ci++, compptr++) {
287  main->buffer[ci] = (*cinfo->mem->alloc_sarray)
288  ((j_common_ptr) cinfo, JPOOL_IMAGE,
289  compptr->width_in_blocks * DCTSIZE,
290  (JDIMENSION) (compptr->v_samp_factor * DCTSIZE));
291  }
292  }
293 }
int v_samp_factor
Definition: jpeglib.h:128
struct jpeg_c_main_controller pub
Definition: jcmainct.cpp:29
Definition: jerror.h:46
jvirt_sarray_ptr(* request_virt_sarray)()
Definition: jpeglib.h:778
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
void *(* alloc_small)()
Definition: jpeglib.h:764
Definition: jcmainct.cpp:28
long jround_up(long a, long b)
Definition: jutils.cpp:81
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
#define SIZEOF(object)
Definition: jinclude.h:80
boolean need_full_buffer
Definition: jpegint.h:338
my_main_controller * my_main_ptr
Definition: jcmainct.cpp:50
jpeg_component_info * compptr
Definition: jdct.h:102
JDIMENSION width_in_blocks
Definition: jpeglib.h:144
#define JPOOL_IMAGE
Definition: jpeglib.h:754
Definition: jpegint.h:56
#define FALSE
Definition: jpleph.cpp:69
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:274
int main(int argc, char **argv)
Definition: agent_001.cpp:50
struct jpeg_c_main_controller * main
Definition: jpeglib.h:401
JSAMPARRAY buffer[10]
Definition: jcmainct.cpp:40
static void start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
Definition: jcmainct.cpp:69
Definition: jpeglib.h:121
#define DCTSIZE
Definition: jpeglib.h:46
JSAMPARRAY(* alloc_sarray)()
Definition: jpeglib.h:769
unsigned int JDIMENSION
Definition: jmorecfg.h:171
boolean raw_data_in
Definition: jpeglib.h:325
jpeg_component_info * comp_info
Definition: jpeglib.h:304