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

📄 quant_h263.c

📁 xvid解码的精简版本.非常好的版本,节省了分离xvid源代码的过程
💻 C
字号:
/***************************************************************************** * *  XVID MPEG-4 VIDEO CODEC *  - MPEG4 Quantization H263 implementation - * *  Copyright(C) 2001-2003 Peter Ross <pross@xvid.org> * *  This program is free software ; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation ; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY ; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program ; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA * * $Id: quant_h263.c,v 1.8 2004/03/22 22:36:24 edgomez Exp $ * ****************************************************************************/#include "global.h"#include "quant.h"/***************************************************************************** * Global function pointers ****************************************************************************//* Quant */quant_intraFuncPtr quant_h263_intra;quant_interFuncPtr quant_h263_inter;/* DeQuant */quant_intraFuncPtr dequant_h263_intra;quant_interFuncPtr dequant_h263_inter;/***************************************************************************** * Local data ****************************************************************************//* divide-by-multiply table * a 16 bit shiting is enough in this case */#define SCALEBITS	16#define FIX(X)		((1L << SCALEBITS) / (X) + 1)/***************************************************************************** * Function definitions ****************************************************************************//*	dequantize intra-block & clamp to [-2048,2047] */uint32_tdequant_h263_intra_c(int16_t * data,					 const int16_t * coeff,					 const uint32_t quant,					 const uint32_t dcscalar,					 const uint16_t * mpeg_quant_matrices){	const int32_t quant_m_2 = quant << 1;	const int32_t quant_add = (quant & 1 ? quant : quant - 1);	int i;	data[0] = coeff[0] * dcscalar;	if (data[0] < -2048) {		data[0] = -2048;	} else if (data[0] > 2047) {		data[0] = 2047;	}	for (i = 1; i < 64; i++) {		int32_t acLevel = coeff[i];		if (acLevel == 0) {			data[i] = 0;		} else if (acLevel < 0) {			acLevel = quant_m_2 * -acLevel + quant_add;			data[i] = (acLevel <= 2048 ? -acLevel : -2048);		} else {			acLevel = quant_m_2 * acLevel + quant_add;			data[i] = (acLevel <= 2047 ? acLevel : 2047);		}	}	return(0);}/* dequantize inter-block & clamp to [-2048,2047] */uint32_tdequant_h263_inter_c(int16_t * data,					 const int16_t * coeff,					 const uint32_t quant,					 const uint16_t * mpeg_quant_matrices){	const uint16_t quant_m_2 = quant << 1;	const uint16_t quant_add = (quant & 1 ? quant : quant - 1);	int i;	for (i = 0; i < 64; i++) {		int16_t acLevel = coeff[i];		if (acLevel == 0) {			data[i] = 0;		} else if (acLevel < 0) {			acLevel = acLevel * quant_m_2 - quant_add;			data[i] = (acLevel >= -2048 ? acLevel : -2048);		} else {			acLevel = acLevel * quant_m_2 + quant_add;			data[i] = (acLevel <= 2047 ? acLevel : 2047);		}	}	return(0);}

⌨️ 快捷键说明

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