📄 jdmainct.c
字号:
*out_row_ctr+= (cinfo->max_v_samp_factor << 3)*cinfo->total_iMCU_rows; // to signal the caller function to exit its loop #else my_main_ptr main = (my_main_ptr) cinfo->main; while (main->iMCU_row_ctr < cinfo->total_iMCU_rows) { *out_row_ctr+= cinfo->max_v_samp_factor << 3; if (! (*cinfo->coef->decompress_data) (cinfo,NULL)) //decompress_onepass() return; // suspension forced, can do nothing more main->iMCU_row_ctr++; } #endif/* // Read input data if we haven't filled the main buffer yet if (! main->buffer_full) { if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) return; // suspension forced, can do nothing more main->buffer_full = TRUE; // OK, we have an iMCU row to work with } // There are always min_DCT_scaled_size row groups in an iMCU row. rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; // Note: at the bottom of the image, we may pass extra garbage row groups // to the postprocessor. The postprocessor has to check for bottom // of image anyway (at row resolution), so no point in us doing it too. // // Feed the postprocessor (*cinfo->post->post_process_data) (cinfo, main->buffer, &main->rowgroup_ctr, rowgroups_avail, output_buf, out_row_ctr, out_rows_avail); // Has postprocessor consumed all the data yet? If so, mark buffer empty if (main->rowgroup_ctr >= rowgroups_avail) { main->buffer_full = FALSE; main->rowgroup_ctr = 0; }*/}/* * Process some data. * This handles the case where context rows must be provided. */METHODDEF(void)process_data_context_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail){ #ifdef USE_INTERNAL_CPU (*cinfo->coef->decompress_data) (cinfo,NULL); //decompress_onepass() *out_row_ctr+= (cinfo->max_v_samp_factor << 3)*cinfo->total_iMCU_rows; // to signal the caller function to exit its loop #else my_main_ptr main = (my_main_ptr) cinfo->main; while (main->iMCU_row_ctr < cinfo->total_iMCU_rows) { *out_row_ctr+= cinfo->max_v_samp_factor << 3; if (! (*cinfo->coef->decompress_data) (cinfo,NULL)) //decompress_onepass() return; /* suspension forced, can do nothing more */ main->iMCU_row_ctr++; } #endif/* // Read input data if we haven't filled the main buffer yet if (! main->buffer_full) { if (! (*cinfo->coef->decompress_data) (cinfo, main->xbuffer[main->whichptr])) //pwhsu:20031031 //decompress_onepass() return; // suspension forced, can do nothing more main->buffer_full = TRUE; // OK, we have an iMCU row to work with main->iMCU_row_ctr++; // count rows received } // Postprocessor typically will not swallow all the input data it is handed // in one call (due to filling the output buffer first). Must be prepared // to exit and restart. This switch lets us keep track of how far we got. // Note that each case falls through to the next on successful completion. // switch (main->context_state) { case CTX_POSTPONED_ROW: // Call postprocessor using previously set pointers for postponed row (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], &main->rowgroup_ctr, main->rowgroups_avail, output_buf, out_row_ctr, out_rows_avail); if (main->rowgroup_ctr < main->rowgroups_avail) return; // Need to suspend main->context_state = CTX_PREPARE_FOR_IMCU; if (*out_row_ctr >= out_rows_avail) return; // Postprocessor exactly filled output buf //FALLTHROUGH case CTX_PREPARE_FOR_IMCU: // Prepare to process first M-1 row groups of this iMCU row main->rowgroup_ctr = 0; main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); // Check for bottom of image: if so, tweak pointers to "duplicate" // the last sample row, and adjust rowgroups_avail to ignore padding rows. // if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) set_bottom_pointers(cinfo); main->context_state = CTX_PROCESS_IMCU; //FALLTHROUGH case CTX_PROCESS_IMCU: // Call postprocessor using previously set pointers (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], &main->rowgroup_ctr, main->rowgroups_avail, output_buf, out_row_ctr, out_rows_avail); if (main->rowgroup_ctr < main->rowgroups_avail) return; // Need to suspend // After the first iMCU, change wraparound pointers to normal state if (main->iMCU_row_ctr == 1) set_wraparound_pointers(cinfo); // Prepare to load new iMCU row using other xbuffer list main->whichptr ^= 1; // 0=>1 or 1=>0 main->buffer_full = FALSE; // Still need to process last row group of this iMCU row, // which is saved at index M+1 of the other xbuffer main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); main->context_state = CTX_POSTPONED_ROW; }*/}/* * Process some data. * Final pass of two-pass quantization: just call the postprocessor. * Source data will be the postprocessor controller's internal buffer. */#ifdef QUANT_2PASS_SUPPORTEDMETHODDEF(void)process_data_crank_post (j_decompress_ptr cinfo, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail){ (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, (JDIMENSION *) NULL, (JDIMENSION) 0, output_buf, out_row_ctr, out_rows_avail);}#endif /* QUANT_2PASS_SUPPORTED *//* * Initialize main buffer controller. */GLOBAL(void)jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer){ my_main_ptr main; int ci, rgroup, ngroups; jpeg_component_info *compptr; main = (my_main_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller)); cinfo->main = (struct jpeg_d_main_controller *) main; main->pub.start_pass = start_pass_main; if (need_full_buffer) /* shouldn't happen */ ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); /* Allocate the workspace. * ngroups is the number of row groups we need. */ if (cinfo->upsample->need_context_rows) { if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ ERREXIT(cinfo, JERR_NOTIMPL); alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ ngroups = cinfo->min_DCT_scaled_size + 2; } else { ngroups = cinfo->min_DCT_scaled_size; } for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / cinfo->min_DCT_scaled_size; /* height of a row group of component */ main->buffer[ci] = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, compptr->width_in_blocks * compptr->DCT_scaled_size, (JDIMENSION) (rgroup * ngroups)); }}GLOBAL(void) generate_dma_chain_table (j_decompress_ptr cinfo,unsigned int MCU_col_num,int buf_descriptor){ my_main_ptr main = (my_main_ptr) cinfo->main; FTMCP100_CODEC *pCodec=(FTMCP100_CODEC *)cinfo->pCodec; int xp; // the x axis's position in char length within each component's output buffer int yp; // the y axis's position in char length within each component's output buffer int ci; // the component index which is merely used for counter purpose int xi; // the x (horizontal) block index within each MCU and is merely used for counter purpose int yi; // the y (vertical) block index within each MCU and is merely used for counter purpose jpeg_component_info *compptr; // the component's pointer unsigned char *p; // the pointer to the beginning of each component's output buffer unsigned char *mp; // beginning of each MCU's pointer unsigned char *s; // the final system address int n = buf_descriptor*40; // the index for pLDMA array int width; #if (defined(CORE_VERSION_2) && defined(USING_AUTO_INCREMNET)) // because of ping-pong buffer, we just set the auto-increment // mechanism for MCU 0 & 1 if(MCU_col_num==0 || MCU_col_num==1) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr=cinfo->cur_comp_info[ci]; p=pCodec->outdata[compptr->component_index]; width=compptr->MCU_width*cinfo->MCUs_per_row*DCTSIZE; xp=MCU_col_num * compptr->MCU_sample_width; // x axis position //yp=(main->iMCU_row_ctr*(compptr->v_samp_factor*DCTSIZE))*(compptr->MCU_sample_width*compptr->MCU_width); yp=main->iMCU_row_ctr*compptr->MCU_height*DCTSIZE; // y axis position mp=p+(yp*width+xp); for(yi=0;yi<compptr->MCU_height;yi++) { for(xi=0;xi<compptr->MCU_width;xi++,n+=4) { // the auto-increment size is about 2*(compptr->MCU_width*DCTSIZE) for // each System Memory Base Register in DMA ping-pong buffer. // And becasue by JPEG standard, the available horizontal and vertical // sampling factor can be only 1,2,3 or 4. So the increment size for // bit 0~2 in System Memory Base Register can be 16,32,48 and 64 bytes // repsectively , which is corresponding to the hardware register setting // 1,2,3,4. // So, you can set the 'Increment Index' field of System Memory Base Address // Register to the 'compptr->MCU_width' directly which is corresponding to the // horizontal sampling factor. s=mp+((yi*width+xi)*DCTSIZE); pCodec->pLDMA[n] = (unsigned int) s | (compptr->MCU_width); } // end of xi } // end of yi } // end of ci } #else for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr=cinfo->cur_comp_info[ci]; p=pCodec->outdata[compptr->component_index]; width=compptr->MCU_width*cinfo->MCUs_per_row*DCTSIZE; xp=MCU_col_num * compptr->MCU_sample_width; // x axis position //yp=(main->iMCU_row_ctr*(compptr->v_samp_factor*DCTSIZE))*(compptr->MCU_sample_width*compptr->MCU_width); yp=main->iMCU_row_ctr*compptr->MCU_height*DCTSIZE; // y axis position mp=p+(yp*width+xp); for(yi=0;yi<compptr->MCU_height;yi++) { for(xi=0;xi<compptr->MCU_width;xi++,n+=4) { s=mp+((yi*width+xi)*DCTSIZE); pCodec->pLDMA[n] = (unsigned int) s; } // end of xi } // end of yi } // end of ci #endif}GLOBAL(void) generate_dma_noninterleaved_chain_table (j_decompress_ptr cinfo,unsigned int MCU_col_num,unsigned int MCU_row_num,int buf_descriptor){ //my_main_ptr main = (my_main_ptr) cinfo->main; FTMCP100_CODEC *pCodec=(FTMCP100_CODEC *)cinfo->pCodec; int xp; // the x axis's position in char length within each component's output buffer int yp; // the y axis's position in char length within each component's output buffer int ci; // the component index which is merely used for counter purpose int xi; // the x (horizontal) block index within each MCU and is merely used for counter purpose int yi; // the y (vertical) block index within each MCU and is merely used for counter purpose jpeg_component_info *compptr; // the component's pointer unsigned char *p; // the pointer to the beginning of each component's output buffer unsigned char *mp; // beginning of each MCU's pointer unsigned char *s; // the final system address int n = buf_descriptor*40; // the index for pLDMA array int width; #if (defined(CORE_VERSION_2) && defined(USING_AUTO_INCREMNET)) // because of ping-pong buffer, we just set the auto-increment // mechanism for MCU 0 & 1 if(MCU_col_num==0 || MCU_col_num==1) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr=cinfo->cur_comp_info[ci]; p=pCodec->outdata[compptr->component_index]; width=compptr->MCU_width*cinfo->MCUs_per_row*DCTSIZE; xp=MCU_col_num * compptr->MCU_sample_width; // x axis position //yp=(main->iMCU_row_ctr*(compptr->v_samp_factor*DCTSIZE))*(compptr->MCU_sample_width*compptr->MCU_width); //yp=main->iMCU_row_ctr*compptr->MCU_height*DCTSIZE; // y axis position yp=MCU_row_num*compptr->MCU_height*DCTSIZE; // y axis position mp=p+(yp*width+xp); for(yi=0;yi<compptr->MCU_height;yi++) { for(xi=0;xi<compptr->MCU_width;xi++,n+=4) { // the auto-increment size is about 2*(compptr->MCU_width*DCTSIZE) for // each System Memory Base Register in DMA ping-pong buffer. // And becasue by JPEG standard, the available horizontal and vertical // sampling factor can be only 1,2,3 or 4. So the increment size for // bit 0~2 in System Memory Base Register can be 16,32,48 and 64 bytes // repsectively , which is corresponding to the hardware register setting // 1,2,3,4. // So, you can set the 'Increment Index' field of System Memory Base Address // Register to the 'compptr->MCU_width' directly which is corresponding to the // horizontal sampling factor. s=mp+((yi*width+xi)*DCTSIZE); pCodec->pLDMA[n] = (unsigned int) s | (compptr->MCU_width); } // end of xi } // end of yi } // end of ci } #else for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr=cinfo->cur_comp_info[ci]; p=pCodec->outdata[compptr->component_index]; width=compptr->MCU_width*cinfo->MCUs_per_row*DCTSIZE; xp=MCU_col_num * compptr->MCU_sample_width; // x axis position //yp=(main->iMCU_row_ctr*(compptr->v_samp_factor*DCTSIZE))*(compptr->MCU_sample_width*compptr->MCU_width); //yp=main->iMCU_row_ctr*compptr->MCU_height*DCTSIZE; // y axis position yp=MCU_row_num*compptr->MCU_height*DCTSIZE; // y axis position mp=p+(yp*width+xp); for(yi=0;yi<compptr->MCU_height;yi++) { for(xi=0;xi<compptr->MCU_width;xi++,n+=4) { s=mp+((yi*width+xi)*DCTSIZE); pCodec->pLDMA[n] = (unsigned int) s; } // end of xi } // end of yi } // end of ci #endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -