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

Macros

#define JPEG_INTERNALS
 

Functions

void jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
 
void jpeg_destroy_compress (j_compress_ptr cinfo)
 
void jpeg_abort_compress (j_compress_ptr cinfo)
 
void jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
 
void jpeg_finish_compress (j_compress_ptr cinfo)
 
void jpeg_write_marker (j_compress_ptr cinfo, int marker, const JOCTET *dataptr, unsigned int datalen)
 
void jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
 
void jpeg_write_m_byte (j_compress_ptr cinfo, int val)
 
void jpeg_write_tables (j_compress_ptr cinfo)
 

Macro Definition Documentation

#define JPEG_INTERNALS

Function Documentation

void jpeg_CreateCompress ( j_compress_ptr  cinfo,
int  version,
size_t  structsize 
)
31 {
32  int i;
33 
34  /* Guard against version mismatches between library and caller. */
35  cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
36  if (version != JPEG_LIB_VERSION)
38  if (structsize != SIZEOF(struct jpeg_compress_struct))
40  (int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
41 
42  /* For debugging purposes, we zero the whole master structure.
43  * But the application has already set the err pointer, and may have set
44  * client_data, so we have to save and restore those fields.
45  * Note: if application hasn't set client_data, tools like Purify may
46  * complain here.
47  */
48  {
49  struct jpeg_error_mgr * err = cinfo->err;
50  void * client_data = cinfo->client_data; /* ignore Purify complaint here */
51  MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct));
52  cinfo->err = err;
53  cinfo->client_data = client_data;
54  }
55  cinfo->is_decompressor = FALSE;
56 
57  /* Initialize a memory manager instance for this object */
59 
60  /* Zero out pointers to permanent structures. */
61  cinfo->progress = NULL;
62  cinfo->dest = NULL;
63 
64  cinfo->comp_info = NULL;
65 
66  for (i = 0; i < NUM_QUANT_TBLS; i++)
67  cinfo->quant_tbl_ptrs[i] = NULL;
68 
69  for (i = 0; i < NUM_HUFF_TBLS; i++) {
70  cinfo->dc_huff_tbl_ptrs[i] = NULL;
71  cinfo->ac_huff_tbl_ptrs[i] = NULL;
72  }
73 
74  cinfo->script_space = NULL;
75 
76  cinfo->input_gamma = 1.0; /* in case application forgets */
77 
78  /* OK, I'm ready */
79  cinfo->global_state = CSTATE_START;
80 }
#define CSTATE_START
Definition: jpegint.h:25
#define NUM_QUANT_TBLS
Definition: jpeglib.h:48
int i
Definition: rw_test.cpp:37
Definition: jerror.h:55
JQUANT_TBL * quant_tbl_ptrs[4]
Definition: jpeglib.h:307
#define NUM_HUFF_TBLS
Definition: jpeglib.h:49
Definition: jpeglib.h:648
Definition: jpeglib.h:258
#define SIZEOF(object)
Definition: jinclude.h:80
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:274
double input_gamma
Definition: jpeglib.h:289
#define FALSE
Definition: jpleph.cpp:69
void * client_data
Definition: jpeglib.h:274
struct jpeg_memory_mgr * mem
Definition: jpeglib.h:274
#define JPEG_LIB_VERSION
Definition: jpeglib.h:38
struct jpeg_error_mgr * err
Definition: jpeglib.h:274
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
string & err
Definition: json11.cpp:362
Definition: jerror.h:67
Definition: jpeglib.h:273
boolean is_decompressor
Definition: jpeglib.h:274
void jinit_memory_mgr(j_common_ptr cinfo)
Definition: jmemmgr.cpp:1028
int global_state
Definition: jpeglib.h:274
JHUFF_TBL * ac_huff_tbl_ptrs[4]
Definition: jpeglib.h:311
JHUFF_TBL * dc_huff_tbl_ptrs[4]
Definition: jpeglib.h:310
jpeg_scan_info * script_space
Definition: jpeglib.h:409
#define ERREXIT2(cinfo, code, p1, p2)
Definition: jerror.h:212
jpeg_component_info * comp_info
Definition: jpeglib.h:304
#define MEMZERO(target, size)
Definition: jinclude.h:67
void jpeg_destroy_compress ( j_compress_ptr  cinfo)
89 {
90  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
91 }
void jpeg_destroy(j_common_ptr cinfo)
Definition: jcomapi.cpp:69
Definition: jpeglib.h:258
void jpeg_abort_compress ( j_compress_ptr  cinfo)
101 {
102  jpeg_abort((j_common_ptr) cinfo); /* use common routine */
103 }
Definition: jpeglib.h:258
void jpeg_abort(j_common_ptr cinfo)
Definition: jcomapi.cpp:29
void jpeg_suppress_tables ( j_compress_ptr  cinfo,
boolean  suppress 
)
120 {
121  int i;
122  JQUANT_TBL * qtbl;
123  JHUFF_TBL * htbl;
124 
125  for (i = 0; i < NUM_QUANT_TBLS; i++) {
126  if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
127  qtbl->sent_table = suppress;
128  }
129 
130  for (i = 0; i < NUM_HUFF_TBLS; i++) {
131  if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
132  htbl->sent_table = suppress;
133  if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
134  htbl->sent_table = suppress;
135  }
136 }
#define NUM_QUANT_TBLS
Definition: jpeglib.h:48
int i
Definition: rw_test.cpp:37
JQUANT_TBL * quant_tbl_ptrs[4]
Definition: jpeglib.h:307
#define NUM_HUFF_TBLS
Definition: jpeglib.h:49
boolean sent_table
Definition: jpeglib.h:99
Definition: jpeglib.h:88
boolean sent_table
Definition: jpeglib.h:115
JHUFF_TBL * ac_huff_tbl_ptrs[4]
Definition: jpeglib.h:311
JHUFF_TBL * dc_huff_tbl_ptrs[4]
Definition: jpeglib.h:310
JHUFF_TBL * htbl
Definition: jchuff.h:47
Definition: jpeglib.h:105
void jpeg_finish_compress ( j_compress_ptr  cinfo)
148 {
149  JDIMENSION iMCU_row;
150 
151  if (cinfo->global_state == CSTATE_SCANNING ||
152  cinfo->global_state == CSTATE_RAW_OK) {
153  /* Terminate first pass */
154  if (cinfo->next_scanline < cinfo->image_height)
156  (*cinfo->master->finish_pass) (cinfo);
157  } else if (cinfo->global_state != CSTATE_WRCOEFS)
158  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
159  /* Perform any remaining passes */
160  while (! cinfo->master->is_last_pass) {
161  (*cinfo->master->prepare_for_pass) (cinfo);
162  for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
163  if (cinfo->progress != NULL) {
164  cinfo->progress->pass_counter = (long) iMCU_row;
165  cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;
166  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
167  }
168  /* We bypass the main controller and invoke coef controller directly;
169  * all work is being done from the coefficient buffer.
170  */
171  if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))
172  ERREXIT(cinfo, JERR_CANT_SUSPEND);
173  }
174  (*cinfo->master->finish_pass) (cinfo);
175  }
176  /* Write EOI, do final cleanup */
177  (*cinfo->marker->write_file_trailer) (cinfo);
178  (*cinfo->dest->term_destination) (cinfo);
179  /* We can use jpeg_abort to release memory and reset global_state */
180  jpeg_abort((j_common_ptr) cinfo);
181 }
void(* progress_monitor)()
Definition: jpeglib.h:707
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:266
long pass_limit
Definition: jpeglib.h:710
JDIMENSION image_height
Definition: jpeglib.h:285
#define ERREXIT(cinfo, code)
Definition: jerror.h:205
Definition: jpeglib.h:258
Definition: jerror.h:65
#define CSTATE_RAW_OK
Definition: jpegint.h:27
struct jpeg_progress_mgr * progress
Definition: jpeglib.h:274
#define CSTATE_SCANNING
Definition: jpegint.h:26
long pass_counter
Definition: jpeglib.h:709
JDIMENSION next_scanline
Definition: jpeglib.h:359
boolean is_last_pass
Definition: jpegint.h:52
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:403
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:372
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
struct jpeg_marker_writer * marker
Definition: jpeglib.h:404
JSAMPARRAY * JSAMPIMAGE
Definition: jpeglib.h:73
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
int global_state
Definition: jpeglib.h:274
Definition: jerror.h:70
unsigned int JDIMENSION
Definition: jmorecfg.h:171
#define CSTATE_WRCOEFS
Definition: jpegint.h:28
struct jpeg_comp_master * master
Definition: jpeglib.h:400
void jpeg_abort(j_common_ptr cinfo)
Definition: jcomapi.cpp:29
void(* term_destination)()
Definition: jpeglib.h:724
Definition: jerror.h:116
void jpeg_write_marker ( j_compress_ptr  cinfo,
int  marker,
const JOCTET dataptr,
unsigned int  datalen 
)
194 {
195  JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val));
196 
197  if (cinfo->next_scanline != 0 ||
198  (cinfo->global_state != CSTATE_SCANNING &&
199  cinfo->global_state != CSTATE_RAW_OK &&
200  cinfo->global_state != CSTATE_WRCOEFS))
201  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
202 
203  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
204  write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */
205  while (datalen--) {
206  (*write_marker_byte) (cinfo, *dataptr);
207  dataptr++;
208  }
209 }
Definition: jerror.h:65
#define CSTATE_RAW_OK
Definition: jpegint.h:27
#define CSTATE_SCANNING
Definition: jpegint.h:26
JDIMENSION next_scanline
Definition: jpeglib.h:359
int datalen
Definition: mcastclient.c:41
struct jpeg_marker_writer * marker
Definition: jpeglib.h:404
#define JMETHOD(type, methodname, arglist)
Definition: jmorecfg.h:202
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
Definition: jpeglib.h:273
static void write_marker_byte(j_compress_ptr cinfo, int val)
Definition: jcmarker.cpp:450
int global_state
Definition: jpeglib.h:274
backing_store_ptr info
Definition: jmemsys.h:181
#define CSTATE_WRCOEFS
Definition: jpegint.h:28
void jpeg_write_m_header ( j_compress_ptr  cinfo,
int  marker,
unsigned int  datalen 
)
215 {
216  if (cinfo->next_scanline != 0 ||
217  (cinfo->global_state != CSTATE_SCANNING &&
218  cinfo->global_state != CSTATE_RAW_OK &&
219  cinfo->global_state != CSTATE_WRCOEFS))
220  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
221 
222  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
223 }
Definition: jerror.h:65
#define CSTATE_RAW_OK
Definition: jpegint.h:27
#define CSTATE_SCANNING
Definition: jpegint.h:26
JDIMENSION next_scanline
Definition: jpeglib.h:359
int datalen
Definition: mcastclient.c:41
struct jpeg_marker_writer * marker
Definition: jpeglib.h:404
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
int global_state
Definition: jpeglib.h:274
#define CSTATE_WRCOEFS
Definition: jpegint.h:28
void jpeg_write_m_byte ( j_compress_ptr  cinfo,
int  val 
)
227 {
228  (*cinfo->marker->write_marker_byte) (cinfo, val);
229 }
struct jpeg_marker_writer * marker
Definition: jpeglib.h:404
void jpeg_write_tables ( j_compress_ptr  cinfo)
255 {
256  if (cinfo->global_state != CSTATE_START)
257  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
258 
259  /* (Re)initialize error mgr and destination modules */
260  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
261  (*cinfo->dest->init_destination) (cinfo);
262  /* Initialize the marker writer ... bit of a crock to do it here. */
263  jinit_marker_writer(cinfo);
264  /* Write them tables! */
265  (*cinfo->marker->write_tables_only) (cinfo);
266  /* And clean up. */
267  (*cinfo->dest->term_destination) (cinfo);
268  /*
269  * In library releases up through v6a, we called jpeg_abort() here to free
270  * any working memory allocated by the destination manager and marker
271  * writer. Some applications had a problem with that: they allocated space
272  * of their own from the library memory manager, and didn't want it to go
273  * away during write_tables. So now we do nothing. This will cause a
274  * memory leak if an app calls write_tables repeatedly without doing a full
275  * compression cycle or otherwise resetting the JPEG object. However, that
276  * seems less bad than unexpectedly freeing memory in the normal case.
277  * An app that prefers the old behavior can call jpeg_abort for itself after
278  * each call to jpeg_write_tables().
279  */
280 }
#define CSTATE_START
Definition: jpegint.h:25
void jinit_marker_writer(j_compress_ptr cinfo)
Definition: jcmarker.cpp:645
Definition: jpeglib.h:258
Definition: jerror.h:65
struct jpeg_error_mgr * err
Definition: jpeglib.h:274
void(* init_destination)()
Definition: jpeglib.h:722
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:277
struct jpeg_marker_writer * marker
Definition: jpeglib.h:404
void(* reset_error_mgr)()
Definition: jpeglib.h:659
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:208
int global_state
Definition: jpeglib.h:274
void(* term_destination)()
Definition: jpeglib.h:724