--- estimation.h 2004/12/05 04:53:01 1.7 +++ estimation.h 2010/12/24 13:21:35 1.16 @@ -4,7 +4,7 @@ * - Motion Estimation related header - * * Copyright(C) 2002 Christoph Lampert - * 2002 Michael Militzer + * 2002-2010 Michael Militzer * 2002-2003 Radoslaw Czyz * * This program is free software ; you can redistribute it and/or modify @@ -21,7 +21,7 @@ * 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.h,v 1.7 2004/12/05 04:53:01 syskin Exp $ + * $Id: estimation.h,v 1.16 2010/12/24 13:21:35 Isibaar Exp $ * ****************************************************************************/ @@ -30,7 +30,7 @@ #include "../portab.h" #include "../global.h" -#include "../image/reduced.h" +#include "sad.h" /* hard coded motion search parameters */ @@ -41,8 +41,9 @@ #define MV16_INTER_BIAS 450 /* vector map (vlc delta size) smoother parameters ! float !*/ -#define NEIGH_TEND_16X16 10.5 -#define NEIGH_TEND_8X8 40.0 +#define NEIGH_TEND_16X16 0.6 +#define NEIGH_TEND_8X8 1.5 + #define NEIGH_8X8_BIAS 40 #define BITS_MULT 16 @@ -69,6 +70,8 @@ typedef struct { + int max_dx, min_dx, max_dy, min_dy; /* maximum search range */ + /* data modified by CheckCandidates */ int32_t iMinSAD[5]; /* smallest SADs found so far */ VECTOR currentMV[5]; /* best vectors found so far */ @@ -78,7 +81,6 @@ int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */ /* general fields */ - int max_dx, min_dx, max_dy, min_dy; /* maximum range */ uint32_t rounding; /* rounding type in use */ VECTOR predMV; /* vector which predicts current vector */ const uint8_t * RefP[6]; /* reference pictures - N, V, H, HV, cU, cV */ @@ -114,9 +116,20 @@ const uint16_t * scan_table; /* current scan table */ const uint16_t * mpeg_quant_matrices; /* current MPEG quantization matrices */ int lambda[6]; /* R-D lambdas for all 6 blocks */ - + unsigned int quant_sq; /* quant squared - saves many multiplications in VHQ */ + uint32_t rel_var8[6]; /* relative variances for all 6 sub-blocks */ + int metric; /* distortion metric for R-D optimizations, currently: PSNR=0, PSNRHVSM=1 */ } SearchData; +static __inline uint32_t +masked_sseh8_16bit(int16_t * const orig, + int16_t * const rec, + const uint32_t rel_var8) +{ + uint16_t mask = ((isqrt(2*coeff8_energy(orig)*rel_var8) + 48) >> 6); + return (5*sseh8_16bit(orig, rec, (uint16_t) mask)) >> 7; +} + typedef void(CheckFunc)(const int x, const int y, SearchData * const Data, const unsigned int Direction); @@ -164,7 +177,8 @@ const IMAGE * const pCurrent, const IMAGE * const pRef, const IMAGE * const vGMC, - const int coding_type); + const int coding_type, + const int bound); void xvid_me_ModeDecision_Fast(SearchData * const Data, @@ -178,7 +192,8 @@ const IMAGE * const pCurrent, const IMAGE * const pRef, const IMAGE * const vGMC, - const int coding_type); + const int coding_type, + const int bound); void ModeDecision_BVOP_RD(SearchData * const Data_d, @@ -190,8 +205,13 @@ VECTOR * f_predMV, VECTOR * b_predMV, const uint32_t MotionFlags, + const uint32_t VopFlags, const MBParam * const pParam, - int x, int y); + int x, int y, + int best_sad, + int force_direct); +unsigned int +getMinFcode(const int MVmax); #endif /* _ESTIMATION_H_ */