Пример #1
0
static void float_to_int16_altivec(int16_t *dst, const float *src, long len)
{
    int i;
    vector signed short d0, d1, d;
    vector unsigned char align;
    if(((long)dst) & 15) //FIXME
        for(i = 0; i < len - 7; i += 8)
        {
            d0 = vec_ld(0, dst + i);
            d = float_to_int16_one_altivec(src + i);
            d1 = vec_ld(15, dst + i);
            d1 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
            align = vec_lvsr(0, dst + i);
            d0 = vec_perm(d1, d, align);
            d1 = vec_perm(d, d1, align);
            vec_st(d0, 0, dst + i);
            vec_st(d1, 15, dst + i);
        }
    else
        for(i = 0; i < len - 7; i += 8)
        {
            d = float_to_int16_one_altivec(src + i);
            vec_st(d, 0, dst + i);
        }
}
Пример #2
0
static void
float_to_int16_interleave_altivec(int16_t *dst, const float **src,
                                  long len, int channels)
{
    int i;
    vector signed short d0, d1, d2, c0, c1, t0, t1;
    vector unsigned char align;
    if(channels == 1)
        float_to_int16_altivec(dst, src[0], len);
    else if (channels == 2)
    {
        if(((long)dst) & 15)
            for(i = 0; i < len - 7; i += 8)
            {
                d0 = vec_ld(0, dst + i);
                t0 = float_to_int16_one_altivec(src[0] + i);
                d1 = vec_ld(31, dst + i);
                t1 = float_to_int16_one_altivec(src[1] + i);
                c0 = vec_mergeh(t0, t1);
                c1 = vec_mergel(t0, t1);
                d2 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
                align = vec_lvsr(0, dst + i);
                d0 = vec_perm(d2, c0, align);
                d1 = vec_perm(c0, c1, align);
                vec_st(d0,  0, dst + i);
                d0 = vec_perm(c1, d2, align);
                vec_st(d1, 15, dst + i);
                vec_st(d0, 31, dst + i);
                dst += 8;
            }
        else
            for(i = 0; i < len - 7; i += 8)
            {
                t0 = float_to_int16_one_altivec(src[0] + i);
                t1 = float_to_int16_one_altivec(src[1] + i);
                d0 = vec_mergeh(t0, t1);
                d1 = vec_mergel(t0, t1);
                vec_st(d0,  0, dst + i);
                vec_st(d1, 16, dst + i);
                dst += 8;
            }
    }
    else
    {
        DECLARE_ALIGNED(16, int16_t, tmp)[len];
        int c, j;
        for (c = 0; c < channels; c++)
        {
            float_to_int16_altivec(tmp, src[c], len);
            for (i = 0, j = c; i < len; i++, j += channels)
            {
                dst[j] = tmp[i];
            }
        }
    }
}
Пример #3
0
static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
        long len, int stride)
{
    int i;
    vector signed short d, s;

    for (i = 0; i < len - 7; i += 8) {
        d = float_to_int16_one_altivec(src + i);

#define ASSIGN_S_VEC_SPLAT_D(j) \
        s = vec_splat(d, j); \
        vec_ste(s, 0, dst); \
        dst += stride

        ASSIGN_S_VEC_SPLAT_D(0);
        ASSIGN_S_VEC_SPLAT_D(1);
        ASSIGN_S_VEC_SPLAT_D(2);
        ASSIGN_S_VEC_SPLAT_D(3);
        ASSIGN_S_VEC_SPLAT_D(4);
        ASSIGN_S_VEC_SPLAT_D(5);
        ASSIGN_S_VEC_SPLAT_D(6);
        ASSIGN_S_VEC_SPLAT_D(7);

#undef ASSIGN_S_VEC_SPLAT_D
    }
}
Пример #4
0
static void float_to_int16_interleave_altivec(int16_t *dst, const float **src,
                                              long len, int channels)
{
    int i;
    vector signed short d0, d1, d2, c0, c1, t0, t1;
    vector unsigned char align;

    if (channels == 1)
        float_to_int16_altivec(dst, src[0], len);
    else {
        if (channels == 2) {
            if (((long)dst) & 15) {
                for (i = 0; i < len - 7; i += 8) {
                    d0 = vec_ld(0,  dst + i);
                    t0 = float_to_int16_one_altivec(src[0] + i);
                    d1 = vec_ld(31, dst + i);
                    t1 = float_to_int16_one_altivec(src[1] + i);
                    c0 = vec_mergeh(t0, t1);
                    c1 = vec_mergel(t0, t1);
                    d2 = vec_perm(d1, d0, vec_lvsl(0, dst + i));
                    align = vec_lvsr(0, dst + i);
                    d0 = vec_perm(d2, c0, align);
                    d1 = vec_perm(c0, c1, align);
                    vec_st(d0,  0, dst + i);
                    d0 = vec_perm(c1, d2, align);
                    vec_st(d1, 15, dst + i);
                    vec_st(d0, 31, dst + i);
                    dst += 8;
                }
            } else {
                for (i = 0; i < len - 7; i += 8) {
                    t0 = float_to_int16_one_altivec(src[0] + i);
                    t1 = float_to_int16_one_altivec(src[1] + i);
                    d0 = vec_mergeh(t0, t1);
                    d1 = vec_mergel(t0, t1);
                    vec_st(d0,  0, dst + i);
                    vec_st(d1, 16, dst + i);
                    dst += 8;
                }
            }
        } else {
            for (i = 0; i < channels; i++)
                float_to_int16_stride_altivec(dst + i, src[i], len, channels);
        }
    }
}
Пример #5
0
static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
                                          long len, int stride)
{
    int i;
    vector signed short d;

    for (i = 0; i < len - 7; i += 8) {
        d = float_to_int16_one_altivec(src + i);
        VSTE_INC(dst, d, 0, stride);
        VSTE_INC(dst, d, 1, stride);
        VSTE_INC(dst, d, 2, stride);
        VSTE_INC(dst, d, 3, stride);
        VSTE_INC(dst, d, 4, stride);
        VSTE_INC(dst, d, 5, stride);
        VSTE_INC(dst, d, 6, stride);
        VSTE_INC(dst, d, 7, stride);
    }
}