comparison ppc/dsputil_altivec.c @ 995:edc10966b081 libavcodec

altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
author michaelni
date Sat, 11 Jan 2003 20:51:03 +0000
parents 8bec850dc9c7
children 3b7cc8e4b83f
comparison
equal deleted inserted replaced
994:7701ff462e3a 995:edc10966b081
583 s2 += stride; 583 s2 += stride;
584 block += 8; 584 block += 8;
585 } 585 }
586 } 586 }
587 587
588 int sad16x16_altivec(void *s, uint8_t *a, uint8_t *b, int stride) {
589 return pix_abs16x16_altivec(a,b,stride);
590 }
591
592 int sad8x8_altivec(void *s, uint8_t *a, uint8_t *b, int stride) {
593 return pix_abs8x8_altivec(a,b,stride);
594 }
595
596 void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) {
597 #if 0
598 int i;
599 for(i=0; i+7<w; i++){
600 dst[i+0] += src[i+0];
601 dst[i+1] += src[i+1];
602 dst[i+2] += src[i+2];
603 dst[i+3] += src[i+3];
604 dst[i+4] += src[i+4];
605 dst[i+5] += src[i+5];
606 dst[i+6] += src[i+6];
607 dst[i+7] += src[i+7];
608 }
609 for(; i<w; i++)
610 dst[i+0] += src[i+0];
611 #else
612 register int i;
613 register uint8_t *temp_src = src, *temp_dst = dst;
614 register vector unsigned char vdst, vsrc, temp1, temp2;
615 register vector unsigned char perm;
616 register int count = 0;
617
618 for (i = 0; (i < w) && ((unsigned long)temp_dst & 0x0000000F) ; i++)
619 {
620 dst[i] = src[i];
621 temp_src ++;
622 temp_dst ++;
623 }
624 /* temp_dst is a properly aligned pointer */
625 /* we still need to deal with ill-aligned src */
626 perm = vec_lvsl(0, temp_src);
627 temp1 = vec_ld(0, temp_src);
628 while ((i + 15) < w)
629 {
630 temp2 = vec_ld(count + 16, temp_src);
631 vdst = vec_ld(count, temp_dst);
632 vsrc = vec_perm(temp1, temp2, perm);
633 temp1 = temp2;
634 vdst = vec_add(vsrc, vdst);
635 vec_st(vdst, count, temp_dst);
636 count += 16;
637 }
638 for (; (i < w) ; i++)
639 {
640 dst[i] = src[i];
641 }
642 #endif
643 }
588 644
589 int has_altivec(void) 645 int has_altivec(void)
590 { 646 {
591 #if CONFIG_DARWIN 647 #if CONFIG_DARWIN
592 int sels[2] = {CTL_HW, HW_VECTORUNIT}; 648 int sels[2] = {CTL_HW, HW_VECTORUNIT};
598 654
599 if (err == 0) return (has_vu != 0); 655 if (err == 0) return (has_vu != 0);
600 #endif 656 #endif
601 return 0; 657 return 0;
602 } 658 }
603