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; |
63 |
*min_dy = MAX(low, k); |
*min_dy = MAX(low, k); |
64 |
} |
} |
65 |
|
|
66 |
/* mv.length table */ |
/* reversed mv.length table */ |
67 |
static const int mvtab[64] = { |
static const int r_mvtab[65] = { |
68 |
1, 2, 3, 4, 6, 7, 7, 7, |
11, 12, 12, 12, 12, 12, 12, 12, 12, |
|
9, 9, 9, 10, 10, 10, 10, 10, |
|
|
10, 10, 10, 10, 10, 10, 10, 10, |
|
|
10, 11, 11, 11, 11, 11, 11, 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, |
72 |
|
12, 11, 11, 11, 11, 11, 11, 10, |
73 |
|
10, 10, 10, 10, 10, 10, 10, 10, |
74 |
|
10, 10, 10, 10, 10, 9, 9, 9, |
75 |
|
7, 7, 7, 6, 4, 3, 2, 1 |
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 |
int bits; |
unsigned int bits; |
|
const int q = (1 << (iFcode - 1)) - 1; |
|
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); |
|
x += q; |
|
89 |
x >>= (iFcode - 1); |
x >>= (iFcode - 1); |
90 |
bits += mvtab[x]; |
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); |
|
y += q; |
|
95 |
y >>= (iFcode - 1); |
y >>= (iFcode - 1); |
96 |
bits += mvtab[y]; |
bits += r_mvtab[y+64]; |
97 |
|
|
98 |
return bits; |
return bits; |
99 |
} |
} |
124 |
pMB->qmvs[0] = pMB->qmvs[1] = pMB->qmvs[2] = pMB->qmvs[3] = zeroMV; |
pMB->qmvs[0] = pMB->qmvs[1] = pMB->qmvs[2] = pMB->qmvs[3] = zeroMV; |
125 |
pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = sad; |
pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = sad; |
126 |
pMB->mcsel = 0; |
pMB->mcsel = 0; |
127 |
|
pMB->cbp = 0; |
128 |
} |
} |
129 |
|
|
130 |
/* check if given vector is equal to any vector checked before */ |
/* check if given vector is equal to any vector checked before */ |