| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jdmainct.c | 2 * jdmainct.c |
| 3 * | 3 * |
| 4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
| 5 * Copyright (C) 1994-1996, Thomas G. Lane. | 5 * Copyright (C) 1994-1996, Thomas G. Lane. |
| 6 * libjpeg-turbo Modifications: | 6 * libjpeg-turbo Modifications: |
| 7 * Copyright (C) 2010, D. R. Commander. | 7 * Copyright (C) 2010, 2016, D. R. Commander. |
| 8 * For conditions of distribution and use, see the accompanying README file. | 8 * For conditions of distribution and use, see the accompanying README.ijg |
| 9 * file. |
| 9 * | 10 * |
| 10 * This file contains the main buffer controller for decompression. | 11 * This file contains the main buffer controller for decompression. |
| 11 * The main buffer lies between the JPEG decompressor proper and the | 12 * The main buffer lies between the JPEG decompressor proper and the |
| 12 * post-processor; it holds downsampled data in the JPEG colorspace. | 13 * post-processor; it holds downsampled data in the JPEG colorspace. |
| 13 * | 14 * |
| 14 * Note that this code is bypassed in raw-data mode, since the application | 15 * Note that this code is bypassed in raw-data mode, since the application |
| 15 * supplies the equivalent of the main buffer in that case. | 16 * supplies the equivalent of the main buffer in that case. |
| 16 */ | 17 */ |
| 17 | 18 |
| 19 #include "jinclude.h" |
| 18 #include "jdmainct.h" | 20 #include "jdmainct.h" |
| 19 | 21 |
| 20 | 22 |
| 21 /* | 23 /* |
| 22 * In the current system design, the main buffer need never be a full-image | 24 * In the current system design, the main buffer need never be a full-image |
| 23 * buffer; any full-height buffers will be found inside the coefficient or | 25 * buffer; any full-height buffers will be found inside the coefficient or |
| 24 * postprocessing controllers. Nonetheless, the main controller is not | 26 * postprocessing controllers. Nonetheless, the main controller is not |
| 25 * trivial. Its responsibility is to provide context rows for upsampling/ | 27 * trivial. Its responsibility is to provide context rows for upsampling/ |
| 26 * rescaling, and doing this in an efficient fashion is a bit tricky. | 28 * rescaling, and doing this in an efficient fashion is a bit tricky. |
| 27 * | 29 * |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 * must be different (eg, we must read two iMCU rows before we can emit the | 106 * must be different (eg, we must read two iMCU rows before we can emit the |
| 105 * first row group). For now, we simply do not support providing context | 107 * first row group). For now, we simply do not support providing context |
| 106 * rows when min_DCT_scaled_size is 1. That combination seems unlikely to | 108 * rows when min_DCT_scaled_size is 1. That combination seems unlikely to |
| 107 * be worth providing --- if someone wants a 1/8th-size preview, they probably | 109 * be worth providing --- if someone wants a 1/8th-size preview, they probably |
| 108 * want it quick and dirty, so a context-free upsampler is sufficient. | 110 * want it quick and dirty, so a context-free upsampler is sufficient. |
| 109 */ | 111 */ |
| 110 | 112 |
| 111 | 113 |
| 112 /* Forward declarations */ | 114 /* Forward declarations */ |
| 113 METHODDEF(void) process_data_simple_main | 115 METHODDEF(void) process_data_simple_main |
| 114 » JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, | 116 (j_decompress_ptr cinfo, JSAMPARRAY output_buf, |
| 115 » JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); | 117 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); |
| 116 METHODDEF(void) process_data_context_main | 118 METHODDEF(void) process_data_context_main |
| 117 » JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, | 119 (j_decompress_ptr cinfo, JSAMPARRAY output_buf, |
| 118 » JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); | 120 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); |
| 119 #ifdef QUANT_2PASS_SUPPORTED | 121 #ifdef QUANT_2PASS_SUPPORTED |
| 120 METHODDEF(void) process_data_crank_post | 122 METHODDEF(void) process_data_crank_post |
| 121 » JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, | 123 (j_decompress_ptr cinfo, JSAMPARRAY output_buf, |
| 122 » JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); | 124 JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail); |
| 123 #endif | 125 #endif |
| 124 | 126 |
| 125 | 127 |
| 126 LOCAL(void) | 128 LOCAL(void) |
| 127 alloc_funny_pointers (j_decompress_ptr cinfo) | 129 alloc_funny_pointers (j_decompress_ptr cinfo) |
| 128 /* Allocate space for the funny pointer lists. | 130 /* Allocate space for the funny pointer lists. |
| 129 * This is done only once, not once per pass. | 131 * This is done only once, not once per pass. |
| 130 */ | 132 */ |
| 131 { | 133 { |
| 132 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; | 134 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; |
| 133 int ci, rgroup; | 135 int ci, rgroup; |
| 134 int M = cinfo->_min_DCT_scaled_size; | 136 int M = cinfo->_min_DCT_scaled_size; |
| 135 jpeg_component_info *compptr; | 137 jpeg_component_info *compptr; |
| 136 JSAMPARRAY xbuf; | 138 JSAMPARRAY xbuf; |
| 137 | 139 |
| 138 /* Get top-level space for component array pointers. | 140 /* Get top-level space for component array pointers. |
| 139 * We alloc both arrays with one call to save a few cycles. | 141 * We alloc both arrays with one call to save a few cycles. |
| 140 */ | 142 */ |
| 141 main_ptr->xbuffer[0] = (JSAMPIMAGE) | 143 main_ptr->xbuffer[0] = (JSAMPIMAGE) |
| 142 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 144 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 143 » » » » cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); | 145 cinfo->num_components * 2 * sizeof(JSAMPARRAY)); |
| 144 main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components; | 146 main_ptr->xbuffer[1] = main_ptr->xbuffer[0] + cinfo->num_components; |
| 145 | 147 |
| 146 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 148 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 147 ci++, compptr++) { | 149 ci++, compptr++) { |
| 148 rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / | 150 rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / |
| 149 cinfo->_min_DCT_scaled_size; /* height of a row group of component */ | 151 cinfo->_min_DCT_scaled_size; /* height of a row group of component */ |
| 150 /* Get space for pointer lists --- M+4 row groups in each list. | 152 /* Get space for pointer lists --- M+4 row groups in each list. |
| 151 * We alloc both pointer lists with one call to save a few cycles. | 153 * We alloc both pointer lists with one call to save a few cycles. |
| 152 */ | 154 */ |
| 153 xbuf = (JSAMPARRAY) | 155 xbuf = (JSAMPARRAY) |
| 154 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 156 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 155 » » » » 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); | 157 2 * (rgroup * (M + 4)) * sizeof(JSAMPROW)); |
| 156 xbuf += rgroup;» » /* want one row group at negative offsets */ | 158 xbuf += rgroup; /* want one row group at negative offsets */ |
| 157 main_ptr->xbuffer[0][ci] = xbuf; | 159 main_ptr->xbuffer[0][ci] = xbuf; |
| 158 xbuf += rgroup * (M + 4); | 160 xbuf += rgroup * (M + 4); |
| 159 main_ptr->xbuffer[1][ci] = xbuf; | 161 main_ptr->xbuffer[1][ci] = xbuf; |
| 160 } | 162 } |
| 161 } | 163 } |
| 162 | 164 |
| 163 | 165 |
| 164 LOCAL(void) | 166 LOCAL(void) |
| 165 make_funny_pointers (j_decompress_ptr cinfo) | 167 make_funny_pointers (j_decompress_ptr cinfo) |
| 166 /* Create the funny pointer lists discussed in the comments above. | 168 /* Create the funny pointer lists discussed in the comments above. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 METHODDEF(void) | 250 METHODDEF(void) |
| 249 start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) | 251 start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) |
| 250 { | 252 { |
| 251 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; | 253 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; |
| 252 | 254 |
| 253 switch (pass_mode) { | 255 switch (pass_mode) { |
| 254 case JBUF_PASS_THRU: | 256 case JBUF_PASS_THRU: |
| 255 if (cinfo->upsample->need_context_rows) { | 257 if (cinfo->upsample->need_context_rows) { |
| 256 main_ptr->pub.process_data = process_data_context_main; | 258 main_ptr->pub.process_data = process_data_context_main; |
| 257 make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ | 259 make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ |
| 258 main_ptr->whichptr = 0;» /* Read first iMCU row into xbuffer[0] */ | 260 main_ptr->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ |
| 259 main_ptr->context_state = CTX_PREPARE_FOR_IMCU; | 261 main_ptr->context_state = CTX_PREPARE_FOR_IMCU; |
| 260 main_ptr->iMCU_row_ctr = 0; | 262 main_ptr->iMCU_row_ctr = 0; |
| 261 } else { | 263 } else { |
| 262 /* Simple case with no context needed */ | 264 /* Simple case with no context needed */ |
| 263 main_ptr->pub.process_data = process_data_simple_main; | 265 main_ptr->pub.process_data = process_data_simple_main; |
| 264 } | 266 } |
| 265 main_ptr->buffer_full = FALSE;» /* Mark buffer empty */ | 267 main_ptr->buffer_full = FALSE; /* Mark buffer empty */ |
| 266 main_ptr->rowgroup_ctr = 0; | 268 main_ptr->rowgroup_ctr = 0; |
| 267 break; | 269 break; |
| 268 #ifdef QUANT_2PASS_SUPPORTED | 270 #ifdef QUANT_2PASS_SUPPORTED |
| 269 case JBUF_CRANK_DEST: | 271 case JBUF_CRANK_DEST: |
| 270 /* For last pass of 2-pass quantization, just crank the postprocessor */ | 272 /* For last pass of 2-pass quantization, just crank the postprocessor */ |
| 271 main_ptr->pub.process_data = process_data_crank_post; | 273 main_ptr->pub.process_data = process_data_crank_post; |
| 272 break; | 274 break; |
| 273 #endif | 275 #endif |
| 274 default: | 276 default: |
| 275 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); | 277 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); |
| 276 break; | 278 break; |
| 277 } | 279 } |
| 278 } | 280 } |
| 279 | 281 |
| 280 | 282 |
| 281 /* | 283 /* |
| 282 * Process some data. | 284 * Process some data. |
| 283 * This handles the simple case where no context is required. | 285 * This handles the simple case where no context is required. |
| 284 */ | 286 */ |
| 285 | 287 |
| 286 METHODDEF(void) | 288 METHODDEF(void) |
| 287 process_data_simple_main (j_decompress_ptr cinfo, | 289 process_data_simple_main (j_decompress_ptr cinfo, |
| 288 » » » JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, | 290 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
| 289 » » » JDIMENSION out_rows_avail) | 291 JDIMENSION out_rows_avail) |
| 290 { | 292 { |
| 291 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; | 293 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; |
| 292 JDIMENSION rowgroups_avail; | 294 JDIMENSION rowgroups_avail; |
| 293 | 295 |
| 294 /* Read input data if we haven't filled the main buffer yet */ | 296 /* Read input data if we haven't filled the main buffer yet */ |
| 295 if (! main_ptr->buffer_full) { | 297 if (! main_ptr->buffer_full) { |
| 296 if (! (*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer)) | 298 if (! (*cinfo->coef->decompress_data) (cinfo, main_ptr->buffer)) |
| 297 return;» » » /* suspension forced, can do nothing more */ | 299 return; /* suspension forced, can do nothing more */ |
| 298 main_ptr->buffer_full = TRUE;» /* OK, we have an iMCU row to work with
*/ | 300 main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with
*/ |
| 299 } | 301 } |
| 300 | 302 |
| 301 /* There are always min_DCT_scaled_size row groups in an iMCU row. */ | 303 /* There are always min_DCT_scaled_size row groups in an iMCU row. */ |
| 302 rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size; | 304 rowgroups_avail = (JDIMENSION) cinfo->_min_DCT_scaled_size; |
| 303 /* Note: at the bottom of the image, we may pass extra garbage row groups | 305 /* Note: at the bottom of the image, we may pass extra garbage row groups |
| 304 * to the postprocessor. The postprocessor has to check for bottom | 306 * to the postprocessor. The postprocessor has to check for bottom |
| 305 * of image anyway (at row resolution), so no point in us doing it too. | 307 * of image anyway (at row resolution), so no point in us doing it too. |
| 306 */ | 308 */ |
| 307 | 309 |
| 308 /* Feed the postprocessor */ | 310 /* Feed the postprocessor */ |
| 309 (*cinfo->post->post_process_data) (cinfo, main_ptr->buffer, | 311 (*cinfo->post->post_process_data) (cinfo, main_ptr->buffer, |
| 310 » » » » &main_ptr->rowgroup_ctr, rowgroups_avail, | 312 &main_ptr->rowgroup_ctr, rowgroups_avail, |
| 311 » » » » output_buf, out_row_ctr, out_rows_avail); | 313 output_buf, out_row_ctr, out_rows_avail); |
| 312 | 314 |
| 313 /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ | 315 /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ |
| 314 if (main_ptr->rowgroup_ctr >= rowgroups_avail) { | 316 if (main_ptr->rowgroup_ctr >= rowgroups_avail) { |
| 315 main_ptr->buffer_full = FALSE; | 317 main_ptr->buffer_full = FALSE; |
| 316 main_ptr->rowgroup_ctr = 0; | 318 main_ptr->rowgroup_ctr = 0; |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 | 322 |
| 321 /* | 323 /* |
| 322 * Process some data. | 324 * Process some data. |
| 323 * This handles the case where context rows must be provided. | 325 * This handles the case where context rows must be provided. |
| 324 */ | 326 */ |
| 325 | 327 |
| 326 METHODDEF(void) | 328 METHODDEF(void) |
| 327 process_data_context_main (j_decompress_ptr cinfo, | 329 process_data_context_main (j_decompress_ptr cinfo, |
| 328 » » » JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, | 330 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
| 329 » » » JDIMENSION out_rows_avail) | 331 JDIMENSION out_rows_avail) |
| 330 { | 332 { |
| 331 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; | 333 my_main_ptr main_ptr = (my_main_ptr) cinfo->main; |
| 332 | 334 |
| 333 /* Read input data if we haven't filled the main buffer yet */ | 335 /* Read input data if we haven't filled the main buffer yet */ |
| 334 if (! main_ptr->buffer_full) { | 336 if (! main_ptr->buffer_full) { |
| 335 if (! (*cinfo->coef->decompress_data) (cinfo, | 337 if (! (*cinfo->coef->decompress_data) (cinfo, |
| 336 » » » » » main_ptr->xbuffer[main_ptr->whichptr]
)) | 338 main_ptr->xbuffer[main_ptr->whichptr]
)) |
| 337 return;» » » /* suspension forced, can do nothing more */ | 339 return; /* suspension forced, can do nothing more */ |
| 338 main_ptr->buffer_full = TRUE;» /* OK, we have an iMCU row to work with
*/ | 340 main_ptr->buffer_full = TRUE; /* OK, we have an iMCU row to work with
*/ |
| 339 main_ptr->iMCU_row_ctr++;» /* count rows received */ | 341 main_ptr->iMCU_row_ctr++; /* count rows received */ |
| 340 } | 342 } |
| 341 | 343 |
| 342 /* Postprocessor typically will not swallow all the input data it is handed | 344 /* Postprocessor typically will not swallow all the input data it is handed |
| 343 * in one call (due to filling the output buffer first). Must be prepared | 345 * in one call (due to filling the output buffer first). Must be prepared |
| 344 * to exit and restart. This switch lets us keep track of how far we got. | 346 * to exit and restart. This switch lets us keep track of how far we got. |
| 345 * Note that each case falls through to the next on successful completion. | 347 * Note that each case falls through to the next on successful completion. |
| 346 */ | 348 */ |
| 347 switch (main_ptr->context_state) { | 349 switch (main_ptr->context_state) { |
| 348 case CTX_POSTPONED_ROW: | 350 case CTX_POSTPONED_ROW: |
| 349 /* Call postprocessor using previously set pointers for postponed row */ | 351 /* Call postprocessor using previously set pointers for postponed row */ |
| 350 (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichp
tr], | 352 (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichp
tr], |
| 351 » » » &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail, | 353 &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail, |
| 352 » » » output_buf, out_row_ctr, out_rows_avail); | 354 output_buf, out_row_ctr, out_rows_avail); |
| 353 if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail) | 355 if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail) |
| 354 return;» » » /* Need to suspend */ | 356 return; /* Need to suspend */ |
| 355 main_ptr->context_state = CTX_PREPARE_FOR_IMCU; | 357 main_ptr->context_state = CTX_PREPARE_FOR_IMCU; |
| 356 if (*out_row_ctr >= out_rows_avail) | 358 if (*out_row_ctr >= out_rows_avail) |
| 357 return;» » » /* Postprocessor exactly filled output buf */ | 359 return; /* Postprocessor exactly filled output buf */ |
| 358 /*FALLTHROUGH*/ | 360 /*FALLTHROUGH*/ |
| 359 case CTX_PREPARE_FOR_IMCU: | 361 case CTX_PREPARE_FOR_IMCU: |
| 360 /* Prepare to process first M-1 row groups of this iMCU row */ | 362 /* Prepare to process first M-1 row groups of this iMCU row */ |
| 361 main_ptr->rowgroup_ctr = 0; | 363 main_ptr->rowgroup_ctr = 0; |
| 362 main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1); | 364 main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size - 1); |
| 363 /* Check for bottom of image: if so, tweak pointers to "duplicate" | 365 /* Check for bottom of image: if so, tweak pointers to "duplicate" |
| 364 * the last sample row, and adjust rowgroups_avail to ignore padding rows. | 366 * the last sample row, and adjust rowgroups_avail to ignore padding rows. |
| 365 */ | 367 */ |
| 366 if (main_ptr->iMCU_row_ctr == cinfo->total_iMCU_rows) | 368 if (main_ptr->iMCU_row_ctr == cinfo->total_iMCU_rows) |
| 367 set_bottom_pointers(cinfo); | 369 set_bottom_pointers(cinfo); |
| 368 main_ptr->context_state = CTX_PROCESS_IMCU; | 370 main_ptr->context_state = CTX_PROCESS_IMCU; |
| 369 /*FALLTHROUGH*/ | 371 /*FALLTHROUGH*/ |
| 370 case CTX_PROCESS_IMCU: | 372 case CTX_PROCESS_IMCU: |
| 371 /* Call postprocessor using previously set pointers */ | 373 /* Call postprocessor using previously set pointers */ |
| 372 (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichp
tr], | 374 (*cinfo->post->post_process_data) (cinfo, main_ptr->xbuffer[main_ptr->whichp
tr], |
| 373 » » » &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail, | 375 &main_ptr->rowgroup_ctr, main_ptr->rowgroups_avail, |
| 374 » » » output_buf, out_row_ctr, out_rows_avail); | 376 output_buf, out_row_ctr, out_rows_avail); |
| 375 if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail) | 377 if (main_ptr->rowgroup_ctr < main_ptr->rowgroups_avail) |
| 376 return;» » » /* Need to suspend */ | 378 return; /* Need to suspend */ |
| 377 /* After the first iMCU, change wraparound pointers to normal state */ | 379 /* After the first iMCU, change wraparound pointers to normal state */ |
| 378 if (main_ptr->iMCU_row_ctr == 1) | 380 if (main_ptr->iMCU_row_ctr == 1) |
| 379 set_wraparound_pointers(cinfo); | 381 set_wraparound_pointers(cinfo); |
| 380 /* Prepare to load new iMCU row using other xbuffer list */ | 382 /* Prepare to load new iMCU row using other xbuffer list */ |
| 381 main_ptr->whichptr ^= 1;» /* 0=>1 or 1=>0 */ | 383 main_ptr->whichptr ^= 1; /* 0=>1 or 1=>0 */ |
| 382 main_ptr->buffer_full = FALSE; | 384 main_ptr->buffer_full = FALSE; |
| 383 /* Still need to process last row group of this iMCU row, */ | 385 /* Still need to process last row group of this iMCU row, */ |
| 384 /* which is saved at index M+1 of the other xbuffer */ | 386 /* which is saved at index M+1 of the other xbuffer */ |
| 385 main_ptr->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1); | 387 main_ptr->rowgroup_ctr = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 1); |
| 386 main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2); | 388 main_ptr->rowgroups_avail = (JDIMENSION) (cinfo->_min_DCT_scaled_size + 2); |
| 387 main_ptr->context_state = CTX_POSTPONED_ROW; | 389 main_ptr->context_state = CTX_POSTPONED_ROW; |
| 388 } | 390 } |
| 389 } | 391 } |
| 390 | 392 |
| 391 | 393 |
| 392 /* | 394 /* |
| 393 * Process some data. | 395 * Process some data. |
| 394 * Final pass of two-pass quantization: just call the postprocessor. | 396 * Final pass of two-pass quantization: just call the postprocessor. |
| 395 * Source data will be the postprocessor controller's internal buffer. | 397 * Source data will be the postprocessor controller's internal buffer. |
| 396 */ | 398 */ |
| 397 | 399 |
| 398 #ifdef QUANT_2PASS_SUPPORTED | 400 #ifdef QUANT_2PASS_SUPPORTED |
| 399 | 401 |
| 400 METHODDEF(void) | 402 METHODDEF(void) |
| 401 process_data_crank_post (j_decompress_ptr cinfo, | 403 process_data_crank_post (j_decompress_ptr cinfo, |
| 402 » » » JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, | 404 JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, |
| 403 » » » JDIMENSION out_rows_avail) | 405 JDIMENSION out_rows_avail) |
| 404 { | 406 { |
| 405 (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, | 407 (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, |
| 406 » » » » (JDIMENSION *) NULL, (JDIMENSION) 0, | 408 (JDIMENSION *) NULL, (JDIMENSION) 0, |
| 407 » » » » output_buf, out_row_ctr, out_rows_avail); | 409 output_buf, out_row_ctr, out_rows_avail); |
| 408 } | 410 } |
| 409 | 411 |
| 410 #endif /* QUANT_2PASS_SUPPORTED */ | 412 #endif /* QUANT_2PASS_SUPPORTED */ |
| 411 | 413 |
| 412 | 414 |
| 413 /* | 415 /* |
| 414 * Initialize main buffer controller. | 416 * Initialize main buffer controller. |
| 415 */ | 417 */ |
| 416 | 418 |
| 417 GLOBAL(void) | 419 GLOBAL(void) |
| 418 jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) | 420 jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) |
| 419 { | 421 { |
| 420 my_main_ptr main_ptr; | 422 my_main_ptr main_ptr; |
| 421 int ci, rgroup, ngroups; | 423 int ci, rgroup, ngroups; |
| 422 jpeg_component_info *compptr; | 424 jpeg_component_info *compptr; |
| 423 | 425 |
| 424 main_ptr = (my_main_ptr) | 426 main_ptr = (my_main_ptr) |
| 425 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, | 427 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 426 » » » » SIZEOF(my_main_controller)); | 428 sizeof(my_main_controller)); |
| 427 cinfo->main = (struct jpeg_d_main_controller *) main_ptr; | 429 cinfo->main = (struct jpeg_d_main_controller *) main_ptr; |
| 428 main_ptr->pub.start_pass = start_pass_main; | 430 main_ptr->pub.start_pass = start_pass_main; |
| 429 | 431 |
| 430 if (need_full_buffer)»» /* shouldn't happen */ | 432 if (need_full_buffer) /* shouldn't happen */ |
| 431 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); | 433 ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); |
| 432 | 434 |
| 433 /* Allocate the workspace. | 435 /* Allocate the workspace. |
| 434 * ngroups is the number of row groups we need. | 436 * ngroups is the number of row groups we need. |
| 435 */ | 437 */ |
| 436 if (cinfo->upsample->need_context_rows) { | 438 if (cinfo->upsample->need_context_rows) { |
| 437 if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */ | 439 if (cinfo->_min_DCT_scaled_size < 2) /* unsupported, see comments above */ |
| 438 ERREXIT(cinfo, JERR_NOTIMPL); | 440 ERREXIT(cinfo, JERR_NOTIMPL); |
| 439 alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ | 441 alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ |
| 440 ngroups = cinfo->_min_DCT_scaled_size + 2; | 442 ngroups = cinfo->_min_DCT_scaled_size + 2; |
| 441 } else { | 443 } else { |
| 442 ngroups = cinfo->_min_DCT_scaled_size; | 444 ngroups = cinfo->_min_DCT_scaled_size; |
| 443 } | 445 } |
| 444 | 446 |
| 445 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 447 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 446 ci++, compptr++) { | 448 ci++, compptr++) { |
| 447 rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / | 449 rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / |
| 448 cinfo->_min_DCT_scaled_size; /* height of a row group of component */ | 450 cinfo->_min_DCT_scaled_size; /* height of a row group of component */ |
| 449 main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray) | 451 main_ptr->buffer[ci] = (*cinfo->mem->alloc_sarray) |
| 450 » » » ((j_common_ptr) cinfo, JPOOL_IMAGE, | 452 ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 451 » » » compptr->width_in_blocks * compptr->_DCT_scaled_size, | 453 compptr->width_in_blocks * compptr->_DCT_scaled_size, |
| 452 » » » (JDIMENSION) (rgroup * ngroups)); | 454 (JDIMENSION) (rgroup * ngroups)); |
| 453 } | 455 } |
| 454 } | 456 } |
| OLD | NEW |