[cvs] / xvidcore / src / motion / estimation.h Repository:
ViewVC logotype

Diff of /xvidcore/src/motion/estimation.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.8, Thu Dec 18 02:02:08 2003 UTC revision 1.16, Fri Dec 24 13:21:35 2010 UTC
# Line 4  Line 4 
4   *  - Motion Estimation related header -   *  - Motion Estimation related header -
5   *   *
6   *  Copyright(C) 2002 Christoph Lampert <gruel@web.de>   *  Copyright(C) 2002 Christoph Lampert <gruel@web.de>
7   *               2002 Michael Militzer <michael@xvid.org>   *               2002-2010 Michael Militzer <michael@xvid.org>
8   *               2002-2003 Radoslaw Czyz <xvid@syskin.cjb.net>   *               2002-2003 Radoslaw Czyz <xvid@syskin.cjb.net>
9   *   *
10   *  This program is free software ; you can redistribute it and/or modify   *  This program is free software ; you can redistribute it and/or modify
# Line 30  Line 30 
30    
31  #include "../portab.h"  #include "../portab.h"
32  #include "../global.h"  #include "../global.h"
33  #include "../image/reduced.h"  #include "sad.h"
34    
35  /* hard coded motion search parameters */  /* hard coded motion search parameters */
36    
# Line 41  Line 41 
41  #define MV16_INTER_BIAS 450  #define MV16_INTER_BIAS 450
42    
43  /* vector map (vlc delta size) smoother parameters ! float !*/  /* vector map (vlc delta size) smoother parameters ! float !*/
44  #define NEIGH_TEND_16X16                10.5  #define NEIGH_TEND_16X16                0.6
45  #define NEIGH_TEND_8X8                  40.0  #define NEIGH_TEND_8X8                  1.5
46    
47  #define NEIGH_8X8_BIAS                  40  #define NEIGH_8X8_BIAS                  40
48    
49  #define BITS_MULT                               16  #define BITS_MULT                               16
50    
51  #define INITIAL_SKIP_THRESH             10  #define INITIAL_SKIP_THRESH             6
52  #define FINAL_SKIP_THRESH               50  #define FINAL_SKIP_THRESH               50
53  #define MAX_SAD00_FOR_SKIP              20  #define MAX_SAD00_FOR_SKIP              20
54  #define MAX_CHROMA_SAD_FOR_SKIP 22  #define MAX_CHROMA_SAD_FOR_SKIP 22
# Line 60  Line 61 
61  #define CHECK_CANDIDATE(X,Y,D) { \  #define CHECK_CANDIDATE(X,Y,D) { \
62          CheckCandidate((X),(Y), data, (D) ); }          CheckCandidate((X),(Y), data, (D) ); }
63    
 #define RRV_MV_SCALEDOWN(a)     ( (a)>=0 ? (a+1)/2 : (a-1)/2 )  
   
64  /* fast ((A)/2)*2 */  /* fast ((A)/2)*2 */
65  #define EVEN(A)         (((A)<0?(A)+1:(A)) & ~1)  #define EVEN(A)         (((A)<0?(A)+1:(A)) & ~1)
66    
# Line 71  Line 70 
70    
71  typedef struct  typedef struct
72  {  {
73            int max_dx, min_dx, max_dy, min_dy; /* maximum search range */
74    
75          /* data modified by CheckCandidates */          /* data modified by CheckCandidates */
76          int32_t iMinSAD[5];                     /* smallest SADs found so far */          int32_t iMinSAD[5];                     /* smallest SADs found so far */
77          VECTOR currentMV[5];            /* best vectors found so far */          VECTOR currentMV[5];            /* best vectors found so far */
# Line 78  Line 79 
79          int temp[4];                            /* temporary space */          int temp[4];                            /* temporary space */
80          unsigned int dir;                       /* 'direction', set when better vector is found */          unsigned int dir;                       /* 'direction', set when better vector is found */
81          int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */          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 */  
82    
83          /* general fields */          /* general fields */
         int max_dx, min_dx, max_dy, min_dy; /* maximum range */  
84          uint32_t rounding;                      /* rounding type in use */          uint32_t rounding;                      /* rounding type in use */
85          VECTOR predMV;                          /* vector which predicts current vector */          VECTOR predMV;                          /* vector which predicts current vector */
86          const uint8_t * RefP[6];        /* reference pictures - N, V, H, HV, cU, cV */          const uint8_t * RefP[6];        /* reference pictures - N, V, H, HV, cU, cV */
# Line 98  Line 96 
96          int qpel;                                       /* if we're coding in qpel mode */          int qpel;                                       /* if we're coding in qpel mode */
97          int qpel_precision;                     /* if X and Y are in qpel precision (refinement probably) */          int qpel_precision;                     /* if X and Y are in qpel precision (refinement probably) */
98          int chroma;                                     /* should we include chroma SAD? */          int chroma;                                     /* should we include chroma SAD? */
         int rrv;                                        /* are we using reduced resolution? */  
99    
100          /* fields for interpolate and direct modes */          /* fields for interpolate and direct modes */
101          const uint8_t * b_RefP[6];      /* backward reference pictures - N, V, H, HV, cU, cV */          const uint8_t * b_RefP[6];      /* backward reference pictures - N, V, H, HV, cU, cV */
102          VECTOR bpredMV;                         /* backward prediction - used interpolate mode only */          VECTOR bpredMV;                         /* backward prediction - used in Interpolate-mode search only */
103          uint32_t bFcode;                        /* backward fcode - used as above */          uint32_t bFcode;                        /* backward fcode - used in Interpolate-mode search only */
104            int b_chromaX, b_chromaY;
105    
106          /* fields for direct mode */          /* fields for direct mode */
107          VECTOR directmvF[4];            /* scaled reference vectors */          VECTOR directmvF[4];            /* scaled reference vectors */
108          VECTOR directmvB[4];            /* as above */          VECTOR directmvB[4];
109          const VECTOR * referencemv; /* pointer to not-scaled reference vectors */          const VECTOR * referencemv; /* pointer to not-scaled reference vectors */
110    
111          /* BITS/R-D stuff */          /* BITS/R-D stuff */
# Line 117  Line 115 
115          unsigned int cbp[2];                                    /* CBP of the best vector found so far + cbp for inter4v search */          unsigned int cbp[2];                                    /* CBP of the best vector found so far + cbp for inter4v search */
116          const uint16_t * scan_table; /* current scan table */          const uint16_t * scan_table; /* current scan table */
117          const uint16_t * mpeg_quant_matrices;                   /* current MPEG quantization matrices */          const uint16_t * mpeg_quant_matrices;                   /* current MPEG quantization matrices */
118            int lambda[6];                          /* R-D lambdas for all 6 blocks */
119            unsigned int quant_sq;          /* quant squared - saves many multiplications in VHQ */
120            uint32_t rel_var8[6];           /* relative variances for all 6 sub-blocks */
121            int metric;                                     /* distortion metric for R-D optimizations, currently: PSNR=0, PSNRHVSM=1 */
122  } SearchData;  } SearchData;
123    
124    static __inline uint32_t
125    masked_sseh8_16bit(int16_t * const orig,
126                       int16_t * const rec,
127                       const uint32_t rel_var8)
128    {
129            uint16_t mask = ((isqrt(2*coeff8_energy(orig)*rel_var8) + 48) >> 6);
130            return (5*sseh8_16bit(orig, rec, (uint16_t) mask)) >> 7;
131    }
132    
133  typedef void(CheckFunc)(const int x, const int y,  typedef void(CheckFunc)(const int x, const int y,
134                                                  SearchData * const Data,                                                  SearchData * const Data,
135                                                  const unsigned int Direction);                                                  const unsigned int Direction);
# Line 140  Line 150 
150  int  int
151  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,
152                                          const int x, const int y,                                          const int x, const int y,
153                                          const uint32_t stride, const uint32_t iQuant, int rrv);                                          const uint32_t stride, const uint32_t iQuant);
154    
155  #define iDiamondSize 2  #define iDiamondSize 2
156  typedef void  typedef void
# Line 150  Line 160 
160  MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch;  MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch;
161    
162  void  void
163  xvid_me_SubpelRefine(SearchData * const data, CheckFunc * const CheckCandidate);  xvid_me_SubpelRefine(VECTOR centerMV, SearchData * const data, CheckFunc * const CheckCandidate, int dir);
164    
165  void  void
166  SubpelRefine_Fast(SearchData * data, CheckFunc * CheckCandidate);  FullRefine_Fast(SearchData * data, CheckFunc * CheckCandidate, int direction);
167    
168  void  void
169  xvid_me_ModeDecision_RD(SearchData * const Data,  xvid_me_ModeDecision_RD(SearchData * const Data,
# Line 167  Line 177 
177                  const IMAGE * const pCurrent,                  const IMAGE * const pCurrent,
178                  const IMAGE * const pRef,                  const IMAGE * const pRef,
179                  const IMAGE * const vGMC,                  const IMAGE * const vGMC,
180                  const int coding_type);                  const int coding_type,
181                    const int bound);
182    
183  void  void
184  xvid_me_ModeDecision_Fast(SearchData * const Data,  xvid_me_ModeDecision_Fast(SearchData * const Data,
# Line 181  Line 192 
192                  const IMAGE * const pCurrent,                  const IMAGE * const pCurrent,
193                  const IMAGE * const pRef,                  const IMAGE * const pRef,
194                  const IMAGE * const vGMC,                  const IMAGE * const vGMC,
195                  const int coding_type);                  const int coding_type,
196                    const int bound);
197    
198    void
199    ModeDecision_BVOP_RD(SearchData * const Data_d,
200                                             SearchData * const Data_b,
201                                             SearchData * const Data_f,
202                                             SearchData * const Data_i,
203                                             MACROBLOCK * const pMB,
204                                             const MACROBLOCK * const b_mb,
205                                             VECTOR * f_predMV,
206                                             VECTOR * b_predMV,
207                                             const uint32_t MotionFlags,
208                                             const uint32_t VopFlags,
209                                             const MBParam * const pParam,
210                                             int x, int y,
211                                             int best_sad,
212                                             int force_direct);
213    
214    unsigned int
215    getMinFcode(const int MVmax);
216    
217  #endif                                                  /* _ESTIMATION_H_ */  #endif                                                  /* _ESTIMATION_H_ */

Legend:
Removed from v.1.1.2.8  
changed lines
  Added in v.1.16

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4