*((uint32_t*)(block )) = (((const struct unaligned_32 *) (pixels))->l); *((uint32_t*)(block+4)) = (((const struct unaligned_32 *) (pixels+4))->l); *((uint32_t*)(block+8)) = (((const struct unaligned_32 *) (pixels+8))->l); *((uint32_t*)(block+12)) = (((const struct unaligned_32 *) (pixels+12))->l);
*((uint32_t*)(block)) = LD32(pixels); *((uint32_t*)(block+4)) = LD32(pixels+4); *((uint32_t*)(block+8)) = LD32(pixels+8); *((uint32_t*)(block+12)) = LD32(pixels+12);
void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h){POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1);#ifdef ALTIVEC_USE_REFERENCE_C_CODE    int i;POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);    for(i=0; i<h; i++) {      *((uint32_t*)(block )) = (((const struct unaligned_32 *) (pixels))->l);      *((uint32_t*)(block+4)) = (((const struct unaligned_32 *) (pixels+4))->l);      *((uint32_t*)(block+8)) = (((const struct unaligned_32 *) (pixels+8))->l);      *((uint32_t*)(block+12)) = (((const struct unaligned_32 *) (pixels+12))->l);      pixels+=line_size;      block +=line_size;    }POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);#else /* ALTIVEC_USE_REFERENCE_C_CODE */    register vector unsigned char pixelsv1, pixelsv2;    register vector unsigned char pixelsv1B, pixelsv2B;    register vector unsigned char pixelsv1C, pixelsv2C;    register vector unsigned char pixelsv1D, pixelsv2D;    register vector unsigned char perm = vec_lvsl(0, pixels);    int i;    register int line_size_2 = line_size << 1;    register int line_size_3 = line_size + line_size_2;    register int line_size_4 = line_size << 2;POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1);// hand-unrolling the loop by 4 gains about 15%// mininum execution time goes from 74 to 60 cycles// it's faster than -funroll-loops, but using// -funroll-loops w/ this is bad - 74 cycles again.// all this is on a 7450, tuning for the 7450#if 0    for(i=0; i<h; i++) {      pixelsv1 = vec_ld(0, (unsigned char*)pixels);      pixelsv2 = vec_ld(16, (unsigned char*)pixels);      vec_st(vec_perm(pixelsv1, pixelsv2, perm),             0, (unsigned char*)block);      pixels+=line_size;      block +=line_size;    }#else    for(i=0; i<h; i+=4) {      pixelsv1 = vec_ld(0, (unsigned char*)pixels);      pixelsv2 = vec_ld(16, (unsigned char*)pixels);      pixelsv1B = vec_ld(line_size, (unsigned char*)pixels);      pixelsv2B = vec_ld(16 + line_size, (unsigned char*)pixels);      pixelsv1C = vec_ld(line_size_2, (unsigned char*)pixels);      pixelsv2C = vec_ld(16 + line_size_2, (unsigned char*)pixels);      pixelsv1D = vec_ld(line_size_3, (unsigned char*)pixels);      pixelsv2D = vec_ld(16 + line_size_3, (unsigned char*)pixels);      vec_st(vec_perm(pixelsv1, pixelsv2, perm),             0, (unsigned char*)block);      vec_st(vec_perm(pixelsv1B, pixelsv2B, perm),             line_size, (unsigned char*)block);      vec_st(vec_perm(pixelsv1C, pixelsv2C, perm),             line_size_2, (unsigned char*)block);      vec_st(vec_perm(pixelsv1D, pixelsv2D, perm),             line_size_3, (unsigned char*)block);      pixels+=line_size_4;      block +=line_size_4;    }#endifPOWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1);#endif /* ALTIVEC_USE_REFERENCE_C_CODE */}