Revision 0fe67fa7

View differences:

libavcodec/ppc/dsputil_altivec.c
343 343
    return s;
344 344
}
345 345

  
346

  
347
int pix_norm_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
348
{
349
    int s, i;
350
    vector unsigned char *tv, zero;
351
    vector unsigned char pix1v, pix2v, t5;
352
    vector unsigned int sv;
353
    vector signed int sum;
354

  
355
    zero = vec_splat_u8(0);
356
    sv = vec_splat_u32(0);
357
    s = 0;
358
    for (i = 0; i < 16; i++) {
359
        /* Read in the potentially unaligned pixels */
360
        tv = (vector unsigned char *) pix1;
361
        pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1));
362

  
363
        tv = (vector unsigned char *) pix2;
364
        pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix2));
365

  
366
        /*
367
           Since we want to use unsigned chars, we can take advantage
368
           of the fact that abs(a-b)^2 = (a-b)^2.
369
        */
370
        
371
        /* Calculate a sum of abs differences vector */
372
        t5 = vec_sub(vec_max(pix1v, pix2v), vec_min(pix1v, pix2v));
373

  
374
        /* Square the values and add them to our sum */
375
        sv = vec_msum(t5, t5, sv);
376
        
377
        pix1 += line_size;
378
        pix2 += line_size;
379
    }
380
    /* Sum up the four partial sums, and put the result into s */
381
    sum = vec_sums((vector signed int) sv, (vector signed int) zero);
382
    sum = vec_splat(sum, 3);
383
    vec_ste(sum, 0, &s);
384
    return s;
385
}
386

  
387

  
388 346
int pix_sum_altivec(UINT8 * pix, int line_size)
389 347
{
390 348

  
libavcodec/ppc/dsputil_altivec.h
23 23
extern int pix_abs16x16_altivec(uint8_t *pix1, uint8_t *pix2, int line_size);
24 24
extern int pix_abs8x8_altivec(uint8_t *pix1, uint8_t *pix2, int line_size);
25 25
extern int pix_norm1_altivec(uint8_t *pix, int line_size);
26
extern int pix_norm_altivec(uint8_t *pix1, uint8_t *pix2, int line_size);
27 26
extern int pix_sum_altivec(UINT8 * pix, int line_size);
28 27
extern void diff_pixels_altivec(DCTELEM* block, const UINT8* s1, const UINT8* s2, int stride);
29 28
extern void get_pixels_altivec(DCTELEM* block, const UINT8 * pixels, int line_size);
libavcodec/ppc/dsputil_ppc.c
42 42
        c->pix_abs16x16 = pix_abs16x16_altivec;
43 43
        c->pix_abs8x8 = pix_abs8x8_altivec;
44 44
        c->pix_norm1 = pix_norm1_altivec;
45
        c->pix_norm = pix_norm_altivec;
46 45
        c->pix_sum = pix_sum_altivec;
47 46
        c->diff_pixels = diff_pixels_altivec;
48 47
        c->get_pixels = get_pixels_altivec;

Also available in: Unified diff