trunk/3rdparty/libjpeg/jcmainct.c
| r242826 | r242827 | |
| 68 | 68 | METHODDEF(void) |
| 69 | 69 | start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) |
| 70 | 70 | { |
| 71 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 71 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 72 | 72 | |
| 73 | 73 | /* Do nothing in raw-data mode. */ |
| 74 | 74 | if (cinfo->raw_data_in) |
| 75 | 75 | return; |
| 76 | 76 | |
| 77 | | main->cur_iMCU_row = 0; /* initialize counters */ |
| 78 | | main->rowgroup_ctr = 0; |
| 79 | | main->suspended = FALSE; |
| 80 | | main->pass_mode = pass_mode; /* save mode for use by process_data */ |
| 77 | mymain->cur_iMCU_row = 0; /* initialize counters */ |
| 78 | mymain->rowgroup_ctr = 0; |
| 79 | mymain->suspended = FALSE; |
| 80 | mymain->pass_mode = pass_mode; /* save mode for use by process_data */ |
| 81 | 81 | |
| 82 | 82 | switch (pass_mode) { |
| 83 | 83 | case JBUF_PASS_THRU: |
| 84 | 84 | #ifdef FULL_MAIN_BUFFER_SUPPORTED |
| 85 | | if (main->whole_image[0] != NULL) |
| 85 | if (mymain->whole_image[0] != NULL) |
| 86 | 86 | ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); |
| 87 | 87 | #endif |
| 88 | | main->pub.process_data = process_data_simple_main; |
| 88 | mymain->pub.process_data = process_data_simple_main; |
| 89 | 89 | break; |
| 90 | 90 | #ifdef FULL_MAIN_BUFFER_SUPPORTED |
| 91 | 91 | case JBUF_SAVE_SOURCE: |
| 92 | 92 | case JBUF_CRANK_DEST: |
| 93 | 93 | case JBUF_SAVE_AND_PASS: |
| 94 | | if (main->whole_image[0] == NULL) |
| 94 | if (mymain->whole_image[0] == NULL) |
| 95 | 95 | ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); |
| 96 | | main->pub.process_data = process_data_buffer_main; |
| 96 | mymain->pub.process_data = process_data_buffer_main; |
| 97 | 97 | break; |
| 98 | 98 | #endif |
| 99 | 99 | default: |
| r242826 | r242827 | |
| 114 | 114 | JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, |
| 115 | 115 | JDIMENSION in_rows_avail) |
| 116 | 116 | { |
| 117 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 117 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 118 | 118 | |
| 119 | | while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { |
| 119 | while (mymain->cur_iMCU_row < cinfo->total_iMCU_rows) { |
| 120 | 120 | /* Read input data if we haven't filled the main buffer yet */ |
| 121 | | if (main->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) |
| 121 | if (mymain->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size) |
| 122 | 122 | (*cinfo->prep->pre_process_data) (cinfo, |
| 123 | 123 | input_buf, in_row_ctr, in_rows_avail, |
| 124 | | main->buffer, &main->rowgroup_ctr, |
| 124 | mymain->buffer, &mymain->rowgroup_ctr, |
| 125 | 125 | (JDIMENSION) cinfo->min_DCT_v_scaled_size); |
| 126 | 126 | |
| 127 | 127 | /* If we don't have a full iMCU row buffered, return to application for |
| 128 | 128 | * more data. Note that preprocessor will always pad to fill the iMCU row |
| 129 | 129 | * at the bottom of the image. |
| 130 | 130 | */ |
| 131 | | if (main->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size) |
| 131 | if (mymain->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size) |
| 132 | 132 | return; |
| 133 | 133 | |
| 134 | 134 | /* Send the completed row to the compressor */ |
| 135 | | if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { |
| 135 | if (! (*cinfo->coef->compress_data) (cinfo, mymain->buffer)) { |
| 136 | 136 | /* If compressor did not consume the whole row, then we must need to |
| 137 | 137 | * suspend processing and return to the application. In this situation |
| 138 | 138 | * we pretend we didn't yet consume the last input row; otherwise, if |
| 139 | 139 | * it happened to be the last row of the image, the application would |
| 140 | 140 | * think we were done. |
| 141 | 141 | */ |
| 142 | | if (! main->suspended) { |
| 142 | if (! mymain->suspended) { |
| 143 | 143 | (*in_row_ctr)--; |
| 144 | | main->suspended = TRUE; |
| 144 | mymain->suspended = TRUE; |
| 145 | 145 | } |
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | /* We did finish the row. Undo our little suspension hack if a previous |
| 149 | 149 | * call suspended; then mark the main buffer empty. |
| 150 | 150 | */ |
| 151 | | if (main->suspended) { |
| 151 | if (mymain->suspended) { |
| 152 | 152 | (*in_row_ctr)++; |
| 153 | | main->suspended = FALSE; |
| 153 | mymain->suspended = FALSE; |
| 154 | 154 | } |
| 155 | | main->rowgroup_ctr = 0; |
| 156 | | main->cur_iMCU_row++; |
| 155 | mymain->rowgroup_ctr = 0; |
| 156 | mymain->cur_iMCU_row++; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| r242826 | r242827 | |
| 244 | 244 | GLOBAL(void) |
| 245 | 245 | jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) |
| 246 | 246 | { |
| 247 | | my_main_ptr main; |
| 247 | my_main_ptr mymain; |
| 248 | 248 | int ci; |
| 249 | 249 | jpeg_component_info *compptr; |
| 250 | 250 | |
| 251 | | main = (my_main_ptr) |
| 251 | mymain = (my_main_ptr) |
| 252 | 252 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 253 | 253 | SIZEOF(my_main_controller)); |
| 254 | | cinfo->main = (struct jpeg_c_main_controller *) main; |
| 255 | | main->pub.start_pass = start_pass_main; |
| 254 | cinfo->main = (struct jpeg_c_main_controller *) mymain; |
| 255 | mymain->pub.start_pass = start_pass_main; |
| 256 | 256 | |
| 257 | 257 | /* We don't need to create a buffer in raw-data mode. */ |
| 258 | 258 | if (cinfo->raw_data_in) |
| r242826 | r242827 | |
| 267 | 267 | /* Note we pad the bottom to a multiple of the iMCU height */ |
| 268 | 268 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 269 | 269 | ci++, compptr++) { |
| 270 | | main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
| 270 | mymain->whole_image[ci] = (*cinfo->mem->request_virt_sarray) |
| 271 | 271 | ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, |
| 272 | 272 | compptr->width_in_blocks * compptr->DCT_h_scaled_size, |
| 273 | 273 | (JDIMENSION) jround_up((long) compptr->height_in_blocks, |
| r242826 | r242827 | |
| 279 | 279 | #endif |
| 280 | 280 | } else { |
| 281 | 281 | #ifdef FULL_MAIN_BUFFER_SUPPORTED |
| 282 | | main->whole_image[0] = NULL; /* flag for no virtual arrays */ |
| 282 | mymain->whole_image[0] = NULL; /* flag for no virtual arrays */ |
| 283 | 283 | #endif |
| 284 | 284 | /* Allocate a strip buffer for each component */ |
| 285 | 285 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 286 | 286 | ci++, compptr++) { |
| 287 | | main->buffer[ci] = (*cinfo->mem->alloc_sarray) |
| 287 | mymain->buffer[ci] = (*cinfo->mem->alloc_sarray) |
| 288 | 288 | ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 289 | 289 | compptr->width_in_blocks * compptr->DCT_h_scaled_size, |
| 290 | 290 | (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size)); |
trunk/3rdparty/libjpeg/jdmainct.c
| r242826 | r242827 | |
| 159 | 159 | * This is done only once, not once per pass. |
| 160 | 160 | */ |
| 161 | 161 | { |
| 162 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 162 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 163 | 163 | int ci, rgroup; |
| 164 | 164 | int M = cinfo->min_DCT_v_scaled_size; |
| 165 | 165 | jpeg_component_info *compptr; |
| r242826 | r242827 | |
| 168 | 168 | /* Get top-level space for component array pointers. |
| 169 | 169 | * We alloc both arrays with one call to save a few cycles. |
| 170 | 170 | */ |
| 171 | | main->xbuffer[0] = (JSAMPIMAGE) |
| 171 | mymain->xbuffer[0] = (JSAMPIMAGE) |
| 172 | 172 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 173 | 173 | cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); |
| 174 | | main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; |
| 174 | mymain->xbuffer[1] = mymain->xbuffer[0] + cinfo->num_components; |
| 175 | 175 | |
| 176 | 176 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 177 | 177 | ci++, compptr++) { |
| r242826 | r242827 | |
| 184 | 184 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 185 | 185 | 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); |
| 186 | 186 | xbuf += rgroup; /* want one row group at negative offsets */ |
| 187 | | main->xbuffer[0][ci] = xbuf; |
| 187 | mymain->xbuffer[0][ci] = xbuf; |
| 188 | 188 | xbuf += rgroup * (M + 4); |
| 189 | | main->xbuffer[1][ci] = xbuf; |
| 189 | mymain->xbuffer[1][ci] = xbuf; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| r242826 | r242827 | |
| 200 | 200 | * This will be repeated at the beginning of each pass. |
| 201 | 201 | */ |
| 202 | 202 | { |
| 203 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 203 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 204 | 204 | int ci, i, rgroup; |
| 205 | 205 | int M = cinfo->min_DCT_v_scaled_size; |
| 206 | 206 | jpeg_component_info *compptr; |
| r242826 | r242827 | |
| 210 | 210 | ci++, compptr++) { |
| 211 | 211 | rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / |
| 212 | 212 | cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ |
| 213 | | xbuf0 = main->xbuffer[0][ci]; |
| 214 | | xbuf1 = main->xbuffer[1][ci]; |
| 213 | xbuf0 = mymain->xbuffer[0][ci]; |
| 214 | xbuf1 = mymain->xbuffer[1][ci]; |
| 215 | 215 | /* First copy the workspace pointers as-is */ |
| 216 | | buf = main->buffer[ci]; |
| 216 | buf = mymain->buffer[ci]; |
| 217 | 217 | for (i = 0; i < rgroup * (M + 2); i++) { |
| 218 | 218 | xbuf0[i] = xbuf1[i] = buf[i]; |
| 219 | 219 | } |
| r242826 | r242827 | |
| 240 | 240 | * This changes the pointer list state from top-of-image to the normal state. |
| 241 | 241 | */ |
| 242 | 242 | { |
| 243 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 243 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 244 | 244 | int ci, i, rgroup; |
| 245 | 245 | int M = cinfo->min_DCT_v_scaled_size; |
| 246 | 246 | jpeg_component_info *compptr; |
| r242826 | r242827 | |
| 250 | 250 | ci++, compptr++) { |
| 251 | 251 | rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / |
| 252 | 252 | cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ |
| 253 | | xbuf0 = main->xbuffer[0][ci]; |
| 254 | | xbuf1 = main->xbuffer[1][ci]; |
| 253 | xbuf0 = mymain->xbuffer[0][ci]; |
| 254 | xbuf1 = mymain->xbuffer[1][ci]; |
| 255 | 255 | for (i = 0; i < rgroup; i++) { |
| 256 | 256 | xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; |
| 257 | 257 | xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; |
| r242826 | r242827 | |
| 269 | 269 | * Also sets rowgroups_avail to indicate number of nondummy row groups in row. |
| 270 | 270 | */ |
| 271 | 271 | { |
| 272 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 272 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 273 | 273 | int ci, i, rgroup, iMCUheight, rows_left; |
| 274 | 274 | jpeg_component_info *compptr; |
| 275 | 275 | JSAMPARRAY xbuf; |
| r242826 | r242827 | |
| 286 | 286 | * so we need only do it once. |
| 287 | 287 | */ |
| 288 | 288 | if (ci == 0) { |
| 289 | | main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); |
| 289 | mymain->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); |
| 290 | 290 | } |
| 291 | 291 | /* Duplicate the last real sample row rgroup*2 times; this pads out the |
| 292 | 292 | * last partial rowgroup and ensures at least one full rowgroup of context. |
| 293 | 293 | */ |
| 294 | | xbuf = main->xbuffer[main->whichptr][ci]; |
| 294 | xbuf = mymain->xbuffer[mymain->whichptr][ci]; |
| 295 | 295 | for (i = 0; i < rgroup * 2; i++) { |
| 296 | 296 | xbuf[rows_left + i] = xbuf[rows_left-1]; |
| 297 | 297 | } |
| r242826 | r242827 | |
| 306 | 306 | METHODDEF(void) |
| 307 | 307 | start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) |
| 308 | 308 | { |
| 309 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 309 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 310 | 310 | |
| 311 | 311 | switch (pass_mode) { |
| 312 | 312 | case JBUF_PASS_THRU: |
| 313 | 313 | if (cinfo->upsample->need_context_rows) { |
| 314 | | main->pub.process_data = process_data_context_main; |
| 314 | mymain->pub.process_data = process_data_context_main; |
| 315 | 315 | make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ |
| 316 | | main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ |
| 317 | | main->context_state = CTX_PREPARE_FOR_IMCU; |
| 318 | | main->iMCU_row_ctr = 0; |
| 316 | mymain->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ |
| 317 | mymain->context_state = CTX_PREPARE_FOR_IMCU; |
| 318 | mymain->iMCU_row_ctr = 0; |
| 319 | 319 | } else { |
| 320 | 320 | /* Simple case with no context needed */ |
| 321 | | main->pub.process_data = process_data_simple_main; |
| 321 | mymain->pub.process_data = process_data_simple_main; |
| 322 | 322 | } |
| 323 | | main->buffer_full = FALSE; /* Mark buffer empty */ |
| 324 | | main->rowgroup_ctr = 0; |
| 323 | mymain->buffer_full = FALSE; /* Mark buffer empty */ |
| 324 | mymain->rowgroup_ctr = 0; |
| 325 | 325 | break; |
| 326 | 326 | #ifdef QUANT_2PASS_SUPPORTED |
| 327 | 327 | case JBUF_CRANK_DEST: |
| 328 | 328 | /* For last pass of 2-pass quantization, just crank the postprocessor */ |
| 329 | | main->pub.process_data = process_data_crank_post; |
| 329 | mymain->pub.process_data = process_data_crank_post; |
| 330 | 330 | break; |
| 331 | 331 | #endif |
| 332 | 332 | default: |
| r242826 | r242827 | |
| 346 | 346 | JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
| 347 | 347 | JDIMENSION out_rows_avail) |
| 348 | 348 | { |
| 349 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 349 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 350 | 350 | JDIMENSION rowgroups_avail; |
| 351 | 351 | |
| 352 | 352 | /* Read input data if we haven't filled the main buffer yet */ |
| 353 | | if (! main->buffer_full) { |
| 354 | | if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) |
| 353 | if (! mymain->buffer_full) { |
| 354 | if (! (*cinfo->coef->decompress_data) (cinfo, mymain->buffer)) |
| 355 | 355 | return; /* suspension forced, can do nothing more */ |
| 356 | | main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ |
| 356 | mymain->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /* There are always min_DCT_scaled_size row groups in an iMCU row. */ |
| r242826 | r242827 | |
| 364 | 364 | */ |
| 365 | 365 | |
| 366 | 366 | /* Feed the postprocessor */ |
| 367 | | (*cinfo->post->post_process_data) (cinfo, main->buffer, |
| 368 | | &main->rowgroup_ctr, rowgroups_avail, |
| 367 | (*cinfo->post->post_process_data) (cinfo, mymain->buffer, |
| 368 | &mymain->rowgroup_ctr, rowgroups_avail, |
| 369 | 369 | output_buf, out_row_ctr, out_rows_avail); |
| 370 | 370 | |
| 371 | 371 | /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ |
| 372 | | if (main->rowgroup_ctr >= rowgroups_avail) { |
| 373 | | main->buffer_full = FALSE; |
| 374 | | main->rowgroup_ctr = 0; |
| 372 | if (mymain->rowgroup_ctr >= rowgroups_avail) { |
| 373 | mymain->buffer_full = FALSE; |
| 374 | mymain->rowgroup_ctr = 0; |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | |
| r242826 | r242827 | |
| 386 | 386 | JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
| 387 | 387 | JDIMENSION out_rows_avail) |
| 388 | 388 | { |
| 389 | | my_main_ptr main = (my_main_ptr) cinfo->main; |
| 389 | my_main_ptr mymain = (my_main_ptr) cinfo->main; |
| 390 | 390 | |
| 391 | 391 | /* Read input data if we haven't filled the main buffer yet */ |
| 392 | | if (! main->buffer_full) { |
| 392 | if (! mymain->buffer_full) { |
| 393 | 393 | if (! (*cinfo->coef->decompress_data) (cinfo, |
| 394 | | main->xbuffer[main->whichptr])) |
| 394 | mymain->xbuffer[mymain->whichptr])) |
| 395 | 395 | return; /* suspension forced, can do nothing more */ |
| 396 | | main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ |
| 397 | | main->iMCU_row_ctr++; /* count rows received */ |
| 396 | mymain->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ |
| 397 | mymain->iMCU_row_ctr++; /* count rows received */ |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /* Postprocessor typically will not swallow all the input data it is handed |
| r242826 | r242827 | |
| 402 | 402 | * to exit and restart. This switch lets us keep track of how far we got. |
| 403 | 403 | * Note that each case falls through to the next on successful completion. |
| 404 | 404 | */ |
| 405 | | switch (main->context_state) { |
| 405 | switch (mymain->context_state) { |
| 406 | 406 | case CTX_POSTPONED_ROW: |
| 407 | 407 | /* Call postprocessor using previously set pointers for postponed row */ |
| 408 | | (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], |
| 409 | | &main->rowgroup_ctr, main->rowgroups_avail, |
| 408 | (*cinfo->post->post_process_data) (cinfo, mymain->xbuffer[mymain->whichptr], |
| 409 | &mymain->rowgroup_ctr, mymain->rowgroups_avail, |
| 410 | 410 | output_buf, out_row_ctr, out_rows_avail); |
| 411 | | if (main->rowgroup_ctr < main->rowgroups_avail) |
| 411 | if (mymain->rowgroup_ctr < mymain->rowgroups_avail) |
| 412 | 412 | return; /* Need to suspend */ |
| 413 | | main->context_state = CTX_PREPARE_FOR_IMCU; |
| 413 | mymain->context_state = CTX_PREPARE_FOR_IMCU; |
| 414 | 414 | if (*out_row_ctr >= out_rows_avail) |
| 415 | 415 | return; /* Postprocessor exactly filled output buf */ |
| 416 | 416 | /*FALLTHROUGH*/ |
| 417 | 417 | case CTX_PREPARE_FOR_IMCU: |
| 418 | 418 | /* Prepare to process first M-1 row groups of this iMCU row */ |
| 419 | | main->rowgroup_ctr = 0; |
| 420 | | main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1); |
| 419 | mymain->rowgroup_ctr = 0; |
| 420 | mymain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1); |
| 421 | 421 | /* Check for bottom of image: if so, tweak pointers to "duplicate" |
| 422 | 422 | * the last sample row, and adjust rowgroups_avail to ignore padding rows. |
| 423 | 423 | */ |
| 424 | | if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) |
| 424 | if (mymain->iMCU_row_ctr == cinfo->total_iMCU_rows) |
| 425 | 425 | set_bottom_pointers(cinfo); |
| 426 | | main->context_state = CTX_PROCESS_IMCU; |
| 426 | mymain->context_state = CTX_PROCESS_IMCU; |
| 427 | 427 | /*FALLTHROUGH*/ |
| 428 | 428 | case CTX_PROCESS_IMCU: |
| 429 | 429 | /* Call postprocessor using previously set pointers */ |
| 430 | | (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], |
| 431 | | &main->rowgroup_ctr, main->rowgroups_avail, |
| 430 | (*cinfo->post->post_process_data) (cinfo, mymain->xbuffer[mymain->whichptr], |
| 431 | &mymain->rowgroup_ctr, mymain->rowgroups_avail, |
| 432 | 432 | output_buf, out_row_ctr, out_rows_avail); |
| 433 | | if (main->rowgroup_ctr < main->rowgroups_avail) |
| 433 | if (mymain->rowgroup_ctr < mymain->rowgroups_avail) |
| 434 | 434 | return; /* Need to suspend */ |
| 435 | 435 | /* After the first iMCU, change wraparound pointers to normal state */ |
| 436 | | if (main->iMCU_row_ctr == 1) |
| 436 | if (mymain->iMCU_row_ctr == 1) |
| 437 | 437 | set_wraparound_pointers(cinfo); |
| 438 | 438 | /* Prepare to load new iMCU row using other xbuffer list */ |
| 439 | | main->whichptr ^= 1; /* 0=>1 or 1=>0 */ |
| 440 | | main->buffer_full = FALSE; |
| 439 | mymain->whichptr ^= 1; /* 0=>1 or 1=>0 */ |
| 440 | mymain->buffer_full = FALSE; |
| 441 | 441 | /* Still need to process last row group of this iMCU row, */ |
| 442 | 442 | /* which is saved at index M+1 of the other xbuffer */ |
| 443 | | main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1); |
| 444 | | main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2); |
| 445 | | main->context_state = CTX_POSTPONED_ROW; |
| 443 | mymain->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1); |
| 444 | mymain->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2); |
| 445 | mymain->context_state = CTX_POSTPONED_ROW; |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | 448 | |
| r242826 | r242827 | |
| 475 | 475 | GLOBAL(void) |
| 476 | 476 | jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) |
| 477 | 477 | { |
| 478 | | my_main_ptr main; |
| 478 | my_main_ptr mymain; |
| 479 | 479 | int ci, rgroup, ngroups; |
| 480 | 480 | jpeg_component_info *compptr; |
| 481 | 481 | |
| 482 | | main = (my_main_ptr) |
| 482 | mymain = (my_main_ptr) |
| 483 | 483 | (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 484 | 484 | SIZEOF(my_main_controller)); |
| 485 | | cinfo->main = (struct jpeg_d_main_controller *) main; |
| 486 | | main->pub.start_pass = start_pass_main; |
| 485 | cinfo->main = (struct jpeg_d_main_controller *) mymain; |
| 486 | mymain->pub.start_pass = start_pass_main; |
| 487 | 487 | |
| 488 | 488 | if (need_full_buffer) /* shouldn't happen */ |
| 489 | 489 | ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); |
| r242826 | r242827 | |
| 504 | 504 | ci++, compptr++) { |
| 505 | 505 | rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) / |
| 506 | 506 | cinfo->min_DCT_v_scaled_size; /* height of a row group of component */ |
| 507 | | main->buffer[ci] = (*cinfo->mem->alloc_sarray) |
| 507 | mymain->buffer[ci] = (*cinfo->mem->alloc_sarray) |
| 508 | 508 | ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 509 | 509 | compptr->width_in_blocks * compptr->DCT_h_scaled_size, |
| 510 | 510 | (JDIMENSION) (rgroup * ngroups)); |