Parent Directory | Revision Log
Revision 118 - (view) (download)
1 : | suxen_drol | 118 | // 14.04.2002 bframe compensation |
2 : | |||
3 : | Isibaar | 3 | #include "../encoder.h" |
4 : | #include "../utils/mbfunctions.h" | ||
5 : | #include "../image/interpolate8x8.h" | ||
6 : | #include "../utils/timer.h" | ||
7 : | suxen_drol | 118 | #include "motion.h" |
8 : | Isibaar | 3 | |
9 : | #define ABS(X) (((X)>0)?(X):-(X)) | ||
10 : | #define SIGN(X) (((X)>0)?1:-1) | ||
11 : | |||
12 : | static __inline void compensate8x8_halfpel( | ||
13 : | int16_t * const dct_codes, | ||
14 : | uint8_t * const cur, | ||
15 : | const uint8_t * const ref, | ||
16 : | const uint8_t * const refh, | ||
17 : | const uint8_t * const refv, | ||
18 : | const uint8_t * const refhv, | ||
19 : | const uint32_t x, const uint32_t y, | ||
20 : | const int32_t dx, const int dy, | ||
21 : | const uint32_t stride) | ||
22 : | { | ||
23 : | int32_t ddx,ddy; | ||
24 : | |||
25 : | switch ( ((dx&1)<<1) + (dy&1) ) // ((dx%2)?2:0)+((dy%2)?1:0) | ||
26 : | { | ||
27 : | case 0 : | ||
28 : | ddx = dx/2; | ||
29 : | ddy = dy/2; | ||
30 : | transfer_8to16sub(dct_codes, cur + y*stride + x, | ||
31 : | ref + (y+ddy)*stride + x+ddx, stride); | ||
32 : | break; | ||
33 : | |||
34 : | case 1 : | ||
35 : | ddx = dx/2; | ||
36 : | ddy = (dy-1)/2; | ||
37 : | transfer_8to16sub(dct_codes, cur + y*stride + x, | ||
38 : | refv + (y+ddy)*stride + x+ddx, stride); | ||
39 : | break; | ||
40 : | |||
41 : | case 2 : | ||
42 : | ddx = (dx-1)/2; | ||
43 : | ddy = dy/2; | ||
44 : | transfer_8to16sub(dct_codes, cur + y*stride + x, | ||
45 : | refh + (y+ddy)*stride + x+ddx, stride); | ||
46 : | break; | ||
47 : | |||
48 : | default : // case 3: | ||
49 : | ddx = (dx-1)/2; | ||
50 : | ddy = (dy-1)/2; | ||
51 : | transfer_8to16sub(dct_codes, cur + y*stride + x, | ||
52 : | refhv + (y+ddy)*stride + x+ddx, stride); | ||
53 : | break; | ||
54 : | } | ||
55 : | } | ||
56 : | |||
57 : | |||
58 : | |||
59 : | void MBMotionCompensation( | ||
60 : | edgomez | 78 | MACROBLOCK * const mb, |
61 : | const uint32_t i, | ||
62 : | const uint32_t j, | ||
63 : | const IMAGE * const ref, | ||
64 : | const IMAGE * const refh, | ||
65 : | const IMAGE * const refv, | ||
66 : | const IMAGE * const refhv, | ||
67 : | IMAGE * const cur, | ||
68 : | int16_t *dct_codes, | ||
69 : | const uint32_t width, | ||
70 : | const uint32_t height, | ||
71 : | const uint32_t edged_width, | ||
72 : | const uint32_t rounding) | ||
73 : | Isibaar | 3 | { |
74 : | static const uint32_t roundtab[16] = | ||
75 : | { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; | ||
76 : | |||
77 : | |||
78 : | if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) | ||
79 : | { | ||
80 : | int32_t dx = mb->mvs[0].x; | ||
81 : | int32_t dy = mb->mvs[0].y; | ||
82 : | |||
83 : | edgomez | 78 | compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
84 : | 16*i, 16*j, dx, dy, edged_width); | ||
85 : | compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
86 : | 16*i + 8, 16*j, dx, dy, edged_width); | ||
87 : | compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
88 : | 16*i, 16*j + 8, dx, dy, edged_width); | ||
89 : | compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
90 : | 16*i + 8, 16*j + 8, dx, dy, edged_width); | ||
91 : | Isibaar | 3 | |
92 : | dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; | ||
93 : | dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; | ||
94 : | |||
95 : | /* uv-image-based compensation | ||
96 : | edgomez | 78 | compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u, |
97 : | 8*i, 8*j, dx, dy, edged_width/2); | ||
98 : | compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v, | ||
99 : | 8*i, 8*j, dx, dy, edged_width/2); */ | ||
100 : | Isibaar | 3 | |
101 : | /* uv-block-based compensation */ | ||
102 : | interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding); | ||
103 : | edgomez | 78 | transfer_8to16sub(&dct_codes[4*64], |
104 : | cur->u + 8*j*edged_width/2 + 8*i, | ||
105 : | refv->u + 8*j*edged_width/2 + 8*i, edged_width/2); | ||
106 : | Isibaar | 3 | |
107 : | interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding); | ||
108 : | edgomez | 78 | transfer_8to16sub(&dct_codes[5*64], |
109 : | cur->v + 8*j*edged_width/2 + 8*i, | ||
110 : | refv->v + 8*j*edged_width/2 + 8*i, edged_width/2); | ||
111 : | Isibaar | 3 | |
112 : | } | ||
113 : | else // mode == MODE_INTER4V | ||
114 : | { | ||
115 : | int32_t sum, dx, dy; | ||
116 : | |||
117 : | edgomez | 78 | compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y, |
118 : | 16*i, 16*j, mb->mvs[0].x, mb->mvs[0].y, edged_width); | ||
119 : | compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
120 : | 16*i + 8, 16*j, mb->mvs[1].x, mb->mvs[1].y, edged_width); | ||
121 : | compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
122 : | 16*i, 16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width); | ||
123 : | compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y, | ||
124 : | 16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width); | ||
125 : | Isibaar | 3 | |
126 : | sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x; | ||
127 : | dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); | ||
128 : | |||
129 : | sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y; | ||
130 : | dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0); | ||
131 : | |||
132 : | /* uv-image-based compensation | ||
133 : | edgomez | 78 | compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u, |
134 : | 8*i, 8*j, dx, dy, edged_width/2); | ||
135 : | compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v, | ||
136 : | 8*i, 8*j, dx, dy, edged_width/2); */ | ||
137 : | Isibaar | 3 | |
138 : | /* uv-block-based compensation */ | ||
139 : | interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding); | ||
140 : | edgomez | 78 | transfer_8to16sub(&dct_codes[4*64], |
141 : | cur->u + 8*j*edged_width/2 + 8*i, | ||
142 : | refv->u + 8*j*edged_width/2 + 8*i, edged_width/2); | ||
143 : | Isibaar | 3 | |
144 : | interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding); | ||
145 : | edgomez | 78 | transfer_8to16sub(&dct_codes[5*64], |
146 : | cur->v + 8*j*edged_width/2 + 8*i, | ||
147 : | refv->v + 8*j*edged_width/2 + 8*i, edged_width/2); | ||
148 : | Isibaar | 3 | |
149 : | } | ||
150 : | } | ||
151 : | suxen_drol | 118 | |
152 : | |||
153 : | |||
154 : | void MBMotionCompensationBVOP( | ||
155 : | MBParam * pParam, | ||
156 : | MACROBLOCK * const mb, | ||
157 : | const uint32_t i, | ||
158 : | const uint32_t j, | ||
159 : | IMAGE * const cur, | ||
160 : | const IMAGE * const f_ref, | ||
161 : | const IMAGE * const f_refh, | ||
162 : | const IMAGE * const f_refv, | ||
163 : | const IMAGE * const f_refhv, | ||
164 : | const IMAGE * const b_ref, | ||
165 : | const IMAGE * const b_refh, | ||
166 : | const IMAGE * const b_refv, | ||
167 : | const IMAGE * const b_refhv, | ||
168 : | int16_t dct_codes[][64]) | ||
169 : | { | ||
170 : | static const uint32_t roundtab[16] = | ||
171 : | { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; | ||
172 : | |||
173 : | const int32_t edged_width = pParam->edged_width; | ||
174 : | int32_t dx, dy; | ||
175 : | int32_t b_dx, b_dy; | ||
176 : | int x = i; | ||
177 : | int y = j; | ||
178 : | |||
179 : | |||
180 : | |||
181 : | switch(mb->mode) | ||
182 : | { | ||
183 : | case MODE_FORWARD : | ||
184 : | dx = mb->mvs[0].x; | ||
185 : | dy = mb->mvs[0].y; | ||
186 : | |||
187 : | transfer_8to16sub_c( | ||
188 : | dct_codes[0], | ||
189 : | cur->y + (j*16)*edged_width + (i*16), | ||
190 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
191 : | i*16, j*16, 1, dx, dy, edged_width), | ||
192 : | edged_width); | ||
193 : | |||
194 : | transfer_8to16sub( | ||
195 : | dct_codes[1], | ||
196 : | cur->y + (j*16)*edged_width + (i*16+8), | ||
197 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
198 : | i*16+8, j*16, 1, dx, dy, edged_width), | ||
199 : | edged_width); | ||
200 : | |||
201 : | transfer_8to16sub_c( | ||
202 : | dct_codes[2], | ||
203 : | cur->y + (j*16+8)*edged_width + (i*16), | ||
204 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
205 : | i*16, j*16+8, 1, dx, dy, edged_width), | ||
206 : | edged_width); | ||
207 : | |||
208 : | transfer_8to16sub( | ||
209 : | dct_codes[3], | ||
210 : | cur->y + (j*16+8)*edged_width + (i*16+8), | ||
211 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
212 : | i*16+8, j*16+8, 1, dx, dy, edged_width), | ||
213 : | edged_width); | ||
214 : | |||
215 : | |||
216 : | dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; | ||
217 : | dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; | ||
218 : | |||
219 : | /* uv-image-based compensation */ | ||
220 : | compensate8x8_halfpel(dct_codes[4], cur->u, f_ref->u, f_refh->u, f_refv->u, f_refhv->u, | ||
221 : | 8*i, 8*j, dx, dy, edged_width/2); | ||
222 : | compensate8x8_halfpel(dct_codes[5], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v, | ||
223 : | 8*i, 8*j, dx, dy, edged_width/2); | ||
224 : | |||
225 : | break; | ||
226 : | |||
227 : | case MODE_BACKWARD : | ||
228 : | b_dx = mb->b_mvs[0].x; | ||
229 : | b_dy = mb->b_mvs[0].y; | ||
230 : | |||
231 : | transfer_8to16sub_c( | ||
232 : | dct_codes[0], | ||
233 : | cur->y + (j*16)*edged_width + (i*16), | ||
234 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
235 : | i*16, j*16, 1, b_dx, b_dy, edged_width), | ||
236 : | edged_width); | ||
237 : | |||
238 : | transfer_8to16sub( | ||
239 : | dct_codes[1], | ||
240 : | cur->y + (j*16)*edged_width + (i*16+8), | ||
241 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
242 : | i*16+8, j*16, 1, b_dx, b_dy, edged_width), | ||
243 : | edged_width); | ||
244 : | |||
245 : | transfer_8to16sub_c( | ||
246 : | dct_codes[2], | ||
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, edged_width), | ||
250 : | edged_width); | ||
251 : | |||
252 : | transfer_8to16sub( | ||
253 : | dct_codes[3], | ||
254 : | cur->y + (j*16+8)*edged_width + (i*16+8), | ||
255 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
256 : | i*16+8, j*16+8, 1, b_dx, b_dy, edged_width), | ||
257 : | edged_width); | ||
258 : | |||
259 : | b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; | ||
260 : | b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; | ||
261 : | |||
262 : | /* uv-image-based compensation */ | ||
263 : | compensate8x8_halfpel(dct_codes[4], cur->u, | ||
264 : | b_ref->u, b_refh->u, b_refv->u, b_refhv->u, | ||
265 : | 8*i, 8*j, b_dx, b_dy, edged_width/2); | ||
266 : | compensate8x8_halfpel(dct_codes[5], cur->v, | ||
267 : | b_ref->v, b_refh->v, b_refv->v, b_refhv->v, | ||
268 : | 8*i, 8*j, b_dx, b_dy, edged_width/2); | ||
269 : | |||
270 : | break; | ||
271 : | |||
272 : | |||
273 : | case MODE_INTERPOLATE : | ||
274 : | dx = mb->mvs[0].x; | ||
275 : | dy = mb->mvs[0].y; | ||
276 : | b_dx = mb->b_mvs[0].x; | ||
277 : | b_dy = mb->b_mvs[0].y; | ||
278 : | |||
279 : | transfer_8to16sub2_c( | ||
280 : | dct_codes[0], | ||
281 : | cur->y + (i*16) + (j*16)*edged_width, | ||
282 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
283 : | 16*i, 16*j, 1, dx, dy, edged_width), | ||
284 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
285 : | 16*i, 16*j, 1, b_dx, b_dy, edged_width), | ||
286 : | edged_width); | ||
287 : | |||
288 : | transfer_8to16sub2_c( | ||
289 : | dct_codes[1], | ||
290 : | cur->y + (i*16+8) + (j*16)*edged_width, | ||
291 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
292 : | 16*i+8, 16*j, 1, dx, dy, edged_width), | ||
293 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
294 : | 16*i+8, 16*j, 1, b_dx, b_dy, edged_width), | ||
295 : | edged_width); | ||
296 : | |||
297 : | transfer_8to16sub2_c( | ||
298 : | dct_codes[2], | ||
299 : | cur->y + (i*16) + (j*16+8)*edged_width, | ||
300 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
301 : | 16*i, 16*j+8, 1, dx, dy, edged_width), | ||
302 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
303 : | 16*i, 16*j+8, 1, b_dx, b_dy, edged_width), | ||
304 : | edged_width); | ||
305 : | |||
306 : | transfer_8to16sub2_c( | ||
307 : | dct_codes[3], | ||
308 : | cur->y + (i*16+8) + (j*16+8)*edged_width, | ||
309 : | get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y, | ||
310 : | 16*i + 8, 16*j + 8, 1, dx, dy, edged_width), | ||
311 : | get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y, | ||
312 : | 16*i + 8, 16*j + 8, 1, b_dx, b_dy, edged_width), | ||
313 : | edged_width); | ||
314 : | |||
315 : | |||
316 : | dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2; | ||
317 : | dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2; | ||
318 : | |||
319 : | b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2; | ||
320 : | b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2; | ||
321 : | |||
322 : | transfer_8to16sub2_c( | ||
323 : | dct_codes[4], | ||
324 : | cur->u + (y*8)*edged_width/2 + (x*8), | ||
325 : | get_ref(f_ref->u, f_refh->u, f_refv->u, f_refhv->u, | ||
326 : | 8*i, 8*j, 1, dx, dy, edged_width/2), | ||
327 : | get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u, | ||
328 : | 8*i, 8*j, 1, b_dx, b_dy, edged_width/2), | ||
329 : | edged_width/2); | ||
330 : | |||
331 : | transfer_8to16sub2_c( | ||
332 : | dct_codes[5], | ||
333 : | cur->v + (y*8)*edged_width/2 + (x*8), | ||
334 : | get_ref(f_ref->v, f_refh->v, f_refv->v, f_refhv->v, | ||
335 : | 8*i, 8*j, 1, dx, dy, edged_width/2), | ||
336 : | get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v, | ||
337 : | 8*i, 8*j, 1, b_dx, b_dy, edged_width/2), | ||
338 : | edged_width/2); | ||
339 : | |||
340 : | break; | ||
341 : | |||
342 : | case MODE_DIRECT : | ||
343 : | // todo | ||
344 : | break; | ||
345 : | } | ||
346 : | |||
347 : | } | ||
348 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |