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