~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/ppc/int_altivec.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <altivec.h>
29
29
#endif
30
30
 
 
31
#include "libavutil/ppc/types_altivec.h"
31
32
#include "libavcodec/dsputil.h"
32
33
 
33
34
#include "dsputil_altivec.h"
34
35
 
35
 
#include "types_altivec.h"
36
 
 
37
36
static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2,
38
37
                                     int size) {
39
38
    int i, size16;
79
78
    return u.score[3];
80
79
}
81
80
 
82
 
static int32_t scalarproduct_int16_altivec(const int16_t * v1, const int16_t * v2, int order, const int shift)
 
81
static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
 
82
                                           int order)
83
83
{
84
84
    int i;
85
85
    LOAD_ZERO;
86
 
    register vec_s16 vec1, *pv;
 
86
    const vec_s16 *pv;
 
87
    register vec_s16 vec1;
87
88
    register vec_s32 res = vec_splat_s32(0), t;
88
 
    register vec_u32 shifts;
89
89
    int32_t ires;
90
90
 
91
 
    shifts = zero_u32v;
92
 
    if(shift & 0x10) shifts = vec_add(shifts, vec_sl(vec_splat_u32(0x08), vec_splat_u32(0x1)));
93
 
    if(shift & 0x08) shifts = vec_add(shifts, vec_splat_u32(0x08));
94
 
    if(shift & 0x04) shifts = vec_add(shifts, vec_splat_u32(0x04));
95
 
    if(shift & 0x02) shifts = vec_add(shifts, vec_splat_u32(0x02));
96
 
    if(shift & 0x01) shifts = vec_add(shifts, vec_splat_u32(0x01));
97
 
 
98
91
    for(i = 0; i < order; i += 8){
99
 
        pv = (vec_s16*)v1;
 
92
        pv = (const vec_s16*)v1;
100
93
        vec1 = vec_perm(pv[0], pv[1], vec_lvsl(0, v1));
101
94
        t = vec_msum(vec1, vec_ld(0, v2), zero_s32v);
102
 
        t = vec_sr(t, shifts);
103
95
        res = vec_sums(t, res);
104
96
        v1 += 8;
105
97
        v2 += 8;
113
105
{
114
106
    LOAD_ZERO;
115
107
    vec_s16 *pv1 = (vec_s16*)v1;
116
 
    vec_s16 *pv2 = (vec_s16*)v2;
117
 
    vec_s16 *pv3 = (vec_s16*)v3;
118
108
    register vec_s16 muls = {mul,mul,mul,mul,mul,mul,mul,mul};
119
 
    register vec_s16 t0, t1, i0, i1;
120
 
    register vec_s16 i2 = pv2[0], i3 = pv3[0];
 
109
    register vec_s16 t0, t1, i0, i1, i4;
 
110
    register vec_s16 i2 = vec_ld(0, v2), i3 = vec_ld(0, v3);
121
111
    register vec_s32 res = zero_s32v;
122
112
    register vec_u8 align = vec_lvsl(0, v2);
123
113
    int32_t ires;
124
114
    order >>= 4;
125
115
    do {
126
 
        t0 = vec_perm(i2, pv2[1], align);
127
 
        i2 = pv2[2];
128
 
        t1 = vec_perm(pv2[1], i2, align);
 
116
        i1 = vec_ld(16, v2);
 
117
        t0 = vec_perm(i2, i1, align);
 
118
        i2 = vec_ld(32, v2);
 
119
        t1 = vec_perm(i1, i2, align);
129
120
        i0 = pv1[0];
130
121
        i1 = pv1[1];
131
122
        res = vec_msum(t0, i0, res);
132
123
        res = vec_msum(t1, i1, res);
133
 
        t0 = vec_perm(i3, pv3[1], align);
134
 
        i3 = pv3[2];
135
 
        t1 = vec_perm(pv3[1], i3, align);
 
124
        i4 = vec_ld(16, v3);
 
125
        t0 = vec_perm(i3, i4, align);
 
126
        i3 = vec_ld(32, v3);
 
127
        t1 = vec_perm(i4, i3, align);
136
128
        pv1[0] = vec_mladd(t0, muls, i0);
137
129
        pv1[1] = vec_mladd(t1, muls, i1);
138
130
        pv1 += 2;
139
 
        pv2 += 2;
140
 
        pv3 += 2;
 
131
        v2  += 8;
 
132
        v3  += 8;
141
133
    } while(--order);
142
134
    res = vec_splat(vec_sums(res, zero_s32v), 3);
143
135
    vec_ste(res, 0, &ires);
144
136
    return ires;
145
137
}
146
138
 
147
 
void int_init_altivec(DSPContext* c, AVCodecContext *avctx)
 
139
void ff_int_init_altivec(DSPContext* c, AVCodecContext *avctx)
148
140
{
149
141
    c->ssd_int8_vs_int16 = ssd_int8_vs_int16_altivec;
150
142
    c->scalarproduct_int16 = scalarproduct_int16_altivec;