38 |
#define MV_MAX_ERROR (4096 * 256) |
#define MV_MAX_ERROR (4096 * 256) |
39 |
|
|
40 |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
/* INTER bias for INTER/INTRA decision; mpeg4 spec suggests 2*nb */ |
41 |
#define MV16_INTER_BIAS 512 |
#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 10.5 |
45 |
#define NEIGH_TEND_8X8 40.0 |
#define NEIGH_TEND_8X8 40.0 |
46 |
#define NEIGH_8X8_BIAS 30 |
#define NEIGH_8X8_BIAS 40 |
47 |
|
|
48 |
#define BITS_MULT 16 |
#define BITS_MULT 16 |
49 |
|
|
71 |
|
|
72 |
typedef struct |
typedef struct |
73 |
{ |
{ |
74 |
|
/* data modified by CheckCandidates */ |
75 |
|
int32_t iMinSAD[5]; /* smallest SADs found so far */ |
76 |
|
VECTOR currentMV[5]; /* best vectors found so far */ |
77 |
|
VECTOR currentQMV[5]; /* as above, but used during qpel search */ |
78 |
|
int temp[4]; /* temporary space */ |
79 |
|
unsigned int dir; /* 'direction', set when better vector is found */ |
80 |
|
int chromaX, chromaY, chromaSAD; /* info to make ChromaSAD faster */ |
81 |
|
VECTOR currentQMV2; /* extra vector for SubpelRefine_fast */ |
82 |
|
int32_t iMinSAD2; /* extra SAD value for SubpelRefine_fast */ |
83 |
|
|
84 |
/* general fields */ |
/* general fields */ |
85 |
int max_dx, min_dx, max_dy, min_dy; |
int max_dx, min_dx, max_dy, min_dy; /* maximum range */ |
86 |
uint32_t rounding; |
uint32_t rounding; /* rounding type in use */ |
87 |
VECTOR predMV; |
VECTOR predMV; /* vector which predicts current vector */ |
88 |
VECTOR * currentMV; |
const uint8_t * RefP[6]; /* reference pictures - N, V, H, HV, cU, cV */ |
89 |
VECTOR * currentQMV; |
const uint8_t * Cur; /* current picture */ |
90 |
VECTOR * currentQMV2; |
const uint8_t *CurU, *CurV; /* current picture - chroma planes */ |
91 |
int32_t * iMinSAD; |
|
92 |
int32_t * iMinSAD2; |
uint8_t * RefQ; /* temporary space for interpolations */ |
93 |
const uint8_t * RefP[6]; /* N, V, H, HV, cU, cV */ |
uint32_t lambda16; /* how much vector bits weight */ |
94 |
const uint8_t * CurU; |
uint32_t lambda8; /* as above - for inter4v mode */ |
95 |
const uint8_t * CurV; |
uint32_t iEdgedWidth; /* picture's stride */ |
96 |
uint8_t * RefQ; |
uint32_t iFcode; /* current fcode */ |
97 |
const uint8_t * Cur; |
|
98 |
uint32_t lambda16; |
int qpel; /* if we're coding in qpel mode */ |
99 |
uint32_t lambda8; |
int qpel_precision; /* if X and Y are in qpel precision (refinement probably) */ |
100 |
uint32_t iEdgedWidth; |
int chroma; /* should we include chroma SAD? */ |
101 |
uint32_t iFcode; |
int rrv; /* are we using reduced resolution? */ |
|
int * temp; |
|
|
unsigned int * dir; |
|
|
int qpel, qpel_precision; |
|
|
int chroma; |
|
|
int rrv; |
|
102 |
|
|
103 |
/* fields for interpolate and direct modes */ |
/* fields for interpolate and direct modes */ |
104 |
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 */ |
105 |
VECTOR bpredMV; |
VECTOR bpredMV; /* backward prediction - used interpolate mode only */ |
106 |
uint32_t bFcode; |
uint32_t bFcode; /* backward fcode - used as above */ |
107 |
|
|
108 |
/* fields for direct mode */ |
/* fields for direct mode */ |
109 |
VECTOR directmvF[4]; |
VECTOR directmvF[4]; /* scaled reference vectors */ |
110 |
VECTOR directmvB[4]; |
VECTOR directmvB[4]; /* as above */ |
111 |
const VECTOR * referencemv; |
const VECTOR * referencemv; /* pointer to not-scaled reference vectors */ |
112 |
|
|
113 |
/* BITS/R-D stuff */ |
/* BITS/R-D stuff */ |
114 |
int16_t * dctSpace; |
int16_t * dctSpace; /* temporary space for dct */ |
115 |
uint32_t iQuant; |
uint32_t iQuant; /* current quant */ |
116 |
uint32_t quant_type; |
uint32_t quant_type; /* current quant type */ |
117 |
int * cbp; |
unsigned int cbp[2]; /* CBP of the best vector found so far + cbp for inter4v search */ |
118 |
const uint16_t * scan_table; |
const uint16_t * scan_table; /* current scan table */ |
119 |
|
const uint16_t * mpeg_quant_matrices; /* current MPEG quantization matrices */ |
120 |
|
|
121 |
} SearchData; |
} SearchData; |
122 |
|
|
123 |
typedef void(CheckFunc)(const int x, const int y, |
typedef void(CheckFunc)(const int x, const int y, |
124 |
const SearchData * const Data, |
SearchData * const Data, |
125 |
const unsigned int Direction); |
const unsigned int Direction); |
126 |
|
|
127 |
CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ |
CheckFunc CheckCandidate16no4v; /* shared between p-vop and b-vop search */ |
135 |
const SearchData * const data); |
const SearchData * const data); |
136 |
|
|
137 |
int32_t |
int32_t |
138 |
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); |
139 |
|
|
140 |
int |
int |
141 |
xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, |
xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference, |
144 |
|
|
145 |
#define iDiamondSize 2 |
#define iDiamondSize 2 |
146 |
typedef void |
typedef void |
147 |
MainSearchFunc(int x, int y, const SearchData * const Data, |
MainSearchFunc(int x, int y, SearchData * const Data, |
148 |
int bDirection, CheckFunc * const CheckCandidate); |
int bDirection, CheckFunc * const CheckCandidate); |
149 |
|
|
150 |
MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; |
MainSearchFunc xvid_me_DiamondSearch, xvid_me_AdvDiamondSearch, xvid_me_SquareSearch; |
151 |
|
|
152 |
void |
void |
153 |
xvid_me_SubpelRefine(const SearchData * const data, CheckFunc * const CheckCandidate); |
xvid_me_SubpelRefine(SearchData * const data, CheckFunc * const CheckCandidate); |
154 |
|
|
155 |
|
void |
156 |
|
SubpelRefine_Fast(SearchData * data, CheckFunc * CheckCandidate); |
157 |
|
|
158 |
void |
void |
159 |
xvid_me_ModeDecision_RD(SearchData * const Data, |
xvid_me_ModeDecision_RD(SearchData * const Data, |