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

Macros

#define JPEG_INTERNALS
 

Functions

static boolean output_pass_setup (j_decompress_ptr cinfo)
 
boolean jpeg_start_decompress (j_decompress_ptr cinfo)
 
JDIMENSION jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
 
JDIMENSION jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, JDIMENSION max_lines)
 
boolean jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
 
boolean jpeg_finish_output (j_decompress_ptr cinfo)
 

Macro Definition Documentation

#define JPEG_INTERNALS

Function Documentation

static boolean output_pass_setup ( j_decompress_ptr  cinfo)
static
96 {
97  if (cinfo->global_state != DSTATE_PRESCAN) {
98  /* First call: do pass setup */
99  (*cinfo->master->prepare_for_output_pass) (cinfo);
100  cinfo->output_scanline = 0;
101  cinfo->global_state = DSTATE_PRESCAN;
102  }
103  /* Loop over any required dummy passes */
104  while (cinfo->master->is_dummy_pass) {
105 #ifdef QUANT_2PASS_SUPPORTED
106  /* Crank through the dummy pass */
107  while (cinfo->output_scanline < cinfo->output_height) {
108  JDIMENSION last_scanline;
109  /* Call progress monitor hook if present */
110  if (cinfo->progress != NULL) {
111  cinfo->progress->pass_counter = (long) cinfo->output_scanline;
112  cinfo->progress->pass_limit = (long) cinfo->output_height;
113  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
114  }
115  /* Process some data */
116  last_scanline = cinfo->output_scanline;
117  (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
118  &cinfo->output_scanline, (JDIMENSION) 0);
119  if (cinfo->output_scanline == last_scanline)
120  return FALSE; /* No progress made, must suspend */
121  }
122  /* Finish up dummy pass, and set up for another one */
123  (*cinfo->master->finish_output_pass) (cinfo);
124  (*cinfo->master->prepare_for_output_pass) (cinfo);
125  cinfo->output_scanline = 0;
126 #else
127  ERREXIT(cinfo, JERR_NOT_COMPILED);
128 #endif /* QUANT_2PASS_SUPPORTED */
129  }
130  /* Ready for application to drive output pass through
131  * jpeg_read_scanlines or jpeg_read_raw_data.
132  */
134  return TRUE;
135 }
#define DSTATE_RAW_OK
Definition: jpegint.h:35
void(* progress_monitor)()
Definition: jpeglib.h:707
JDIMENSION output_height
Definition: jpeglib.h:465
boolean is_dummy_pass
Definition: jpegint.h:142
struct jpeg_d_main_controller * main
Definition: jpeglib.h:625
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
long pass_limit
Definition: jpeglib.h:710
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
long pass_counter
Definition: jpeglib.h:709
#define FALSE
Definition: jpleph.cpp:69
Definition: jerror.h:95
boolean raw_data_out
Definition: jpeglib.h:442
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
#define DSTATE_SCANNING
Definition: jpegint.h:34
#define TRUE
Definition: jpleph.cpp:68
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:72
JDIMENSION output_scanline
Definition: jpeglib.h:494
#define DSTATE_PRESCAN
Definition: jpegint.h:33
int global_state
Definition: jpeglib.h:417
unsigned int JDIMENSION
Definition: jmorecfg.h:171
boolean jpeg_start_decompress ( j_decompress_ptr  cinfo)
39 {
40  if (cinfo->global_state == DSTATE_READY) {
41  /* First call: initialize master control, select active modules */
43  if (cinfo->buffered_image) {
44  /* No more work here; expecting jpeg_start_output next */
46  return TRUE;
47  }
49  }
50  if (cinfo->global_state == DSTATE_PRELOAD) {
51  /* If file has multiple scans, absorb them all into the coef buffer */
52  if (cinfo->inputctl->has_multiple_scans) {
53 #ifdef D_MULTISCAN_FILES_SUPPORTED
54  for (;;) {
55  int retcode;
56  /* Call progress monitor hook if present */
57  if (cinfo->progress != NULL)
58  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
59  /* Absorb some more input */
60  retcode = (*cinfo->inputctl->consume_input) (cinfo);
61  if (retcode == JPEG_SUSPENDED)
62  return FALSE;
63  if (retcode == JPEG_REACHED_EOI)
64  break;
65  /* Advance progress counter if appropriate */
66  if (cinfo->progress != NULL &&
67  (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
68  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
69  /* jdmaster underestimated number of scans; ratchet up one scan */
70  cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
71  }
72  }
73  }
74 #else
75  ERREXIT(cinfo, JERR_NOT_COMPILED);
76 #endif /* D_MULTISCAN_FILES_SUPPORTED */
77  }
78  cinfo->output_scan_number = cinfo->input_scan_number;
79  } else if (cinfo->global_state != DSTATE_PRESCAN)
80  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
81  /* Perform any dummy output passes, and set up for the final pass */
82  return output_pass_setup(cinfo);
83 }
boolean has_multiple_scans
Definition: jpegint.h:153
void(* progress_monitor)()
Definition: jpeglib.h:707
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
#define JPEG_REACHED_SOS
Definition: jpeglib.h:1001
#define JPEG_REACHED_EOI
Definition: jpeglib.h:1002
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
#define DSTATE_BUFIMAGE
Definition: jpegint.h:36
long pass_limit
Definition: jpeglib.h:710
int output_scan_number
Definition: jpeglib.h:506
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
#define JPEG_ROW_COMPLETED
Definition: jpeglib.h:1003
Definition: jpeglib.h:258
Definition: jerror.h:65
#define DSTATE_PRELOAD
Definition: jpegint.h:32
long pass_counter
Definition: jpeglib.h:709
#define FALSE
Definition: jpleph.cpp:69
Definition: jerror.h:95
static boolean output_pass_setup(j_decompress_ptr cinfo)
Definition: jdapistd.cpp:95
#define DSTATE_READY
Definition: jpegint.h:31
int input_scan_number
Definition: jpeglib.h:499
#define TRUE
Definition: jpleph.cpp:68
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
#define DSTATE_PRESCAN
Definition: jpegint.h:33
void jinit_master_decompress(j_decompress_ptr cinfo)
Definition: jdmaster.cpp:543
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
int global_state
Definition: jpeglib.h:417
boolean buffered_image
Definition: jpeglib.h:441
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:585
JDIMENSION jpeg_read_scanlines ( j_decompress_ptr  cinfo,
JSAMPARRAY  scanlines,
JDIMENSION  max_lines 
)
154 {
155  JDIMENSION row_ctr;
156 
157  if (cinfo->global_state != DSTATE_SCANNING)
158  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
159  if (cinfo->output_scanline >= cinfo->output_height) {
160  WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
161  return 0;
162  }
163 
164  /* Call progress monitor hook if present */
165  if (cinfo->progress != NULL) {
166  cinfo->progress->pass_counter = (long) cinfo->output_scanline;
167  cinfo->progress->pass_limit = (long) cinfo->output_height;
168  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
169  }
170 
171  /* Process some data */
172  row_ctr = 0;
173  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
174  cinfo->output_scanline += row_ctr;
175  return row_ctr;
176 }
void(* progress_monitor)()
Definition: jpeglib.h:707
JDIMENSION output_height
Definition: jpeglib.h:465
struct jpeg_d_main_controller * main
Definition: jpeglib.h:625
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
long pass_limit
Definition: jpeglib.h:710
Definition: jpeglib.h:258
Definition: jerror.h:65
long pass_counter
Definition: jpeglib.h:709
Definition: jerror.h:184
#define WARNMS(cinfo, code)
Definition: jerror.h:238
#define DSTATE_SCANNING
Definition: jpegint.h:34
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
JDIMENSION output_scanline
Definition: jpeglib.h:494
int global_state
Definition: jpeglib.h:417
unsigned int JDIMENSION
Definition: jmorecfg.h:171
JDIMENSION jpeg_read_raw_data ( j_decompress_ptr  cinfo,
JSAMPIMAGE  data,
JDIMENSION  max_lines 
)
187 {
188  JDIMENSION lines_per_iMCU_row;
189 
190  if (cinfo->global_state != DSTATE_RAW_OK)
191  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
192  if (cinfo->output_scanline >= cinfo->output_height) {
193  WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
194  return 0;
195  }
196 
197  /* Call progress monitor hook if present */
198  if (cinfo->progress != NULL) {
199  cinfo->progress->pass_counter = (long) cinfo->output_scanline;
200  cinfo->progress->pass_limit = (long) cinfo->output_height;
201  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
202  }
203 
204  /* Verify that at least one iMCU row can be returned. */
205  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;
206  if (max_lines < lines_per_iMCU_row)
207  ERREXIT(cinfo, JERR_BUFFER_SIZE);
208 
209  /* Decompress directly into user's buffer. */
210  if (! (*cinfo->coef->decompress_data) (cinfo, data))
211  return 0; /* suspension forced, can do nothing more */
212 
213  /* OK, we processed one iMCU row. */
214  cinfo->output_scanline += lines_per_iMCU_row;
215  return lines_per_iMCU_row;
216 }
#define DSTATE_RAW_OK
Definition: jpegint.h:35
void(* progress_monitor)()
Definition: jpeglib.h:707
JDIMENSION output_height
Definition: jpeglib.h:465
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:417
int min_DCT_scaled_size
Definition: jpeglib.h:583
long pass_limit
Definition: jpeglib.h:710
struct jpeg_d_coef_controller * coef
Definition: jpeglib.h:626
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
Definition: jerror.h:65
long pass_counter
Definition: jpeglib.h:709
Definition: jerror.h:184
Definition: jerror.h:69
#define WARNMS(cinfo, code)
Definition: jerror.h:238
int max_v_samp_factor
Definition: jpeglib.h:581
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
JDIMENSION output_scanline
Definition: jpeglib.h:494
int global_state
Definition: jpeglib.h:417
unsigned int JDIMENSION
Definition: jmorecfg.h:171
boolean jpeg_start_output ( j_decompress_ptr  cinfo,
int  scan_number 
)
229 {
230  if (cinfo->global_state != DSTATE_BUFIMAGE &&
231  cinfo->global_state != DSTATE_PRESCAN)
232  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
233  /* Limit scan number to valid range */
234  if (scan_number <= 0)
235  scan_number = 1;
236  if (cinfo->inputctl->eoi_reached &&
237  scan_number > cinfo->input_scan_number)
238  scan_number = cinfo->input_scan_number;
239  cinfo->output_scan_number = scan_number;
240  /* Perform any dummy output passes, and set up for the real pass */
241  return output_pass_setup(cinfo);
242 }
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
#define DSTATE_BUFIMAGE
Definition: jpegint.h:36
int output_scan_number
Definition: jpeglib.h:506
Definition: jerror.h:65
static boolean output_pass_setup(j_decompress_ptr cinfo)
Definition: jdapistd.cpp:95
int input_scan_number
Definition: jpeglib.h:499
boolean eoi_reached
Definition: jpegint.h:154
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
#define DSTATE_PRESCAN
Definition: jpegint.h:33
int global_state
Definition: jpeglib.h:417
boolean jpeg_finish_output ( j_decompress_ptr  cinfo)
254 {
255  if ((cinfo->global_state == DSTATE_SCANNING ||
256  cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
257  /* Terminate this pass. */
258  /* We do not require the whole pass to have been completed. */
259  (*cinfo->master->finish_output_pass) (cinfo);
260  cinfo->global_state = DSTATE_BUFPOST;
261  } else if (cinfo->global_state != DSTATE_BUFPOST) {
262  /* BUFPOST = repeat call after a suspension, anything else is error */
263  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
264  }
265  /* Read markers looking for SOS or EOI */
266  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
267  ! cinfo->inputctl->eoi_reached) {
268  if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
269  return FALSE; /* Suspend, come back later */
270  }
271  cinfo->global_state = DSTATE_BUFIMAGE;
272  return TRUE;
273 }
#define DSTATE_RAW_OK
Definition: jpegint.h:35
struct jpeg_input_controller * inputctl
Definition: jpeglib.h:628
#define DSTATE_BUFIMAGE
Definition: jpegint.h:36
int output_scan_number
Definition: jpeglib.h:506
Definition: jerror.h:65
#define FALSE
Definition: jpleph.cpp:69
int input_scan_number
Definition: jpeglib.h:499
struct jpeg_decomp_master * master
Definition: jpeglib.h:624
boolean eoi_reached
Definition: jpegint.h:154
#define DSTATE_SCANNING
Definition: jpegint.h:34
#define TRUE
Definition: jpleph.cpp:68
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
#define DSTATE_BUFPOST
Definition: jpegint.h:37
#define JPEG_SUSPENDED
Definition: jpeglib.h:970
int global_state
Definition: jpeglib.h:417
boolean buffered_image
Definition: jpeglib.h:441