예제 #1
0
void jint_process_mcu(jpeg_compress_info *cinfo) 
{
  //处理每个颜色元件
  	int cn,tn;
  	for(cn=0;cn<cinfo->num_comp;cn++) 
  	{
    //元件中使用到的变量
    	DCTBLOCK   *dct_table=cinfo->comp[cn].dct_table;
    	JQUANT_TBL *quant_table=cinfo->quant_table[cinfo->comp[cn].quant_tbl_no];
    	JHUFF_TBL  *dc_table=cinfo->dc_huff_table[cinfo->comp[cn].dc_tbl_no];
    	JHUFF_TBL  *ac_table=cinfo->ac_huff_table[cinfo->comp[cn].ac_tbl_no];    
    	//处理每个DCT表--'Block'    
    	for(tn=0;tn<cinfo->comp[cn].num_dct_table;tn++) 
    	{
      		DCTVAL tmp=0;
      		DCTVAL *val=dct_table[tn];
      		int i;         		
      		for(i=0;i<DCTSIZE2;i++)val[i]-=128;//Forward-DCT的数据偏移       	      
      		for(i=0;i<64;i++)temp_dct1[i]=val[i];//Forward-DCT计算     
      		dsp_fdct_8x8((short *)val,1);     		
      		jutl_zigzag_sort((short*)val);//Z变换
      		//量化表 
      		for(i=0;i<DCTSIZE2;i++)val[i]=(DCTVAL)((float)val[i]/(float)quant_table->quantval[i]+0.5);     
      		//不同编码的计算
      		tmp=val[0];
      		val[0]-=cinfo->comp[cn].preval;
      		cinfo->comp[cn].preval=tmp;           		
      		jhuff_encode_one_block(cinfo, val, dc_table, ac_table);//Huffman
    	}
  	}
}
예제 #2
0
파일: jcint.c 프로젝트: darcyg/openwrt-ctl
void jint_process_mcu(jpeg_compress_info *cinfo) 
{
  /* process every color component */
  int cn, tn;
  for (cn=0; cn<cinfo->num_comp; cn++) 
  {
    /* Variable used in component. */
    DCTBLOCK   *dct_table = cinfo->comp[cn].dct_table;
    JQUANT_TBL *quant_table = cinfo->quant_table[cinfo->comp[cn].quant_tbl_no];
    JHUFF_TBL  *dc_table = cinfo->dc_huff_table[cinfo->comp[cn].dc_tbl_no];
    JHUFF_TBL  *ac_table = cinfo->ac_huff_table[cinfo->comp[cn].ac_tbl_no];
    
    /* process every DCT table -- 'Block'
     */    
    for (tn=0; tn<cinfo->comp[cn].num_dct_table; tn++) 
    {
      DCTVAL tmp=0;
      DCTVAL *val = dct_table[tn];
      int i;
      #ifdef DEBUG
        show_dcttable(val, "\n\t[basic val]");
      #endif
      
      /* data offset for Forward-DCT 
       */
      for (i=0; i<DCTSIZE2; i++) 
      {
        val[i] -= 128;
      }
      #ifdef DEBUG
        show_dcttable(val, "[val -= 128]");//先减去128在DCT
      #endif  

      /* Forward-DCT calculate 
       */   
      //jjj
      /* fdct_8x8(val); */
      
      for(i = 0;i<64;i++)
 	    temp_dct1[i] = val[i];
      
      dsp_fdct_8x8((short *)val, 1);//DCT变换
      //show_dcttable(val, "[fdct_8x8]");
      //#ifdef DEBUG
        //show_dcttable(val, "[fdct_8x8]");
      //#endif
      
      /* Zig-Zag Sort*/  
      jutl_zigzag_sort((INT16 *)val);//z排序
      //jutl_zigzag_sort((DCTBLOCK *)val);
      #ifdef DEBUG
        show_dcttable(val, "[zig-zag sort]");
      #endif
      /* Quant */  
      for (i=0; i<DCTSIZE2; i++) 
	  {
        val[i] = (DCTVAL)((float)val[i]/(float)quant_table->quantval[i]+0.5);//量化
      }
      #ifdef DEBUG
        show_dcttable(quant_table->quantval, "[quant-table]");
        show_dcttable(val, "[quant]");
      #endif
      
      /* Difference encode calculate */ 
      tmp = val[0];
      val[0] -= cinfo->comp[cn].preval;//对DC进行差分编码
      cinfo->comp[cn].preval = tmp;
      #ifdef DEBUG
        show_dcttable(val, "[diff code]");
      #endif
      /* Huffman */
      jhuff_encode_one_block(cinfo, val, dc_table, ac_table);//对剩下的63个AC分量进行霍夫曼编码
    }
  }
}