16 #define JPEG_INTERNALS
137 #define CTX_PREPARE_FOR_IMCU 0
138 #define CTX_PROCESS_IMCU 1
139 #define CTX_POSTPONED_ROW 2
149 #ifdef QUANT_2PASS_SUPPORTED
187 main->xbuffer[0][ci] = xbuf;
188 xbuf += rgroup * (M + 4);
189 main->xbuffer[1][ci] = xbuf;
205 int M = cinfo->min_DCT_scaled_size;
209 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
212 cinfo->min_DCT_scaled_size;
213 xbuf0 =
main->xbuffer[0][ci];
214 xbuf1 =
main->xbuffer[1][ci];
217 for (
i = 0;
i < rgroup * (M + 2);
i++) {
218 xbuf0[
i] = xbuf1[
i] =
buf[
i];
221 for (
i = 0;
i < rgroup * 2;
i++) {
222 xbuf1[rgroup*(M-2) +
i] =
buf[rgroup*M +
i];
223 xbuf1[rgroup*M +
i] =
buf[rgroup*(M-2) +
i];
230 for (
i = 0;
i < rgroup;
i++) {
231 xbuf0[
i - rgroup] = xbuf0[0];
245 int M = cinfo->min_DCT_scaled_size;
249 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
252 cinfo->min_DCT_scaled_size;
253 xbuf0 =
main->xbuffer[0][ci];
254 xbuf1 =
main->xbuffer[1][ci];
255 for (
i = 0;
i < rgroup;
i++) {
256 xbuf0[
i - rgroup] = xbuf0[rgroup*(M+1) +
i];
257 xbuf1[
i - rgroup] = xbuf1[rgroup*(M+1) +
i];
258 xbuf0[rgroup*(M+2) +
i] = xbuf0[
i];
259 xbuf1[rgroup*(M+2) +
i] = xbuf1[
i];
273 int ci,
i, rgroup, iMCUheight, rows_left;
277 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
281 rgroup = iMCUheight / cinfo->min_DCT_scaled_size;
284 if (rows_left == 0) rows_left = iMCUheight;
289 main->rowgroups_avail = (
JDIMENSION) ((rows_left-1) / rgroup + 1);
294 xbuf =
main->xbuffer[
main->whichptr][ci];
295 for (
i = 0;
i < rgroup * 2;
i++) {
296 xbuf[rows_left +
i] = xbuf[rows_left-1];
313 if (cinfo->upsample->need_context_rows) {
318 main->iMCU_row_ctr = 0;
324 main->rowgroup_ctr = 0;
326 #ifdef QUANT_2PASS_SUPPORTED
333 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
353 if (!
main->buffer_full) {
354 if (! (*cinfo->coef->decompress_data) (cinfo,
main->buffer))
360 rowgroups_avail = (
JDIMENSION) cinfo->min_DCT_scaled_size;
367 (*cinfo->post->post_process_data) (cinfo,
main->buffer,
368 &
main->rowgroup_ctr, rowgroups_avail,
372 if (
main->rowgroup_ctr >= rowgroups_avail) {
374 main->rowgroup_ctr = 0;
392 if (!
main->buffer_full) {
393 if (! (*cinfo->coef->decompress_data) (cinfo,
397 main->iMCU_row_ctr++;
405 switch (
main->context_state) {
408 (*cinfo->post->post_process_data) (cinfo,
main->xbuffer[
main->whichptr],
409 &
main->rowgroup_ctr,
main->rowgroups_avail,
411 if (
main->rowgroup_ctr <
main->rowgroups_avail)
414 if (*out_row_ctr >= out_rows_avail)
419 main->rowgroup_ctr = 0;
420 main->rowgroups_avail = (
JDIMENSION) (cinfo->min_DCT_scaled_size - 1);
424 if (
main->iMCU_row_ctr == cinfo->total_iMCU_rows)
430 (*cinfo->post->post_process_data) (cinfo,
main->xbuffer[
main->whichptr],
431 &
main->rowgroup_ctr,
main->rowgroups_avail,
433 if (
main->rowgroup_ctr <
main->rowgroups_avail)
436 if (
main->iMCU_row_ctr == 1)
443 main->rowgroup_ctr = (
JDIMENSION) (cinfo->min_DCT_scaled_size + 1);
444 main->rowgroups_avail = (
JDIMENSION) (cinfo->min_DCT_scaled_size + 2);
456 #ifdef QUANT_2PASS_SUPPORTED
463 (*cinfo->post->post_process_data) (cinfo, (
JSAMPIMAGE) NULL,
479 int ci, rgroup, ngroups;
489 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
494 if (cinfo->upsample->need_context_rows) {
495 if (cinfo->min_DCT_scaled_size < 2)
497 alloc_funny_pointers(cinfo);
498 ngroups = cinfo->min_DCT_scaled_size + 2;
500 ngroups = cinfo->min_DCT_scaled_size;
503 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
506 cinfo->min_DCT_scaled_size;
507 main->buffer[ci] = (*cinfo->mem->alloc_sarray)