30 |
|
|
31 |
#include "../portab.h" |
#include "../portab.h" |
32 |
#include "../global.h" |
#include "../global.h" |
|
#include "../image/reduced.h" |
|
33 |
|
|
34 |
/* hard coded motion search parameters */ |
/* hard coded motion search parameters */ |
35 |
|
|
37 |
#define MV_MAX_ERROR (4096 * 256) |
#define MV_MAX_ERROR (4096 * 256) |
38 |
|
|
39 |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
40 |
#define MV16_INTER_BIAS 512 |
#define MV16_INTER_BIAS 450 |
41 |
|
|
42 |
/* vector map (vlc delta size) smoother parameters ! float !*/ |
/* vector map (vlc delta size) smoother parameters ! float !*/ |
43 |
#define NEIGH_TEND_16X16 10.5 |
#define NEIGH_TEND_16X16 10.5 |
44 |
#define NEIGH_TEND_8X8 40.0 |
#define NEIGH_TEND_8X8 40.0 |
45 |
#define NEIGH_8X8_BIAS 30 |
#define NEIGH_8X8_BIAS 40 |
46 |
|
|
47 |
#define BITS_MULT 16 |
#define BITS_MULT 16 |
48 |
|
|
49 |
#define INITIAL_SKIP_THRESH 10 |
#define INITIAL_SKIP_THRESH 6 |
50 |
#define FINAL_SKIP_THRESH 50 |
#define FINAL_SKIP_THRESH 50 |
51 |
#define MAX_SAD00_FOR_SKIP 20 |
#define MAX_SAD00_FOR_SKIP 20 |
52 |
#define MAX_CHROMA_SAD_FOR_SKIP 22 |
#define MAX_CHROMA_SAD_FOR_SKIP 22 |
59 |
#define CHECK_CANDIDATE(X,Y,D) { \ |
#define CHECK_CANDIDATE(X,Y,D) { \ |
60 |
CheckCandidate((X),(Y), data, (D) ); } |
CheckCandidate((X),(Y), data, (D) ); } |
61 |
|
|
|
#define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) |
|
|
|
|
62 |
/* fast ((A)/2)*2 */ |
/* fast ((A)/2)*2 */ |
63 |
#define EVEN(A) (((A)<0?(A)+1:(A)) & ~1) |
#define EVEN(A) (((A)<0?(A)+1:(A)) & ~1) |
64 |
|
|
68 |
|
|
69 |
typedef struct |
typedef struct |
70 |
{ |
{ |
71 |
|
/* data modified by CheckCandidates */ |
72 |
|
int32_t iMinSAD[5]; /* smallest SADs found so far */ |
73 |
|
VECTOR currentMV[5]; /* best vectors found so far */ |
74 |
|
VECTOR currentQMV[5]; /* as above, but used during qpel search */ |
75 |
|
int temp[4]; /* temporary space */ |
76 |
|
unsigned int dir; /* 'direction', set when better vector is found */ |
77 |
|
int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */ |
78 |
|
|
79 |
/* general fields */ |
/* general fields */ |
80 |
int max_dx, min_dx, max_dy, min_dy; |
int max_dx, min_dx, max_dy, min_dy; /* maximum range */ |
81 |
uint32_t rounding; |
uint32_t rounding; /* rounding type in use */ |
82 |
VECTOR predMV; |
VECTOR predMV; /* vector which predicts current vector */ |
83 |
VECTOR * currentMV; |
const uint8_t * RefP[6]; /* reference pictures - N, V, H, HV, cU, cV */ |
84 |
VECTOR * currentQMV; |
const uint8_t * Cur; /* current picture */ |
85 |
VECTOR * currentQMV2; |
const uint8_t *CurU, *CurV; /* current picture - chroma planes */ |
86 |
int32_t * iMinSAD; |
|
87 |
int32_t * iMinSAD2; |
uint8_t * RefQ; /* temporary space for interpolations */ |
88 |
const uint8_t * RefP[6]; /* N, V, H, HV, cU, cV */ |
uint32_t lambda16; /* how much vector bits weight */ |
89 |
const uint8_t * CurU; |
uint32_t lambda8; /* as above - for inter4v mode */ |
90 |
const uint8_t * CurV; |
uint32_t iEdgedWidth; /* picture's stride */ |
91 |
uint8_t * RefQ; |
uint32_t iFcode; /* current fcode */ |
92 |
const uint8_t * Cur; |
|
93 |
uint32_t lambda16; |
int qpel; /* if we're coding in qpel mode */ |
94 |
uint32_t lambda8; |
int qpel_precision; /* if X and Y are in qpel precision (refinement probably) */ |
95 |
uint32_t iEdgedWidth; |
int chroma; /* should we include chroma SAD? */ |
|
uint32_t iFcode; |
|
|
int * temp; |
|
|
unsigned int * dir; |
|
|
int qpel, qpel_precision; |
|
|
int chroma; |
|
|
int rrv; |
|
96 |
|
|
97 |
/* fields for interpolate and direct modes */ |
/* fields for interpolate and direct modes */ |
98 |
const uint8_t * b_RefP[6]; /* N, V, H, HV, cU, cV */ |
const uint8_t * b_RefP[6]; /* backward reference pictures - N, V, H, HV, cU, cV */ |
99 |
VECTOR bpredMV; |
VECTOR bpredMV; /* backward prediction - used in Interpolate-mode search only */ |
100 |
uint32_t bFcode; |
uint32_t bFcode; /* backward fcode - used in Interpolate-mode search only */ |
101 |
|
int b_chromaX, b_chromaY; |
102 |
|
|
103 |
/* fields for direct mode */ |
/* fields for direct mode */ |
104 |
VECTOR directmvF[4]; |
VECTOR directmvF[4]; /* scaled reference vectors */ |
105 |
VECTOR directmvB[4]; |
VECTOR directmvB[4]; |
106 |
const VECTOR * referencemv; |
const VECTOR * referencemv; /* pointer to not-scaled reference vectors */ |
107 |
|
|
108 |
/* BITS/R-D stuff */ |
/* BITS/R-D stuff */ |
109 |
int16_t * dctSpace; |
int16_t * dctSpace; /* temporary space for dct */ |
110 |
uint32_t iQuant; |
uint32_t iQuant; /* current quant */ |
111 |
uint32_t quant_type; |
uint32_t quant_type; /* current quant type */ |
112 |
int * cbp; |
unsigned int cbp[2]; /* CBP of the best vector found so far + cbp for inter4v search */ |
113 |
const uint16_t * scan_table; |
const uint16_t * scan_table; /* current scan table */ |
114 |
|
const uint16_t * mpeg_quant_matrices; /* current MPEG quantization matrices */ |
115 |
|
int lambda[6]; /* R-D lambdas for all 6 blocks */ |
116 |
|
|
117 |
} SearchData; |
} SearchData; |
118 |
|
|
119 |
typedef void(CheckFunc)(const int x, const int y, |
typedef void(CheckFunc)(const int x, const int y, |
120 |
const SearchData * const Data, |
SearchData * const Data, |
121 |
const unsigned int Direction); |
const unsigned int Direction); |
122 |
|
|
123 |
CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ |
CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ |
131 |
const SearchData * const data); |
const SearchData * const data); |
132 |
|
|
133 |
int32_t |
int32_t |
134 |
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); |
135 |
|
|
136 |
int |
int |
137 |
xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, |
xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, |
138 |
const int x, const int y, |
const int x, const int y, |
139 |
const uint32_t stride, const uint32_t iQuant, int rrv); |
const uint32_t stride, const uint32_t iQuant); |
140 |
|
|
141 |
#define iDiamondSize 2 |
#define iDiamondSize 2 |
142 |
typedef void |
typedef void |
143 |
MainSearchFunc(int x, int y, const SearchData * const Data, |
MainSearchFunc(int x, int y, SearchData * const Data, |
144 |
int bDirection, CheckFunc * const CheckCandidate); |
int bDirection, CheckFunc * const CheckCandidate); |
145 |
|
|
146 |
MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; |
MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; |
147 |
|
|
148 |
void |
void |
149 |
xvid_me_SubpelRefine(const SearchData * const data, CheckFunc * const CheckCandidate); |
xvid_me_SubpelRefine(VECTOR centerMV, SearchData * const data, CheckFunc * const CheckCandidate, int dir); |
150 |
|
|
151 |
|
void |
152 |
|
FullRefine_Fast(SearchData * data, CheckFunc * CheckCandidate, int direction); |
153 |
|
|
154 |
void |
void |
155 |
xvid_me_ModeDecision_RD(SearchData * const Data, |
xvid_me_ModeDecision_RD(SearchData * const Data, |
179 |
const IMAGE * const vGMC, |
const IMAGE * const vGMC, |
180 |
const int coding_type); |
const int coding_type); |
181 |
|
|
182 |
|
void |
183 |
|
ModeDecision_BVOP_RD(SearchData * const Data_d, |
184 |
|
SearchData * const Data_b, |
185 |
|
SearchData * const Data_f, |
186 |
|
SearchData * const Data_i, |
187 |
|
MACROBLOCK * const pMB, |
188 |
|
const MACROBLOCK * const b_mb, |
189 |
|
VECTOR * f_predMV, |
190 |
|
VECTOR * b_predMV, |
191 |
|
const uint32_t MotionFlags, |
192 |
|
const MBParam * const pParam, |
193 |
|
int x, int y); |
194 |
|
|
195 |
|
|
196 |
#endif /* _ESTIMATION_H_ */ |
#endif /* _ESTIMATION_H_ */ |