19 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
* |
* |
22 |
* $Id: gmc.c,v 1.1.2.6 2003-10-01 23:23:01 edgomez Exp $ |
* $Id: gmc.c,v 1.1.2.9 2004-03-31 13:40:59 Skal Exp $ |
23 |
* |
* |
24 |
****************************************************************************/ |
****************************************************************************/ |
25 |
|
|
70 |
U += dUx; V += dVx; |
U += dUx; V += dVx; |
71 |
|
|
72 |
if (u > 0 && u <= W) { ri = MTab[u&15]; Offset = u>>4; } |
if (u > 0 && u <= W) { ri = MTab[u&15]; Offset = u>>4; } |
73 |
else if (u > W) Offset = W>>4; |
else { |
74 |
else Offset = -1; |
if (u > W) Offset = W>>4; |
75 |
|
else Offset = 0; |
76 |
|
ri = MTab[0]; |
77 |
|
} |
78 |
|
|
79 |
if (v > 0 && v <= H) { rj = MTab[v&15]; Offset += (v>>4)*srcstride; } |
if (v > 0 && v <= H) { rj = MTab[v&15]; Offset += (v>>4)*srcstride; } |
80 |
else if (v > H) Offset += (H>>4)*srcstride; |
else { |
81 |
else Offset -= srcstride; |
if (v > H) Offset += (H>>4)*srcstride; |
82 |
|
rj = MTab[0]; |
83 |
|
} |
84 |
|
|
85 |
f0 = src[Offset + 0]; |
f0 = src[Offset + 0]; |
86 |
f0 |= src[Offset + 1] << 16; |
f0 |= src[Offset + 1] << 16; |
136 |
ri = MTab[u&15]; |
ri = MTab[u&15]; |
137 |
Offset = u>>4; |
Offset = u>>4; |
138 |
} else { |
} else { |
|
ri = 16; |
|
139 |
if (u>W) Offset = W>>4; |
if (u>W) Offset = W>>4; |
140 |
else Offset = -1; |
else Offset = 0; |
141 |
|
ri = MTab[0]; |
142 |
} |
} |
143 |
|
|
144 |
if (v > 0 && v <= H) { |
if (v > 0 && v <= H) { |
145 |
rj = MTab[v&15]; |
rj = MTab[v&15]; |
146 |
Offset += (v>>4)*srcstride; |
Offset += (v>>4)*srcstride; |
147 |
} else { |
} else { |
|
rj = 16; |
|
148 |
if (v>H) Offset += (H>>4)*srcstride; |
if (v>H) Offset += (H>>4)*srcstride; |
149 |
else Offset -= srcstride; |
rj = MTab[0]; |
150 |
} |
} |
151 |
|
|
152 |
f0 = uSrc[Offset + 0]; |
f0 = uSrc[Offset + 0]; |
218 |
|
|
219 |
int32_t uo = This->Uo + (x<<8); /* ((16*x)<<4) */ |
int32_t uo = This->Uo + (x<<8); /* ((16*x)<<4) */ |
220 |
int32_t vo = This->Vo + (y<<8); |
int32_t vo = This->Vo + (y<<8); |
221 |
const uint32_t ri = MTab[uo & 15]; |
uint32_t ri = MTab[uo & 15]; |
222 |
const uint32_t rj = MTab[vo & 15]; |
uint32_t rj = MTab[vo & 15]; |
223 |
int i, j; |
int i, j; |
224 |
|
|
225 |
int32_t Offset; |
int32_t Offset; |
226 |
if ((uint32_t)vo<=(uint32_t)H) Offset = (vo>>4)*srcstride; |
if (vo>=(-16*4) && vo<=H) Offset = (vo>>4)*srcstride; |
227 |
else if (vo>H) Offset = ( H>>4)*srcstride; |
else { |
228 |
|
if (vo>H) Offset = ( H>>4)*srcstride; |
229 |
else Offset =-16*srcstride; |
else Offset =-16*srcstride; |
230 |
if ((uint32_t)uo<=(uint32_t)W) Offset += (uo>>4); |
rj = MTab[0]; |
231 |
else if (uo>W) Offset += ( W>>4); |
} |
232 |
|
if (uo>=(-16*4) && uo<=W) Offset += (uo>>4); |
233 |
|
else { |
234 |
|
if (uo>W) Offset += (W>>4); |
235 |
else Offset -= 16; |
else Offset -= 16; |
236 |
|
ri = MTab[0]; |
237 |
|
} |
238 |
|
|
239 |
Dst += 16; |
Dst += 16; |
240 |
|
|
269 |
|
|
270 |
int32_t uo = This->Uco + (x<<7); |
int32_t uo = This->Uco + (x<<7); |
271 |
int32_t vo = This->Vco + (y<<7); |
int32_t vo = This->Vco + (y<<7); |
272 |
const uint32_t rri = MTab[uo & 15]; |
uint32_t rri = MTab[uo & 15]; |
273 |
const uint32_t rrj = MTab[vo & 15]; |
uint32_t rrj = MTab[vo & 15]; |
274 |
int i, j; |
int i, j; |
275 |
|
|
276 |
int32_t Offset; |
int32_t Offset; |
277 |
if ((uint32_t)vo<=(uint32_t)H) Offset = (vo>>4)*srcstride; |
if (vo>=(-8*4) && vo<=H) Offset = (vo>>4)*srcstride; |
278 |
else if (vo>H) Offset = ( H>>4)*srcstride; |
else { |
279 |
|
if (vo>H) Offset = ( H>>4)*srcstride; |
280 |
else Offset =-8*srcstride; |
else Offset =-8*srcstride; |
281 |
if ((uint32_t)uo<=(uint32_t)W) Offset += (uo>>4); |
rrj = MTab[0]; |
282 |
else if (uo>W) Offset += (W>>4); |
} |
283 |
|
if (uo>=(-8*4) && uo<=W) Offset += (uo>>4); |
284 |
|
else { |
285 |
|
if (uo>W) Offset += ( W>>4); |
286 |
else Offset -= 8; |
else Offset -= 8; |
287 |
|
rri = MTab[0]; |
288 |
|
} |
289 |
|
|
290 |
uDst += 8; |
uDst += 8; |
291 |
vDst += 8; |
vDst += 8; |
341 |
gmc->num_wp = nb_pts; |
gmc->num_wp = nb_pts; |
342 |
|
|
343 |
/* reduce the number of points, if possible */ |
/* reduce the number of points, if possible */ |
344 |
if (nb_pts<3 || (pts->duv[2].x==-pts->duv[1].y && pts->duv[2].y==pts->duv[1].x)) { |
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)) { |
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)) { |
if (nb_pts<1 || (pts->duv[0].x==0 && pts->duv[0].y==0)) { |
347 |
nb_pts = 0; |
nb_pts = 0; |
350 |
} |
} |
351 |
else nb_pts = 2; |
else nb_pts = 2; |
352 |
} |
} |
|
else nb_pts = 3; |
|
353 |
|
|
354 |
/* now, nb_pts stores the actual number of points required for interpolation */ |
/* now, nb_pts stores the actual number of points required for interpolation */ |
355 |
|
|
379 |
gmc->dU[0] = 16*Ws + RDIV( 8*Ws*pts->duv[1].x, width ); /* dU/dx */ |
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 */ |
gmc->dV[0] = RDIV( 8*Ws*pts->duv[1].y, width ); /* dV/dx */ |
381 |
|
|
|
/* disabled, because possibly buggy? */ |
|
|
|
|
|
#if 0 |
|
382 |
if (nb_pts==2) { |
if (nb_pts==2) { |
383 |
gmc->dU[1] = -gmc->dV[0]; /* -Sin */ |
gmc->dU[1] = -gmc->dV[0]; /* -Sin */ |
384 |
gmc->dV[1] = gmc->dU[0] ; /* Cos */ |
gmc->dV[1] = gmc->dU[0] ; /* Cos */ |
385 |
} |
} |
386 |
else |
else |
|
#endif |
|
387 |
{ |
{ |
388 |
const int Beta = log2bin(height-1); |
const int Beta = log2bin(height-1); |
389 |
const int Hs = 1<<Beta; |
const int Hs = 1<<Beta; |