10 #define JPEG_INTERNALS 15 #ifndef D_PROGRESSIVE_SUPPORTED 16 #undef BLOCK_SMOOTHING_SUPPORTED 29 int MCU_rows_per_iMCU_row;
44 #ifdef D_MULTISCAN_FILES_SUPPORTED 49 #ifdef BLOCK_SMOOTHING_SUPPORTED 61 #ifdef D_MULTISCAN_FILES_SUPPORTED 65 #ifdef BLOCK_SMOOTHING_SUPPORTED 81 if (cinfo->comps_in_scan > 1)
87 if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows - 1))
89 cinfo->cur_comp_info[0]->v_samp_factor;
92 cinfo->cur_comp_info[0]->last_row_height;
106 cinfo->input_iMCU_row = 0;
117 #ifdef BLOCK_SMOOTHING_SUPPORTED 121 if (coef->
pub.coef_arrays !=
nullptr)
129 cinfo->output_iMCU_row = 0;
147 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
148 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
149 int blkn, ci, xindex, yindex,
yoffset, useful_width;
153 inverse_DCT_method_ptr inverse_DCT;
159 for (MCU_col_num = coef->
MCU_ctr; MCU_col_num <= last_MCU_col;
167 if (!(*cinfo->entropy->decode_mcu)(cinfo, coef->
MCU_buffer))
181 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
183 compptr = cinfo->cur_comp_info[ci];
192 useful_width = (MCU_col_num < last_MCU_col)
200 if (cinfo->input_iMCU_row < last_iMCU_row ||
201 yoffset + yindex < compptr->last_row_height)
204 for (xindex = 0; xindex < useful_width; xindex++)
222 cinfo->output_iMCU_row++;
223 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows)
229 (*cinfo->inputctl->finish_input_pass)(cinfo);
243 #ifdef D_MULTISCAN_FILES_SUPPORTED 257 int blkn, ci, xindex, yindex,
yoffset;
264 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
266 compptr = cinfo->cur_comp_info[ci];
267 buffer[ci] = (*cinfo->mem->access_virt_barray)(
281 for (MCU_col_num = coef->
MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
286 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
288 compptr = cinfo->cur_comp_info[ci];
300 if (!(*cinfo->entropy->decode_mcu)(cinfo, coef->
MCU_buffer))
312 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows)
318 (*cinfo->inputctl->finish_input_pass)(cinfo);
334 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
336 int ci, block_row, block_rows;
342 inverse_DCT_method_ptr inverse_DCT;
345 while (cinfo->input_scan_number < cinfo->output_scan_number ||
346 (cinfo->input_scan_number == cinfo->output_scan_number &&
347 cinfo->input_iMCU_row <= cinfo->output_iMCU_row))
354 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
360 buffer = (*cinfo->mem->access_virt_barray)(
365 if (cinfo->output_iMCU_row < last_iMCU_row)
375 inverse_DCT = cinfo->idct->inverse_DCT[ci];
378 for (block_row = 0; block_row < block_rows; block_row++)
380 buffer_ptr =
buffer[block_row];
395 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
402 #ifdef BLOCK_SMOOTHING_SUPPORTED 431 boolean smoothing_useful =
FALSE;
436 int* coef_bits_latch;
438 if (!cinfo->progressive_mode || cinfo->coef_bits ==
nullptr)
return FALSE;
447 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
454 if (qtable->quantval[0] == 0 || qtable->quantval[
Q01_POS] == 0 ||
455 qtable->quantval[
Q10_POS] == 0 || qtable->quantval[
Q20_POS] == 0 ||
459 coef_bits = cinfo->coef_bits[ci];
460 if (coef_bits[0] < 0)
return FALSE;
463 for (coefi = 1; coefi <= 5; coefi++)
465 coef_bits_latch[coefi] = coef_bits[coefi];
466 if (coef_bits[coefi] != 0) smoothing_useful =
TRUE;
471 return smoothing_useful;
482 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
484 int ci, block_row, block_rows, access_rows;
486 JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
490 inverse_DCT_method_ptr inverse_DCT;
491 boolean first_row, last_row;
495 INT32 Q00, Q01, Q02, Q10, Q11, Q20,
num;
496 int DC1, DC2, DC3, DC4, DC5, DC6, DC7, DC8, DC9;
500 while (cinfo->input_scan_number <= cinfo->output_scan_number &&
501 !cinfo->inputctl->eoi_reached)
503 if (cinfo->input_scan_number == cinfo->output_scan_number)
511 if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
break;
518 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
524 if (cinfo->output_iMCU_row < last_iMCU_row)
527 access_rows = block_rows * 2;
537 access_rows = block_rows;
541 if (cinfo->output_iMCU_row > 0)
544 buffer = (*cinfo->mem->access_virt_barray)(
553 buffer = (*cinfo->mem->access_virt_barray)(
562 Q01 = quanttbl->quantval[
Q01_POS];
563 Q10 = quanttbl->quantval[
Q10_POS];
564 Q20 = quanttbl->quantval[
Q20_POS];
565 Q11 = quanttbl->quantval[
Q11_POS];
566 Q02 = quanttbl->quantval[
Q02_POS];
567 inverse_DCT = cinfo->idct->inverse_DCT[ci];
570 for (block_row = 0; block_row < block_rows; block_row++)
572 buffer_ptr =
buffer[block_row];
573 if (first_row && block_row == 0)
574 prev_block_row = buffer_ptr;
576 prev_block_row =
buffer[block_row - 1];
577 if (last_row && block_row == block_rows - 1)
578 next_block_row = buffer_ptr;
580 next_block_row =
buffer[block_row + 1];
586 DC1 = DC2 = DC3 = (int)prev_block_row[0][0];
587 DC4 = DC5 = DC6 = (int)buffer_ptr[0][0];
588 DC7 = DC8 = DC9 = (int)next_block_row[0][0];
591 for (block_num = 0; block_num <= last_block_column; block_num++)
598 if (block_num < last_block_column)
600 DC3 = (int)prev_block_row[1][0];
601 DC6 = (int)buffer_ptr[1][0];
602 DC9 = (int)next_block_row[1][0];
609 if ((Al = coef_bits[1]) != 0 &&
workspace[1] == 0)
611 num = 36 * Q00 * (DC4 - DC6);
614 pred = (int)(((Q01 << 7) +
num) / (Q01 << 8));
615 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
619 pred = (int)(((Q01 << 7) -
num) / (Q01 << 8));
620 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
626 if ((Al = coef_bits[2]) != 0 &&
workspace[8] == 0)
628 num = 36 * Q00 * (DC2 - DC8);
631 pred = (int)(((Q10 << 7) +
num) / (Q10 << 8));
632 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
636 pred = (int)(((Q10 << 7) -
num) / (Q10 << 8));
637 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
643 if ((Al = coef_bits[3]) != 0 &&
workspace[16] == 0)
645 num = 9 * Q00 * (DC2 + DC8 - 2 * DC5);
648 pred = (int)(((Q20 << 7) +
num) / (Q20 << 8));
649 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
653 pred = (int)(((Q20 << 7) -
num) / (Q20 << 8));
654 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
660 if ((Al = coef_bits[4]) != 0 &&
workspace[9] == 0)
662 num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
665 pred = (int)(((Q11 << 7) +
num) / (Q11 << 8));
666 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
670 pred = (int)(((Q11 << 7) -
num) / (Q11 << 8));
671 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
677 if ((Al = coef_bits[5]) != 0 &&
workspace[2] == 0)
679 num = 9 * Q00 * (DC4 + DC6 - 2 * DC5);
682 pred = (int)(((Q02 << 7) +
num) / (Q02 << 8));
683 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
687 pred = (int)(((Q02 << 7) -
num) / (Q02 << 8));
688 if (Al > 0 && pred >= (1 << Al)) pred = (1 << Al) - 1;
704 buffer_ptr++, prev_block_row++, next_block_row++;
711 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
732 #ifdef BLOCK_SMOOTHING_SUPPORTED 737 if (need_full_buffer)
739 #ifdef D_MULTISCAN_FILES_SUPPORTED 746 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
750 #ifdef BLOCK_SMOOTHING_SUPPORTED 752 if (cinfo->progressive_mode) access_rows *= 3;
754 coef->
whole_image[ci] = (*cinfo->mem->request_virt_barray)(
768 ERREXIT(cinfo, JERR_NOT_COMPILED);
786 coef->
pub.coef_arrays =
nullptr;
decompress_smooth_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
#define JPEG_ROW_COMPLETED
start_iMCU_row(j_decompress_ptr cinfo)
jzero_far(void FAR *target, size_t bytestozero)
consume_data(j_decompress_ptr cinfo)
LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo))
dummy_consume_data(j_decompress_ptr)
UINT16 quantval[DCTSIZE2]
FAST_FLOAT workspace[DCTSIZE2]
jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks)
#define MAX_COMPS_IN_SCAN
#define D_MAX_BLOCKS_IN_MCU
jround_up(long a, long b)
struct jpeg_common_struct * j_common_ptr
#define ERREXIT(cinfo, code)
for(ctr=DCTSIZE;ctr > 0;ctr--)
smoothing_ok(j_decompress_ptr cinfo)
JDIMENSION width_in_blocks
jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
struct jpeg_c_coef_controller pub
JDIMENSION height_in_blocks
GLint GLint GLint yoffset
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
decompress_onepass JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf))
decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
start_output_pass(j_decompress_ptr cinfo)
start_input_pass(j_decompress_ptr cinfo)
decompress_data(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
my_coef_controller * my_coef_ptr
#define JPEG_SCAN_COMPLETED
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]
jpeg_component_info * compptr
int MCU_rows_per_iMCU_row
jvirt_barray_ptr whole_image[MAX_COMPONENTS]