1 |
|
// 04.10.2002 added qpel support to MBMotionCompensation |
2 |
// 01.05.2002 updated MBMotionCompensationBVOP |
// 01.05.2002 updated MBMotionCompensationBVOP |
3 |
// 14.04.2002 bframe compensation |
// 14.04.2002 bframe compensation |
4 |
|
|
11 |
#define ABS(X) (((X)>0)?(X):-(X)) |
#define ABS(X) (((X)>0)?(X):-(X)) |
12 |
#define SIGN(X) (((X)>0)?1:-1) |
#define SIGN(X) (((X)>0)?1:-1) |
13 |
|
|
14 |
static __inline void compensate8x8_halfpel( |
|
15 |
int16_t * const dct_codes, |
static __inline void |
16 |
|
compensate8x8_interpolate(int16_t * const dct_codes, |
17 |
uint8_t * const cur, |
uint8_t * const cur, |
18 |
const uint8_t * const ref, |
const uint8_t * const ref, |
19 |
const uint8_t * const refh, |
const uint8_t * const refh, |
20 |
const uint8_t * const refv, |
const uint8_t * const refv, |
21 |
const uint8_t * const refhv, |
const uint8_t * const refhv, |
22 |
const uint32_t x, const uint32_t y, |
const uint32_t x, |
23 |
const int32_t dx, const int dy, |
const uint32_t y, |
24 |
const uint32_t stride) |
const int32_t dx, |
25 |
{ |
const int32_t dy, |
26 |
int32_t ddx,ddy; |
const uint32_t stride, |
27 |
|
const uint32_t quarterpel, |
28 |
switch ( ((dx&1)<<1) + (dy&1) ) // ((dx%2)?2:0)+((dy%2)?1:0) |
const uint32_t rounding) |
29 |
{ |
{ |
30 |
case 0 : |
if(quarterpel) { |
31 |
ddx = dx/2; |
interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh, |
32 |
ddy = dy/2; |
(uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding); |
|
transfer_8to16sub(dct_codes, cur + y*stride + x, |
|
|
ref + (y+ddy)*stride + x+ddx, stride); |
|
|
break; |
|
33 |
|
|
|
case 1 : |
|
|
ddx = dx/2; |
|
|
ddy = (dy-1)/2; |
|
34 |
transfer_8to16sub(dct_codes, cur + y*stride + x, |
transfer_8to16sub(dct_codes, cur + y*stride + x, |
35 |
refv + (y+ddy)*stride + x+ddx, stride); |
refv + y*stride + x, stride); |
36 |
break; |
} |
37 |
|
else |
38 |
case 2 : |
{ |
39 |
ddx = (dx-1)/2; |
const uint8_t * reference; |
|
ddy = dy/2; |
|
|
transfer_8to16sub(dct_codes, cur + y*stride + x, |
|
|
refh + (y+ddy)*stride + x+ddx, stride); |
|
|
break; |
|
40 |
|
|
41 |
|
switch (((dx & 1) << 1) + (dy & 1)) // ((dx%2)?2:0)+((dy%2)?1:0) |
42 |
|
{ |
43 |
|
case 0: reference = ref + ((y + dy / 2) * stride + x + dx / 2); break; |
44 |
|
case 1: reference = refv + ((y + (dy-1) / 2) * stride + x + dx / 2); break; |
45 |
|
case 2: reference = refh + ((y + dy / 2) * stride + x + (dx-1) / 2); break; |
46 |
default : // case 3: |
default : // case 3: |
47 |
ddx = (dx-1)/2; |
reference = refhv + ((y + (dy-1) / 2) * stride + x + (dx-1) / 2); break; |
48 |
ddy = (dy-1)/2; |
} |
49 |
transfer_8to16sub(dct_codes, cur + y*stride + x, |
transfer_8to16sub(dct_codes, cur + y*stride + x, |
50 |
refhv + (y+ddy)*stride + x+ddx, stride); |
reference, stride); |
|
break; |
|
51 |
} |
} |
52 |
} |
} |
53 |
|
|
54 |
|
void |
55 |
|
MBMotionCompensation(MACROBLOCK * const mb, |
|
void MBMotionCompensation( |
|
|
MACROBLOCK * const mb, |
|
56 |
const uint32_t i, |
const uint32_t i, |
57 |
const uint32_t j, |
const uint32_t j, |
58 |
const IMAGE * const ref, |
const IMAGE * const ref, |
64 |
const uint32_t width, |
const uint32_t width, |
65 |
const uint32_t height, |
const uint32_t height, |
66 |
const uint32_t edged_width, |
const uint32_t edged_width, |
67 |
|
const uint32_t quarterpel, |
68 |
const uint32_t rounding) |
const uint32_t rounding) |
69 |
{ |
{ |
70 |
static const uint32_t roundtab[16] = |
if (mb->mode == MODE_NOT_CODED) { |
71 |
{ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; |
transfer8x8_copy(cur->y + 16 * (i + j * edged_width), |
72 |
|
ref->y + 16 * (i + j * edged_width), |
73 |
|
edged_width); |
74 |
|
transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8, |
75 |
|
ref->y + 16 * (i + j * edged_width) + 8, |
76 |
|
edged_width); |
77 |
|
transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * edged_width, |
78 |
|
ref->y + 16 * (i + j * edged_width) + 8 * edged_width, |
79 |
|
edged_width); |
80 |
|
transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * (edged_width+1), |
81 |
|
ref->y + 16 * (i + j * edged_width) + 8 * (edged_width+1), |
82 |
|
edged_width); |
83 |
|
|
84 |
|
transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2), |
85 |
|
ref->u + 8 * (i + j * edged_width/2), |
86 |
|
edged_width / 2); |
87 |
|
transfer8x8_copy(cur->v + 8 * (i + j * edged_width/2), |
88 |
|
ref->v + 8 * (i + j * edged_width/2), |
89 |
|
edged_width / 2); |
90 |
|
return; |
91 |
|
} |
92 |
|
|
93 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
|
{ |
|
94 |
int32_t dx = mb->mvs[0].x; |
int32_t dx = mb->mvs[0].x; |
95 |
int32_t dy = mb->mvs[0].y; |
int32_t dy = mb->mvs[0].y; |
96 |
|
|
97 |
compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
if(quarterpel) { |
98 |
16*i, 16*j, dx, dy, edged_width); |
dx = mb->qmvs[0].x; |
99 |
compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
dy = mb->qmvs[0].y; |
100 |
16*i + 8, 16*j, dx, dy, edged_width); |
} |
101 |
compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
|
102 |
16*i, 16*j + 8, dx, dy, edged_width); |
compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y, |
103 |
compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
refv->y, refhv->y, 16 * i, 16 * j, dx, dy, |
104 |
16*i + 8, 16*j + 8, dx, dy, edged_width); |
edged_width, quarterpel, rounding); |
105 |
|
compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y, |
106 |
|
refv->y, refhv->y, 16 * i + 8, 16 * j, dx, dy, |
107 |
|
edged_width, quarterpel, rounding); |
108 |
|
compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y, |
109 |
|
refv->y, refhv->y, 16 * i, 16 * j + 8, dx, dy, |
110 |
|
edged_width, quarterpel, rounding); |
111 |
|
compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y, |
112 |
|
refv->y, refhv->y, 16 * i + 8, 16 * j + 8, dx, |
113 |
|
dy, edged_width, quarterpel, rounding); |
114 |
|
|
115 |
|
if (quarterpel) |
116 |
|
{ |
117 |
|
dx = (dx >> 1) | (dx & 1); |
118 |
|
dy = (dy >> 1) | (dy & 1); |
119 |
|
} |
120 |
|
|
121 |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
122 |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
123 |
|
|
|
/* uv-image-based compensation */ |
|
|
#ifdef BFRAMES |
|
|
compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u, |
|
|
8*i, 8*j, dx, dy, edged_width/2); |
|
|
compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v, |
|
|
8*i, 8*j, dx, dy, edged_width/2); |
|
|
#else |
|
124 |
/* uv-block-based compensation */ |
/* uv-block-based compensation */ |
|
interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding); |
|
125 |
transfer_8to16sub(&dct_codes[4*64], |
transfer_8to16sub(&dct_codes[4*64], |
126 |
cur->u + 8*j*edged_width/2 + 8*i, |
cur->u + 8*j*edged_width/2 + 8*i, |
127 |
refv->u + 8*j*edged_width/2 + 8*i, edged_width/2); |
interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j, |
128 |
|
dx, dy, edged_width / 2, rounding), |
129 |
|
edged_width / 2); |
130 |
|
|
|
interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding); |
|
131 |
transfer_8to16sub(&dct_codes[5*64], |
transfer_8to16sub(&dct_codes[5*64], |
132 |
cur->v + 8*j*edged_width/2 + 8*i, |
cur->v + 8*j*edged_width/2 + 8*i, |
133 |
refv->v + 8*j*edged_width/2 + 8*i, edged_width/2); |
interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j, |
134 |
#endif |
dx, dy, edged_width / 2, rounding), |
135 |
} |
edged_width / 2); |
136 |
else // mode == MODE_INTER4V |
|
137 |
{ |
} else { // mode == MODE_INTER4V |
138 |
int32_t sum, dx, dy; |
int32_t sum, dx, dy; |
139 |
|
VECTOR *mvs; |
140 |
|
|
141 |
compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
if(quarterpel) |
142 |
16*i, 16*j, mb->mvs[0].x, mb->mvs[0].y, edged_width); |
mvs = mb->qmvs; |
143 |
compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
else |
144 |
16*i + 8, 16*j, mb->mvs[1].x, mb->mvs[1].y, edged_width); |
mvs = mb->mvs; |
145 |
compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
|
146 |
16*i, 16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width); |
compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y, |
147 |
compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x, |
148 |
16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width); |
mvs[0].y, edged_width, quarterpel, rounding); |
149 |
|
compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y, |
150 |
|
refv->y, refhv->y, 16 * i + 8, 16 * j, |
151 |
|
mvs[1].x, mvs[1].y, edged_width, quarterpel, rounding); |
152 |
|
compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y, |
153 |
|
refv->y, refhv->y, 16 * i, 16 * j + 8, |
154 |
|
mvs[2].x, mvs[2].y, edged_width, quarterpel, rounding); |
155 |
|
compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y, |
156 |
|
refv->y, refhv->y, 16 * i + 8, 16 * j + 8, |
157 |
|
mvs[3].x, mvs[3].y, edged_width, quarterpel, rounding); |
158 |
|
|
159 |
|
sum = mvs[0].x + mvs[1].x + mvs[2].x + mvs[3].x; |
160 |
|
|
161 |
|
if(quarterpel) |
162 |
|
sum /= 2; |
163 |
|
|
164 |
|
dx = (sum ? SIGN(sum) * |
165 |
|
(roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); |
166 |
|
|
167 |
sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x; |
sum = mvs[0].y + mvs[1].y + mvs[2].y + mvs[3].y; |
|
dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); |
|
168 |
|
|
169 |
sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y; |
if(quarterpel) |
170 |
dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); |
sum /= 2; |
171 |
|
|
172 |
|
dy = (sum ? SIGN(sum) * |
173 |
|
(roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); |
174 |
|
|
|
/* uv-image-based compensation */ |
|
|
#ifdef BFRAMES |
|
|
compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u, |
|
|
8*i, 8*j, dx, dy, edged_width/2); |
|
|
compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v, |
|
|
8*i, 8*j, dx, dy, edged_width/2); |
|
|
#else |
|
175 |
/* uv-block-based compensation */ |
/* uv-block-based compensation */ |
|
interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding); |
|
176 |
transfer_8to16sub(&dct_codes[4*64], |
transfer_8to16sub(&dct_codes[4*64], |
177 |
cur->u + 8*j*edged_width/2 + 8*i, |
cur->u + 8*j*edged_width/2 + 8*i, |
178 |
refv->u + 8*j*edged_width/2 + 8*i, edged_width/2); |
interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j, |
179 |
|
dx, dy, edged_width / 2, rounding), |
180 |
|
edged_width / 2); |
181 |
|
|
|
interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding); |
|
182 |
transfer_8to16sub(&dct_codes[5*64], |
transfer_8to16sub(&dct_codes[5*64], |
183 |
cur->v + 8*j*edged_width/2 + 8*i, |
cur->v + 8*j*edged_width/2 + 8*i, |
184 |
refv->v + 8*j*edged_width/2 + 8*i, edged_width/2); |
interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j, |
185 |
#endif |
dx, dy, edged_width / 2, rounding), |
186 |
|
|
187 |
|
edged_width / 2); |
188 |
} |
} |
189 |
} |
} |
190 |
|
|
191 |
|
|
192 |
void MBMotionCompensationBVOP( |
void |
193 |
MBParam * pParam, |
MBMotionCompensationBVOP(MBParam * pParam, |
194 |
MACROBLOCK * const mb, |
MACROBLOCK * const mb, |
195 |
const uint32_t i, |
const uint32_t i, |
196 |
const uint32_t j, |
const uint32_t j, |
211 |
const int32_t edged_width = pParam->edged_width; |
const int32_t edged_width = pParam->edged_width; |
212 |
int32_t dx, dy; |
int32_t dx, dy; |
213 |
int32_t b_dx, b_dy; |
int32_t b_dx, b_dy; |
214 |
|
int k,sum; |
215 |
int x = i; |
int x = i; |
216 |
int y = j; |
int y = j; |
217 |
|
|
218 |
|
|
219 |
|
switch (mb->mode) { |
|
switch(mb->mode) |
|
|
{ |
|
220 |
case MODE_FORWARD : |
case MODE_FORWARD : |
221 |
dx = mb->mvs[0].x; |
dx = mb->mvs[0].x; |
222 |
dy = mb->mvs[0].y; |
dy = mb->mvs[0].y; |
223 |
|
|
224 |
transfer_8to16sub_c( |
transfer_8to16sub(&dct_codes[0 * 64], |
|
&dct_codes[0*64], |
|
225 |
cur->y + (j*16)*edged_width + (i*16), |
cur->y + (j*16)*edged_width + (i*16), |
226 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
227 |
i*16, j*16, 1, dx, dy, edged_width), |
i*16, j*16, 1, dx, dy, edged_width), |
228 |
edged_width); |
edged_width); |
229 |
|
|
230 |
transfer_8to16sub( |
transfer_8to16sub(&dct_codes[1 * 64], |
|
&dct_codes[1*64], |
|
231 |
cur->y + (j*16)*edged_width + (i*16+8), |
cur->y + (j*16)*edged_width + (i*16+8), |
232 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
233 |
i*16+8, j*16, 1, dx, dy, edged_width), |
i*16+8, j*16, 1, dx, dy, edged_width), |
234 |
edged_width); |
edged_width); |
235 |
|
|
236 |
transfer_8to16sub_c( |
transfer_8to16sub(&dct_codes[2 * 64], |
|
&dct_codes[2*64], |
|
237 |
cur->y + (j*16+8)*edged_width + (i*16), |
cur->y + (j*16+8)*edged_width + (i*16), |
238 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
239 |
i*16, j*16+8, 1, dx, dy, edged_width), |
i*16, j*16+8, 1, dx, dy, edged_width), |
240 |
edged_width); |
edged_width); |
241 |
|
|
242 |
transfer_8to16sub( |
transfer_8to16sub(&dct_codes[3 * 64], |
|
&dct_codes[3*64], |
|
243 |
cur->y + (j*16+8)*edged_width + (i*16+8), |
cur->y + (j*16+8)*edged_width + (i*16+8), |
244 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
245 |
i*16+8, j*16+8, 1, dx, dy, edged_width), |
i*16+8, j*16+8, 1, dx, dy, edged_width), |
249 |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
250 |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
251 |
|
|
252 |
/* uv-image-based compensation */ |
/* uv-block-based compensation */ |
253 |
compensate8x8_halfpel(&dct_codes[4*64], cur->u, f_ref->u, f_refh->u, f_refv->u, f_refhv->u, |
transfer_8to16sub(&dct_codes[4 * 64], |
254 |
8*i, 8*j, dx, dy, edged_width/2); |
cur->u + 8 * j * edged_width / 2 + 8 * i, |
255 |
compensate8x8_halfpel(&dct_codes[5*64], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v, |
interpolate8x8_switch2(f_refv->u, f_ref->u, 8 * i, 8 * j, |
256 |
8*i, 8*j, dx, dy, edged_width/2); |
dx, dy, edged_width / 2, 0), |
257 |
|
|
258 |
|
edged_width / 2); |
259 |
|
|
260 |
|
transfer_8to16sub(&dct_codes[5 * 64], |
261 |
|
cur->v + 8 * j * edged_width / 2 + 8 * i, |
262 |
|
interpolate8x8_switch2(f_refv->u, f_ref->v, 8 * i, 8 * j, |
263 |
|
dx, dy, edged_width / 2, 0), |
264 |
|
|
265 |
|
edged_width / 2); |
266 |
|
|
267 |
break; |
break; |
268 |
|
|
270 |
b_dx = mb->b_mvs[0].x; |
b_dx = mb->b_mvs[0].x; |
271 |
b_dy = mb->b_mvs[0].y; |
b_dy = mb->b_mvs[0].y; |
272 |
|
|
273 |
transfer_8to16sub_c( |
transfer_8to16sub(&dct_codes[0 * 64], |
|
&dct_codes[0*64], |
|
274 |
cur->y + (j*16)*edged_width + (i*16), |
cur->y + (j*16)*edged_width + (i*16), |
275 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
276 |
i*16, j*16, 1, b_dx, b_dy, edged_width), |
i * 16, j * 16, 1, b_dx, b_dy, |
277 |
edged_width); |
edged_width), edged_width); |
278 |
|
|
279 |
transfer_8to16sub( |
transfer_8to16sub(&dct_codes[1 * 64], |
|
&dct_codes[1*64], |
|
280 |
cur->y + (j*16)*edged_width + (i*16+8), |
cur->y + (j*16)*edged_width + (i*16+8), |
281 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
282 |
i*16+8, j*16, 1, b_dx, b_dy, edged_width), |
i * 16 + 8, j * 16, 1, b_dx, b_dy, |
283 |
edged_width); |
edged_width), edged_width); |
284 |
|
|
285 |
transfer_8to16sub_c( |
transfer_8to16sub(&dct_codes[2 * 64], |
|
&dct_codes[2*64], |
|
286 |
cur->y + (j*16+8)*edged_width + (i*16), |
cur->y + (j*16+8)*edged_width + (i*16), |
287 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
288 |
i*16, j*16+8, 1, b_dx, b_dy, edged_width), |
i * 16, j * 16 + 8, 1, b_dx, b_dy, |
289 |
edged_width); |
edged_width), edged_width); |
290 |
|
|
291 |
transfer_8to16sub( |
transfer_8to16sub(&dct_codes[3 * 64], |
|
&dct_codes[3*64], |
|
292 |
cur->y + (j*16+8)*edged_width + (i*16+8), |
cur->y + (j*16+8)*edged_width + (i*16+8), |
293 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
294 |
i*16+8, j*16+8, 1, b_dx, b_dy, edged_width), |
i * 16 + 8, j * 16 + 8, 1, b_dx, b_dy, |
295 |
edged_width); |
edged_width), edged_width); |
296 |
|
|
297 |
b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; |
b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; |
298 |
b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; |
b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; |
299 |
|
|
300 |
/* uv-image-based compensation */ |
/* uv-block-based compensation */ |
301 |
compensate8x8_halfpel(&dct_codes[4*64], cur->u, |
transfer_8to16sub(&dct_codes[4 * 64], |
302 |
b_ref->u, b_refh->u, b_refv->u, b_refhv->u, |
cur->u + 8 * j * edged_width / 2 + 8 * i, |
303 |
8*i, 8*j, b_dx, b_dy, edged_width/2); |
interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j, |
304 |
compensate8x8_halfpel(&dct_codes[5*64], cur->v, |
b_dx, b_dy, edged_width / 2, 0), |
305 |
b_ref->v, b_refh->v, b_refv->v, b_refhv->v, |
|
306 |
8*i, 8*j, b_dx, b_dy, edged_width/2); |
edged_width / 2); |
307 |
|
|
308 |
|
transfer_8to16sub(&dct_codes[5 * 64], |
309 |
|
cur->v + 8 * j * edged_width / 2 + 8 * i, |
310 |
|
interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j, |
311 |
|
b_dx, b_dy, edged_width / 2, 0), |
312 |
|
|
313 |
|
edged_width / 2); |
314 |
|
|
315 |
break; |
break; |
316 |
|
|
317 |
|
|
318 |
case MODE_INTERPOLATE : |
case MODE_INTERPOLATE: /* _could_ use DIRECT, but would be overkill (no 4MV there) */ |
319 |
|
case MODE_DIRECT_NO4V: |
320 |
|
|
321 |
dx = mb->mvs[0].x; |
dx = mb->mvs[0].x; |
322 |
dy = mb->mvs[0].y; |
dy = mb->mvs[0].y; |
323 |
|
|
324 |
b_dx = mb->b_mvs[0].x; |
b_dx = mb->b_mvs[0].x; |
325 |
b_dy = mb->b_mvs[0].y; |
b_dy = mb->b_mvs[0].y; |
326 |
|
|
327 |
transfer_8to16sub2_c( |
for (k = 0; k < 4; k++) { |
328 |
&dct_codes[0*64], |
transfer_8to16sub2(&dct_codes[k * 64], |
329 |
cur->y + (i*16) + (j*16)*edged_width, |
cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width, |
330 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, |
331 |
16*i, 16*j, 1, dx, dy, edged_width), |
f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy, |
332 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
edged_width), |
333 |
16*i, 16*j, 1, b_dx, b_dy, edged_width), |
get_ref(b_ref->y, b_refh->y, b_refv->y, |
334 |
|
b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy, |
335 |
|
edged_width), |
336 |
edged_width); |
edged_width); |
337 |
|
} |
338 |
|
|
339 |
transfer_8to16sub2_c( |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
340 |
&dct_codes[1*64], |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
|
cur->y + (i*16+8) + (j*16)*edged_width, |
|
|
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
|
|
16*i+8, 16*j, 1, dx, dy, edged_width), |
|
|
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
|
|
16*i+8, 16*j, 1, b_dx, b_dy, edged_width), |
|
|
edged_width); |
|
341 |
|
|
342 |
transfer_8to16sub2_c( |
b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; |
343 |
&dct_codes[2*64], |
b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; |
344 |
cur->y + (i*16) + (j*16+8)*edged_width, |
|
345 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
transfer_8to16sub2(&dct_codes[4 * 64], |
346 |
16*i, 16*j+8, 1, dx, dy, edged_width), |
cur->u + (y * 8) * edged_width / 2 + (x * 8), |
347 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j, |
348 |
16*i, 16*j+8, 1, b_dx, b_dy, edged_width), |
b_dx, b_dy, edged_width / 2, 0), |
349 |
edged_width); |
interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, |
350 |
|
dx, dy, edged_width / 2, 0), |
351 |
|
edged_width / 2); |
352 |
|
|
353 |
|
transfer_8to16sub2(&dct_codes[5 * 64], |
354 |
|
cur->v + (y * 8) * edged_width / 2 + (x * 8), |
355 |
|
interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j, |
356 |
|
b_dx, b_dy, edged_width / 2, 0), |
357 |
|
interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j, |
358 |
|
dx, dy, edged_width / 2, 0), |
359 |
|
edged_width / 2); |
360 |
|
|
361 |
|
break; |
362 |
|
|
363 |
|
case MODE_DIRECT: |
364 |
|
|
365 |
|
for (k=0;k<4;k++) |
366 |
|
{ |
367 |
|
dx = mb->mvs[k].x; |
368 |
|
dy = mb->mvs[k].y; |
369 |
|
|
370 |
|
b_dx = mb->b_mvs[k].x; |
371 |
|
b_dy = mb->b_mvs[k].y; |
372 |
|
|
373 |
transfer_8to16sub2_c( |
// fprintf(stderr,"Direct Vector %d -- %d:%d %d:%d\n",k,dx,dy,b_dx,b_dy); |
374 |
&dct_codes[3*64], |
|
375 |
cur->y + (i*16+8) + (j*16+8)*edged_width, |
transfer_8to16sub2(&dct_codes[k * 64], |
376 |
|
cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width, |
377 |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, |
378 |
16*i + 8, 16*j + 8, 1, dx, dy, edged_width), |
2*i + (k&1), 2*j + (k>>1), 8, dx, dy, |
379 |
|
edged_width), |
380 |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, |
381 |
16*i + 8, 16*j + 8, 1, b_dx, b_dy, edged_width), |
2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy, |
382 |
|
edged_width), |
383 |
edged_width); |
edged_width); |
384 |
|
} |
385 |
|
|
386 |
|
sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x; |
387 |
|
dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
388 |
|
|
389 |
dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; |
sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y; |
390 |
dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; |
dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
391 |
|
|
|
b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; |
|
|
b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; |
|
392 |
|
|
393 |
transfer_8to16sub2_c( |
sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x; |
394 |
&dct_codes[4*64], |
b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
395 |
|
|
396 |
|
sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y; |
397 |
|
b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2)); |
398 |
|
|
399 |
|
/* // for QPel don't forget to always do |
400 |
|
|
401 |
|
if (quarterpel) |
402 |
|
sum /= 2; |
403 |
|
*/ |
404 |
|
transfer_8to16sub2(&dct_codes[4 * 64], |
405 |
cur->u + (y*8)*edged_width/2 + (x*8), |
cur->u + (y*8)*edged_width/2 + (x*8), |
406 |
get_ref(f_ref->u, f_refh->u, f_refv->u, f_refhv->u, |
interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j, |
407 |
8*i, 8*j, 1, dx, dy, edged_width/2), |
b_dx, b_dy, edged_width / 2, 0), |
408 |
get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u, |
interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, dx, dy, |
409 |
8*i, 8*j, 1, b_dx, b_dy, edged_width/2), |
edged_width / 2, 0), |
410 |
edged_width/2); |
edged_width/2); |
411 |
|
|
412 |
transfer_8to16sub2_c( |
transfer_8to16sub2(&dct_codes[5 * 64], |
|
&dct_codes[5*64], |
|
413 |
cur->v + (y*8)*edged_width/2 + (x*8), |
cur->v + (y*8)*edged_width/2 + (x*8), |
414 |
get_ref(f_ref->v, f_refh->v, f_refv->v, f_refhv->v, |
interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j, |
415 |
8*i, 8*j, 1, dx, dy, edged_width/2), |
b_dx, b_dy, edged_width / 2, 0), |
416 |
get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v, |
interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j, |
417 |
8*i, 8*j, 1, b_dx, b_dy, edged_width/2), |
dx, dy, edged_width / 2, 0), |
418 |
edged_width/2); |
edged_width/2); |
419 |
|
|
|
break; |
|
420 |
|
|
|
case MODE_DIRECT : |
|
|
// todo |
|
421 |
break; |
break; |
422 |
} |
} |
|
|
|
423 |
} |
} |