ReactOS  0.4.14-dev-1007-g90d795b
jcapimin.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jcapimin.c:

Go to the source code of this file.

Macros

#define JPEG_INTERNALS
 

Functions

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

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 20 of file jcapimin.c.

Function Documentation

◆ jpeg_abort_compress()

jpeg_abort_compress ( j_compress_ptr  cinfo)

Definition at line 108 of file jcapimin.c.

109 {
110  jpeg_abort((j_common_ptr) cinfo); /* use common routine */
111 }
jpeg_abort(j_common_ptr cinfo)
Definition: jcomapi.c:30

◆ jpeg_CreateCompress()

jpeg_CreateCompress ( j_compress_ptr  cinfo,
int  version,
size_t  structsize 
)

Definition at line 31 of file jcapimin.c.

32 {
33  int i;
34 
35  /* Guard against version mismatches between library and caller. */
36  cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
38  ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
39  if (structsize != SIZEOF(struct jpeg_compress_struct))
40  ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
41  (int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
42 
43  /* For debugging purposes, we zero the whole master structure.
44  * But the application has already set the err pointer, and may have set
45  * client_data, so we have to save and restore those fields.
46  * Note: if application hasn't set client_data, tools like Purify may
47  * complain here.
48  */
49  {
50  struct jpeg_error_mgr * err = cinfo->err;
51  void * client_data = cinfo->client_data; /* ignore Purify complaint here */
52  MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct));
53  cinfo->err = err;
54  cinfo->client_data = client_data;
55  }
56  cinfo->is_decompressor = FALSE;
57 
58  /* Initialize a memory manager instance for this object */
60 
61  /* Zero out pointers to permanent structures. */
62  cinfo->progress = NULL;
63  cinfo->dest = NULL;
64 
65  cinfo->comp_info = NULL;
66 
67  for (i = 0; i < NUM_QUANT_TBLS; i++) {
68  cinfo->quant_tbl_ptrs[i] = NULL;
69  cinfo->q_scale_factor[i] = 100;
70  }
71 
72  for (i = 0; i < NUM_HUFF_TBLS; i++) {
73  cinfo->dc_huff_tbl_ptrs[i] = NULL;
74  cinfo->ac_huff_tbl_ptrs[i] = NULL;
75  }
76 
77  /* Must do it here for emit_dqt in case jpeg_write_tables is used */
78  cinfo->block_size = DCTSIZE;
80  cinfo->lim_Se = DCTSIZE2-1;
81 
82  cinfo->script_space = NULL;
83 
84  cinfo->input_gamma = 1.0; /* in case application forgets */
85 
86  /* OK, I'm ready */
87  cinfo->global_state = CSTATE_START;
88 }
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:342
#define CSTATE_START
Definition: jpegint.h:26
#define NUM_QUANT_TBLS
Definition: jpeglib.h:52
#define NUM_HUFF_TBLS
Definition: jpeglib.h:53
#define MEMZERO(addr, type, size)
Definition: svc_dg.c:324
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:343
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
#define SIZEOF(_ar)
Definition: calc.h:97
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:66
#define JPEG_LIB_VERSION
Definition: jpeglib.h:40
#define DCTSIZE2
Definition: jpeglib.h:51
jinit_memory_mgr(j_common_ptr cinfo)
Definition: jmemmgr.c:1025
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:295
int size_t structsize
Definition: jpeglib.h:966
#define err(...)
const int jpeg_natural_order[DCTSIZE2+16]
Definition: jutils.c:54
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
Definition: jpeglib.h:336
const int * natural_order
Definition: jpeglib.h:437
#define DCTSIZE
Definition: jpeglib.h:50
int q_scale_factor[NUM_QUANT_TBLS]
Definition: jpeglib.h:337
jpeg_scan_info * script_space
Definition: jpeglib.h:452
#define ERREXIT2(cinfo, code, p1, p2)
Definition: jerror.h:216
jpeg_component_info * comp_info
Definition: jpeglib.h:333

◆ jpeg_destroy_compress()

jpeg_destroy_compress ( j_compress_ptr  cinfo)

Definition at line 96 of file jcapimin.c.

97 {
98  jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
99 }
jpeg_destroy(j_common_ptr cinfo)
Definition: jcomapi.c:70

Referenced by main(), and write_JPEG_file().

◆ jpeg_finish_compress()

jpeg_finish_compress ( j_compress_ptr  cinfo)

Definition at line 155 of file jcapimin.c.

156 {
157  JDIMENSION iMCU_row;
158 
159  if (cinfo->global_state == CSTATE_SCANNING ||
160  cinfo->global_state == CSTATE_RAW_OK) {
161  /* Terminate first pass */
162  if (cinfo->next_scanline < cinfo->image_height)
163  ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
164  (*cinfo->master->finish_pass) (cinfo);
165  } else if (cinfo->global_state != CSTATE_WRCOEFS)
166  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
167  /* Perform any remaining passes */
168  while (! cinfo->master->is_last_pass) {
169  (*cinfo->master->prepare_for_pass) (cinfo);
170  for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) {
171  if (cinfo->progress != NULL) {
172  cinfo->progress->pass_counter = (long) iMCU_row;
173  cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows;
174  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
175  }
176  /* We bypass the main controller and invoke coef controller directly;
177  * all work is being done from the coefficient buffer.
178  */
179  if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL))
180  ERREXIT(cinfo, JERR_CANT_SUSPEND);
181  }
182  (*cinfo->master->finish_pass) (cinfo);
183  }
184  /* Write EOI, do final cleanup */
185  (*cinfo->marker->write_file_trailer) (cinfo);
186  (*cinfo->dest->term_destination) (cinfo);
187  /* We can use jpeg_abort to release memory and reset global_state */
188  jpeg_abort((j_common_ptr) cinfo);
189 }
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
JDIMENSION image_height
Definition: jpeglib.h:303
#define CSTATE_RAW_OK
Definition: jpegint.h:28
#define CSTATE_SCANNING
Definition: jpegint.h:27
JDIMENSION next_scanline
Definition: jpeglib.h:395
smooth NULL
Definition: ftsmooth.c:416
jpeg_abort(j_common_ptr cinfo)
Definition: jcomapi.c:30
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:446
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:411
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:295
struct jpeg_marker_writer * marker
Definition: jpeglib.h:447
JSAMPARRAY * JSAMPIMAGE
Definition: jpeglib.h:77
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
#define long
Definition: qsort.c:33
unsigned int JDIMENSION
Definition: jmorecfg.h:229
#define CSTATE_WRCOEFS
Definition: jpegint.h:29
struct jpeg_comp_master * master
Definition: jpeglib.h:443

Referenced by main(), and write_JPEG_file().

◆ jpeg_suppress_tables()

jpeg_suppress_tables ( j_compress_ptr  cinfo,
boolean  suppress 
)

Definition at line 127 of file jcapimin.c.

128 {
129  int i;
130  JQUANT_TBL * qtbl;
131  JHUFF_TBL * htbl;
132 
133  for (i = 0; i < NUM_QUANT_TBLS; i++) {
134  if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
135  qtbl->sent_table = suppress;
136  }
137 
138  for (i = 0; i < NUM_HUFF_TBLS; i++) {
139  if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL)
140  htbl->sent_table = suppress;
141  if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL)
142  htbl->sent_table = suppress;
143  }
144 }
boolean suppress
Definition: jpeglib.h:1006
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:342
#define NUM_QUANT_TBLS
Definition: jpeglib.h:52
boolean sent_table
Definition: jpeglib.h:119
#define NUM_HUFF_TBLS
Definition: jpeglib.h:53
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
Definition: jpeglib.h:343
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
smooth NULL
Definition: ftsmooth.c:416
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
Definition: jpeglib.h:336
boolean sent_table
Definition: jpeglib.h:103

Referenced by jpeg_start_compress().

◆ jpeg_write_m_byte()

jpeg_write_m_byte ( j_compress_ptr  cinfo,
int  val 
)

Definition at line 234 of file jcapimin.c.

235 {
236  (*cinfo->marker->write_marker_byte) (cinfo, val);
237 }
GLuint GLfloat * val
Definition: glext.h:7180
struct jpeg_marker_writer * marker
Definition: jpeglib.h:447

Referenced by jcopy_markers_execute().

◆ jpeg_write_m_header()

jpeg_write_m_header ( j_compress_ptr  cinfo,
int  marker,
unsigned int  datalen 
)

Definition at line 222 of file jcapimin.c.

223 {
224  if (cinfo->next_scanline != 0 ||
225  (cinfo->global_state != CSTATE_SCANNING &&
226  cinfo->global_state != CSTATE_RAW_OK &&
227  cinfo->global_state != CSTATE_WRCOEFS))
228  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
229 
230  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
231 }
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
#define CSTATE_RAW_OK
Definition: jpegint.h:28
#define CSTATE_SCANNING
Definition: jpegint.h:27
JDIMENSION next_scanline
Definition: jpeglib.h:395
int marker
Definition: jpeglib.h:1030
struct jpeg_marker_writer * marker
Definition: jpeglib.h:447
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
#define CSTATE_WRCOEFS
Definition: jpegint.h:29

Referenced by jcopy_markers_execute().

◆ jpeg_write_marker()

jpeg_write_marker ( j_compress_ptr  cinfo,
int  marker,
const JOCTET dataptr,
unsigned int  datalen 
)

Definition at line 200 of file jcapimin.c.

202 {
204 
205  if (cinfo->next_scanline != 0 ||
206  (cinfo->global_state != CSTATE_SCANNING &&
207  cinfo->global_state != CSTATE_RAW_OK &&
208  cinfo->global_state != CSTATE_WRCOEFS))
209  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
210 
211  (*cinfo->marker->write_marker_header) (cinfo, marker, datalen);
212  write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */
213  while (datalen--) {
214  (*write_marker_byte) (cinfo, *dataptr);
215  dataptr++;
216  }
217 }
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
#define CSTATE_RAW_OK
Definition: jpegint.h:28
#define CSTATE_SCANNING
Definition: jpegint.h:27
write_marker_byte(j_compress_ptr cinfo, int val)
Definition: jcmarker.c:499
JDIMENSION next_scanline
Definition: jpeglib.h:395
int marker
Definition: jpeglib.h:1030
GLuint GLfloat * val
Definition: glext.h:7180
struct jpeg_marker_writer * marker
Definition: jpeglib.h:447
#define JMETHOD(type, methodname, arglist)
Definition: jmorecfg.h:308
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
int const JOCTET * dataptr
Definition: jpeglib.h:1030
#define CSTATE_WRCOEFS
Definition: jpegint.h:29

Referenced by jcopy_markers_execute().

◆ jpeg_write_tables()

jpeg_write_tables ( j_compress_ptr  cinfo)

Definition at line 262 of file jcapimin.c.

263 {
264  if (cinfo->global_state != CSTATE_START)
265  ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
266 
267  /* (Re)initialize error mgr and destination modules */
268  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
269  (*cinfo->dest->init_destination) (cinfo);
270  /* Initialize the marker writer ... bit of a crock to do it here. */
271  jinit_marker_writer(cinfo);
272  /* Write them tables! */
273  (*cinfo->marker->write_tables_only) (cinfo);
274  /* And clean up. */
275  (*cinfo->dest->term_destination) (cinfo);
276  /*
277  * In library releases up through v6a, we called jpeg_abort() here to free
278  * any working memory allocated by the destination manager and marker
279  * writer. Some applications had a problem with that: they allocated space
280  * of their own from the library memory manager, and didn't want it to go
281  * away during write_tables. So now we do nothing. This will cause a
282  * memory leak if an app calls write_tables repeatedly without doing a full
283  * compression cycle or otherwise resetting the JPEG object. However, that
284  * seems less bad than unexpectedly freeing memory in the normal case.
285  * An app that prefers the old behavior can call jpeg_abort for itself after
286  * each call to jpeg_write_tables().
287  */
288 }
#define CSTATE_START
Definition: jpegint.h:26
struct jpeg_destination_mgr * dest
Definition: jpeglib.h:295
struct jpeg_marker_writer * marker
Definition: jpeglib.h:447
#define ERREXIT1(cinfo, code, p1)
Definition: jerror.h:212
jinit_marker_writer(j_compress_ptr cinfo)
Definition: jcmarker.c:699