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