⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jidct_bin_a1.c

📁 JPEG Image compression using IJG standards followed
💻 C
📖 第 1 页 / 共 2 页
字号:
    tmp11=(tmp1 - tmp6);	outptr[1] = range_limit[(int)DESCALE(tmp10, 4) & RANGE_MASK];	outptr[6] = range_limit[(int)DESCALE(tmp11, 4) & RANGE_MASK];    //outptr[1] =  (char)DESCALE(tmp10, 4);    //outptr[6] =  (char)DESCALE(tmp11, 4);	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }    tmp10=(tmp2 + tmp5);    tmp11=(tmp2 - tmp5);	outptr[2] = range_limit[(int)DESCALE(tmp10, 4) & RANGE_MASK];	outptr[5] = range_limit[(int)DESCALE(tmp11, 4) & RANGE_MASK];    //outptr[2] = (char)DESCALE(tmp10,4);    //outptr[5] = (char)DESCALE(tmp11,4);	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }    tmp10=(tmp3 + tmp4);    tmp11=(tmp3 - tmp4);	outptr[3] = range_limit[(int)DESCALE(tmp10, 4) & RANGE_MASK];	outptr[4] = range_limit[(int)DESCALE(tmp11, 4) & RANGE_MASK];       //outptr[3] =  (char)DESCALE(tmp10,4);    //outptr[4] =  (char)DESCALE(tmp11,4);   	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }         wsptr += DCTSIZE;		/* advance pointer to next row *//*******************//* Jie: test code */	/*	for (tmp0 = 0; tmp0 < 8; tmp0 ++) {	  fprintf(stderr, "%10d", outptr[tmp0]);	}	fprintf(stderr, "\n");	*/  }/****************************************************************************/   } else {/****************************************************************************/  //Case 2: lossless binDCT: descale by 2 immediately after inverse butterfly.  /* Pass 1: process columns from input, store into work array. */  /* Note results are scaled up by sqrt(8) compared to a true IDCT; */  /* furthermore, we scale the results by 2**PASS1_BITS. */  inptr = coef_block;  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;  wsptr = workspace;  for (ctr = DCTSIZE; ctr > 0; ctr--) {	/************************** When new butterflies are used, the short-circuiting trick is invalid. For example, the input [0, 0, 1, 1, 1, 1, 0, 0] will give output [ 2, 0, 0, 0, 0, 0, 0, 0], if round operation is used for 1/2. Jie: 07/09/00.	if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&	inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&	inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&	inptr[DCTSIZE*7] == 0) {      dcval = inptr[DCTSIZE*0] >> 2;            wsptr[DCTSIZE*0] = dcval;      wsptr[DCTSIZE*1] = dcval;      wsptr[DCTSIZE*2] = dcval;      wsptr[DCTSIZE*3] = dcval;      wsptr[DCTSIZE*4] = dcval;      wsptr[DCTSIZE*5] = dcval;      wsptr[DCTSIZE*6] = dcval;      wsptr[DCTSIZE*7] = dcval;            inptr++;			      quantptr++;      wsptr++;      continue;	  }**********************/        tmp0 = inptr[DCTSIZE*0];    tmp1 = inptr[DCTSIZE*4];    tmp2 = inptr[DCTSIZE*6];    tmp3 = inptr[DCTSIZE*2];    tmp4 = inptr[DCTSIZE*7];    tmp5 = inptr[DCTSIZE*5];    tmp6 = inptr[DCTSIZE*3];    tmp7 = inptr[DCTSIZE*1];	/*	    fprintf(stderr, "%10d", tmp0);    fprintf(stderr, "%10d", tmp7);    fprintf(stderr, "%10d", tmp3);    fprintf(stderr, "%10d", tmp6);    fprintf(stderr, "%10d", tmp1);    fprintf(stderr, "%10d", tmp5);    fprintf(stderr, "%10d", tmp2);    fprintf(stderr, "%10d", tmp4);	fprintf(stderr, "\n");		*/	/* X[0] and X[4] */	//tmp11 = ((tmp0 ) >> 1) - tmp1;	//tmp10 = tmp0 - tmp11;	tmp10 = tmp0 + ((tmp1 ) >> 1);	tmp11 = tmp10 - tmp1;		/* X[6] and X[2]: 1/2, 1/2 */	tmp13 = tmp3 + ((tmp2 ) >> 1);	tmp12 = ((tmp13 ) >> 1) - tmp2;	//lossless binDCT: use new nutterflies.	//tmp3 = ((tmp10 ) >> 1) - tmp13;	//tmp0 = tmp10 - tmp3;	tmp0 = tmp10 + ((tmp13 ) >> 1);	tmp3 = tmp0 - tmp13;	//tmp2 = ((tmp11 ) >> 1) - tmp12;	//tmp1 = tmp11 - tmp2;	tmp1 = tmp11 + ((tmp12 ) >> 1);	tmp2 = tmp1 - tmp12;	/* X[7] and X[1]: */	/* 7pi/16 = 1/4d 1/4u */    tmp13 = tmp7 + ( ( tmp4 ) >> 2 );	tmp10 = ( ( tmp13 ) >> 2 ) - tmp4;	/* X[5] and X[3] */	/* new 1/2 and -1*/	tmp12 = tmp6 + ((tmp5 ) >> 1);    tmp11 = tmp5 - tmp12; 	//lossless binDCT: use new butterflies.	tmp5 = ((tmp10 ) >> 1) - tmp11;	tmp4 = tmp10 - tmp5;    tmp6 = ((tmp13 ) >> 1) - tmp12;	tmp7 = tmp13 - tmp6;	/* pi/4 = -1/2u -3/4d 1/2u */	tmp5 = ((tmp6 ) >> 1) - tmp5;	tmp6 = tmp6 - tmp5 + ((tmp5 ) >> 2);	tmp5 = tmp5 + (( tmp6 ) >> 1); 	/* last stage: butterfly */	wsptr[DCTSIZE*0] = tmp0 + ((tmp7 ) >> 1);    wsptr[DCTSIZE*7] = wsptr[DCTSIZE*0] - tmp7 ;    wsptr[DCTSIZE*1] = tmp1 + ((tmp6 ) >> 1);    wsptr[DCTSIZE*6] = wsptr[DCTSIZE*1] - tmp6 ;    wsptr[DCTSIZE*2] = tmp2 + ((tmp5 ) >> 1);    wsptr[DCTSIZE*5] = wsptr[DCTSIZE*2] - tmp5 ;    wsptr[DCTSIZE*3] = tmp3 + ((tmp4 ) >> 1);    wsptr[DCTSIZE*4] = wsptr[DCTSIZE*3] - tmp4 ;        inptr++;			/* advance pointers to next column */    quantptr++;    wsptr++;  }    /* Pass 2: process rows from work array, store into output array. */  /* Note that we must descale the results by a factor of 8 == 2**3, */  /* and also undo the PASS1_BITS scaling. */  //fprintf(stderr, "\nAfter inverse DCT:\n");  wsptr = workspace;  for (ctr = 0; ctr < DCTSIZE; ctr++) {    outptr = output_buf[ctr] + output_col;    /* Rows of zeroes can be exploited in the same way as we did with columns.     * However, the column calculation has created many nonzero AC terms, so     * the simplification applies less often (typically 5% to 10% of the time).     * On machines with very fast multiplication, it's possible that the     * test takes more time than it's worth.  In that case this section     * may be commented out.     */    #ifndef NO_ZERO_ROW_TEST/********************************* When new butterflies are used, the short-circuiting trick is invalid. For example, the input [0, 0, 1, 1, 1, 1, 0, 0] will give output [ 2, 0, 0, 0, 0, 0, 0, 0], if round operation is used for 1/2. Jie: 07/09/00.	 if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&			wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {	  //In lossless binDCT, if all AC are 0, all inverse transform values woule be the DC value scaled by 8,	  //caused by 3-level butterfly in obtaining the DC.	  JSAMPLE dcval = range_limit[(wsptr[0] >> 2) & RANGE_MASK];      outptr[0] = dcval;      outptr[1] = dcval;      outptr[2] = dcval;      outptr[3] = dcval;      outptr[4] = dcval;      outptr[5] = dcval;      outptr[6] = dcval;      outptr[7] = dcval;      wsptr += DCTSIZE;		      continue;	  }****************************/#endif        /* Even part: reverse the even part of the forward DCT. */    /* The rotator is sqrt(2)*c(-6). */    /* Even part *//**********************//* not necessary ??? *//************************//********    tmp0 = (INT32) wsptr[0];    tmp1 = (INT32) wsptr[4];    tmp2 = (INT32) wsptr[6];    tmp3 = (INT32) wsptr[2];    tmp4 = (INT32) wsptr[7];    tmp5 = (INT32) wsptr[5];    tmp6 = (INT32) wsptr[3];    tmp7 = (INT32) wsptr[1];*********/	/* X[0] and X[4] */	//tmp11 = ((wsptr[0] ) >> 1) - wsptr[4];	//tmp10 = wsptr[0] - tmp11;	tmp10 = wsptr[0] + ((wsptr[4] ) >> 1);	tmp11 = tmp10 - wsptr[4];		/* X[6] and X[2]:1/2, 1/2 */	tmp13 = wsptr[2] + (( wsptr[6] ) >> 1);	tmp12 = (( tmp13 ) >> 1) - wsptr[6];	//lossless binDCT: use new nutterflies.	//	tmp3 = ((tmp10 ) >> 1) - tmp13;	//	tmp0 = tmp10 - tmp3;	tmp0 = tmp10 + ((tmp13 ) >> 1);	tmp3 = tmp0 - tmp13;	//	tmp2 = ((tmp11 ) >> 1) - tmp12;	//	tmp1 = tmp11 - tmp2;	tmp1 = tmp11 + ((tmp12 ) >> 1);	tmp2 = tmp1 - tmp12;	/* 7pi/16 = -1/4d 1/4u */    tmp13 = wsptr[1] +( ( wsptr[7] ) >> 2 );	tmp10 = ( (tmp13 ) >> 2 ) - wsptr[7];	/* 3pi/16 = 1/2d -1u */	tmp12 = wsptr[3] + (( wsptr[5] ) >> 1);    tmp11 = wsptr[5] - tmp12 ; 	//lossless binDCT: use new butterflies.	tmp5 = ((tmp10 ) >> 1) - tmp11;	tmp4 = tmp10 - tmp5;    tmp6 = ((tmp13 ) >> 1) - tmp12;	tmp7 = tmp13 - tmp6;	/* pi/4 = -1/2u -3/4d 1/2u */	tmp5 = ((tmp6 ) >> 1) - tmp5;	tmp6 = tmp6 - tmp5 + ((tmp5 ) >> 2);	tmp5 = tmp5 + ((tmp6 ) >> 1);	/* last stage: butterfly */    /* Final output stage: scale down by a factor of 8 and range-limit */    tmp10=tmp0 + ((tmp7 ) >> 1);    tmp11=tmp10 - tmp7;	outptr[0] = range_limit[tmp10 & RANGE_MASK];	outptr[7] = range_limit[tmp11 & RANGE_MASK];    //outptr[0] = (char)DESCALE(tmp10, 4);    //outptr[7] = (char)DESCALE(tmp11,4);	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }    tmp10=tmp1 + ((tmp6 ) >> 1);    tmp11=(tmp10 - tmp6);	outptr[1] = range_limit[tmp10 & RANGE_MASK];	outptr[6] = range_limit[tmp11 & RANGE_MASK];    //outptr[1] =  (char)DESCALE(tmp10, 4);    //outptr[6] =  (char)DESCALE(tmp11, 4);	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }    tmp10=tmp2 + ((tmp5 ) >> 1);    tmp11=(tmp10 - tmp5);	outptr[2] = range_limit[tmp10 & RANGE_MASK];	outptr[5] = range_limit[tmp11 & RANGE_MASK];    //outptr[2] = (char)DESCALE(tmp10,4);    //outptr[5] = (char)DESCALE(tmp11,4);	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }    tmp10=tmp3 + ((tmp4 ) >> 1);    tmp11=(tmp10 - tmp4);	outptr[3] = range_limit[tmp10 & RANGE_MASK];	outptr[4] = range_limit[tmp11 & RANGE_MASK];       //outptr[3] =  (char)DESCALE(tmp10,4);    //outptr[4] =  (char)DESCALE(tmp11,4);   	if (tmp10 > 4096 || tmp10 < -4096 || tmp11 > 4096 || tmp11 < -4096) {	  fprintf(stderr,"Possible IDCT overflow!\n");    }         wsptr += DCTSIZE;		/* advance pointer to next row *//*******************//* Jie: test code */	/*	for (tmp0 = 0; tmp0 < 8; tmp0 ++) {	  fprintf(stderr, "%10d", outptr[tmp0]);	}	fprintf(stderr, "\n");	*/  }}}#endif /* DCT_BIN_A1_SUPPORTED */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -