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

📄 estimation_common.c

📁 xvid解码的精简版本.非常好的版本,节省了分离xvid源代码的过程
💻 C
字号:
/***************************************************************************** * *  XVID MPEG-4 VIDEO CODEC *  - Motion Estimation shared functions - * *  Copyright(C) 2002 Christoph Lampert <gruel@web.de> *               2002 Michael Militzer <michael@xvid.org> *               2002-2003 Radoslaw Czyz <xvid@syskin.cjb.net> * *  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: estimation_common.c,v 1.12.2.1 2005/12/09 05:07:31 syskin Exp $ * ****************************************************************************/#include "encoder.h"#include "global.h"#include "interpolate8x8.h"#include "estimation.h"#include "motion.h"#include "motion_inlines.h"/***************************************************************************** * Modified rounding tables * Original tables see ISO spec tables 7-6 -> 7-9 ****************************************************************************/const uint32_t roundtab[16] ={0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };/* K = 4 */const uint32_t roundtab_76[16] ={ 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 };/* K = 2 */const uint32_t roundtab_78[8] ={ 0, 0, 1, 1, 0, 0, 0, 1  };/* K = 1 */const uint32_t roundtab_79[4] ={ 0, 1, 0, 0 };/***************************************************************************** * Code ****************************************************************************/uint8_t *xvid_me_interpolate8x8qpel(const int x, const int y, const uint32_t block, const uint32_t dir, const SearchData * const data){	/* create or find a qpel-precision reference picture; return pointer to it */	uint8_t * Reference = data->RefQ + 16*dir;	const uint32_t iEdgedWidth = data->iEdgedWidth;	const uint32_t rounding = data->rounding;	const int halfpel_x = x/2;	const int halfpel_y = y/2;	const uint8_t *ref1, *ref2, *ref3, *ref4;	ref1 = GetReferenceB(halfpel_x, halfpel_y, dir, data);	ref1 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;	switch( ((x&1)<<1) + (y&1) ) {	case 3: /* x and y in qpel resolution - the "corners" (top left/right and */			/* bottom left/right) during qpel refinement */		ref2 = GetReferenceB(halfpel_x, y - halfpel_y, dir, data);		ref3 = GetReferenceB(x - halfpel_x, halfpel_y, dir, data);		ref4 = GetReferenceB(x - halfpel_x, y - halfpel_y, dir, data);		ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;		ref3 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;		ref4 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;		interpolate8x8_avg4(Reference, ref1, ref2, ref3, ref4, iEdgedWidth, rounding);		break;	case 1: /* x halfpel, y qpel - top or bottom during qpel refinement */		ref2 = GetReferenceB(halfpel_x, y - halfpel_y, dir, data);		ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;		interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8);		break;	case 2: /* x qpel, y halfpel - left or right during qpel refinement */		ref2 = GetReferenceB(x - halfpel_x, halfpel_y, dir, data);		ref2 += 8 * (block&1) + 8 * (block>>1) * iEdgedWidth;		interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8);		break;	default: /* pure halfpel position */		return (uint8_t *) ref1;	}	return Reference;}uint8_t *xvid_me_interpolate16x16qpel(const int x, const int y, const uint32_t dir, const SearchData * const data){	/* create or find a qpel-precision reference picture; return pointer to it */	uint8_t * Reference = data->RefQ + 16*dir;	const uint32_t iEdgedWidth = data->iEdgedWidth;	const uint32_t rounding = data->rounding;	const int halfpel_x = x/2;	const int halfpel_y = y/2;	const uint8_t *ref1, *ref2, *ref3, *ref4;	ref1 = GetReferenceB(halfpel_x, halfpel_y, dir, data);	switch( ((x&1)<<1) + (y&1) ) {	case 3:		/*		 * x and y in qpel resolution - the "corners" (top left/right and		 * bottom left/right) during qpel refinement		 */		ref2 = GetReferenceB(halfpel_x, y - halfpel_y, dir, data);		ref3 = GetReferenceB(x - halfpel_x, halfpel_y, dir, data);		ref4 = GetReferenceB(x - halfpel_x, y - halfpel_y, dir, data);		interpolate8x8_avg4(Reference, ref1, ref2, ref3, ref4, iEdgedWidth, rounding);		interpolate8x8_avg4(Reference+8, ref1+8, ref2+8, ref3+8, ref4+8, iEdgedWidth, rounding);		interpolate8x8_avg4(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, ref3+8*iEdgedWidth, ref4+8*iEdgedWidth, iEdgedWidth, rounding);		interpolate8x8_avg4(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, ref3+8*iEdgedWidth+8, ref4+8*iEdgedWidth+8, iEdgedWidth, rounding);		break;	case 1: /* x halfpel, y qpel - top or bottom during qpel refinement */		ref2 = GetReferenceB(halfpel_x, y - halfpel_y, dir, data);		interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding, 8);		break;	case 2: /* x qpel, y halfpel - left or right during qpel refinement */		ref2 = GetReferenceB(x - halfpel_x, halfpel_y, dir, data);		interpolate8x8_avg2(Reference, ref1, ref2, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8, ref1+8, ref2+8, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8*iEdgedWidth, ref1+8*iEdgedWidth, ref2+8*iEdgedWidth, iEdgedWidth, rounding, 8);		interpolate8x8_avg2(Reference+8*iEdgedWidth+8, ref1+8*iEdgedWidth+8, ref2+8*iEdgedWidth+8, iEdgedWidth, rounding, 8);		break;	default: /* pure halfpel position */		return (uint8_t *) ref1;	}	return Reference;}

⌨️ 快捷键说明

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