void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)

{

POWERPC_TBL_DECLARE(altivec_avg_pixels8_num, 1);

#ifdef ALTIVEC_USE_REFERENCE_C_CODE

    int i;

POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

    for (i = 0; i < h; i++) {

        *((uint32_t *) (block)) =

            (((*((uint32_t *) (block))) |

              ((((const struct unaligned_32 *) (pixels))->l))) -

             ((((*((uint32_t *) (block))) ^

                ((((const struct unaligned_32 *) (pixels))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        *((uint32_t *) (block + 4)) =

            (((*((uint32_t *) (block + 4))) |

              ((((const struct unaligned_32 *) (pixels + 4))->l))) -

             ((((*((uint32_t *) (block + 4))) ^

                ((((const struct unaligned_32 *) (pixels +

                                                  4))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        pixels += line_size;

        block += line_size;

    }

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);



#else /* ALTIVEC_USE_REFERENCE_C_CODE */

    register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;

    int i;



POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

 

   for (i = 0; i < h; i++) {

     /*

       block is 8 bytes-aligned, so we're either in the

       left block (16 bytes-aligned) or in the right block (not)

     */

     int rightside = ((unsigned long)block & 0x0000000F);

     

     blockv = vec_ld(0, block);

     pixelsv1 = vec_ld(0, (unsigned char*)pixels);

     pixelsv2 = vec_ld(16, (unsigned char*)pixels);

     pixelsv = vec_perm(pixelsv1, pixelsv2, vec_lvsl(0, pixels));

     

     if (rightside)

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1));

     }

     else

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3));

     }

     

     blockv = vec_avg(blockv, pixelsv);



     vec_st(blockv, 0, block);

     

     pixels += line_size;

     block += line_size;

   }

   

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);

 

#endif /* ALTIVEC_USE_REFERENCE_C_CODE */

}

void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)

{

POWERPC_TBL_DECLARE(altivec_avg_pixels8_num, 1);

#ifdef ALTIVEC_USE_REFERENCE_C_CODE

    int i;

POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

    for (i = 0; i < h; i++) {

        *((uint32_t *) (block)) =

            (((*((uint32_t *) (block))) |

              ((((const struct unaligned_32 *) (pixels))->l))) -

             ((((*((uint32_t *) (block))) ^

                ((((const struct unaligned_32 *) (pixels))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        *((uint32_t *) (block + 4)) =

            (((*((uint32_t *) (block + 4))) |

              ((((const struct unaligned_32 *) (pixels + 4))->l))) -

             ((((*((uint32_t *) (block + 4))) ^

                ((((const struct unaligned_32 *) (pixels +

                                                  4))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        pixels += line_size;

        block += line_size;

    }

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);



#else 

    register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv;

    int i;



POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

 

   for (i = 0; i < h; i++) {

     







     int rightside = ((unsigned long)block & 0x0000000F);

     

     blockv = vec_ld(0, block);

     pixelsv1 = vec_ld(0, (unsigned char*)pixels);

     pixelsv2 = vec_ld(16, (unsigned char*)pixels);

     pixelsv = vec_perm(pixelsv1, pixelsv2, vec_lvsl(0, pixels));

     

     if (rightside)

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1));

     }

     else

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3));

     }

     

     blockv = vec_avg(blockv, pixelsv);



     vec_st(blockv, 0, block);

     

     pixels += line_size;

     block += line_size;

   }

   

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);

 

#endif 

}

void FUNC_0(uint8_t * VAR_0, const uint8_t * VAR_1, int VAR_2, int VAR_3)

{

POWERPC_TBL_DECLARE(altivec_avg_pixels8_num, 1);

#ifdef ALTIVEC_USE_REFERENCE_C_CODE

    int VAR_5;

POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

    for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {

        *((uint32_t *) (VAR_0)) =

            (((*((uint32_t *) (VAR_0))) |

              ((((const struct unaligned_32 *) (VAR_1))->l))) -

             ((((*((uint32_t *) (VAR_0))) ^

                ((((const struct unaligned_32 *) (VAR_1))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        *((uint32_t *) (VAR_0 + 4)) =

            (((*((uint32_t *) (VAR_0 + 4))) |

              ((((const struct unaligned_32 *) (VAR_1 + 4))->l))) -

             ((((*((uint32_t *) (VAR_0 + 4))) ^

                ((((const struct unaligned_32 *) (VAR_1 +

                                                  4))->

                  l))) & 0xFEFEFEFEUL) >> 1));

        VAR_1 += VAR_2;

        VAR_0 += VAR_2;

    }

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);



#else 

    register vector unsigned char VAR_4, pixelsv2, pixelsv, blockv;

    int VAR_5;



POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1);

 

   for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {

     







     int VAR_6 = ((unsigned long)VAR_0 & 0x0000000F);

     

     blockv = vec_ld(0, VAR_0);

     VAR_4 = vec_ld(0, (unsigned char*)VAR_1);

     pixelsv2 = vec_ld(16, (unsigned char*)VAR_1);

     pixelsv = vec_perm(VAR_4, pixelsv2, vec_lvsl(0, VAR_1));

     

     if (VAR_6)

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1));

     }

     else

     {

       pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3));

     }

     

     blockv = vec_avg(blockv, pixelsv);



     vec_st(blockv, 0, VAR_0);

     

     VAR_1 += VAR_2;

     VAR_0 += VAR_2;

   }

   

POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1);

 

#endif 

}

void FUNC_0(uint8_t * VAR_0, const uint8_t * VAR_1, int VAR_2, int VAR_3)
{ POWERPC_TBL_DECLARE(altivec_avg_pixels8_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE
int VAR_5; POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1); for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) { *((uint32_t *) (VAR_0)) =
(((*((uint32_t *) (VAR_0))) |
((((const struct unaligned_32 *) (VAR_1))->l))) -
((((*((uint32_t *) (VAR_0))) ^
((((const struct unaligned_32 *) (VAR_1))->
l))) & 0xFEFEFEFEUL) >> 1)); *((uint32_t *) (VAR_0 + 4)) =
(((*((uint32_t *) (VAR_0 + 4))) |
((((const struct unaligned_32 *) (VAR_1 + 4))->l))) -
((((*((uint32_t *) (VAR_0 + 4))) ^
((((const struct unaligned_32 *) (VAR_1 +
4))->
l))) & 0xFEFEFEFEUL) >> 1)); VAR_1 += VAR_2; VAR_0 += VAR_2; } POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1); #else
register vector unsigned char VAR_4, pixelsv2, pixelsv, blockv; int VAR_5; POWERPC_TBL_START_COUNT(altivec_avg_pixels8_num, 1); for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) { int VAR_6 = ((unsigned long)VAR_0 & 0x0000000F); blockv = vec_ld(0, VAR_0); VAR_4 = vec_ld(0, (unsigned char*)VAR_1); pixelsv2 = vec_ld(16, (unsigned char*)VAR_1); pixelsv = vec_perm(VAR_4, pixelsv2, vec_lvsl(0, VAR_1)); if (VAR_6)
{ pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1)); } else
{ pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3)); } blockv = vec_avg(blockv, pixelsv); vec_st(blockv, 0, VAR_0); VAR_1 += VAR_2; VAR_0 += VAR_2; } POWERPC_TBL_STOP_COUNT(altivec_avg_pixels8_num, 1); #endif
}