26 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
* |
* |
29 |
* $Id: motion_est.h,v 1.1.2.10 2002-12-11 10:32:29 syskin Exp $ |
* $Id: motion_est.h,v 1.1.2.14 2003-01-24 11:44:24 syskin Exp $ |
30 |
* |
* |
31 |
***************************************************************************/ |
***************************************************************************/ |
32 |
|
|
35 |
|
|
36 |
#include "../portab.h" |
#include "../portab.h" |
37 |
#include "../global.h" |
#include "../global.h" |
38 |
|
#include "../image/reduced.h" |
39 |
|
|
40 |
/* hard coded motion search parameters for motion_est and smp_motion_est */ |
/* hard coded motion search parameters for motion_est and smp_motion_est */ |
41 |
|
|
47 |
|
|
48 |
/* vector map (vlc delta size) smoother parameters ! float !*/ |
/* vector map (vlc delta size) smoother parameters ! float !*/ |
49 |
#define NEIGH_TEND_16X16 10.5 |
#define NEIGH_TEND_16X16 10.5 |
50 |
#define NEIGH_TEND_8X8 4.0 |
#define NEIGH_TEND_8X8 40.0 |
51 |
#define NEIGH_8X8_BIAS 30 |
#define NEIGH_8X8_BIAS 30 |
52 |
|
|
53 |
/* Parameters which control inter/inter4v decision */ |
/* Parameters which control inter/inter4v decision */ |
102 |
}; |
}; |
103 |
|
|
104 |
#define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) |
#define RRV_MV_SCALEDOWN(a) ( (a)>=0 ? (a+1)/2 : (a-1)/2 ) |
105 |
#define RRV_MV_SCALEUP(a) ( (a)>0 ? 2*(a)-1 : (a)<0 ? 2*(a)+1 : (a) ) |
|
106 |
|
static const VECTOR zeroMV = {0,0}; |
107 |
|
|
108 |
typedef struct |
typedef struct |
109 |
{ |
{ |
132 |
int qpel, qpel_precision; |
int qpel, qpel_precision; |
133 |
int chroma; |
int chroma; |
134 |
int rrv; |
int rrv; |
135 |
//fields for interpolate and direct mode |
//fields for interpolate and direct modes |
136 |
const uint8_t *bRef; |
const uint8_t *bRef; |
137 |
const uint8_t *bRefH; |
const uint8_t *bRefH; |
138 |
const uint8_t *bRefV; |
const uint8_t *bRefV; |
139 |
const uint8_t *bRefHV; |
const uint8_t *bRefHV; |
140 |
|
const uint8_t * b_RefCU; |
141 |
|
const uint8_t * b_RefCV; |
142 |
|
|
143 |
VECTOR bpredMV; |
VECTOR bpredMV; |
144 |
uint32_t bFcode; |
uint32_t bFcode; |
145 |
// fields for direct mode |
// fields for direct mode |
146 |
VECTOR directmvF[4]; |
VECTOR directmvF[4]; |
147 |
VECTOR directmvB[4]; |
VECTOR directmvB[4]; |
148 |
const VECTOR * referencemv; |
const VECTOR * referencemv; |
149 |
} |
|
150 |
SearchData; |
} SearchData; |
151 |
|
|
152 |
|
|
153 |
typedef void(CheckFunc)(const int x, const int y, |
typedef void(CheckFunc)(const int x, const int y, |
154 |
const int Direction, int * const dir, |
const int Direction, int * const dir, |
155 |
const SearchData * const Data); |
const SearchData * const Data); |
|
|
|
|
static CheckFunc CheckCandidate16, CheckCandidate16no4v, CheckCandidateInt, |
|
|
CheckCandidateDirect, CheckCandidateDirectno4v, |
|
|
CheckCandidate8; |
|
156 |
CheckFunc *CheckCandidate; |
CheckFunc *CheckCandidate; |
157 |
|
|
158 |
/* |
/* |
159 |
* Calculate the min/max range (in halfpixels) |
* Calculate the min/max range |
160 |
* relative to the _MACROBLOCK_ position |
* relative to the _MACROBLOCK_ position |
161 |
*/ |
*/ |
162 |
static void __inline |
static void __inline |
166 |
int32_t * const max_dy, |
int32_t * const max_dy, |
167 |
const uint32_t x, |
const uint32_t x, |
168 |
const uint32_t y, |
const uint32_t y, |
169 |
const uint32_t block_sz, /* block dimension, 8 or 16 */ |
uint32_t block_sz, /* block dimension, 8 or 16 */ |
|
const uint32_t width, |
|
|
const uint32_t height, |
|
|
const uint32_t fcode) |
|
|
{ |
|
|
int k; |
|
|
const int search_range = 32 << (fcode - 1); |
|
|
const int high = search_range - 1; |
|
|
const int low = -search_range; |
|
|
|
|
|
k = 2 * (int)(width - x*block_sz); |
|
|
*max_dx = MIN(high, k); |
|
|
k = 2 * (int)(height - y*block_sz); |
|
|
*max_dy = MIN(high, k); |
|
|
|
|
|
k = -2 * (int)((x+1) * block_sz); |
|
|
*min_dx = MAX(low, k); |
|
|
k = -2 * (int)((y+1) * block_sz); |
|
|
*min_dy = MAX(low, k); |
|
|
} |
|
|
|
|
|
static void __inline |
|
|
get_range_rrv(int32_t * const min_dx, |
|
|
int32_t * const max_dx, |
|
|
int32_t * const min_dy, |
|
|
int32_t * const max_dy, |
|
|
const uint32_t x, |
|
|
const uint32_t y, |
|
|
const uint32_t block_sz, /* block dimension, 8 or 16 */ |
|
170 |
const uint32_t width, |
const uint32_t width, |
171 |
const uint32_t height, |
const uint32_t height, |
172 |
const uint32_t fcode) |
const uint32_t fcode, |
173 |
|
const int qpel, /* 1 if the resulting range should be in qpel precision; otherwise 0 */ |
174 |
|
const int rrv) |
175 |
{ |
{ |
176 |
int k; |
int k, m = qpel ? 4 : 2; |
177 |
const int search_range = 32 << (fcode - 1); |
const int search_range = 32 << (fcode - 1); |
178 |
const int high = RRV_MV_SCALEUP(search_range - 1); //halfzero -> halfpel, because we do our search in halfpel |
int high = search_range - 1; |
179 |
const int low = RRV_MV_SCALEUP(-search_range); |
int low = -search_range; |
180 |
|
|
181 |
k = 2 * (int)(width - x*block_sz); |
if (rrv) { |
182 |
*max_dx = MIN(high, k); |
high = RRV_MV_SCALEUP(high); |
183 |
k = 2 * (int)(height - y*block_sz); |
low = RRV_MV_SCALEUP(low); |
184 |
*max_dy = MIN(high, k); |
block_sz *= 2; |
|
|
|
|
k = -2 * (int)((x+1) * block_sz); |
|
|
*min_dx = MAX(low, k); |
|
|
k = -2 * (int)((y+1) * block_sz); |
|
|
*min_dy = MAX(low, k); |
|
185 |
} |
} |
186 |
|
|
187 |
static void __inline |
k = m * (int)(width - x * block_sz); |
|
get_range_qpel(int32_t * const min_dx, |
|
|
int32_t * const max_dx, |
|
|
int32_t * const min_dy, |
|
|
int32_t * const max_dy, |
|
|
const uint32_t x, |
|
|
const uint32_t y, |
|
|
const uint32_t block_sz, /* block dimension, 8 or 16 */ |
|
|
const uint32_t width, |
|
|
const uint32_t height, |
|
|
const uint32_t fcode) |
|
|
{ |
|
|
int k; |
|
|
const int search_range = 32 << (fcode - 1); |
|
|
const int high = search_range - 1; |
|
|
const int low = -search_range; |
|
|
|
|
|
k = 4 * (int)(width - x*block_sz); |
|
188 |
*max_dx = MIN(high, k); |
*max_dx = MIN(high, k); |
189 |
k = 4 * (int)(height - y*block_sz); |
k = m * (int)(height - y * block_sz); |
190 |
*max_dy = MIN(high, k); |
*max_dy = MIN(high, k); |
191 |
|
|
192 |
k = -4 * (int)((x+1) * block_sz); |
k = -m * (int)((x+1) * block_sz); |
193 |
*min_dx = MAX(low, k); |
*min_dx = MAX(low, k); |
194 |
k = -4 * (int)((y+1) * block_sz); |
k = -m * (int)((y+1) * block_sz); |
195 |
*min_dy = MAX(low, k); |
*min_dy = MAX(low, k); |
196 |
} |
} |
197 |
|
|
|
|
|
198 |
typedef void MainSearchFunc(int x, int y, const SearchData * const Data, int bDirection); |
typedef void MainSearchFunc(int x, int y, const SearchData * const Data, int bDirection); |
199 |
|
|
200 |
static MainSearchFunc DiamondSearch, AdvDiamondSearch, SquareSearch; |
static MainSearchFunc DiamondSearch, AdvDiamondSearch, SquareSearch; |
234 |
int inter4v, |
int inter4v, |
235 |
MACROBLOCK * const pMB); |
MACROBLOCK * const pMB); |
236 |
|
|
237 |
|
|
238 |
|
static WARPPOINTS |
239 |
|
GlobalMotionEst(const MACROBLOCK * const pMBs, |
240 |
|
const MBParam * const pParam, |
241 |
|
const FRAMEINFO * const current, |
242 |
|
const FRAMEINFO * const reference, |
243 |
|
const IMAGE * const pRefH, |
244 |
|
const IMAGE * const pRefV, |
245 |
|
const IMAGE * const pRefHV ); |
246 |
|
|
247 |
|
#define iDiamondSize 2 |
248 |
|
|
249 |
#endif /* _MOTION_EST_H_ */ |
#endif /* _MOTION_EST_H_ */ |