17 #define JPEG_INTERNALS
22 #ifndef D_PROGRESSIVE_SUPPORTED
23 #undef BLOCK_SMOOTHING_SUPPORTED
35 int MCU_rows_per_iMCU_row;
50 #ifdef D_MULTISCAN_FILES_SUPPORTED
55 #ifdef BLOCK_SMOOTHING_SUPPORTED
67 #ifdef D_MULTISCAN_FILES_SUPPORTED
71 #ifdef BLOCK_SMOOTHING_SUPPORTED
109 cinfo->input_iMCU_row = 0;
121 #ifdef BLOCK_SMOOTHING_SUPPORTED
125 if (coef->
pub.coef_arrays != NULL) {
132 cinfo->output_iMCU_row = 0;
151 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
152 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
153 int blkn, ci, xindex, yindex, yoffset, useful_width;
157 inverse_DCT_method_ptr inverse_DCT;
162 for (MCU_col_num = coef->
MCU_ctr; MCU_col_num <= last_MCU_col;
167 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->
MCU_buffer)) {
179 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
180 compptr = cinfo->cur_comp_info[ci];
193 if (cinfo->input_iMCU_row < last_iMCU_row ||
194 yoffset+yindex < compptr->last_row_height) {
196 for (xindex = 0; xindex < useful_width; xindex++) {
197 (*inverse_DCT) (cinfo,
compptr,
212 cinfo->output_iMCU_row++;
213 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
218 (*cinfo->inputctl->finish_input_pass) (cinfo);
234 #ifdef D_MULTISCAN_FILES_SUPPORTED
248 int blkn, ci, xindex, yindex, yoffset;
255 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
256 compptr = cinfo->cur_comp_info[ci];
257 buffer[ci] = (*cinfo->mem->access_virt_barray)
268 for (yoffset = coef->
MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
270 for (MCU_col_num = coef->
MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
274 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
275 compptr = cinfo->cur_comp_info[ci];
278 buffer_ptr =
buffer[ci][yindex+yoffset] + start_col;
285 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->
MCU_buffer)) {
296 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
301 (*cinfo->inputctl->finish_input_pass) (cinfo);
318 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
320 int ci, block_row, block_rows;
326 inverse_DCT_method_ptr inverse_DCT;
329 while (cinfo->input_scan_number < cinfo->output_scan_number ||
330 (cinfo->input_scan_number == cinfo->output_scan_number &&
331 cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
337 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
343 buffer = (*cinfo->mem->access_virt_barray)
348 if (cinfo->output_iMCU_row < last_iMCU_row)
355 inverse_DCT = cinfo->idct->inverse_DCT[ci];
358 for (block_row = 0; block_row < block_rows; block_row++) {
359 buffer_ptr =
buffer[block_row];
371 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
379 #ifdef BLOCK_SMOOTHING_SUPPORTED
408 boolean smoothing_useful =
FALSE;
413 int * coef_bits_latch;
415 if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
422 cinfo->num_components *
426 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
432 if (qtable->quantval[0] == 0 ||
433 qtable->quantval[
Q01_POS] == 0 ||
434 qtable->quantval[
Q10_POS] == 0 ||
435 qtable->quantval[
Q20_POS] == 0 ||
436 qtable->quantval[
Q11_POS] == 0 ||
437 qtable->quantval[
Q02_POS] == 0)
440 coef_bits = cinfo->coef_bits[ci];
441 if (coef_bits[0] < 0)
444 for (coefi = 1; coefi <= 5; coefi++) {
445 coef_bits_latch[coefi] = coef_bits[coefi];
446 if (coef_bits[coefi] != 0)
447 smoothing_useful =
TRUE;
452 return smoothing_useful;
464 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
466 int ci, block_row, block_rows, access_rows;
468 JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
472 inverse_DCT_method_ptr inverse_DCT;
473 boolean first_row, last_row;
478 int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
482 while (cinfo->input_scan_number <= cinfo->output_scan_number &&
483 ! cinfo->inputctl->eoi_reached) {
484 if (cinfo->input_scan_number == cinfo->output_scan_number) {
491 if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
499 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
505 if (cinfo->output_iMCU_row < last_iMCU_row) {
507 access_rows = block_rows * 2;
513 access_rows = block_rows;
517 if (cinfo->output_iMCU_row > 0) {
519 buffer = (*cinfo->mem->access_virt_barray)
526 buffer = (*cinfo->mem->access_virt_barray)
535 Q01 = quanttbl->quantval[
Q01_POS];
536 Q10 = quanttbl->quantval[
Q10_POS];
537 Q20 = quanttbl->quantval[
Q20_POS];
538 Q11 = quanttbl->quantval[
Q11_POS];
539 Q02 = quanttbl->quantval[
Q02_POS];
540 inverse_DCT = cinfo->idct->inverse_DCT[ci];
543 for (block_row = 0; block_row < block_rows; block_row++) {
544 buffer_ptr =
buffer[block_row];
545 if (first_row && block_row == 0)
546 prev_block_row = buffer_ptr;
548 prev_block_row =
buffer[block_row-1];
549 if (last_row && block_row == block_rows-1)
550 next_block_row = buffer_ptr;
552 next_block_row =
buffer[block_row+1];
556 DC1 = DC2 = DC3 = (
int) prev_block_row[0][0];
557 DC4 = DC5 = DC6 = (
int) buffer_ptr[0][0];
558 DC7 = DC8 = DC9 = (
int) next_block_row[0][0];
561 for (block_num = 0; block_num <= last_block_column; block_num++) {
565 if (block_num < last_block_column) {
566 DC3 = (
int) prev_block_row[1][0];
567 DC6 = (
int) buffer_ptr[1][0];
568 DC9 = (
int) next_block_row[1][0];
575 if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
576 num = 36 * Q00 * (DC4 - DC6);
578 pred = (
int) (((Q01<<7) +
num) / (Q01<<8));
579 if (Al > 0 && pred >= (1<<Al))
582 pred = (
int) (((Q01<<7) -
num) / (Q01<<8));
583 if (Al > 0 && pred >= (1<<Al))
587 workspace[1] = (
JCOEF) pred;
590 if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
591 num = 36 * Q00 * (DC2 - DC8);
593 pred = (
int) (((Q10<<7) +
num) / (Q10<<8));
594 if (Al > 0 && pred >= (1<<Al))
597 pred = (
int) (((Q10<<7) -
num) / (Q10<<8));
598 if (Al > 0 && pred >= (1<<Al))
602 workspace[8] = (
JCOEF) pred;
605 if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
606 num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
608 pred = (
int) (((Q20<<7) +
num) / (Q20<<8));
609 if (Al > 0 && pred >= (1<<Al))
612 pred = (
int) (((Q20<<7) -
num) / (Q20<<8));
613 if (Al > 0 && pred >= (1<<Al))
617 workspace[16] = (
JCOEF) pred;
620 if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
621 num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
623 pred = (
int) (((Q11<<7) +
num) / (Q11<<8));
624 if (Al > 0 && pred >= (1<<Al))
627 pred = (
int) (((Q11<<7) -
num) / (Q11<<8));
628 if (Al > 0 && pred >= (1<<Al))
632 workspace[9] = (
JCOEF) pred;
635 if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
636 num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
638 pred = (
int) (((Q02<<7) +
num) / (Q02<<8));
639 if (Al > 0 && pred >= (1<<Al))
642 pred = (
int) (((Q02<<7) -
num) / (Q02<<8));
643 if (Al > 0 && pred >= (1<<Al))
647 workspace[2] = (
JCOEF) pred;
653 DC1 = DC2; DC2 = DC3;
654 DC4 = DC5; DC5 = DC6;
655 DC7 = DC8; DC8 = DC9;
656 buffer_ptr++, prev_block_row++, next_block_row++;
663 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
686 #ifdef BLOCK_SMOOTHING_SUPPORTED
692 #ifdef D_MULTISCAN_FILES_SUPPORTED
699 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
702 #ifdef BLOCK_SMOOTHING_SUPPORTED
704 if (cinfo->progressive_mode)
707 coef->
whole_image[ci] = (*cinfo->mem->request_virt_barray)
719 ERREXIT(cinfo, JERR_NOT_COMPILED);
734 coef->
pub.coef_arrays = NULL;