comparison ra144.c @ 6781:2f505f532aa8 libavcodec

Replace some hardcoded swapping with FFSWAP. Patch by Vitor Sessak (vitor1001 gmail com)
author astrange
date Sun, 11 May 2008 18:43:11 +0000
parents 6b0dfbe7b7f9
children 781bfad6e40e
comparison
equal deleted inserted replaced
6780:6b0dfbe7b7f9 6781:2f505f532aa8
106 static void do_voice(int *a1, int *a2) 106 static void do_voice(int *a1, int *a2)
107 { 107 {
108 int buffer[10]; 108 int buffer[10];
109 int *b1, *b2; 109 int *b1, *b2;
110 int x, y; 110 int x, y;
111 int *ptr, *tmp; 111 int *ptr;
112 112
113 b1 = buffer; 113 b1 = buffer;
114 b2 = a2; 114 b2 = a2;
115 115
116 for (x=0; x < 10; x++) { 116 for (x=0; x < 10; x++) {
119 if(x > 0) { 119 if(x > 0) {
120 ptr = b2 + x; 120 ptr = b2 + x;
121 for (y=0; y <= x - 1; y++) 121 for (y=0; y <= x - 1; y++)
122 b1[y] = (((*a1) * (*(--ptr))) >> 12) + b2[y]; 122 b1[y] = (((*a1) * (*(--ptr))) >> 12) + b2[y];
123 } 123 }
124 tmp = b1; 124 FFSWAP(int *, b1, b2);
125 b1 = b2;
126 b2 = tmp;
127 a1++; 125 a1++;
128 } 126 }
129 ptr = a2 + 10; 127 ptr = a2 + 10;
130 128
131 while (ptr > a2) 129 while (ptr > a2)
357 int b; 355 int b;
358 int c; 356 int c;
359 unsigned int u; 357 unsigned int u;
360 short *sptr; 358 short *sptr;
361 int *ptr1, *ptr2, *ptr3; 359 int *ptr1, *ptr2, *ptr3;
362 int *bp1, *bp2, *temp; 360 int *bp1, *bp2;
363 361
364 retval = 0; 362 retval = 0;
365 bp1 = glob->buffer1; 363 bp1 = glob->buffer1;
366 bp2 = glob->buffer2; 364 bp2 = glob->buffer2;
367 ptr2 = (ptr3 = glob->buffer2) + 9; 365 ptr2 = (ptr3 = glob->buffer2) + 9;
401 *(--target) = u = bp1[(c--)]; 399 *(--target) = u = bp1[(c--)];
402 400
403 if ((u + 0x1000) > 0x1fff) 401 if ((u + 0x1000) > 0x1fff)
404 retval = 1; 402 retval = 1;
405 403
406 temp = bp2; 404 FFSWAP(unsigned int *, bp1, bp2);
407 bp2 = bp1;
408 bp1 = temp;
409 } 405 }
410 return retval; 406 return retval;
411 } 407 }
412 408
413 static void dec2(Real144_internal *glob, int *data, int *inp, int n, int f, 409 static void dec2(Real144_internal *glob, int *data, int *inp, int n, int f,
452 void *vdata, int *data_size, 448 void *vdata, int *data_size,
453 const uint8_t * buf, int buf_size) 449 const uint8_t * buf, int buf_size)
454 { 450 {
455 unsigned int a, b, c; 451 unsigned int a, b, c;
456 signed short *shptr; 452 signed short *shptr;
457 unsigned int *lptr, *temp; 453 unsigned int *lptr;
458 const short **dptr; 454 const short **dptr;
459 int16_t *datao; 455 int16_t *datao;
460 int16_t *data = vdata; 456 int16_t *data = vdata;
461 Real144_internal *glob = avctx->priv_data; 457 Real144_internal *glob = avctx->priv_data;
462 458
511 *data++ = av_clip_int16(*(shptr++) << 2); 507 *data++ = av_clip_int16(*(shptr++) << 2);
512 b += 30; 508 b += 30;
513 } 509 }
514 510
515 glob->oldval = glob->val; 511 glob->oldval = glob->val;
516 temp = glob->swapbuf1alt; 512
517 glob->swapbuf1alt = glob->swapbuf1; 513 FFSWAP(unsigned int *, glob->swapbuf1alt, glob->swapbuf1);
518 glob->swapbuf1 = temp; 514 FFSWAP(unsigned int *, glob->swapbuf2alt, glob->swapbuf2);
519 temp = glob->swapbuf2alt; 515
520 glob->swapbuf2alt = glob->swapbuf2;
521 glob->swapbuf2 = temp;
522 *data_size = (data-datao)*sizeof(*data); 516 *data_size = (data-datao)*sizeof(*data);
523 return 20; 517 return 20;
524 } 518 }
525 519
526 520