100 |
|
|
101 |
|
|
102 |
|
|
103 |
/* diamond search stuff |
/* |
104 |
keep the the sequence in circular order (so optimization works) |
* diamond search stuff |
105 |
|
* keep the the sequence in circular order (so optimization works) |
106 |
*/ |
*/ |
107 |
|
|
108 |
typedef struct |
typedef struct |
186 |
const uint32_t width, const uint32_t height, |
const uint32_t width, const uint32_t height, |
187 |
const uint32_t fcode) |
const uint32_t fcode) |
188 |
{ |
{ |
189 |
|
|
190 |
const int search_range = 32 << (fcode - 1); |
const int search_range = 32 << (fcode - 1); |
191 |
const int high = search_range - 1; |
const int high = search_range - 1; |
192 |
const int low = -search_range; |
const int low = -search_range; |
202 |
*max_dy = MIN(high, hp_height - hp_y); |
*max_dy = MIN(high, hp_height - hp_y); |
203 |
*min_dx = MAX(low, -(hp_edge + hp_x)); |
*min_dx = MAX(low, -(hp_edge + hp_x)); |
204 |
*min_dy = MAX(low, -(hp_edge + hp_y)); |
*min_dy = MAX(low, -(hp_edge + hp_y)); |
205 |
|
|
206 |
} |
} |
207 |
|
|
208 |
|
|
209 |
/* getref: calculate reference image pointer |
/* |
210 |
the decision to use interpolation h/v/hv or the normal image is |
* getref: calculate reference image pointer |
211 |
based on dx & dy. |
* the decision to use interpolation h/v/hv or the normal image is |
212 |
|
* based on dx & dy. |
213 |
*/ |
*/ |
214 |
|
|
215 |
static __inline const uint8_t * get_ref( |
static __inline const uint8_t * get_ref( |
222 |
const int32_t dx, const int32_t dy, |
const int32_t dx, const int32_t dy, |
223 |
const uint32_t stride) |
const uint32_t stride) |
224 |
{ |
{ |
225 |
|
|
226 |
switch ( ((dx&1)<<1) + (dy&1) ) // ((dx%2)?2:0)+((dy%2)?1:0) |
switch ( ((dx&1)<<1) + (dy&1) ) // ((dx%2)?2:0)+((dy%2)?1:0) |
227 |
{ |
{ |
228 |
case 0 : return refn + (x*block+dx/2) + (y*block+dy/2)*stride; |
case 0 : return refn + (x*block+dx/2) + (y*block+dy/2)*stride; |
231 |
default : |
default : |
232 |
case 3 : return refhv + (x*block+(dx-1)/2) + (y*block+(dy-1)/2)*stride; |
case 3 : return refhv + (x*block+(dx-1)/2) + (y*block+(dy-1)/2)*stride; |
233 |
} |
} |
234 |
|
|
235 |
} |
} |
236 |
|
|
237 |
|
|
247 |
const VECTOR* mv, // measured in half-pel! |
const VECTOR* mv, // measured in half-pel! |
248 |
const uint32_t stride) |
const uint32_t stride) |
249 |
{ |
{ |
250 |
|
|
251 |
switch ( (((mv->x)&1)<<1) + ((mv->y)&1) ) |
switch ( (((mv->x)&1)<<1) + ((mv->y)&1) ) |
252 |
{ |
{ |
253 |
case 0 : return refn + (x*block+(mv->x)/2) + (y*block+(mv->y)/2)*stride; |
case 0 : return refn + (x*block+(mv->x)/2) + (y*block+(mv->y)/2)*stride; |
256 |
default : |
default : |
257 |
case 3 : return refhv + (x*block+((mv->x)-1)/2) + (y*block+((mv->y)-1)/2)*stride; |
case 3 : return refhv + (x*block+((mv->x)-1)/2) + (y*block+((mv->y)-1)/2)*stride; |
258 |
} |
} |
259 |
|
|
260 |
} |
} |
261 |
|
|
262 |
#ifndef SEARCH16 |
#ifndef SEARCH16 |