--- estimation.h 2003/09/10 22:18:59 1.1.2.1 +++ estimation.h 2003/12/18 02:02:08 1.1.2.8 @@ -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.1.2.1 2003/09/10 22:18:59 edgomez Exp $ + * $Id: estimation.h,v 1.1.2.8 2003/12/18 02:02:08 Isibaar Exp $ * ****************************************************************************/ @@ -38,12 +38,12 @@ #define MV_MAX_ERROR (4096 * 256) /* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ -#define MV16_INTER_BIAS 512 +#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_8X8_BIAS 30 +#define NEIGH_8X8_BIAS 40 #define BITS_MULT 16 @@ -71,51 +71,57 @@ typedef struct { + /* data modified by CheckCandidates */ + int32_t iMinSAD[5]; /* smallest SADs found so far */ + VECTOR currentMV[5]; /* best vectors found so far */ + VECTOR currentQMV[5]; /* as above, but used during qpel search */ + int temp[4]; /* temporary space */ + unsigned int dir; /* 'direction', set when better vector is found */ + int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */ + VECTOR currentQMV2; /* extra vector for SubpelRefine_fast */ + int32_t iMinSAD2; /* extra SAD value for SubpelRefine_fast */ + /* general fields */ - int max_dx, min_dx, max_dy, min_dy; - uint32_t rounding; - VECTOR predMV; - VECTOR * currentMV; - VECTOR * currentQMV; - VECTOR * currentMV2; - VECTOR * currentQMV2; - int32_t * iMinSAD; - int32_t * iMinSAD2; - const uint8_t * RefP[6]; /* N, V, H, HV, cU, cV */ - const uint8_t * CurU; - const uint8_t * CurV; - uint8_t * RefQ; - const uint8_t * Cur; - uint32_t lambda16; - uint32_t lambda8; - uint32_t iEdgedWidth; - uint32_t iFcode; - int * temp; - unsigned int * dir; - int qpel, qpel_precision; - int chroma; - int rrv; + 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 */ + const uint8_t * Cur; /* current picture */ + const uint8_t *CurU, *CurV; /* current picture - chroma planes */ + + uint8_t * RefQ; /* temporary space for interpolations */ + uint32_t lambda16; /* how much vector bits weight */ + uint32_t lambda8; /* as above - for inter4v mode */ + uint32_t iEdgedWidth; /* picture's stride */ + uint32_t iFcode; /* current fcode */ + + int qpel; /* if we're coding in qpel mode */ + int qpel_precision; /* if X and Y are in qpel precision (refinement probably) */ + int chroma; /* should we include chroma SAD? */ + int rrv; /* are we using reduced resolution? */ /* fields for interpolate and direct modes */ - const uint8_t * b_RefP[6]; /* N, V, H, HV, cU, cV */ - VECTOR bpredMV; - uint32_t bFcode; + const uint8_t * b_RefP[6]; /* backward reference pictures - N, V, H, HV, cU, cV */ + VECTOR bpredMV; /* backward prediction - used interpolate mode only */ + uint32_t bFcode; /* backward fcode - used as above */ /* fields for direct mode */ - VECTOR directmvF[4]; - VECTOR directmvB[4]; - const VECTOR * referencemv; + VECTOR directmvF[4]; /* scaled reference vectors */ + VECTOR directmvB[4]; /* as above */ + const VECTOR * referencemv; /* pointer to not-scaled reference vectors */ /* BITS/R-D stuff */ - int16_t * dctSpace; - uint32_t iQuant; - uint32_t quant_type; - int * cbp; + int16_t * dctSpace; /* temporary space for dct */ + uint32_t iQuant; /* current quant */ + uint32_t quant_type; /* current quant type */ + unsigned int cbp[2]; /* CBP of the best vector found so far + cbp for inter4v search */ + const uint16_t * scan_table; /* current scan table */ + const uint16_t * mpeg_quant_matrices; /* current MPEG quantization matrices */ } SearchData; typedef void(CheckFunc)(const int x, const int y, - const SearchData * const Data, + SearchData * const Data, const unsigned int Direction); CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ @@ -129,7 +135,7 @@ const SearchData * const data); int32_t -xvid_me_ChromaSAD(const int dx, const int dy, const SearchData * const data); +xvid_me_ChromaSAD(const int dx, const int dy, SearchData * const data); int xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, @@ -138,22 +144,16 @@ #define iDiamondSize 2 typedef void -MainSearchFunc(int x, int y, const SearchData * const Data, +MainSearchFunc(int x, int y, SearchData * const Data, int bDirection, CheckFunc * const CheckCandidate); MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; void -xvid_me_SubpelRefine(const SearchData * const data, CheckFunc * const CheckCandidate); +xvid_me_SubpelRefine(SearchData * const data, CheckFunc * const CheckCandidate); -int -globalSAD(const WARPPOINTS *const wp, - const MBParam * const pParam, - const MACROBLOCK * const pMBs, - const FRAMEINFO * const current, - const IMAGE * const pRef, - const IMAGE * const pCurr, - uint8_t *const GMCblock); +void +SubpelRefine_Fast(SearchData * data, CheckFunc * CheckCandidate); void xvid_me_ModeDecision_RD(SearchData * const Data,