44 |
uint32_t block_sz, /* block dimension, 3(8) or 4(16) */ |
uint32_t block_sz, /* block dimension, 3(8) or 4(16) */ |
45 |
const uint32_t width, |
const uint32_t width, |
46 |
const uint32_t height, |
const uint32_t height, |
47 |
const uint32_t fcode, |
const int fcode, |
48 |
const int precision, /* 2 for qpel, 1 for halfpel */ |
const int precision) /* 2 for qpel, 1 for halfpel */ |
|
const int rrv) |
|
49 |
{ |
{ |
50 |
int k; |
int k; |
51 |
const int search_range = 16 << fcode; |
const int search_range = 1 << (4+fcode); |
52 |
int high = search_range - 1; |
int high = search_range - 1; |
53 |
int low = -search_range; |
int low = -search_range; |
54 |
|
|
|
if (rrv) { |
|
|
high = RRV_MV_SCALEUP(high); |
|
|
low = RRV_MV_SCALEUP(low); |
|
|
block_sz++; |
|
|
} |
|
|
|
|
55 |
k = (int)(width - (x<<block_sz))<<precision; |
k = (int)(width - (x<<block_sz))<<precision; |
56 |
*max_dx = MIN(high, k); |
*max_dx = MIN(high, k); |
57 |
k = (int)(height - (y<<block_sz))<<precision; |
k = (int)(height - (y<<block_sz))<<precision; |
64 |
} |
} |
65 |
|
|
66 |
/* reversed mv.length table */ |
/* reversed mv.length table */ |
67 |
static const int r_mvtab[64] = { |
static const int r_mvtab[65] = { |
68 |
12, 12, 12, 12, 12, 12, 12, 12, |
11, 12, 12, 12, 12, 12, 12, 12, 12, |
69 |
12, 12, 12, 12, 12, 12, 12, 12, |
12, 12, 12, 12, 12, 12, 12, 12, |
70 |
12, 12, 12, 12, 12, 12, 12, 12, |
12, 12, 12, 12, 12, 12, 12, 12, |
71 |
12, 12, 12, 12, 12, 12, 12, 12, |
12, 12, 12, 12, 12, 12, 12, 12, |
76 |
}; |
}; |
77 |
|
|
78 |
static __inline uint32_t |
static __inline uint32_t |
79 |
d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv) |
d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel) |
80 |
{ |
{ |
81 |
unsigned int bits; |
unsigned int bits; |
82 |
|
|
83 |
x <<= qpel; |
x <<= qpel; |
84 |
y <<= qpel; |
y <<= qpel; |
|
if (rrv) { x = RRV_MV_SCALEDOWN(x); y = RRV_MV_SCALEDOWN(y); } |
|
85 |
|
|
86 |
x -= pred.x; |
x -= pred.x; |
87 |
bits = (x != 0 ? iFcode:0); |
bits = (x != 0 ? iFcode:0); |
88 |
x = -abs(x); |
x = -abs(x); |
89 |
x >>= (iFcode - 1); |
x >>= (iFcode - 1); |
90 |
bits += r_mvtab[x+63]; |
bits += r_mvtab[x+64]; |
91 |
|
|
92 |
y -= pred.y; |
y -= pred.y; |
93 |
bits += (y != 0 ? iFcode:0); |
bits += (y != 0 ? iFcode:0); |
94 |
y = -abs(y); |
y = -abs(y); |
95 |
y >>= (iFcode - 1); |
y >>= (iFcode - 1); |
96 |
bits += r_mvtab[y+63]; |
bits += r_mvtab[y+64]; |
97 |
|
|
98 |
return bits; |
return bits; |
99 |
} |
} |