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
57 int * coef_bits_latch;
67 #ifdef D_MULTISCAN_FILES_SUPPORTED
71 #ifdef BLOCK_SMOOTHING_SUPPORTED
121 #ifdef BLOCK_SMOOTHING_SUPPORTED
127 coef->
pub.decompress_data = decompress_smooth_data;
129 coef->
pub.decompress_data = decompress_data;
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;
182 if (! compptr->component_needed) {
187 useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
188 : compptr->last_col_width;
189 output_ptr = output_buf[ci] +
yoffset * compptr->DCT_scaled_size;
190 start_col = MCU_col_num * compptr->MCU_sample_width;
191 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
193 yoffset+yindex < compptr->last_row_height) {
194 output_col = start_col;
195 for (xindex = 0; xindex < useful_width; xindex++) {
196 (*inverse_DCT) (cinfo, compptr,
198 output_ptr, output_col);
199 output_col += compptr->DCT_scaled_size;
202 blkn += compptr->MCU_width;
203 output_ptr += compptr->DCT_scaled_size;
217 (*cinfo->
inputctl->finish_input_pass) (cinfo);
233 #ifdef D_MULTISCAN_FILES_SUPPORTED
247 int blkn, ci, xindex, yindex,
yoffset;
256 buffer[ci] = (*cinfo->mem->access_virt_barray)
269 for (MCU_col_num = coef->
MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
275 start_col = MCU_col_num * compptr->
MCU_width;
276 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
278 for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
300 (*cinfo->
inputctl->finish_input_pass) (cinfo);
319 int ci, block_row, block_rows;
325 inverse_DCT_method_ptr inverse_DCT;
336 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
339 if (! compptr->component_needed)
342 buffer = (*cinfo->mem->access_virt_barray)
348 block_rows = compptr->v_samp_factor;
351 block_rows = (
int) (compptr->height_in_blocks % compptr->v_samp_factor);
352 if (block_rows == 0) block_rows = compptr->v_samp_factor;
355 output_ptr = output_buf[ci];
357 for (block_row = 0; block_row < block_rows; block_row++) {
358 buffer_ptr =
buffer[block_row];
360 for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
361 (*inverse_DCT) (cinfo, compptr, (
JCOEFPTR) buffer_ptr,
362 output_ptr, output_col);
364 output_col += compptr->DCT_scaled_size;
366 output_ptr += compptr->DCT_scaled_size;
378 #ifdef BLOCK_SMOOTHING_SUPPORTED
400 boolean smoothing_useful =
FALSE;
405 int * coef_bits_latch;
411 if (coef->coef_bits_latch ==
NULL)
412 coef->coef_bits_latch = (
int *)
415 (SAVED_COEFS *
SIZEOF(
int)));
416 coef_bits_latch = coef->coef_bits_latch;
418 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
421 if ((qtable = compptr->quant_table) ==
NULL)
424 for (coefi = 0; coefi <= 5; coefi++) {
425 if (qtable->quantval[coefi] == 0)
430 if (coef_bits[0] < 0)
433 for (coefi = 1; coefi <= 5; coefi++) {
434 coef_bits_latch[coefi] = coef_bits[coefi];
435 if (coef_bits[coefi] != 0)
436 smoothing_useful =
TRUE;
438 coef_bits_latch += SAVED_COEFS;
441 return smoothing_useful;
455 int ci, block_row, block_rows, access_rows;
457 JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
461 inverse_DCT_method_ptr inverse_DCT;
462 boolean first_row, last_row;
467 int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
488 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
491 if (! compptr->component_needed)
495 block_rows = compptr->v_samp_factor;
496 access_rows = block_rows * 2;
500 block_rows = (
int) (compptr->height_in_blocks % compptr->v_samp_factor);
501 if (block_rows == 0) block_rows = compptr->v_samp_factor;
502 access_rows = block_rows;
507 access_rows += compptr->v_samp_factor;
508 buffer = (*cinfo->mem->access_virt_barray)
512 buffer += compptr->v_samp_factor;
515 buffer = (*cinfo->mem->access_virt_barray)
521 coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
522 quanttbl = compptr->quant_table;
523 Q00 = quanttbl->quantval[0];
524 Q01 = quanttbl->quantval[1];
525 Q10 = quanttbl->quantval[2];
526 Q20 = quanttbl->quantval[3];
527 Q11 = quanttbl->quantval[4];
528 Q02 = quanttbl->quantval[5];
530 output_ptr = output_buf[ci];
532 for (block_row = 0; block_row < block_rows; block_row++) {
533 buffer_ptr =
buffer[block_row];
534 if (first_row && block_row == 0)
535 prev_block_row = buffer_ptr;
537 prev_block_row =
buffer[block_row-1];
538 if (last_row && block_row == block_rows-1)
539 next_block_row = buffer_ptr;
541 next_block_row =
buffer[block_row+1];
545 DC1 = DC2 = DC3 = (
int) prev_block_row[0][0];
546 DC4 = DC5 = DC6 = (
int) buffer_ptr[0][0];
547 DC7 = DC8 = DC9 = (
int) next_block_row[0][0];
549 last_block_column = compptr->width_in_blocks - 1;
550 for (block_num = 0; block_num <= last_block_column; block_num++) {
554 if (block_num < last_block_column) {
555 DC3 = (
int) prev_block_row[1][0];
556 DC6 = (
int) buffer_ptr[1][0];
557 DC9 = (
int) next_block_row[1][0];
564 if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
565 num = 36 * Q00 * (DC4 - DC6);
567 pred = (
int) (((Q01<<7) +
num) / (Q01<<8));
568 if (Al > 0 && pred >= (1<<Al))
571 pred = (
int) (((Q01<<7) -
num) / (Q01<<8));
572 if (Al > 0 && pred >= (1<<Al))
576 workspace[1] = (
JCOEF) pred;
579 if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
580 num = 36 * Q00 * (DC2 - DC8);
582 pred = (
int) (((Q10<<7) +
num) / (Q10<<8));
583 if (Al > 0 && pred >= (1<<Al))
586 pred = (
int) (((Q10<<7) -
num) / (Q10<<8));
587 if (Al > 0 && pred >= (1<<Al))
591 workspace[8] = (
JCOEF) pred;
594 if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
595 num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
597 pred = (
int) (((Q20<<7) +
num) / (Q20<<8));
598 if (Al > 0 && pred >= (1<<Al))
601 pred = (
int) (((Q20<<7) -
num) / (Q20<<8));
602 if (Al > 0 && pred >= (1<<Al))
606 workspace[16] = (
JCOEF) pred;
609 if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
610 num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
612 pred = (
int) (((Q11<<7) +
num) / (Q11<<8));
613 if (Al > 0 && pred >= (1<<Al))
616 pred = (
int) (((Q11<<7) -
num) / (Q11<<8));
617 if (Al > 0 && pred >= (1<<Al))
621 workspace[9] = (
JCOEF) pred;
624 if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
625 num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
627 pred = (
int) (((Q02<<7) +
num) / (Q02<<8));
628 if (Al > 0 && pred >= (1<<Al))
631 pred = (
int) (((Q02<<7) -
num) / (Q02<<8));
632 if (Al > 0 && pred >= (1<<Al))
636 workspace[2] = (
JCOEF) pred;
639 (*inverse_DCT) (cinfo, compptr, (
JCOEFPTR) workspace,
640 output_ptr, output_col);
642 DC1 = DC2; DC2 = DC3;
643 DC4 = DC5; DC5 = DC6;
644 DC7 = DC8; DC8 = DC9;
645 buffer_ptr++, prev_block_row++, next_block_row++;
646 output_col += compptr->DCT_scaled_size;
648 output_ptr += compptr->DCT_scaled_size;
675 #ifdef BLOCK_SMOOTHING_SUPPORTED
676 coef->coef_bits_latch =
NULL;
680 if (need_full_buffer) {
681 #ifdef D_MULTISCAN_FILES_SUPPORTED
688 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
691 #ifdef BLOCK_SMOOTHING_SUPPORTED
696 coef->
whole_image[ci] = (*cinfo->mem->request_virt_barray)
704 coef->
pub.consume_data = consume_data;
705 coef->
pub.decompress_data = decompress_data;
708 ERREXIT(cinfo, JERR_NOT_COMPILED);
boolean do_block_smoothing
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
struct jpeg_input_controller * inputctl
jpeg_component_info * comp_info
inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]
struct jpeg_common_struct * j_common_ptr
struct jpeg_d_coef_controller * coef
METHODDEF int dummy_consume_data(j_decompress_ptr cinfo)
#define ERREXIT(cinfo, code)
#define JPEG_ROW_COMPLETED
METHODDEF int decompress_onepass JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf))
LOCAL void start_iMCU_row(j_decompress_ptr cinfo)
JDIMENSION width_in_blocks
struct jpeg_c_coef_controller pub
METHODDEF void start_output_pass(j_decompress_ptr cinfo)
JDIMENSION height_in_blocks
GLOBAL void jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
METHODDEF void start_input_pass(j_decompress_ptr cinfo)
GLOBAL void jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row, JDIMENSION num_blocks)
GLint GLint GLint yoffset
GLOBAL void jzero_far(void FAR *target, size_t bytestozero)
#define D_MAX_BLOCKS_IN_MCU
#define JPEG_SCAN_COMPLETED
JDIMENSION input_iMCU_row
JDIMENSION output_iMCU_row
METHODDEF int decompress_onepass(j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
jvirt_barray_ptr whole_image[MAX_COMPONENTS]
int(* coef_bits)[DCTSIZE2]
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
struct jpeg_inverse_dct * idct
my_coef_controller * my_coef_ptr
struct jpeg_entropy_decoder * entropy
JDIMENSION total_iMCU_rows
#define MAX_COMPS_IN_SCAN
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]
GLOBAL long jround_up(long a, long b)
int MCU_rows_per_iMCU_row