ReactOS 0.4.16-dev-2617-g01a0906
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 59 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 ci, xindex, yindex, yoffset, blockcnt;
151 JBLOCKROW blkp;
152 JSAMPARRAY input_ptr;
153 JDIMENSION xpos;
155 forward_DCT_ptr forward_DCT;
156
157 /* Loop to write as much as one whole iMCU row */
158 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
159 yoffset++) {
160 for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
161 MCU_col_num++) {
162 /* Determine where data comes from in input_buf and do the DCT thing.
163 * Each call on forward_DCT processes a horizontal row of DCT blocks as
164 * wide as an MCU. Dummy blocks at the right or bottom edge are filled in
165 * specially. The data in them does not matter for image reconstruction,
166 * so we fill them with values that will encode to the smallest amount of
167 * data, viz: all zeroes in the AC entries, DC entries equal to previous
168 * block's DC value. (Thanks to Thomas Kinsman for this idea.)
169 */
170 blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */
171 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
172 compptr = cinfo->cur_comp_info[ci];
173 forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index];
174 input_ptr = input_buf[compptr->component_index] +
176 /* ypos == (yoffset + yindex) * compptr->DCT_v_scaled_size */
177 blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
179 xpos = MCU_col_num * compptr->MCU_sample_width;
180 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
181 if (coef->iMCU_row_num < last_iMCU_row ||
182 yoffset + yindex < compptr->last_row_height) {
183 (*forward_DCT) (cinfo, compptr, input_ptr, blkp,
184 xpos, (JDIMENSION) blockcnt);
185 input_ptr += compptr->DCT_v_scaled_size;
186 blkp += blockcnt;
187 /* Dummy blocks at right edge */
188 if ((xindex = compptr->MCU_width - blockcnt) == 0)
189 continue;
190 } else {
191 /* At bottom of image, need a whole row of dummy blocks */
192 xindex = compptr->MCU_width;
193 }
194 /* Fill in any dummy blocks needed in this row */
195 MEMZERO(blkp, xindex * SIZEOF(JBLOCK));
196 do {
197 blkp[0][0] = blkp[-1][0];
198 blkp++;
199 } while (--xindex);
200 }
201 }
202 /* Try to write the MCU. In event of a suspension failure, we will
203 * re-DCT the MCU on restart (a bit inefficient, could be fixed...)
204 */
205 if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
206 /* Suspension forced; update state counters and exit */
207 coef->MCU_vert_offset = yoffset;
208 coef->MCU_ctr = MCU_col_num;
209 return FALSE;
210 }
211 }
212 /* Completed an MCU row, but perhaps not an iMCU row */
213 coef->MCU_ctr = 0;
214 }
215 /* Completed the iMCU row, advance counters for next one */
216 coef->iMCU_row_num++;
217 start_iMCU_row(cinfo);
218 return TRUE;
219}
#define SIZEOF(_ar)
Definition: calc.h:97
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
for(i=0;i< ARRAY_SIZE(offsets);i++)
GLint GLint GLint yoffset
Definition: gl.h:1547
my_coef_controller * my_coef_ptr
Definition: jccoefct.c:59
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr, JSAMPARRAY sample_data, JBLOCKROW coef_blocks, JDIMENSION start_col, JDIMENSION num_blocks)
Definition: jcdctmgr.c:62
start_iMCU_row(j_compress_ptr cinfo)
Definition: jctrans.c:242
jpeg_component_info * compptr
Definition: jdct.h:252
unsigned int JDIMENSION
Definition: jmorecfg.h:265
JBLOCK FAR * JBLOCKROW
Definition: jpeglib.h:80
JCOEF JBLOCK[DCTSIZE2]
Definition: jpeglib.h:79
JSAMPROW * JSAMPARRAY
Definition: jpeglib.h:76
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
Definition: jpeglib.h:424
struct jpeg_entropy_encoder * entropy
Definition: jpeglib.h:452
JDIMENSION MCUs_per_row
Definition: jpeglib.h:427
struct jpeg_forward_dct * fdct
Definition: jpeglib.h:451
struct jpeg_c_coef_controller * coef
Definition: jpeglib.h:447
JDIMENSION total_iMCU_rows
Definition: jpeglib.h:412
JDIMENSION MCU_ctr
Definition: jccoefct.c:39
JBLOCK blk_buffer[C_MAX_BLOCKS_IN_MCU]
Definition: jccoefct.c:56
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]
Definition: jccoefct.c:50
JDIMENSION iMCU_row_num
Definition: jccoefct.c:38
#define MEMZERO(addr, type, size)
Definition: svc_dg.c:324

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 if (need_full_buffer) {
415#ifdef FULL_COEF_BUFFER_SUPPORTED
416 /* Allocate a full-image virtual array for each component, */
417 /* padded to a multiple of samp_factor DCT blocks in each direction. */
418 int ci;
420
421 coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
422 ((j_common_ptr) cinfo, JPOOL_IMAGE,
424 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
425 ci++, compptr++) {
426 coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
427 ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
433 }
434#else
435 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
436#endif
437 } else {
438 /* We only need a single-MCU buffer. */
439 JBLOCKARRAY blkp;
440 JBLOCKROW buffer_ptr;
441 int bi;
442
443 coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
445 blkp = coef->MCU_buffer;
446 buffer_ptr = coef->blk_buffer;
448 do {
449 *blkp++ = buffer_ptr++;
450 } while (--bi);
451 coef->whole_image[0] = NULL; /* flag for no virtual arrays */
452 }
453
454 coef->pub.start_pass = start_pass_coef;
455 cinfo->coef = &coef->pub;
456}
#define NULL
Definition: types.h:112
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
Definition: jccoefct.c:102
boolean need_full_buffer
Definition: jpegint.h:383
struct jpeg_common_struct * j_common_ptr
Definition: jpeglib.h:284
#define C_MAX_BLOCKS_IN_MCU
Definition: jpeglib.h:64
JBLOCKROW * JBLOCKARRAY
Definition: jpeglib.h:81
#define JPOOL_IMAGE
Definition: jpeglib.h:810
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:53

Referenced by jinit_compress_master().

◆ METHODDEF()

METHODDEF ( boolean  )

Definition at line 63 of file jccoefct.c.

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

103{
104 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
105
106 coef->iMCU_row_num = 0;
107 start_iMCU_row(cinfo);
108
109 switch (pass_mode) {
110 case JBUF_PASS_THRU:
111 if (coef->whole_image[0] != NULL)
112 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
113 coef->pub.compress_data = compress_data;
114 break;
115#ifdef FULL_COEF_BUFFER_SUPPORTED
117 if (coef->whole_image[0] == NULL)
118 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
119 coef->pub.compress_data = compress_first_pass;
120 break;
121 case JBUF_CRANK_DEST:
122 if (coef->whole_image[0] == NULL)
123 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
124 coef->pub.compress_data = compress_output;
125 break;
126#endif
127 default:
128 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
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().