📄 jcmaster.c
字号:
compptr->last_col_width = 1; for(i=0;i<compptr->MCU_blocks;i++){ DMA_COMMAND_local[2+blkidx*4] = ((( cinfo->MCUs_per_row * compptr->MCU_width)*2-1)<<8) | 0x02; DMA_COMMAND_local[42+blkidx*4] = ((( cinfo->MCUs_per_row * compptr->MCU_width)*2-1)<<8) | 0x02; blkidx++; } /* For noninterleaved scans, it is convenient to define last_row_height * as the number of block rows present in the last iMCU row. */ tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); if (tmp == 0) tmp = compptr->v_samp_factor; compptr->last_row_height = tmp; /* Prepare array describing MCU composition */ cinfo->blocks_in_MCU = 1; cinfo->MCU_membership[0] = 0; mcublkn = compptr->MCU_blocks; //pwhsu++:20040108 tbidx0 = compptr->ac_tbl_no; tbidx0 = (tbidx0<<1) | compptr->dc_tbl_no; tbidx0 = (tbidx0<<2) | compptr->quant_tbl_no; tbidx0 = tbidx0 & 0xf; Comp_member = 0x0; tbidx = tbidx0; imginfo = (tbidx<<20) | (Comp_member&0xfffff); } else { /* Interleaved (multi-component) scan */ if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, MAX_COMPS_IN_SCAN); /* Overall image size in MCUs */ cinfo->MCUs_per_row = (JDIMENSION) jdiv_round_up((long) cinfo->image_width, (long) (cinfo->max_h_samp_factor*DCTSIZE)); cinfo->MCU_rows_in_scan = (JDIMENSION) jdiv_round_up((long) cinfo->image_height, (long) (cinfo->max_v_samp_factor*DCTSIZE)); cinfo->blocks_in_MCU = 0; for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; /* Sampling factors give # of blocks of component in each MCU */ compptr->MCU_width = compptr->h_samp_factor; compptr->MCU_height = compptr->v_samp_factor; compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; for(i=0;i<compptr->MCU_blocks;i++){ DMA_COMMAND_local[2+blkidx*4] = ((( cinfo->MCUs_per_row * compptr->MCU_width)*2-1)<<8) | 0x02; DMA_COMMAND_local[42+blkidx*4] = ((( cinfo->MCUs_per_row * compptr->MCU_width)*2-1)<<8) | 0x02; blkidx++; } /* Figure number of non-dummy blocks in last MCU column & row */ tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); if (tmp == 0) tmp = compptr->MCU_width; compptr->last_col_width = tmp; tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); if (tmp == 0) tmp = compptr->MCU_height; compptr->last_row_height = tmp; /* Prepare array describing MCU composition */ mcublks = compptr->MCU_blocks; mcublkn = mcublkn + compptr->MCU_blocks; //pwhsu++:20040108 if ( ci==0 ){ //pwhsu++:20040108 tbidx0 = compptr->ac_tbl_no; tbidx0 = (tbidx0<<1) | compptr->dc_tbl_no; tbidx0 = (tbidx0<<2) | compptr->quant_tbl_no; tbidx0 = tbidx0 & 0xf; }else if ( ci==1 ){ tbidx1 = compptr->ac_tbl_no; tbidx1 = (tbidx1<<1) | compptr->dc_tbl_no; tbidx1 = (tbidx1<<2) | compptr->quant_tbl_no; tbidx1 = tbidx1 & 0xf; }else if ( ci==2 ){ tbidx2 = compptr->ac_tbl_no; tbidx2 = (tbidx2<<1) | compptr->dc_tbl_no; tbidx2 = (tbidx2<<2) | compptr->quant_tbl_no; tbidx2 = tbidx2 & 0xf; } if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) //pwhsu:20031016 C_MAX_BLOCKS_IN_MCU = 10 ERREXIT(cinfo, JERR_BAD_MCU_SIZE); while (mcublks-- > 0) { cinfo->MCU_membership[cinfo->blocks_in_MCU] = ci; //rinfo.MCU_membership[cinfo->blocks_in_MCU] = ci; //pwhsu++:20031023 Comp_member = Comp_member | ci << 2*icount; //pwhsu++:20040108 cinfo->blocks_in_MCU++; icount = icount + 1; } } tbidx = (tbidx2<<8) | (tbidx1<<4) | tbidx0; //pwhsu++:20040108 imginfo = (tbidx<<20) | (Comp_member&0xfffff); } //pwhsu++:20040108 SET_MCUBR(mcublkn); SET_MCUTIR(imginfo); rinfo.mcublkn = mcublkn; DMA_COMMAND_local[mcublkn*4-1] = 0x810010; //chain disable DMA_COMMAND_local[mcublkn*4+39] = 0x810010; //chain disable //DMA_COMMAND_local[3+(blkn-1)*4+dbnum*40] = 0x810010; //chain disable /* Convert restart specified in rows to actual MCU count. */ /* Note that count must fit in 16 bits, so we provide limiting. */ if (cinfo->restart_in_rows > 0) { long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); }}/* * Per-pass setup. * This is called at the beginning of each pass. We determine which modules * will be active during this pass and give them appropriate start_pass calls. * We also set is_last_pass to indicate whether any more passes will be * required. */METHODDEF(void)prepare_for_pass (j_compress_ptr cinfo){ my_master_ptr master = (my_master_ptr) cinfo->master; switch (master->pass_type) { case main_pass: /* Initial pass: will collect input data, and do either Huffman * optimization or data output for the first scan. */ select_scan_parameters(cinfo); per_scan_setup(cinfo); //pwhsu:20031016 setup the MCU number //(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); //pwhsu:20031009 start_pass_huff start_pass_huff1(cinfo); (*cinfo->coef->start_pass) (cinfo, (master->total_passes > 1 ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); //pwhsu:20031009 start_pass_coef (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); //pwhsu:20031009 start_pass_main// if (cinfo->optimize_coding) { /* No immediate data output; postpone writing frame/scan headers */// master->pub.call_pass_startup = FALSE;// } else { //pwhsu:20031009 The condition will execute this part /* Will write frame/scan headers at first jpeg_write_scanlines call */ master->pub.call_pass_startup = TRUE;// } break; default: ERREXIT(cinfo, JERR_NOT_COMPILED); } master->pub.is_last_pass = (master->pass_number == master->total_passes-1);#if 0 /* Set up progress monitor's pass info if present */ if (cinfo->progress != NULL) { //pwhsu:20031009 ぃ穦磅︽ cinfo->progress->completed_passes = master->pass_number; cinfo->progress->total_passes = master->total_passes; }#endif}/* * Special start-of-pass hook. * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. * In single-pass processing, we need this hook because we don't want to * write frame/scan headers during jpeg_start_compress; we want to let the * application write COM markers etc. between jpeg_start_compress and the * jpeg_write_scanlines loop. * In multi-pass processing, this routine is not used. */METHODDEF(void)pass_startup (j_compress_ptr cinfo){ cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ //(*cinfo->marker->write_frame_header) (cinfo); //pwhsu:20031015 write_frame_header() //(*cinfo->marker->write_scan_header) (cinfo); //pwhsu:20031015 write_scan_header() write_frame_header1(cinfo); write_scan_header1(cinfo);}/* * Finish up at end of pass. */METHODDEF(void)finish_pass_master (j_compress_ptr cinfo){ my_master_ptr master = (my_master_ptr) cinfo->master; /* The entropy coder always needs an end-of-pass call, * either to analyze statistics or to flush its output buffer. */ (*cinfo->entropy->finish_pass) (cinfo); //pwhsu:20031027 finish_pass_huff() /* Update state for next pass */ switch (master->pass_type) { case main_pass: /* next pass is either output of scan 0 (after optimization) * or output of scan 1 (if no optimization). */ master->pass_type = output_pass; if (! cinfo->optimize_coding) master->scan_number++; break; case huff_opt_pass: /* next pass is always output of current scan */ master->pass_type = output_pass; break; case output_pass: /* next pass is either optimization or output of next scan */ if (cinfo->optimize_coding) master->pass_type = huff_opt_pass; master->scan_number++; break; } master->pass_number++;}#if 0void finish_pass_master1 (j_compress_ptr cinfo){ my_master_ptr master = (my_master_ptr) cinfo->master; /* The entropy coder always needs an end-of-pass call, * either to analyze statistics or to flush its output buffer. */ (*cinfo->entropy->finish_pass) (cinfo); //pwhsu:20031027 finish_pass_huff() /* Update state for next pass */ switch (master->pass_type) { case main_pass: /* next pass is either output of scan 0 (after optimization) * or output of scan 1 (if no optimization). */ master->pass_type = output_pass; if (! cinfo->optimize_coding) master->scan_number++; break; case huff_opt_pass: /* next pass is always output of current scan */ master->pass_type = output_pass; break; case output_pass: /* next pass is either optimization or output of next scan */ if (cinfo->optimize_coding) master->pass_type = huff_opt_pass; master->scan_number++; break; } master->pass_number++;}#endif/* * Initialize master compression control. */GLOBAL(void)jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only){ my_master_ptr master; master = (my_master_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master)); cinfo->master = (struct jpeg_comp_master *) master; master->pub.prepare_for_pass = prepare_for_pass; master->pub.pass_startup = pass_startup; master->pub.finish_pass = finish_pass_master; master->pub.is_last_pass = FALSE; /* Validate parameters, determine derived values */ initial_setup(cinfo); if (cinfo->scan_info != NULL) {#ifdef C_MULTISCAN_FILES_SUPPORTED validate_script(cinfo);#else ERREXIT(cinfo, JERR_NOT_COMPILED);#endif } else { cinfo->progressive_mode = FALSE; cinfo->num_scans = 1; }// if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */// cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ master->pass_type = main_pass;#if 0 /* Initialize my private state */ if (transcode_only) { /* no main pass in transcoding */ if (cinfo->optimize_coding) master->pass_type = huff_opt_pass; else master->pass_type = output_pass; } else { //pwhsu:20031013 磅︽ /* for normal compression, first pass is always this type: */ master->pass_type = main_pass; }#endif master->scan_number = 0; master->pass_number = 0;// if (cinfo->optimize_coding)// master->total_passes = cinfo->num_scans * 2;// else master->total_passes = cinfo->num_scans;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -