00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define JPEG_INTERNALS
00018 #include "jinclude.h"
00019 #include "jpeglib.h"
00020
00021
00022 #ifndef D_PROGRESSIVE_SUPPORTED
00023 #undef BLOCK_SMOOTHING_SUPPORTED
00024 #endif
00025
00026
00027
00028 typedef struct {
00029 struct jpeg_d_coef_controller pub;
00030
00031
00032
00033 JDIMENSION MCU_ctr;
00034 int MCU_vert_offset;
00035 int MCU_rows_per_iMCU_row;
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];
00049
00050 #ifdef D_MULTISCAN_FILES_SUPPORTED
00051
00052 jvirt_barray_ptr whole_image[MAX_COMPONENTS];
00053 #endif
00054
00055 #ifdef BLOCK_SMOOTHING_SUPPORTED
00056
00057 int * coef_bits_latch;
00058 #define SAVED_COEFS 6
00059 #endif
00060 } my_coef_controller;
00061
00062 typedef my_coef_controller * my_coef_ptr;
00063
00064
00065 METHODDEF(int) decompress_onepass
00066 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
00067 #ifdef D_MULTISCAN_FILES_SUPPORTED
00068 METHODDEF(int) decompress_data
00069 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
00070 #endif
00071 #ifdef BLOCK_SMOOTHING_SUPPORTED
00072 LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo));
00073 METHODDEF(int) decompress_smooth_data
00074 JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
00075 #endif
00076
00077
00078 LOCAL(void)
00079 start_iMCU_row (j_decompress_ptr cinfo)
00080
00081 {
00082 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00083
00084
00085
00086
00087
00088 if (cinfo->comps_in_scan > 1) {
00089 coef->MCU_rows_per_iMCU_row = 1;
00090 } else {
00091 if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
00092 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
00093 else
00094 coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
00095 }
00096
00097 coef->MCU_ctr = 0;
00098 coef->MCU_vert_offset = 0;
00099 }
00100
00101
00102
00103
00104
00105
00106 METHODDEF(void)
00107 start_input_pass (j_decompress_ptr cinfo)
00108 {
00109 cinfo->input_iMCU_row = 0;
00110 start_iMCU_row(cinfo);
00111 }
00112
00113
00114
00115
00116
00117
00118 METHODDEF(void)
00119 start_output_pass (j_decompress_ptr cinfo)
00120 {
00121 #ifdef BLOCK_SMOOTHING_SUPPORTED
00122 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00123
00124
00125 if (coef->pub.coef_arrays != NULL) {
00126 if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
00127 coef->pub.decompress_data = decompress_smooth_data;
00128 else
00129 coef->pub.decompress_data = decompress_data;
00130 }
00131 #endif
00132 cinfo->output_iMCU_row = 0;
00133 }
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 METHODDEF(int)
00147 decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
00148 {
00149 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00150 JDIMENSION MCU_col_num;
00151 JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
00152 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00153 int blkn, ci, xindex, yindex, yoffset, useful_width;
00154 JSAMPARRAY output_ptr;
00155 JDIMENSION start_col, output_col;
00156 jpeg_component_info *compptr;
00157 inverse_DCT_method_ptr inverse_DCT;
00158
00159
00160 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00161 yoffset++) {
00162 for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
00163 MCU_col_num++) {
00164
00165 jzero_far((void FAR *) coef->MCU_buffer[0],
00166 (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
00167 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
00168
00169 coef->MCU_vert_offset = yoffset;
00170 coef->MCU_ctr = MCU_col_num;
00171 return JPEG_SUSPENDED;
00172 }
00173
00174
00175
00176
00177
00178 blkn = 0;
00179 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00180 compptr = cinfo->cur_comp_info[ci];
00181
00182 if (! compptr->component_needed) {
00183 blkn += compptr->MCU_blocks;
00184 continue;
00185 }
00186 inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
00187 useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
00188 : compptr->last_col_width;
00189 output_ptr = output_buf[compptr->component_index] +
00190 yoffset * compptr->DCT_scaled_size;
00191 start_col = MCU_col_num * compptr->MCU_sample_width;
00192 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00193 if (cinfo->input_iMCU_row < last_iMCU_row ||
00194 yoffset+yindex < compptr->last_row_height) {
00195 output_col = start_col;
00196 for (xindex = 0; xindex < useful_width; xindex++) {
00197 (*inverse_DCT) (cinfo, compptr,
00198 (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
00199 output_ptr, output_col);
00200 output_col += compptr->DCT_scaled_size;
00201 }
00202 }
00203 blkn += compptr->MCU_width;
00204 output_ptr += compptr->DCT_scaled_size;
00205 }
00206 }
00207 }
00208
00209 coef->MCU_ctr = 0;
00210 }
00211
00212 cinfo->output_iMCU_row++;
00213 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
00214 start_iMCU_row(cinfo);
00215 return JPEG_ROW_COMPLETED;
00216 }
00217
00218 (*cinfo->inputctl->finish_input_pass) (cinfo);
00219 return JPEG_SCAN_COMPLETED;
00220 }
00221
00222
00223
00224
00225
00226
00227 METHODDEF(int)
00228 dummy_consume_data (j_decompress_ptr cinfo)
00229 {
00230 return JPEG_SUSPENDED;
00231 }
00232
00233
00234 #ifdef D_MULTISCAN_FILES_SUPPORTED
00235
00236
00237
00238
00239
00240
00241
00242
00243 METHODDEF(int)
00244 consume_data (j_decompress_ptr cinfo)
00245 {
00246 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00247 JDIMENSION MCU_col_num;
00248 int blkn, ci, xindex, yindex, yoffset;
00249 JDIMENSION start_col;
00250 JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
00251 JBLOCKROW buffer_ptr;
00252 jpeg_component_info *compptr;
00253
00254
00255 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00256 compptr = cinfo->cur_comp_info[ci];
00257 buffer[ci] = (*cinfo->mem->access_virt_barray)
00258 ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
00259 cinfo->input_iMCU_row * compptr->v_samp_factor,
00260 (JDIMENSION) compptr->v_samp_factor, TRUE);
00261
00262
00263
00264
00265 }
00266
00267
00268 for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
00269 yoffset++) {
00270 for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
00271 MCU_col_num++) {
00272
00273 blkn = 0;
00274 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
00275 compptr = cinfo->cur_comp_info[ci];
00276 start_col = MCU_col_num * compptr->MCU_width;
00277 for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
00278 buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
00279 for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
00280 coef->MCU_buffer[blkn++] = buffer_ptr++;
00281 }
00282 }
00283 }
00284
00285 if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
00286
00287 coef->MCU_vert_offset = yoffset;
00288 coef->MCU_ctr = MCU_col_num;
00289 return JPEG_SUSPENDED;
00290 }
00291 }
00292
00293 coef->MCU_ctr = 0;
00294 }
00295
00296 if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
00297 start_iMCU_row(cinfo);
00298 return JPEG_ROW_COMPLETED;
00299 }
00300
00301 (*cinfo->inputctl->finish_input_pass) (cinfo);
00302 return JPEG_SCAN_COMPLETED;
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 METHODDEF(int)
00315 decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
00316 {
00317 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00318 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00319 JDIMENSION block_num;
00320 int ci, block_row, block_rows;
00321 JBLOCKARRAY buffer;
00322 JBLOCKROW buffer_ptr;
00323 JSAMPARRAY output_ptr;
00324 JDIMENSION output_col;
00325 jpeg_component_info *compptr;
00326 inverse_DCT_method_ptr inverse_DCT;
00327
00328
00329 while (cinfo->input_scan_number < cinfo->output_scan_number ||
00330 (cinfo->input_scan_number == cinfo->output_scan_number &&
00331 cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
00332 if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
00333 return JPEG_SUSPENDED;
00334 }
00335
00336
00337 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00338 ci++, compptr++) {
00339
00340 if (! compptr->component_needed)
00341 continue;
00342
00343 buffer = (*cinfo->mem->access_virt_barray)
00344 ((j_common_ptr) cinfo, coef->whole_image[ci],
00345 cinfo->output_iMCU_row * compptr->v_samp_factor,
00346 (JDIMENSION) compptr->v_samp_factor, FALSE);
00347
00348 if (cinfo->output_iMCU_row < last_iMCU_row)
00349 block_rows = compptr->v_samp_factor;
00350 else {
00351
00352 block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00353 if (block_rows == 0) block_rows = compptr->v_samp_factor;
00354 }
00355 inverse_DCT = cinfo->idct->inverse_DCT[ci];
00356 output_ptr = output_buf[ci];
00357
00358 for (block_row = 0; block_row < block_rows; block_row++) {
00359 buffer_ptr = buffer[block_row];
00360 output_col = 0;
00361 for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
00362 (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
00363 output_ptr, output_col);
00364 buffer_ptr++;
00365 output_col += compptr->DCT_scaled_size;
00366 }
00367 output_ptr += compptr->DCT_scaled_size;
00368 }
00369 }
00370
00371 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
00372 return JPEG_ROW_COMPLETED;
00373 return JPEG_SCAN_COMPLETED;
00374 }
00375
00376 #endif
00377
00378
00379 #ifdef BLOCK_SMOOTHING_SUPPORTED
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 #define Q01_POS 1
00391 #define Q10_POS 8
00392 #define Q20_POS 16
00393 #define Q11_POS 9
00394 #define Q02_POS 2
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 LOCAL(boolean)
00405 smoothing_ok (j_decompress_ptr cinfo)
00406 {
00407 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00408 boolean smoothing_useful = FALSE;
00409 int ci, coefi;
00410 jpeg_component_info *compptr;
00411 JQUANT_TBL * qtable;
00412 int * coef_bits;
00413 int * coef_bits_latch;
00414
00415 if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
00416 return FALSE;
00417
00418
00419 if (coef->coef_bits_latch == NULL)
00420 coef->coef_bits_latch = (int *)
00421 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00422 cinfo->num_components *
00423 (SAVED_COEFS * SIZEOF(int)));
00424 coef_bits_latch = coef->coef_bits_latch;
00425
00426 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00427 ci++, compptr++) {
00428
00429 if ((qtable = compptr->quant_table) == NULL)
00430 return FALSE;
00431
00432 if (qtable->quantval[0] == 0 ||
00433 qtable->quantval[Q01_POS] == 0 ||
00434 qtable->quantval[Q10_POS] == 0 ||
00435 qtable->quantval[Q20_POS] == 0 ||
00436 qtable->quantval[Q11_POS] == 0 ||
00437 qtable->quantval[Q02_POS] == 0)
00438 return FALSE;
00439
00440 coef_bits = cinfo->coef_bits[ci];
00441 if (coef_bits[0] < 0)
00442 return FALSE;
00443
00444 for (coefi = 1; coefi <= 5; coefi++) {
00445 coef_bits_latch[coefi] = coef_bits[coefi];
00446 if (coef_bits[coefi] != 0)
00447 smoothing_useful = TRUE;
00448 }
00449 coef_bits_latch += SAVED_COEFS;
00450 }
00451
00452 return smoothing_useful;
00453 }
00454
00455
00456
00457
00458
00459
00460 METHODDEF(int)
00461 decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
00462 {
00463 my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
00464 JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
00465 JDIMENSION block_num, last_block_column;
00466 int ci, block_row, block_rows, access_rows;
00467 JBLOCKARRAY buffer;
00468 JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
00469 JSAMPARRAY output_ptr;
00470 JDIMENSION output_col;
00471 jpeg_component_info *compptr;
00472 inverse_DCT_method_ptr inverse_DCT;
00473 boolean first_row, last_row;
00474 JBLOCK workspace;
00475 int *coef_bits;
00476 JQUANT_TBL *quanttbl;
00477 INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;
00478 int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
00479 int Al, pred;
00480
00481
00482 while (cinfo->input_scan_number <= cinfo->output_scan_number &&
00483 ! cinfo->inputctl->eoi_reached) {
00484 if (cinfo->input_scan_number == cinfo->output_scan_number) {
00485
00486
00487
00488
00489
00490 JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
00491 if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
00492 break;
00493 }
00494 if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
00495 return JPEG_SUSPENDED;
00496 }
00497
00498
00499 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00500 ci++, compptr++) {
00501
00502 if (! compptr->component_needed)
00503 continue;
00504
00505 if (cinfo->output_iMCU_row < last_iMCU_row) {
00506 block_rows = compptr->v_samp_factor;
00507 access_rows = block_rows * 2;
00508 last_row = FALSE;
00509 } else {
00510
00511 block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
00512 if (block_rows == 0) block_rows = compptr->v_samp_factor;
00513 access_rows = block_rows;
00514 last_row = TRUE;
00515 }
00516
00517 if (cinfo->output_iMCU_row > 0) {
00518 access_rows += compptr->v_samp_factor;
00519 buffer = (*cinfo->mem->access_virt_barray)
00520 ((j_common_ptr) cinfo, coef->whole_image[ci],
00521 (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
00522 (JDIMENSION) access_rows, FALSE);
00523 buffer += compptr->v_samp_factor;
00524 first_row = FALSE;
00525 } else {
00526 buffer = (*cinfo->mem->access_virt_barray)
00527 ((j_common_ptr) cinfo, coef->whole_image[ci],
00528 (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
00529 first_row = TRUE;
00530 }
00531
00532 coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
00533 quanttbl = compptr->quant_table;
00534 Q00 = quanttbl->quantval[0];
00535 Q01 = quanttbl->quantval[Q01_POS];
00536 Q10 = quanttbl->quantval[Q10_POS];
00537 Q20 = quanttbl->quantval[Q20_POS];
00538 Q11 = quanttbl->quantval[Q11_POS];
00539 Q02 = quanttbl->quantval[Q02_POS];
00540 inverse_DCT = cinfo->idct->inverse_DCT[ci];
00541 output_ptr = output_buf[ci];
00542
00543 for (block_row = 0; block_row < block_rows; block_row++) {
00544 buffer_ptr = buffer[block_row];
00545 if (first_row && block_row == 0)
00546 prev_block_row = buffer_ptr;
00547 else
00548 prev_block_row = buffer[block_row-1];
00549 if (last_row && block_row == block_rows-1)
00550 next_block_row = buffer_ptr;
00551 else
00552 next_block_row = buffer[block_row+1];
00553
00554
00555
00556 DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
00557 DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
00558 DC7 = DC8 = DC9 = (int) next_block_row[0][0];
00559 output_col = 0;
00560 last_block_column = compptr->width_in_blocks - 1;
00561 for (block_num = 0; block_num <= last_block_column; block_num++) {
00562
00563 jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
00564
00565 if (block_num < last_block_column) {
00566 DC3 = (int) prev_block_row[1][0];
00567 DC6 = (int) buffer_ptr[1][0];
00568 DC9 = (int) next_block_row[1][0];
00569 }
00570
00571
00572
00573
00574
00575 if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
00576 num = 36 * Q00 * (DC4 - DC6);
00577 if (num >= 0) {
00578 pred = (int) (((Q01<<7) + num) / (Q01<<8));
00579 if (Al > 0 && pred >= (1<<Al))
00580 pred = (1<<Al)-1;
00581 } else {
00582 pred = (int) (((Q01<<7) - num) / (Q01<<8));
00583 if (Al > 0 && pred >= (1<<Al))
00584 pred = (1<<Al)-1;
00585 pred = -pred;
00586 }
00587 workspace[1] = (JCOEF) pred;
00588 }
00589
00590 if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
00591 num = 36 * Q00 * (DC2 - DC8);
00592 if (num >= 0) {
00593 pred = (int) (((Q10<<7) + num) / (Q10<<8));
00594 if (Al > 0 && pred >= (1<<Al))
00595 pred = (1<<Al)-1;
00596 } else {
00597 pred = (int) (((Q10<<7) - num) / (Q10<<8));
00598 if (Al > 0 && pred >= (1<<Al))
00599 pred = (1<<Al)-1;
00600 pred = -pred;
00601 }
00602 workspace[8] = (JCOEF) pred;
00603 }
00604
00605 if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
00606 num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
00607 if (num >= 0) {
00608 pred = (int) (((Q20<<7) + num) / (Q20<<8));
00609 if (Al > 0 && pred >= (1<<Al))
00610 pred = (1<<Al)-1;
00611 } else {
00612 pred = (int) (((Q20<<7) - num) / (Q20<<8));
00613 if (Al > 0 && pred >= (1<<Al))
00614 pred = (1<<Al)-1;
00615 pred = -pred;
00616 }
00617 workspace[16] = (JCOEF) pred;
00618 }
00619
00620 if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
00621 num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
00622 if (num >= 0) {
00623 pred = (int) (((Q11<<7) + num) / (Q11<<8));
00624 if (Al > 0 && pred >= (1<<Al))
00625 pred = (1<<Al)-1;
00626 } else {
00627 pred = (int) (((Q11<<7) - num) / (Q11<<8));
00628 if (Al > 0 && pred >= (1<<Al))
00629 pred = (1<<Al)-1;
00630 pred = -pred;
00631 }
00632 workspace[9] = (JCOEF) pred;
00633 }
00634
00635 if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
00636 num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
00637 if (num >= 0) {
00638 pred = (int) (((Q02<<7) + num) / (Q02<<8));
00639 if (Al > 0 && pred >= (1<<Al))
00640 pred = (1<<Al)-1;
00641 } else {
00642 pred = (int) (((Q02<<7) - num) / (Q02<<8));
00643 if (Al > 0 && pred >= (1<<Al))
00644 pred = (1<<Al)-1;
00645 pred = -pred;
00646 }
00647 workspace[2] = (JCOEF) pred;
00648 }
00649
00650 (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
00651 output_ptr, output_col);
00652
00653 DC1 = DC2; DC2 = DC3;
00654 DC4 = DC5; DC5 = DC6;
00655 DC7 = DC8; DC8 = DC9;
00656 buffer_ptr++, prev_block_row++, next_block_row++;
00657 output_col += compptr->DCT_scaled_size;
00658 }
00659 output_ptr += compptr->DCT_scaled_size;
00660 }
00661 }
00662
00663 if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
00664 return JPEG_ROW_COMPLETED;
00665 return JPEG_SCAN_COMPLETED;
00666 }
00667
00668 #endif
00669
00670
00671
00672
00673
00674
00675 GLOBAL(void)
00676 jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
00677 {
00678 my_coef_ptr coef;
00679
00680 coef = (my_coef_ptr)
00681 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00682 SIZEOF(my_coef_controller));
00683 cinfo->coef = (struct jpeg_d_coef_controller *) coef;
00684 coef->pub.start_input_pass = start_input_pass;
00685 coef->pub.start_output_pass = start_output_pass;
00686 #ifdef BLOCK_SMOOTHING_SUPPORTED
00687 coef->coef_bits_latch = NULL;
00688 #endif
00689
00690
00691 if (need_full_buffer) {
00692 #ifdef D_MULTISCAN_FILES_SUPPORTED
00693
00694
00695
00696 int ci, access_rows;
00697 jpeg_component_info *compptr;
00698
00699 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
00700 ci++, compptr++) {
00701 access_rows = compptr->v_samp_factor;
00702 #ifdef BLOCK_SMOOTHING_SUPPORTED
00703
00704 if (cinfo->progressive_mode)
00705 access_rows *= 3;
00706 #endif
00707 coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
00708 ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
00709 (JDIMENSION) jround_up((long) compptr->width_in_blocks,
00710 (long) compptr->h_samp_factor),
00711 (JDIMENSION) jround_up((long) compptr->height_in_blocks,
00712 (long) compptr->v_samp_factor),
00713 (JDIMENSION) access_rows);
00714 }
00715 coef->pub.consume_data = consume_data;
00716 coef->pub.decompress_data = decompress_data;
00717 coef->pub.coef_arrays = coef->whole_image;
00718 #else
00719 ERREXIT(cinfo, JERR_NOT_COMPILED);
00720 #endif
00721 } else {
00722
00723 JBLOCKROW buffer;
00724 int i;
00725
00726 buffer = (JBLOCKROW)
00727 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
00728 D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
00729 for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
00730 coef->MCU_buffer[i] = buffer + i;
00731 }
00732 coef->pub.consume_data = dummy_consume_data;
00733 coef->pub.decompress_data = decompress_onepass;
00734 coef->pub.coef_arrays = NULL;
00735 }
00736 }