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

📄 quantize.c

📁 魔兽2Linux版
💻 C
📖 第 1 页 / 共 3 页
字号:
        else if ( DCT_blockPtr[2] <= -FquantZBinSizePtr[2] )        {			temp = FquantCoeffsPtr[2] * ( DCT_blockPtr[2] - FquantRoundPtr[2] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[2]] = ( val < -511 ) ? -511 : val;        }        // Column 3         if ( DCT_blockPtr[3] >= FquantZBinSizePtr[3] )        {			temp = FquantCoeffsPtr[3] * ( DCT_blockPtr[3] + FquantRoundPtr[3] ) ;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[3]] = ( val > 511 ) ? 511 : val;        }        else if ( DCT_blockPtr[3] <= -FquantZBinSizePtr[3] )        {			temp = FquantCoeffsPtr[3] * ( DCT_blockPtr[3] - FquantRoundPtr[3] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[3]] = ( val < -511 ) ? -511 : val;        }        // Column 4         if ( DCT_blockPtr[4] >= FquantZBinSizePtr[4] )        {			temp = FquantCoeffsPtr[4] * ( DCT_blockPtr[4] + FquantRoundPtr[4] ) ;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[4]] = ( val > 511 ) ? 511 : val;        }        else if ( DCT_blockPtr[4] <= -FquantZBinSizePtr[4] )        {			temp = FquantCoeffsPtr[4] * ( DCT_blockPtr[4] - FquantRoundPtr[4] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[4]] = ( val < -511 ) ? -511 : val;        }        // Column 5         if ( DCT_blockPtr[5] >= FquantZBinSizePtr[5] )        {			temp = FquantCoeffsPtr[5] * ( DCT_blockPtr[5] + FquantRoundPtr[5] ) ;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[5]] = ( val > 511 ) ? 511 : val;        }        else if ( DCT_blockPtr[5] <= -FquantZBinSizePtr[5] )        {			temp = FquantCoeffsPtr[5] * ( DCT_blockPtr[5] - FquantRoundPtr[5] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[5]] = ( val < -511 ) ? -511 : val;        }        // Column 6         if ( DCT_blockPtr[6] >= FquantZBinSizePtr[6] )        {			temp = FquantCoeffsPtr[6] * ( DCT_blockPtr[6] + FquantRoundPtr[6] ) ;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[6]] = ( val > 511 ) ? 511 : val;        }        else if ( DCT_blockPtr[6] <= -FquantZBinSizePtr[6] )        {			temp = FquantCoeffsPtr[6] * ( DCT_blockPtr[6] - FquantRoundPtr[6] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[6]] = ( val < -511 ) ? -511 : val;        }        // Column 7         if ( DCT_blockPtr[7] >= FquantZBinSizePtr[7] )        {			temp = FquantCoeffsPtr[7] * ( DCT_blockPtr[7] + FquantRoundPtr[7] ) ;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[7]] = ( val > 511 ) ? 511 : val;        }        else if ( DCT_blockPtr[7] <= -FquantZBinSizePtr[7] )        {			temp = FquantCoeffsPtr[7] * ( DCT_blockPtr[7] - FquantRoundPtr[7] ) + MIN16;			val = (Q_LIST_ENTRY) (temp>>16);            quantized_list[QIndexPtr[7]] = ( val < -511 ) ? -511 : val;        }        FquantRoundPtr += 8;        FquantCoeffsPtr += 8;        FquantZBinSizePtr += 8;        DCT_blockPtr += 8;        QIndexPtr += 8;    }}#endif/**************************** END COMPRESSOR SPECIFIC **********************************//****************************************************************************************  Dequantiser code for decode loop***************************************************************************************/#ifdef PBDLL/***************************************************************************** *   Routine:	init_pbi->dequantizer**   Purpose:    Used to initialize the encoding/decoding data structures*				and to select DCT algorithm	**   Parameters :*       Input :*           UINT32          scale_factor*                           Defines the factor by which to scale QUANT_ARRAY to*                           produce quantization_array**           UINT8           QIndex          :: *                           Index into Q table for current quantiser value.*   Return value :*       None.******************************************************************************/void init_dequantizer ( PB_INSTANCE *pbi, UINT32 scale_factor, UINT8 QIndex ){    int i, j;						 // Loop counter 		// Used for decoder version specific tables	Q_LIST_ENTRY * Inter_coeffs;	 	Q_LIST_ENTRY * Y_coeffs;	 	Q_LIST_ENTRY * UV_coeffs;	 	Q_LIST_ENTRY * DcScaleFactorTable;	Q_LIST_ENTRY * UVDcScaleFactorTable;	// Decoder specific selections	Inter_coeffs = Inter_coeffsV1;	Y_coeffs = Y_coeffsV1;	UV_coeffs = UV_coeffsV1;	DcScaleFactorTable = DcScaleFactorTableV1;	UVDcScaleFactorTable = DcScaleFactorTableV1;	// invert the dequant index into the quant index    // the dxer has a different order than the cxer.    pbi->BuildQuantIndex(pbi);	// Reorder dequantisation coefficients into dct zigzag order.	for ( i = 0; i < BLOCK_SIZE; i++ )	{	        j = pbi->quant_index[i];		pbi->dequant_Y_coeffs[j] = Y_coeffs[i];	}	for ( i = 0; i < BLOCK_SIZE; i++ )	{			j = pbi->quant_index[i];		pbi->dequant_Inter_coeffs[j] = Inter_coeffs[i];	}	for ( i = 0; i < BLOCK_SIZE; i++ )	{	        j = pbi->quant_index[i];		pbi->dequant_UV_coeffs[j] = UV_coeffs[i];	}	for ( i = 0; i < BLOCK_SIZE; i++ )	{			j = pbi->quant_index[i];		pbi->dequant_InterUV_coeffs[j] = Inter_coeffs[i];	}    // Intra Y    pbi->dequant_Y_coeffs[0] = (Q_LIST_ENTRY)((DcScaleFactorTable[QIndex] * pbi->dequant_Y_coeffs[0])/100);    if ( pbi->dequant_Y_coeffs[0] < MIN_DEQUANT_VAL * 2 )        pbi->dequant_Y_coeffs[0] = MIN_DEQUANT_VAL * 2;    pbi->dequant_Y_coeffs[0] = pbi->dequant_Y_coeffs[0] << IDCT_SCALE_FACTOR;    // Intra UV    pbi->dequant_UV_coeffs[0] = (Q_LIST_ENTRY)((UVDcScaleFactorTable[QIndex] * pbi->dequant_UV_coeffs[0])/100);    if ( pbi->dequant_UV_coeffs[0] < MIN_DEQUANT_VAL * 2 )        pbi->dequant_UV_coeffs[0] = MIN_DEQUANT_VAL * 2;    pbi->dequant_UV_coeffs[0] = pbi->dequant_UV_coeffs[0] << IDCT_SCALE_FACTOR;    // Inter Y    pbi->dequant_Inter_coeffs[0] = (Q_LIST_ENTRY)((DcScaleFactorTable[QIndex] * pbi->dequant_Inter_coeffs[0])/100);    if ( pbi->dequant_Inter_coeffs[0] < MIN_DEQUANT_VAL * 4 )        pbi->dequant_Inter_coeffs[0] = MIN_DEQUANT_VAL * 4;    pbi->dequant_Inter_coeffs[0] = pbi->dequant_Inter_coeffs[0] << IDCT_SCALE_FACTOR;    // Inter UV    pbi->dequant_InterUV_coeffs[0] = (Q_LIST_ENTRY)((UVDcScaleFactorTable[QIndex] * pbi->dequant_InterUV_coeffs[0])/100);    if ( pbi->dequant_InterUV_coeffs[0] < MIN_DEQUANT_VAL * 4 )        pbi->dequant_InterUV_coeffs[0] = MIN_DEQUANT_VAL * 4;    pbi->dequant_InterUV_coeffs[0] = pbi->dequant_InterUV_coeffs[0] << IDCT_SCALE_FACTOR;	for ( i = 1; i < 64; i++ )	{			// now scale coefficients by required compression factor		pbi->dequant_Y_coeffs[i] = (Q_LIST_ENTRY)(( scale_factor * pbi->dequant_Y_coeffs[i] ) / 100);		if ( pbi->dequant_Y_coeffs[i] < MIN_DEQUANT_VAL )			pbi->dequant_Y_coeffs[i] = MIN_DEQUANT_VAL;		pbi->dequant_Y_coeffs[i] = pbi->dequant_Y_coeffs[i] << IDCT_SCALE_FACTOR;		pbi->dequant_UV_coeffs[i] = (Q_LIST_ENTRY)(( scale_factor * pbi->dequant_UV_coeffs[i] ) / 100);		if ( pbi->dequant_UV_coeffs[i] < MIN_DEQUANT_VAL )			pbi->dequant_UV_coeffs[i] = MIN_DEQUANT_VAL;		pbi->dequant_UV_coeffs[i] = pbi->dequant_UV_coeffs[i] << IDCT_SCALE_FACTOR;		pbi->dequant_Inter_coeffs[i] = (Q_LIST_ENTRY)(( scale_factor * pbi->dequant_Inter_coeffs[i] ) / 100);		if ( pbi->dequant_Inter_coeffs[i] < (MIN_DEQUANT_VAL * 2) )			pbi->dequant_Inter_coeffs[i] = MIN_DEQUANT_VAL * 2;		pbi->dequant_Inter_coeffs[i] = pbi->dequant_Inter_coeffs[i] << IDCT_SCALE_FACTOR;		pbi->dequant_InterUV_coeffs[i] = (Q_LIST_ENTRY)(( scale_factor * pbi->dequant_InterUV_coeffs[i] ) / 100);		if ( pbi->dequant_InterUV_coeffs[i] < (MIN_DEQUANT_VAL * 2) )			pbi->dequant_InterUV_coeffs[i] = MIN_DEQUANT_VAL * 2;		pbi->dequant_InterUV_coeffs[i] = pbi->dequant_InterUV_coeffs[i] << IDCT_SCALE_FACTOR;    }	pbi->dequant_coeffs = pbi->dequant_Y_coeffs;}/****************************************************************************//*																			*//*		Select Quantisation Parameters										*//*																			*//*		void select_Y_dequantiser ( void )									*//*			sets dequantiser to use for intra Y         					*//*																			*//*		void select_Inter_dequantiser ( void )									*//*			sets dequantiser to use for inter Y         					*//*																			*//*		void select_UV_dequantiser ( void )									*//*			sets dequantiser to use UV compression constants				*//*																			*//****************************************************************************/void select_Y_dequantiser ( PB_INSTANCE *pbi){	    pbi->dequant_coeffs = pbi->dequant_Y_coeffs;}																			  void select_Inter_dequantiser ( PB_INSTANCE *pbi ){	    pbi->dequant_coeffs = pbi->dequant_Inter_coeffs;}void select_UV_dequantiser ( PB_INSTANCE *pbi ){	    pbi->dequant_coeffs = pbi->dequant_UV_coeffs;}/***************************************************************************** *   Routine:    dequant**   Purpose:    The reverse of routine quantize, this routine takes a Q_LIST*               list of quantized values and multipies by the relevant value in*               quantization array. **   Parameters :  *       Input :*           quantized_list :: Q_LIST*                      -- The quantized values in zig-zag order*       Output :*           DCT_block      :: INT16 *              *                      -- The expanded values in a 2-D block**   Return value :*       None.** *****************************************************************************/void dequant( PB_INSTANCE *pbi, Q_LIST_ENTRY * quantized_list, INT32 * DCT_block){    // Loop fully expanded for maximum speed    DCT_block[dequant_index[0]] = quantized_list[0] * pbi->dequant_coeffs[0];    DCT_block[dequant_index[1]] = quantized_list[1] * pbi->dequant_coeffs[1];    DCT_block[dequant_index[2]] = quantized_list[2] * pbi->dequant_coeffs[2];    DCT_block[dequant_index[3]] = quantized_list[3] * pbi->dequant_coeffs[3];    DCT_block[dequant_index[4]] = quantized_list[4] * pbi->dequant_coeffs[4];    DCT_block[dequant_index[5]] = quantized_list[5] * pbi->dequant_coeffs[5];    DCT_block[dequant_index[6]] = quantized_list[6] * pbi->dequant_coeffs[6];    DCT_block[dequant_index[7]] = quantized_list[7] * pbi->dequant_coeffs[7];    DCT_block[dequant_index[8]] = quantized_list[8] * pbi->dequant_coeffs[8];    DCT_block[dequant_index[9]] = quantized_list[9] * pbi->dequant_coeffs[9];    DCT_block[dequant_index[10]] = quantized_list[10] * pbi->dequant_coeffs[10];    DCT_block[dequant_index[11]] = quantized_list[11] * pbi->dequant_coeffs[11];    DCT_block[dequant_index[12]] = quantized_list[12] * pbi->dequant_coeffs[12];    DCT_block[dequant_index[13]] = quantized_list[13] * pbi->dequant_coeffs[13];    DCT_block[dequant_index[14]] = quantized_list[14] * pbi->dequant_coeffs[14];    DCT_block[dequant_index[15]] = quantized_list[15] * pbi->dequant_coeffs[15];    DCT_block[dequant_index[16]] = quantized_list[16] * pbi->dequant_coeffs[16];    DCT_block[dequant_index[17]] = quantized_list[17] * pbi->dequant_coeffs[17];    DCT_block[dequant_index[18]] = quantized_list[18] * pbi->dequant_coeffs[18];    DCT_block[dequant_index[19]] = quantized_list[19] * pbi->dequant_coeffs[19];    DCT_block[dequant_index[20]] = quantized_list[20] * pbi->dequant_coeffs[20];    DCT_block[dequant_index[21]] = quantized_list[21] * pbi->dequant_coeffs[21];    DCT_block[dequant_index[22]] = quantized_list[22] * pbi->dequant_coeffs[22];    DCT_block[dequant_index[23]] = quantized_list[23] * pbi->dequant_coeffs[23];    DCT_block[dequant_index[24]] = quantized_list[24] * pbi->dequant_coeffs[24];    DCT_block[dequant_index[25]] = quantized_list[25] * pbi->dequant_coeffs[25];    DCT_block[dequant_index[26]] = quantized_list[26] * pbi->dequant_coeffs[26];    DCT_block[dequant_index[27]] = quantized_list[27] * pbi->dequant_coeffs[27];    DCT_block[dequant_index[28]] = quantized_list[28] * pbi->dequant_coeffs[28];    DCT_block[dequant_index[29]] = quantized_list[29] * pbi->dequant_coeffs[29];    DCT_block[dequant_index[30]] = quantized_list[30] * pbi->dequant_coeffs[30];    DCT_block[dequant_index[31]] = quantized_list[31] * pbi->dequant_coeffs[31];    DCT_block[dequant_index[32]] = quantized_list[32] * pbi->dequant_coeffs[32];    DCT_block[dequant_index[33]] = quantized_list[33] * pbi->dequant_coeffs[33];    DCT_block[dequant_index[34]] = quantized_list[34] * pbi->dequant_coeffs[34];    DCT_block[dequant_index[35]] = quantized_list[35] * pbi->dequant_coeffs[35];    DCT_block[dequant_index[36]] = quantized_list[36] * pbi->dequant_coeffs[36];    DCT_block[dequant_index[37]] = quantized_list[37] * pbi->dequant_coeffs[37];    DCT_block[dequant_index[38]] = quantized_list[38] * pbi->dequant_coeffs[38];    DCT_block[dequant_index[39]] = quantized_list[39] * pbi->dequant_coeffs[39];    DCT_block[dequant_index[40]] = quantized_list[40] * pbi->dequant_coeffs[40];    DCT_block[dequant_index[41]] = quantized_list[41] * pbi->dequant_coeffs[41];    DCT_block[dequant_index[42]] = quantized_list[42] * pbi->dequant_coeffs[42];    DCT_block[dequant_index[43]] = quantized_list[43] * pbi->dequant_coeffs[43];    DCT_block[dequant_index[44]] = quantized_list[44] * pbi->dequant_coeffs[44];    DCT_block[dequant_index[45]] = quantized_list[45] * pbi->dequant_coeffs[45];    DCT_block[dequant_index[46]] = quantized_list[46] * pbi->dequant_coeffs[46];    DCT_block[dequant_index[47]] = quantized_list[47] * pbi->dequant_coeffs[47];    DCT_block[dequant_index[48]] = quantized_list[48] * pbi->dequant_coeffs[48];    DCT_block[dequant_index[49]] = quantized_list[49] * pbi->dequant_coeffs[49];    DCT_block[dequant_index[50]] = quantized_list[50] * pbi->dequant_coeffs[50];    DCT_block[dequant_index[51]] = quantized_list[51] * pbi->dequant_coeffs[51];    DCT_block[dequant_index[52]] = quantized_list[52] * pbi->dequant_coeffs[52];    DCT_block[dequant_index[53]] = quantized_list[53] * pbi->dequant_coeffs[53];    DCT_block[dequant_index[54]] = quantized_list[54] * pbi->dequant_coeffs[54];    DCT_block[dequant_index[55]] = quantized_list[55] * pbi->dequant_coeffs[55];    DCT_block[dequant_index[56]] = quantized_list[56] * pbi->dequant_coeffs[56];    DCT_block[dequant_index[57]] = quantized_list[57] * pbi->dequant_coeffs[57];    DCT_block[dequant_index[58]] = quantized_list[58] * pbi->dequant_coeffs[58];    DCT_block[dequant_index[59]] = quantized_list[59] * pbi->dequant_coeffs[59];    DCT_block[dequant_index[60]] = quantized_list[60] * pbi->dequant_coeffs[60];    DCT_block[dequant_index[61]] = quantized_list[61] * pbi->dequant_coeffs[61];    DCT_block[dequant_index[62]] = quantized_list[62] * pbi->dequant_coeffs[62];    DCT_block[dequant_index[63]] = quantized_list[63] * pbi->dequant_coeffs[63];}#endif

⌨️ 快捷键说明

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