Mercurial > libavcodec.hg
comparison ra144.c @ 6852:84dc84916bab libavcodec
Simplify eq()
author | vitor |
---|---|
date | Sat, 24 May 2008 12:33:00 +0000 |
parents | c225307f241d |
children | d4c8338a09a8 |
comparison
equal
deleted
inserted
replaced
6851:c225307f241d | 6852:84dc84916bab |
---|---|
250 *(ptr++) = *(inp++); | 250 *(ptr++) = *(inp++); |
251 } | 251 } |
252 | 252 |
253 static int eq(const short *in, int *target) | 253 static int eq(const short *in, int *target) |
254 { | 254 { |
255 int retval; | 255 int retval = 0; |
256 int a; | 256 int b, c, i; |
257 int b; | |
258 int c; | |
259 unsigned int u; | 257 unsigned int u; |
260 const short *sptr; | |
261 int *ptr1, *ptr2, *ptr3; | |
262 int *bp1, *bp2; | |
263 int buffer1[10]; | 258 int buffer1[10]; |
264 int buffer2[10]; | 259 int buffer2[10]; |
265 | 260 int *bp1 = buffer1; |
266 retval = 0; | 261 int *bp2 = buffer2; |
267 bp1 = buffer1; | 262 |
268 bp2 = buffer2; | 263 for (i=0; i < 10; i++) |
269 ptr2 = (ptr3 = buffer2) + 9; | 264 buffer2[i] = in[i]; |
270 sptr = in; | 265 |
271 | 266 u = target[9] = bp2[9]; |
272 while (ptr2 >= ptr3) | 267 |
273 *(ptr3++) = *(sptr++); | 268 if (u + 0x1000 > 0x1fff) |
274 | |
275 target += 9; | |
276 a = bp2[9]; | |
277 *target = a; | |
278 | |
279 if (a + 0x1000 > 0x1fff) | |
280 return 0; /* We're screwed, might as well go out with a bang. :P */ | 269 return 0; /* We're screwed, might as well go out with a bang. :P */ |
281 | 270 |
282 c = 8; | 271 for (c=8; c >= 0; c--) { |
283 u = a; | |
284 | |
285 while (c >= 0) { | |
286 if (u == 0x1000) | 272 if (u == 0x1000) |
287 u++; | 273 u++; |
288 | 274 |
289 if (u == 0xfffff000) | 275 if (u == 0xfffff000) |
290 u--; | 276 u--; |
292 b = 0x1000-((u * u) >> 12); | 278 b = 0x1000-((u * u) >> 12); |
293 | 279 |
294 if (b == 0) | 280 if (b == 0) |
295 b++; | 281 b++; |
296 | 282 |
297 ptr2 = bp1; | |
298 ptr1 = (ptr3 = bp2) + c; | |
299 | |
300 for (u=0; u<=c; u++) | 283 for (u=0; u<=c; u++) |
301 *(ptr2++) = ((*(ptr3++) - (((*target) * (*(ptr1--))) >> 12)) * (0x1000000 / b)) >> 12; | 284 bp1[u] = ((bp2[u] - ((target[c+1] * bp2[c-u]) >> 12)) * (0x1000000 / b)) >> 12; |
302 | 285 |
303 *(--target) = u = bp1[(c--)]; | 286 target[c] = u = bp1[c]; |
304 | 287 |
305 if ((u + 0x1000) > 0x1fff) | 288 if ((u + 0x1000) > 0x1fff) |
306 retval = 1; | 289 retval = 1; |
307 | 290 |
308 FFSWAP(int *, bp1, bp2); | 291 FFSWAP(int *, bp1, bp2); |