Parent Directory | Revision Log
Revision 1394 - (view) (download)
1 : | edgomez | 1142 | /***************************************************************************** |
2 : | chl | 1077 | * |
3 : | edgomez | 1142 | * XVID MPEG-4 VIDEO CODEC |
4 : | * - GMC interpolation module - | ||
5 : | chl | 1077 | * |
6 : | edgomez | 1142 | * Copyright(C) 2002-2003 Pascal Massimino <skal@planet-d.net> |
7 : | chl | 1077 | * |
8 : | edgomez | 1142 | * This program is free software ; you can redistribute it and/or modify |
9 : | * it under the terms of the GNU General Public License as published by | ||
10 : | * the Free Software Foundation ; either version 2 of the License, or | ||
11 : | * (at your option) any later version. | ||
12 : | chl | 1077 | * |
13 : | edgomez | 1142 | * This program is distributed in the hope that it will be useful, |
14 : | * but WITHOUT ANY WARRANTY ; without even the implied warranty of | ||
15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 : | * GNU General Public License for more details. | ||
17 : | chl | 1077 | * |
18 : | edgomez | 1142 | * You should have received a copy of the GNU General Public License |
19 : | * along with this program ; if not, write to the Free Software | ||
20 : | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 : | * | ||
22 : | Skal | 1394 | * $Id: gmc.c,v 1.1.2.9 2004-03-31 13:40:59 Skal Exp $ |
23 : | edgomez | 1142 | * |
24 : | ****************************************************************************/ | ||
25 : | chl | 1077 | |
26 : | #include "../portab.h" | ||
27 : | #include "../global.h" | ||
28 : | #include "../encoder.h" | ||
29 : | #include "gmc.h" | ||
30 : | |||
31 : | #include <stdio.h> | ||
32 : | |||
33 : | edgomez | 1160 | /* ************************************************************ |
34 : | * Pts = 2 or 3 | ||
35 : | * | ||
36 : | * Warning! *src is the global frame pointer (that is: adress | ||
37 : | * of pixel 0,0), not the macroblock one. | ||
38 : | * Conversely, *dst is the macroblock top-left adress. | ||
39 : | */ | ||
40 : | chl | 1077 | |
41 : | void Predict_16x16_C(const NEW_GMC_DATA * const This, | ||
42 : | syskin | 1085 | uint8_t *dst, const uint8_t *src, |
43 : | int dststride, int srcstride, int x, int y, int rounding) | ||
44 : | chl | 1077 | { |
45 : | syskin | 1085 | const int W = This->sW; |
46 : | const int H = This->sH; | ||
47 : | const int rho = 3 - This->accuracy; | ||
48 : | const int Rounder = ( (1<<7) - (rounding<<(2*rho)) ) << 16; | ||
49 : | chl | 1077 | |
50 : | syskin | 1085 | const int dUx = This->dU[0]; |
51 : | const int dVx = This->dV[0]; | ||
52 : | const int dUy = This->dU[1]; | ||
53 : | const int dVy = This->dV[1]; | ||
54 : | chl | 1077 | |
55 : | syskin | 1085 | int Uo = This->Uo + 16*(dUy*y + dUx*x); |
56 : | int Vo = This->Vo + 16*(dVy*y + dVx*x); | ||
57 : | chl | 1077 | |
58 : | syskin | 1085 | int i, j; |
59 : | chl | 1077 | |
60 : | syskin | 1085 | dst += 16; |
61 : | syskin | 1117 | for (j=16; j>0; --j) { |
62 : | int U = Uo, V = Vo; | ||
63 : | Uo += dUy; Vo += dVy; | ||
64 : | for (i=-16; i<0; ++i) { | ||
65 : | unsigned int f0, f1, ri = 16, rj = 16; | ||
66 : | int Offset; | ||
67 : | int u = ( U >> 16 ) << rho; | ||
68 : | int v = ( V >> 16 ) << rho; | ||
69 : | chl | 1077 | |
70 : | syskin | 1117 | U += dUx; V += dVx; |
71 : | chl | 1077 | |
72 : | syskin | 1117 | if (u > 0 && u <= W) { ri = MTab[u&15]; Offset = u>>4; } |
73 : | syskin | 1374 | else { |
74 : | if (u > W) Offset = W>>4; | ||
75 : | syskin | 1377 | else Offset = 0; |
76 : | ri = MTab[0]; | ||
77 : | syskin | 1374 | } |
78 : | edgomez | 1161 | |
79 : | syskin | 1117 | if (v > 0 && v <= H) { rj = MTab[v&15]; Offset += (v>>4)*srcstride; } |
80 : | syskin | 1374 | else { |
81 : | if (v > H) Offset += (H>>4)*srcstride; | ||
82 : | syskin | 1377 | rj = MTab[0]; |
83 : | syskin | 1374 | } |
84 : | chl | 1077 | |
85 : | syskin | 1117 | f0 = src[Offset + 0]; |
86 : | f0 |= src[Offset + 1] << 16; | ||
87 : | f1 = src[Offset + srcstride + 0]; | ||
88 : | f1 |= src[Offset + srcstride + 1] << 16; | ||
89 : | f0 = (ri*f0)>>16; | ||
90 : | f1 = (ri*f1) & 0x0fff0000; | ||
91 : | f0 |= f1; | ||
92 : | f0 = (rj*f0 + Rounder) >> 24; | ||
93 : | chl | 1077 | |
94 : | syskin | 1117 | dst[i] = (uint8_t)f0; |
95 : | } | ||
96 : | dst += dststride; | ||
97 : | syskin | 1085 | } |
98 : | chl | 1077 | } |
99 : | |||
100 : | void Predict_8x8_C(const NEW_GMC_DATA * const This, | ||
101 : | syskin | 1085 | uint8_t *uDst, const uint8_t *uSrc, |
102 : | uint8_t *vDst, const uint8_t *vSrc, | ||
103 : | int dststride, int srcstride, int x, int y, int rounding) | ||
104 : | chl | 1077 | { |
105 : | syskin | 1085 | const int W = This->sW >> 1; |
106 : | const int H = This->sH >> 1; | ||
107 : | const int rho = 3-This->accuracy; | ||
108 : | const int32_t Rounder = ( 128 - (rounding<<(2*rho)) ) << 16; | ||
109 : | chl | 1077 | |
110 : | syskin | 1085 | const int32_t dUx = This->dU[0]; |
111 : | const int32_t dVx = This->dV[0]; | ||
112 : | const int32_t dUy = This->dU[1]; | ||
113 : | const int32_t dVy = This->dV[1]; | ||
114 : | chl | 1077 | |
115 : | syskin | 1085 | int32_t Uo = This->Uco + 8*(dUy*y + dUx*x); |
116 : | int32_t Vo = This->Vco + 8*(dVy*y + dVx*x); | ||
117 : | chl | 1077 | |
118 : | syskin | 1085 | int i, j; |
119 : | chl | 1077 | |
120 : | syskin | 1085 | uDst += 8; |
121 : | vDst += 8; | ||
122 : | syskin | 1117 | for (j=8; j>0; --j) { |
123 : | int32_t U = Uo, V = Vo; | ||
124 : | Uo += dUy; Vo += dVy; | ||
125 : | chl | 1077 | |
126 : | syskin | 1117 | for (i=-8; i<0; ++i) { |
127 : | int Offset; | ||
128 : | uint32_t f0, f1, ri, rj; | ||
129 : | int32_t u, v; | ||
130 : | chl | 1077 | |
131 : | syskin | 1117 | u = ( U >> 16 ) << rho; |
132 : | v = ( V >> 16 ) << rho; | ||
133 : | U += dUx; V += dVx; | ||
134 : | chl | 1077 | |
135 : | syskin | 1117 | if (u > 0 && u <= W) { |
136 : | ri = MTab[u&15]; | ||
137 : | Offset = u>>4; | ||
138 : | } else { | ||
139 : | if (u>W) Offset = W>>4; | ||
140 : | syskin | 1377 | else Offset = 0; |
141 : | ri = MTab[0]; | ||
142 : | syskin | 1117 | } |
143 : | edgomez | 1161 | |
144 : | syskin | 1117 | if (v > 0 && v <= H) { |
145 : | rj = MTab[v&15]; | ||
146 : | Offset += (v>>4)*srcstride; | ||
147 : | } else { | ||
148 : | if (v>H) Offset += (H>>4)*srcstride; | ||
149 : | syskin | 1377 | rj = MTab[0]; |
150 : | syskin | 1117 | } |
151 : | chl | 1077 | |
152 : | syskin | 1117 | f0 = uSrc[Offset + 0]; |
153 : | f0 |= uSrc[Offset + 1] << 16; | ||
154 : | f1 = uSrc[Offset + srcstride + 0]; | ||
155 : | f1 |= uSrc[Offset + srcstride + 1] << 16; | ||
156 : | f0 = (ri*f0)>>16; | ||
157 : | f1 = (ri*f1) & 0x0fff0000; | ||
158 : | f0 |= f1; | ||
159 : | f0 = (rj*f0 + Rounder) >> 24; | ||
160 : | chl | 1077 | |
161 : | syskin | 1117 | uDst[i] = (uint8_t)f0; |
162 : | chl | 1077 | |
163 : | syskin | 1117 | f0 = vSrc[Offset + 0]; |
164 : | f0 |= vSrc[Offset + 1] << 16; | ||
165 : | f1 = vSrc[Offset + srcstride + 0]; | ||
166 : | f1 |= vSrc[Offset + srcstride + 1] << 16; | ||
167 : | edgomez | 1161 | f0 = (ri*f0)>>16; |
168 : | syskin | 1117 | f1 = (ri*f1) & 0x0fff0000; |
169 : | edgomez | 1161 | f0 |= f1; |
170 : | syskin | 1117 | f0 = (rj*f0 + Rounder) >> 24; |
171 : | chl | 1077 | |
172 : | syskin | 1117 | vDst[i] = (uint8_t)f0; |
173 : | } | ||
174 : | uDst += dststride; | ||
175 : | vDst += dststride; | ||
176 : | syskin | 1085 | } |
177 : | chl | 1077 | } |
178 : | |||
179 : | syskin | 1085 | void get_average_mv_C(const NEW_GMC_DATA * const Dsp, VECTOR * const mv, |
180 : | int x, int y, int qpel) | ||
181 : | chl | 1077 | { |
182 : | syskin | 1085 | int i, j; |
183 : | int vx = 0, vy = 0; | ||
184 : | int32_t uo = Dsp->Uo + 16*(Dsp->dU[1]*y + Dsp->dU[0]*x); | ||
185 : | int32_t vo = Dsp->Vo + 16*(Dsp->dV[1]*y + Dsp->dV[0]*x); | ||
186 : | for (j=16; j>0; --j) | ||
187 : | { | ||
188 : | int32_t U, V; | ||
189 : | U = uo; uo += Dsp->dU[1]; | ||
190 : | V = vo; vo += Dsp->dV[1]; | ||
191 : | edgomez | 1161 | for (i=16; i>0; --i) |
192 : | syskin | 1085 | { |
193 : | int32_t u,v; | ||
194 : | edgomez | 1161 | u = U >> 16; U += Dsp->dU[0]; vx += u; |
195 : | syskin | 1085 | v = V >> 16; V += Dsp->dV[0]; vy += v; |
196 : | } | ||
197 : | } | ||
198 : | edgomez | 1160 | vx -= (256*x+120) << (5+Dsp->accuracy); /* 120 = 15*16/2 */ |
199 : | syskin | 1085 | vy -= (256*y+120) << (5+Dsp->accuracy); |
200 : | chl | 1077 | |
201 : | syskin | 1085 | mv->x = RSHIFT( vx, 8+Dsp->accuracy - qpel ); |
202 : | mv->y = RSHIFT( vy, 8+Dsp->accuracy - qpel ); | ||
203 : | chl | 1077 | } |
204 : | |||
205 : | edgomez | 1160 | /* ************************************************************ |
206 : | * simplified version for 1 warp point | ||
207 : | */ | ||
208 : | chl | 1077 | |
209 : | void Predict_1pt_16x16_C(const NEW_GMC_DATA * const This, | ||
210 : | edgomez | 1161 | uint8_t *Dst, const uint8_t *Src, |
211 : | syskin | 1085 | int dststride, int srcstride, int x, int y, int rounding) |
212 : | chl | 1077 | { |
213 : | syskin | 1085 | const int W = This->sW; |
214 : | const int H = This->sH; | ||
215 : | const int rho = 3-This->accuracy; | ||
216 : | const int32_t Rounder = ( 128 - (rounding<<(2*rho)) ) << 16; | ||
217 : | chl | 1077 | |
218 : | |||
219 : | edgomez | 1160 | int32_t uo = This->Uo + (x<<8); /* ((16*x)<<4) */ |
220 : | syskin | 1085 | int32_t vo = This->Vo + (y<<8); |
221 : | syskin | 1374 | uint32_t ri = MTab[uo & 15]; |
222 : | uint32_t rj = MTab[vo & 15]; | ||
223 : | syskin | 1085 | int i, j; |
224 : | chl | 1077 | |
225 : | syskin | 1085 | int32_t Offset; |
226 : | syskin | 1374 | if (vo>=(-16*4) && vo<=H) Offset = (vo>>4)*srcstride; |
227 : | else { | ||
228 : | if (vo>H) Offset = ( H>>4)*srcstride; | ||
229 : | else Offset =-16*srcstride; | ||
230 : | rj = MTab[0]; | ||
231 : | } | ||
232 : | if (uo>=(-16*4) && uo<=W) Offset += (uo>>4); | ||
233 : | else { | ||
234 : | if (uo>W) Offset += (W>>4); | ||
235 : | else Offset -= 16; | ||
236 : | ri = MTab[0]; | ||
237 : | } | ||
238 : | chl | 1077 | |
239 : | syskin | 1085 | Dst += 16; |
240 : | chl | 1077 | |
241 : | syskin | 1085 | for(j=16; j>0; --j, Offset+=srcstride-16) |
242 : | { | ||
243 : | for(i=-16; i<0; ++i, ++Offset) | ||
244 : | { | ||
245 : | uint32_t f0, f1; | ||
246 : | f0 = Src[ Offset +0 ]; | ||
247 : | f0 |= Src[ Offset +1 ] << 16; | ||
248 : | f1 = Src[ Offset+srcstride +0 ]; | ||
249 : | f1 |= Src[ Offset+srcstride +1 ] << 16; | ||
250 : | f0 = (ri*f0)>>16; | ||
251 : | f1 = (ri*f1) & 0x0fff0000; | ||
252 : | edgomez | 1161 | f0 |= f1; |
253 : | syskin | 1085 | f0 = ( rj*f0 + Rounder ) >> 24; |
254 : | Dst[i] = (uint8_t)f0; | ||
255 : | } | ||
256 : | Dst += dststride; | ||
257 : | } | ||
258 : | edgomez | 1161 | } |
259 : | chl | 1077 | |
260 : | void Predict_1pt_8x8_C(const NEW_GMC_DATA * const This, | ||
261 : | syskin | 1085 | uint8_t *uDst, const uint8_t *uSrc, |
262 : | uint8_t *vDst, const uint8_t *vSrc, | ||
263 : | int dststride, int srcstride, int x, int y, int rounding) | ||
264 : | chl | 1077 | { |
265 : | syskin | 1085 | const int W = This->sW >> 1; |
266 : | const int H = This->sH >> 1; | ||
267 : | const int rho = 3-This->accuracy; | ||
268 : | const int32_t Rounder = ( 128 - (rounding<<(2*rho)) ) << 16; | ||
269 : | chl | 1077 | |
270 : | syskin | 1085 | int32_t uo = This->Uco + (x<<7); |
271 : | int32_t vo = This->Vco + (y<<7); | ||
272 : | syskin | 1374 | uint32_t rri = MTab[uo & 15]; |
273 : | uint32_t rrj = MTab[vo & 15]; | ||
274 : | syskin | 1085 | int i, j; |
275 : | chl | 1077 | |
276 : | syskin | 1085 | int32_t Offset; |
277 : | syskin | 1374 | if (vo>=(-8*4) && vo<=H) Offset = (vo>>4)*srcstride; |
278 : | else { | ||
279 : | if (vo>H) Offset = ( H>>4)*srcstride; | ||
280 : | else Offset =-8*srcstride; | ||
281 : | rrj = MTab[0]; | ||
282 : | } | ||
283 : | if (uo>=(-8*4) && uo<=W) Offset += (uo>>4); | ||
284 : | else { | ||
285 : | if (uo>W) Offset += ( W>>4); | ||
286 : | else Offset -= 8; | ||
287 : | rri = MTab[0]; | ||
288 : | } | ||
289 : | chl | 1077 | |
290 : | syskin | 1085 | uDst += 8; |
291 : | vDst += 8; | ||
292 : | for(j=8; j>0; --j, Offset+=srcstride-8) | ||
293 : | { | ||
294 : | for(i=-8; i<0; ++i, Offset++) | ||
295 : | { | ||
296 : | uint32_t f0, f1; | ||
297 : | edgomez | 1161 | f0 = uSrc[ Offset + 0 ]; |
298 : | syskin | 1085 | f0 |= uSrc[ Offset + 1 ] << 16; |
299 : | f1 = uSrc[ Offset + srcstride + 0 ]; | ||
300 : | f1 |= uSrc[ Offset + srcstride + 1 ] << 16; | ||
301 : | f0 = (rri*f0)>>16; | ||
302 : | edgomez | 1161 | f1 = (rri*f1) & 0x0fff0000; |
303 : | f0 |= f1; | ||
304 : | syskin | 1085 | f0 = ( rrj*f0 + Rounder ) >> 24; |
305 : | edgomez | 1161 | uDst[i] = (uint8_t)f0; |
306 : | chl | 1077 | |
307 : | edgomez | 1161 | f0 = vSrc[ Offset + 0 ]; |
308 : | syskin | 1085 | f0 |= vSrc[ Offset + 1 ] << 16; |
309 : | f1 = vSrc[ Offset + srcstride + 0 ]; | ||
310 : | f1 |= vSrc[ Offset + srcstride + 1 ] << 16; | ||
311 : | f0 = (rri*f0)>>16; | ||
312 : | f1 = (rri*f1) & 0x0fff0000; | ||
313 : | f0 |= f1; | ||
314 : | f0 = ( rrj*f0 + Rounder ) >> 24; | ||
315 : | vDst[i] = (uint8_t)f0; | ||
316 : | } | ||
317 : | uDst += dststride; | ||
318 : | vDst += dststride; | ||
319 : | } | ||
320 : | chl | 1077 | } |
321 : | |||
322 : | syskin | 1085 | void get_average_mv_1pt_C(const NEW_GMC_DATA * const Dsp, VECTOR * const mv, |
323 : | int x, int y, int qpel) | ||
324 : | chl | 1077 | { |
325 : | syskin | 1085 | mv->x = RSHIFT(Dsp->Uo<<qpel, 3); |
326 : | mv->y = RSHIFT(Dsp->Vo<<qpel, 3); | ||
327 : | chl | 1077 | } |
328 : | |||
329 : | edgomez | 1160 | /* ************************************************************* |
330 : | * Warning! It's Accuracy being passed, not 'resolution'! | ||
331 : | */ | ||
332 : | chl | 1077 | |
333 : | void generate_GMCparameters( int nb_pts, const int accuracy, | ||
334 : | syskin | 1085 | const WARPPOINTS *const pts, |
335 : | const int width, const int height, | ||
336 : | NEW_GMC_DATA *const gmc) | ||
337 : | chl | 1077 | { |
338 : | syskin | 1085 | gmc->sW = width << 4; |
339 : | gmc->sH = height << 4; | ||
340 : | gmc->accuracy = accuracy; | ||
341 : | gmc->num_wp = nb_pts; | ||
342 : | chl | 1077 | |
343 : | edgomez | 1160 | /* reduce the number of points, if possible */ |
344 : | Skal | 1394 | if (nb_pts<2 || (pts->duv[2].x==0 && pts->duv[2].y==0 && pts->duv[1].x==0 && pts->duv[1].y==0 )) { |
345 : | if (nb_pts<2 || (pts->duv[1].x==0 && pts->duv[1].y==0)) { | ||
346 : | if (nb_pts<1 || (pts->duv[0].x==0 && pts->duv[0].y==0)) { | ||
347 : | nb_pts = 0; | ||
348 : | } | ||
349 : | else nb_pts = 1; | ||
350 : | } | ||
351 : | else nb_pts = 2; | ||
352 : | } | ||
353 : | edgomez | 1161 | |
354 : | edgomez | 1160 | /* now, nb_pts stores the actual number of points required for interpolation */ |
355 : | chl | 1077 | |
356 : | syskin | 1085 | if (nb_pts<=1) |
357 : | { | ||
358 : | if (nb_pts==1) { | ||
359 : | edgomez | 1160 | /* store as 4b fixed point */ |
360 : | syskin | 1085 | gmc->Uo = pts->duv[0].x << accuracy; |
361 : | gmc->Vo = pts->duv[0].y << accuracy; | ||
362 : | edgomez | 1160 | gmc->Uco = ((pts->duv[0].x>>1) | (pts->duv[0].x&1)) << accuracy; /* DIV2RND() */ |
363 : | gmc->Vco = ((pts->duv[0].y>>1) | (pts->duv[0].y&1)) << accuracy; /* DIV2RND() */ | ||
364 : | syskin | 1085 | } |
365 : | edgomez | 1160 | else { /* zero points?! */ |
366 : | syskin | 1085 | gmc->Uo = gmc->Vo = 0; |
367 : | gmc->Uco = gmc->Vco = 0; | ||
368 : | } | ||
369 : | chl | 1077 | |
370 : | syskin | 1085 | gmc->predict_16x16 = Predict_1pt_16x16_C; |
371 : | gmc->predict_8x8 = Predict_1pt_8x8_C; | ||
372 : | gmc->get_average_mv = get_average_mv_1pt_C; | ||
373 : | } | ||
374 : | edgomez | 1160 | else { /* 2 or 3 points */ |
375 : | const int rho = 3 - accuracy; /* = {3,2,1,0} for Acc={0,1,2,3} */ | ||
376 : | syskin | 1085 | int Alpha = log2bin(width-1); |
377 : | int Ws = 1 << Alpha; | ||
378 : | chl | 1077 | |
379 : | edgomez | 1160 | gmc->dU[0] = 16*Ws + RDIV( 8*Ws*pts->duv[1].x, width ); /* dU/dx */ |
380 : | gmc->dV[0] = RDIV( 8*Ws*pts->duv[1].y, width ); /* dV/dx */ | ||
381 : | chl | 1077 | |
382 : | edgomez | 1160 | if (nb_pts==2) { |
383 : | gmc->dU[1] = -gmc->dV[0]; /* -Sin */ | ||
384 : | gmc->dV[1] = gmc->dU[0] ; /* Cos */ | ||
385 : | syskin | 1085 | } |
386 : | edgomez | 1160 | else |
387 : | chl | 1077 | { |
388 : | syskin | 1085 | const int Beta = log2bin(height-1); |
389 : | const int Hs = 1<<Beta; | ||
390 : | edgomez | 1160 | gmc->dU[1] = RDIV( 8*Hs*pts->duv[2].x, height ); /* dU/dy */ |
391 : | gmc->dV[1] = 16*Hs + RDIV( 8*Hs*pts->duv[2].y, height ); /* dV/dy */ | ||
392 : | syskin | 1085 | if (Beta>Alpha) { |
393 : | gmc->dU[0] <<= (Beta-Alpha); | ||
394 : | gmc->dV[0] <<= (Beta-Alpha); | ||
395 : | Alpha = Beta; | ||
396 : | Ws = Hs; | ||
397 : | } | ||
398 : | else { | ||
399 : | gmc->dU[1] <<= Alpha - Beta; | ||
400 : | gmc->dV[1] <<= Alpha - Beta; | ||
401 : | } | ||
402 : | } | ||
403 : | edgomez | 1160 | /* upscale to 16b fixed-point */ |
404 : | syskin | 1085 | gmc->dU[0] <<= (16-Alpha - rho); |
405 : | gmc->dU[1] <<= (16-Alpha - rho); | ||
406 : | gmc->dV[0] <<= (16-Alpha - rho); | ||
407 : | gmc->dV[1] <<= (16-Alpha - rho); | ||
408 : | chl | 1077 | |
409 : | syskin | 1085 | gmc->Uo = ( pts->duv[0].x <<(16+ accuracy)) + (1<<15); |
410 : | gmc->Vo = ( pts->duv[0].y <<(16+ accuracy)) + (1<<15); | ||
411 : | gmc->Uco = ((pts->duv[0].x-1)<<(17+ accuracy)) + (1<<17); | ||
412 : | gmc->Vco = ((pts->duv[0].y-1)<<(17+ accuracy)) + (1<<17); | ||
413 : | gmc->Uco = (gmc->Uco + gmc->dU[0] + gmc->dU[1])>>2; | ||
414 : | gmc->Vco = (gmc->Vco + gmc->dV[0] + gmc->dV[1])>>2; | ||
415 : | chl | 1077 | |
416 : | syskin | 1085 | gmc->predict_16x16 = Predict_16x16_C; |
417 : | gmc->predict_8x8 = Predict_8x8_C; | ||
418 : | gmc->get_average_mv = get_average_mv_C; | ||
419 : | } | ||
420 : | chl | 1077 | } |
421 : | |||
422 : | edgomez | 1160 | /* ******************************************************************* |
423 : | * quick and dirty routine to generate the full warped image | ||
424 : | * (pGMC != NULL) or just all average Motion Vectors (pGMC == NULL) */ | ||
425 : | chl | 1077 | |
426 : | void | ||
427 : | edgomez | 1160 | generate_GMCimage( const NEW_GMC_DATA *const gmc_data, /* [input] precalculated data */ |
428 : | const IMAGE *const pRef, /* [input] */ | ||
429 : | chl | 1077 | const int mb_width, |
430 : | const int mb_height, | ||
431 : | const int stride, | ||
432 : | const int stride2, | ||
433 : | edgomez | 1160 | const int fcode, /* [input] some parameters... */ |
434 : | const int32_t quarterpel, /* [input] for rounding avgMV */ | ||
435 : | const int reduced_resolution, /* [input] ignored */ | ||
436 : | const int32_t rounding, /* [input] for rounding image data */ | ||
437 : | MACROBLOCK *const pMBs, /* [output] average motion vectors */ | ||
438 : | IMAGE *const pGMC) /* [output] full warped image */ | ||
439 : | chl | 1077 | { |
440 : | |||
441 : | unsigned int mj,mi; | ||
442 : | VECTOR avgMV; | ||
443 : | |||
444 : | for (mj = 0; mj < (unsigned int)mb_height; mj++) | ||
445 : | for (mi = 0; mi < (unsigned int)mb_width; mi++) { | ||
446 : | const int mbnum = mj*mb_width+mi; | ||
447 : | if (pGMC) | ||
448 : | { | ||
449 : | edgomez | 1161 | gmc_data->predict_16x16(gmc_data, |
450 : | pGMC->y + mj*16*stride + mi*16, pRef->y, | ||
451 : | chl | 1077 | stride, stride, mi, mj, rounding); |
452 : | |||
453 : | gmc_data->predict_8x8(gmc_data, | ||
454 : | pGMC->u + mj*8*stride2 + mi*8, pRef->u, | ||
455 : | pGMC->v + mj*8*stride2 + mi*8, pRef->v, | ||
456 : | stride2, stride2, mi, mj, rounding); | ||
457 : | } | ||
458 : | gmc_data->get_average_mv(gmc_data, &avgMV, mi, mj, quarterpel); | ||
459 : | |||
460 : | pMBs[mbnum].amv.x = gmc_sanitize(avgMV.x, quarterpel, fcode); | ||
461 : | pMBs[mbnum].amv.y = gmc_sanitize(avgMV.y, quarterpel, fcode); | ||
462 : | |||
463 : | pMBs[mbnum].mcsel = 0; /* until mode decision */ | ||
464 : | } | ||
465 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |