ReactOS 0.4.16-dev-125-g798ea90
jccoefct.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
Include dependency graph for jccoefct.c:

Go to the source code of this file.

Classes

struct  my_coef_controller
 

Macros

#define JPEG_INTERNALS
 

Typedefs

typedef my_coef_controllermy_coef_ptr
 

Functions

 METHODDEF (boolean)
 
 start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
 
 compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
 
 jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
 

Macro Definition Documentation

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 14 of file jccoefct.c.

Typedef Documentation

◆ my_coef_ptr

Definition at line 58 of file jccoefct.c.

Function Documentation

◆ compress_data()

compress_data ( j_compress_ptr  cinfo,
JSAMPIMAGE  input_buf 
)

Definition at line 144 of file jccoefct.c.

145{
146 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
147 JDIMENSION MCU_col_num; /* index of current MCU within row */
148 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
149 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
150 int blkn, bi, ci, yindex, yoffset, blockcnt;
151 JDIMENSION ypos, xpos;
153 forward_DCT_ptr forward_DCT;
154
155 /* Loop to write as much as one whole iMCU row */
156 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
157 yoffset++) {
158 for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col;
159 MCU_col_num++) {
160 /* Determine where data comes from in input_buf and do the DCT thing.
161 * Each call on forward_DCT processes a horizontal row of DCT blocks
162 * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks
163 * sequentially. Dummy blocks at the right or bottom edge are filled in
164 * specially. The data in them does not matter for image reconstruction,
165 * so we fill them with values that will encode to the smallest amount of
166 * data, viz: all zeroes in the AC entries, DC entries equal to previous
167 * block's DC value. (Thanks to Thomas Kinsman for this idea.)
168 */
169 blkn = 0;
170 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
171 compptr = cinfo->cur_comp_info[ci];
172 forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index];
173 blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
175 xpos = MCU_col_num * compptr->MCU_sample_width;
177 /* ypos == (yoffset+yindex) * DCTSIZE */
178 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
179 if (coef->iMCU_row_num < last_iMCU_row ||
180 yoffset+yindex < compptr->last_row_height) {
181 (*forward_DCT) (cinfo, compptr,
182 input_buf[compptr->component_index],
183 coef->MCU_buffer[blkn],
184 ypos, xpos, (JDIMENSION) blockcnt);
185 if (blockcnt < compptr->MCU_width) {
186 /* Create some dummy blocks at the right edge of the image. */
187 FMEMZERO((void FAR *) coef->MCU_buffer[blkn + blockcnt],
188 (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
189 for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
190 coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
191 }
192 }
193 } else {
194 /* Create a row of dummy blocks at the bottom of the image. */
195 FMEMZERO((void FAR *) coef->MCU_buffer[blkn],
197 for (bi = 0; bi < compptr->MCU_width; bi++) {
198 coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
199 }
200 }
201 blkn += compptr->MCU_width;
202 ypos += compptr->DCT_v_scaled_size;
203 }
204 }
205 /* Try to write the MCU. In event of a suspension failure, we will
206 * re-DCT the MCU on restart (a bit inefficient, could be fixed...)
207 */
208 if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
209 /* Suspension forced; update state counters and exit */
210 coef->MCU_vert_offset = yoffset;
211 coef->mcu_ctr = MCU_col_num;
212 return FALSE;
213 }
214 }
215 /* Completed an MCU row, but perhaps not an iMCU row */
216 coef->mcu_ctr = 0;
217 }
218 /* Completed the iMCU row, advance counters for next one */
219 coef->iMCU_row_num++;
220 start_iMCU_row(cinfo);
221 return TRUE;
222}
#define SIZEOF(_ar)
Definition: calc.h:97
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FAR
Definition: zlib.h:34
GLint GLint GLint yoffset
Definition: gl.h:1547
my_coef_controller * my_coef_ptr
Definition: jccoefct.c:58
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY sample_data, JBLOCKROW coef_blocks, JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
Definition: jcdctmgr.c:74
start_iMCU_row(j_compress_ptr cinfo)
Definition: jctrans.c:242
jpeg_component_info * compptr
Definition: jdct.h:238
unsigned int JDIMENSION
Definition: jmorecfg.h:229
#define FMEMZERO(target, size)
Definition: jpegint.h:368
JCOEF JBLOCK[DCTSIZE2]
Definition: jpeglib.h:79
#define for
Definition: utility.h:88
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
Definition: jpeglib.h:423
struct jpeg_entropy_encoder * entropy
Definition: jpeglib.h:451
JDIMENSION MCUs_per_row
Definition: jpeglib.h:426
struct jpeg_forward_dct * fdct
Definition: jpeglib.h:450
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:446
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:411
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]
Definition: jccoefct.c:52
JDIMENSION mcu_ctr
Definition: jccoefct.c:39
JDIMENSION iMCU_row_num
Definition: jccoefct.c:38

Referenced by start_pass_coef().

◆ jinit_c_coef_controller()

jinit_c_coef_controller ( j_compress_ptr  cinfo,
boolean  need_full_buffer 
)

Definition at line 410 of file jccoefct.c.

411{
412 my_coef_ptr coef;
413
414 coef = (my_coef_ptr)
415 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
417 cinfo->coef = (struct jpeg_c_coef_controller *) coef;
418 coef->pub.start_pass = start_pass_coef;
419
420 /* Create the coefficient buffer. */
421 if (need_full_buffer) {
422#ifdef FULL_COEF_BUFFER_SUPPORTED
423 /* Allocate a full-image virtual array for each component, */
424 /* padded to a multiple of samp_factor DCT blocks in each direction. */
425 int ci;
427
428 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
429 ci++, compptr++) {
430 coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
431 ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
437 }
438#else
439 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
440#endif
441 } else {
442 /* We only need a single-MCU buffer. */
444 int i;
445
446 buffer = (JBLOCKROW)
447 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
449 for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
450 coef->MCU_buffer[i] = buffer + i;
451 }
452 coef->whole_image[0] = NULL; /* flag for no virtual arrays */
453 }
454}
#define NULL
Definition: types.h:112
GLuint buffer
Definition: glext.h:5915
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
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
Definition: jccoefct.c:101
boolean need_full_buffer
Definition: jpegint.h:384
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define C_MAX_BLOCKS_IN_MCU
Definition: jpeglib.h:64
#define JPOOL_IMAGE
Definition: jpeglib.h:808
jround_up(long a, long b)
Definition: jutils.c:133
#define long
Definition: qsort.c:33
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
JDIMENSION width_in_blocks
Definition: jpeglib.h:148
JDIMENSION height_in_blocks
Definition: jpeglib.h:149
jpeg_component_info * comp_info
Definition: jpeglib.h:333
struct jpeg_c_coef_controller pub
Definition: jccoefct.c:36
jvirt_barray_ptr whole_image[MAX_COMPONENTS]
Definition: jccoefct.c:55

Referenced by jinit_compress_master().

◆ METHODDEF()

METHODDEF ( boolean  )

Definition at line 62 of file jccoefct.c.

75{
76 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
77
78 /* In an interleaved scan, an MCU row is the same as an iMCU row.
79 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
80 * But at the bottom of the image, process only what's left.
81 */
82 if (cinfo->comps_in_scan > 1) {
83 coef->MCU_rows_per_iMCU_row = 1;
84 } else {
85 if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
86 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
87 else
88 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
89 }
90
91 coef->mcu_ctr = 0;
92 coef->MCU_vert_offset = 0;
93}
if(dx< 0)
Definition: linetemp.h:194
int MCU_rows_per_iMCU_row
Definition: jccoefct.c:41

◆ start_pass_coef()

start_pass_coef ( j_compress_ptr  cinfo,
J_BUF_MODE  pass_mode 
)

Definition at line 101 of file jccoefct.c.

102{
103 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
104
105 coef->iMCU_row_num = 0;
106 start_iMCU_row(cinfo);
107
108 switch (pass_mode) {
109 case JBUF_PASS_THRU:
110 if (coef->whole_image[0] != NULL)
111 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
112 coef->pub.compress_data = compress_data;
113 break;
114#ifdef FULL_COEF_BUFFER_SUPPORTED
116 if (coef->whole_image[0] == NULL)
117 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
118 coef->pub.compress_data = compress_first_pass;
119 break;
120 case JBUF_CRANK_DEST:
121 if (coef->whole_image[0] == NULL)
122 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
123 coef->pub.compress_data = compress_output;
124 break;
125#endif
126 default:
127 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
128 break;
129 }
130}
compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
Definition: jccoefct.c:144
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
Definition: jctrans.c:293
@ JBUF_PASS_THRU
Definition: jpegint.h:18
@ JBUF_SAVE_AND_PASS
Definition: jpegint.h:22
@ JBUF_CRANK_DEST
Definition: jpegint.h:21

Referenced by jinit_c_coef_controller().