annotate libswscale/ppc/swscale_altivec_template.c @ 31633:3af732078f52

Reindent.
author reimar
date Sun, 11 Jul 2010 09:47:47 +0000
parents 4d50825554ee
children b90559772910
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
1 /*
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
2 * AltiVec-enhanced yuv2yuvX
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
3 *
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
4 * Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
5 * based on the equivalent C code in swscale.c
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
6 *
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
7 * This file is part of FFmpeg.
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
8 *
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
9 * FFmpeg is free software; you can redistribute it and/or
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
10 * modify it under the terms of the GNU Lesser General Public
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
11 * License as published by the Free Software Foundation; either
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
12 * version 2.1 of the License, or (at your option) any later version.
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
13 *
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
14 * FFmpeg is distributed in the hope that it will be useful,
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
17 * Lesser General Public License for more details.
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
18 *
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
20 * License along with FFmpeg; if not, write to the Free Software
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
22 */
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
23
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
24 #define vzero vec_splat_s32(0)
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
25
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
26 static inline void
29481
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
27 altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW)
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
28 {
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
29 register int i;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
30 vector unsigned int altivec_vectorShiftInt19 =
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
31 vec_add(vec_splat_u32(10), vec_splat_u32(9));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
32 if ((unsigned long)dest % 16) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
33 /* badly aligned store, we force store alignment */
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
34 /* and will handle load misalignment on val w/ vec_perm */
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
35 vector unsigned char perm1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
36 vector signed int v1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
37 for (i = 0 ; (i < dstW) &&
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
38 (((unsigned long)dest + i) % 16) ; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
39 int t = val[i] >> 19;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
40 dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
41 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
42 perm1 = vec_lvsl(i << 2, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
43 v1 = vec_ld(i << 2, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
44 for ( ; i < (dstW - 15); i+=16) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
45 int offset = i << 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
46 vector signed int v2 = vec_ld(offset + 16, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
47 vector signed int v3 = vec_ld(offset + 32, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
48 vector signed int v4 = vec_ld(offset + 48, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
49 vector signed int v5 = vec_ld(offset + 64, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
50 vector signed int v12 = vec_perm(v1, v2, perm1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
51 vector signed int v23 = vec_perm(v2, v3, perm1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
52 vector signed int v34 = vec_perm(v3, v4, perm1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
53 vector signed int v45 = vec_perm(v4, v5, perm1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
54
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
55 vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
56 vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
57 vector signed int vC = vec_sra(v34, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
58 vector signed int vD = vec_sra(v45, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
59 vector unsigned short vs1 = vec_packsu(vA, vB);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
60 vector unsigned short vs2 = vec_packsu(vC, vD);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
61 vector unsigned char vf = vec_packsu(vs1, vs2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
62 vec_st(vf, i, dest);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
63 v1 = v5;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
64 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
65 } else { // dest is properly aligned, great
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
66 for (i = 0; i < (dstW - 15); i+=16) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
67 int offset = i << 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
68 vector signed int v1 = vec_ld(offset, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
69 vector signed int v2 = vec_ld(offset + 16, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
70 vector signed int v3 = vec_ld(offset + 32, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
71 vector signed int v4 = vec_ld(offset + 48, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
72 vector signed int v5 = vec_sra(v1, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
73 vector signed int v6 = vec_sra(v2, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
74 vector signed int v7 = vec_sra(v3, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
75 vector signed int v8 = vec_sra(v4, altivec_vectorShiftInt19);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
76 vector unsigned short vs1 = vec_packsu(v5, v6);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
77 vector unsigned short vs2 = vec_packsu(v7, v8);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
78 vector unsigned char vf = vec_packsu(vs1, vs2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
79 vec_st(vf, i, dest);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
80 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
81 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
82 for ( ; i < dstW ; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
83 int t = val[i] >> 19;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
84 dest[i] = (t < 0) ? 0 : ((t > 255) ? 255 : t);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
85 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
86 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
87
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
88 static inline void
29239
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
89 yuv2yuvX_altivec_real(const int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
90 const int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
91 uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
92 {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
93 const vector signed int vini = {(1 << 18), (1 << 18), (1 << 18), (1 << 18)};
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
94 register int i, j;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
95 {
30343
4d50825554ee Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents: 29481
diff changeset
96 DECLARE_ALIGNED(16, int, val)[dstW];
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
97
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
98 for (i = 0; i < (dstW -7); i+=4) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
99 vec_st(vini, i << 2, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
100 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
101 for (; i < dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
102 val[i] = (1 << 18);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
103 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
104
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
105 for (j = 0; j < lumFilterSize; j++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
106 vector signed short l1, vLumFilter = vec_ld(j << 1, lumFilter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
107 vector unsigned char perm, perm0 = vec_lvsl(j << 1, lumFilter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
108 vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
109 vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
110
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
111 perm = vec_lvsl(0, lumSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
112 l1 = vec_ld(0, lumSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
113
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
114 for (i = 0; i < (dstW - 7); i+=8) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
115 int offset = i << 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
116 vector signed short l2 = vec_ld((i << 1) + 16, lumSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
117
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
118 vector signed int v1 = vec_ld(offset, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
119 vector signed int v2 = vec_ld(offset + 16, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
120
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
121 vector signed short ls = vec_perm(l1, l2, perm); // lumSrc[j][i] ... lumSrc[j][i+7]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
122
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
123 vector signed int i1 = vec_mule(vLumFilter, ls);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
124 vector signed int i2 = vec_mulo(vLumFilter, ls);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
125
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
126 vector signed int vf1 = vec_mergeh(i1, i2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
127 vector signed int vf2 = vec_mergel(i1, i2); // lumSrc[j][i] * lumFilter[j] ... lumSrc[j][i+7] * lumFilter[j]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
128
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
129 vector signed int vo1 = vec_add(v1, vf1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
130 vector signed int vo2 = vec_add(v2, vf2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
131
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
132 vec_st(vo1, offset, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
133 vec_st(vo2, offset + 16, val);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
134
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
135 l1 = l2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
136 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
137 for ( ; i < dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
138 val[i] += lumSrc[j][i] * lumFilter[j];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
139 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
140 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
141 altivec_packIntArrayToCharArray(val, dest, dstW);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
142 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
143 if (uDest != 0) {
30343
4d50825554ee Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents: 29481
diff changeset
144 DECLARE_ALIGNED(16, int, u)[chrDstW];
4d50825554ee Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents: 29481
diff changeset
145 DECLARE_ALIGNED(16, int, v)[chrDstW];
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
146
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
147 for (i = 0; i < (chrDstW -7); i+=4) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
148 vec_st(vini, i << 2, u);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
149 vec_st(vini, i << 2, v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
150 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
151 for (; i < chrDstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
152 u[i] = (1 << 18);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
153 v[i] = (1 << 18);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
154 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
155
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
156 for (j = 0; j < chrFilterSize; j++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
157 vector signed short l1, l1_V, vChrFilter = vec_ld(j << 1, chrFilter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
158 vector unsigned char perm, perm0 = vec_lvsl(j << 1, chrFilter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
159 vChrFilter = vec_perm(vChrFilter, vChrFilter, perm0);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
160 vChrFilter = vec_splat(vChrFilter, 0); // chrFilter[j] is loaded 8 times in vChrFilter
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
161
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
162 perm = vec_lvsl(0, chrSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
163 l1 = vec_ld(0, chrSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
164 l1_V = vec_ld(2048 << 1, chrSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
165
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
166 for (i = 0; i < (chrDstW - 7); i+=8) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
167 int offset = i << 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
168 vector signed short l2 = vec_ld((i << 1) + 16, chrSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
169 vector signed short l2_V = vec_ld(((i + 2048) << 1) + 16, chrSrc[j]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
170
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
171 vector signed int v1 = vec_ld(offset, u);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
172 vector signed int v2 = vec_ld(offset + 16, u);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
173 vector signed int v1_V = vec_ld(offset, v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
174 vector signed int v2_V = vec_ld(offset + 16, v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
175
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
176 vector signed short ls = vec_perm(l1, l2, perm); // chrSrc[j][i] ... chrSrc[j][i+7]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
177 vector signed short ls_V = vec_perm(l1_V, l2_V, perm); // chrSrc[j][i+2048] ... chrSrc[j][i+2055]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
178
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
179 vector signed int i1 = vec_mule(vChrFilter, ls);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
180 vector signed int i2 = vec_mulo(vChrFilter, ls);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
181 vector signed int i1_V = vec_mule(vChrFilter, ls_V);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
182 vector signed int i2_V = vec_mulo(vChrFilter, ls_V);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
183
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
184 vector signed int vf1 = vec_mergeh(i1, i2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
185 vector signed int vf2 = vec_mergel(i1, i2); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
186 vector signed int vf1_V = vec_mergeh(i1_V, i2_V);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
187 vector signed int vf2_V = vec_mergel(i1_V, i2_V); // chrSrc[j][i] * chrFilter[j] ... chrSrc[j][i+7] * chrFilter[j]
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
188
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
189 vector signed int vo1 = vec_add(v1, vf1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
190 vector signed int vo2 = vec_add(v2, vf2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
191 vector signed int vo1_V = vec_add(v1_V, vf1_V);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
192 vector signed int vo2_V = vec_add(v2_V, vf2_V);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
193
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
194 vec_st(vo1, offset, u);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
195 vec_st(vo2, offset + 16, u);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
196 vec_st(vo1_V, offset, v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
197 vec_st(vo2_V, offset + 16, v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
198
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
199 l1 = l2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
200 l1_V = l2_V;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
201 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
202 for ( ; i < chrDstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
203 u[i] += chrSrc[j][i] * chrFilter[j];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
204 v[i] += chrSrc[j][i + 2048] * chrFilter[j];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
205 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
206 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
207 altivec_packIntArrayToCharArray(u, uDest, chrDstW);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
208 altivec_packIntArrayToCharArray(v, vDest, chrDstW);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
209 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
210 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
211
29239
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
212 static inline void hScale_altivec_real(int16_t *dst, int dstW,
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
213 const uint8_t *src, int srcW,
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
214 int xInc, const int16_t *filter,
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
215 const int16_t *filterPos, int filterSize)
882a1f5613e1 Add missing const qualifiers to AltiVec function parameters where appropriate.
diego
parents: 29060
diff changeset
216 {
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
217 register int i;
30343
4d50825554ee Move array specifiers outside DECLARE_ALIGNED() invocations
mru
parents: 29481
diff changeset
218 DECLARE_ALIGNED(16, int, tempo)[4];
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
219
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
220 if (filterSize % 4) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
221 for (i=0; i<dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
222 register int j;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
223 register int srcPos = filterPos[i];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
224 register int val = 0;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
225 for (j=0; j<filterSize; j++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
226 val += ((int)src[srcPos + j])*filter[filterSize*i + j];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
227 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
228 dst[i] = FFMIN(val>>7, (1<<15)-1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
229 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
230 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
231 else
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
232 switch (filterSize) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
233 case 4:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
234 {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
235 for (i=0; i<dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
236 register int srcPos = filterPos[i];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
237
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
238 vector unsigned char src_v0 = vec_ld(srcPos, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
239 vector unsigned char src_v1, src_vF;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
240 vector signed short src_v, filter_v;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
241 vector signed int val_vEven, val_s;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
242 if ((((int)src + srcPos)% 16) > 12) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
243 src_v1 = vec_ld(srcPos + 16, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
244 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
245 src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
246
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
247 src_v = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
248 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
249 // now put our elements in the even slots
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
250 src_v = vec_mergeh(src_v, (vector signed short)vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
251
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
252 filter_v = vec_ld(i << 3, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
253 // The 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2).
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
254
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
255 // The neat trick: We only care for half the elements,
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
256 // high or low depending on (i<<3)%16 (it's 0 or 8 here),
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
257 // and we're going to use vec_mule, so we choose
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
258 // carefully how to "unpack" the elements into the even slots.
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
259 if ((i << 3) % 16)
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
260 filter_v = vec_mergel(filter_v, (vector signed short)vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
261 else
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
262 filter_v = vec_mergeh(filter_v, (vector signed short)vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
263
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
264 val_vEven = vec_mule(src_v, filter_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
265 val_s = vec_sums(val_vEven, vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
266 vec_st(val_s, 0, tempo);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
267 dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
268 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
269 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
270 break;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
271
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
272 case 8:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
273 {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
274 for (i=0; i<dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
275 register int srcPos = filterPos[i];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
276
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
277 vector unsigned char src_v0 = vec_ld(srcPos, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
278 vector unsigned char src_v1, src_vF;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
279 vector signed short src_v, filter_v;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
280 vector signed int val_v, val_s;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
281 if ((((int)src + srcPos)% 16) > 8) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
282 src_v1 = vec_ld(srcPos + 16, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
283 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
284 src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
285
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
286 src_v = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
287 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
288 filter_v = vec_ld(i << 4, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
289 // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2)
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
290
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
291 val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
292 val_s = vec_sums(val_v, vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
293 vec_st(val_s, 0, tempo);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
294 dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
295 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
296 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
297 break;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
298
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
299 case 16:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
300 {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
301 for (i=0; i<dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
302 register int srcPos = filterPos[i];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
303
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
304 vector unsigned char src_v0 = vec_ld(srcPos, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
305 vector unsigned char src_v1 = vec_ld(srcPos + 16, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
306 vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
307
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
308 vector signed short src_vA = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
309 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
310 vector signed short src_vB = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
311 (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
312
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
313 vector signed short filter_v0 = vec_ld(i << 5, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
314 vector signed short filter_v1 = vec_ld((i << 5) + 16, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
315 // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2)
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
316
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
317 vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
318 vector signed int val_v = vec_msums(src_vB, filter_v1, val_acc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
319
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
320 vector signed int val_s = vec_sums(val_v, vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
321
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
322 vec_st(val_s, 0, tempo);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
323 dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
324 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
325 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
326 break;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
327
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
328 default:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
329 {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
330 for (i=0; i<dstW; i++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
331 register int j;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
332 register int srcPos = filterPos[i];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
333
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
334 vector signed int val_s, val_v = (vector signed int)vzero;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
335 vector signed short filter_v0R = vec_ld(i * 2 * filterSize, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
336 vector unsigned char permF = vec_lvsl((i * 2 * filterSize), filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
337
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
338 vector unsigned char src_v0 = vec_ld(srcPos, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
339 vector unsigned char permS = vec_lvsl(srcPos, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
340
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
341 for (j = 0 ; j < filterSize - 15; j += 16) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
342 vector unsigned char src_v1 = vec_ld(srcPos + j + 16, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
343 vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
344
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
345 vector signed short src_vA = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
346 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
347 vector signed short src_vB = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
348 (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
349
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
350 vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
351 vector signed short filter_v2R = vec_ld((i * 2 * filterSize) + (j * 2) + 32, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
352 vector signed short filter_v0 = vec_perm(filter_v0R, filter_v1R, permF);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
353 vector signed short filter_v1 = vec_perm(filter_v1R, filter_v2R, permF);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
354
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
355 vector signed int val_acc = vec_msums(src_vA, filter_v0, val_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
356 val_v = vec_msums(src_vB, filter_v1, val_acc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
357
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
358 filter_v0R = filter_v2R;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
359 src_v0 = src_v1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
360 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
361
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
362 if (j < filterSize-7) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
363 // loading src_v0 is useless, it's already done above
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
364 //vector unsigned char src_v0 = vec_ld(srcPos + j, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
365 vector unsigned char src_v1, src_vF;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
366 vector signed short src_v, filter_v1R, filter_v;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
367 if ((((int)src + srcPos)% 16) > 8) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
368 src_v1 = vec_ld(srcPos + j + 16, src);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
369 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
370 src_vF = vec_perm(src_v0, src_v1, permS);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
371
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
372 src_v = // vec_unpackh sign-extends...
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
373 (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
374 // loading filter_v0R is useless, it's already done above
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
375 //vector signed short filter_v0R = vec_ld((i * 2 * filterSize) + j, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
376 filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
377 filter_v = vec_perm(filter_v0R, filter_v1R, permF);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
378
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
379 val_v = vec_msums(src_v, filter_v, val_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
380 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
381
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
382 val_s = vec_sums(val_v, vzero);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
383
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
384 vec_st(val_s, 0, tempo);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
385 dst[i] = FFMIN(tempo[3]>>7, (1<<15)-1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
386 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
387
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
388 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
389 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
390 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
391
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
392 static inline int yv12toyuy2_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
29481
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
393 int srcSliceH, uint8_t* dstParam[], int dstStride_a[])
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
394 {
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
395 uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
396 // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
397 uint8_t *ysrc = src[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
398 uint8_t *usrc = src[1];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
399 uint8_t *vsrc = src[2];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
400 const int width = c->srcW;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
401 const int height = srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
402 const int lumStride = srcStride[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
403 const int chromStride = srcStride[1];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
404 const int dstStride = dstStride_a[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
405 const vector unsigned char yperm = vec_lvsl(0, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
406 const int vertLumPerChroma = 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
407 register unsigned int y;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
408
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
409 if (width&15) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
410 yv12toyuy2(ysrc, usrc, vsrc, dst, c->srcW, srcSliceH, lumStride, chromStride, dstStride);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
411 return srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
412 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
413
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
414 /* This code assumes:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
415
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
416 1) dst is 16 bytes-aligned
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
417 2) dstStride is a multiple of 16
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
418 3) width is a multiple of 16
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
419 4) lum & chrom stride are multiples of 8
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
420 */
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
421
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
422 for (y=0; y<height; y++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
423 int i;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
424 for (i = 0; i < width - 31; i+= 32) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
425 const unsigned int j = i >> 1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
426 vector unsigned char v_yA = vec_ld(i, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
427 vector unsigned char v_yB = vec_ld(i + 16, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
428 vector unsigned char v_yC = vec_ld(i + 32, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
429 vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
430 vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
431 vector unsigned char v_uA = vec_ld(j, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
432 vector unsigned char v_uB = vec_ld(j + 16, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
433 vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
434 vector unsigned char v_vA = vec_ld(j, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
435 vector unsigned char v_vB = vec_ld(j + 16, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
436 vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
437 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
438 vector unsigned char v_uv_b = vec_mergel(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
439 vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
440 vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
441 vector unsigned char v_yuy2_2 = vec_mergeh(v_y2, v_uv_b);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
442 vector unsigned char v_yuy2_3 = vec_mergel(v_y2, v_uv_b);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
443 vec_st(v_yuy2_0, (i << 1), dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
444 vec_st(v_yuy2_1, (i << 1) + 16, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
445 vec_st(v_yuy2_2, (i << 1) + 32, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
446 vec_st(v_yuy2_3, (i << 1) + 48, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
447 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
448 if (i < width) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
449 const unsigned int j = i >> 1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
450 vector unsigned char v_y1 = vec_ld(i, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
451 vector unsigned char v_u = vec_ld(j, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
452 vector unsigned char v_v = vec_ld(j, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
453 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
454 vector unsigned char v_yuy2_0 = vec_mergeh(v_y1, v_uv_a);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
455 vector unsigned char v_yuy2_1 = vec_mergel(v_y1, v_uv_a);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
456 vec_st(v_yuy2_0, (i << 1), dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
457 vec_st(v_yuy2_1, (i << 1) + 16, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
458 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
459 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
460 usrc += chromStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
461 vsrc += chromStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
462 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
463 ysrc += lumStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
464 dst += dstStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
465 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
466
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
467 return srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
468 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
469
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
470 static inline int yv12touyvy_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
29481
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
471 int srcSliceH, uint8_t* dstParam[], int dstStride_a[])
c080f1f5c07e Cosmetics:
ramiro
parents: 29308
diff changeset
472 {
29060
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
473 uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
474 // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
475 uint8_t *ysrc = src[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
476 uint8_t *usrc = src[1];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
477 uint8_t *vsrc = src[2];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
478 const int width = c->srcW;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
479 const int height = srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
480 const int lumStride = srcStride[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
481 const int chromStride = srcStride[1];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
482 const int dstStride = dstStride_a[0];
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
483 const int vertLumPerChroma = 2;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
484 const vector unsigned char yperm = vec_lvsl(0, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
485 register unsigned int y;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
486
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
487 if (width&15) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
488 yv12touyvy(ysrc, usrc, vsrc, dst, c->srcW, srcSliceH, lumStride, chromStride, dstStride);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
489 return srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
490 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
491
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
492 /* This code assumes:
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
493
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
494 1) dst is 16 bytes-aligned
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
495 2) dstStride is a multiple of 16
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
496 3) width is a multiple of 16
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
497 4) lum & chrom stride are multiples of 8
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
498 */
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
499
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
500 for (y=0; y<height; y++) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
501 int i;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
502 for (i = 0; i < width - 31; i+= 32) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
503 const unsigned int j = i >> 1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
504 vector unsigned char v_yA = vec_ld(i, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
505 vector unsigned char v_yB = vec_ld(i + 16, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
506 vector unsigned char v_yC = vec_ld(i + 32, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
507 vector unsigned char v_y1 = vec_perm(v_yA, v_yB, yperm);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
508 vector unsigned char v_y2 = vec_perm(v_yB, v_yC, yperm);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
509 vector unsigned char v_uA = vec_ld(j, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
510 vector unsigned char v_uB = vec_ld(j + 16, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
511 vector unsigned char v_u = vec_perm(v_uA, v_uB, vec_lvsl(j, usrc));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
512 vector unsigned char v_vA = vec_ld(j, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
513 vector unsigned char v_vB = vec_ld(j + 16, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
514 vector unsigned char v_v = vec_perm(v_vA, v_vB, vec_lvsl(j, vsrc));
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
515 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
516 vector unsigned char v_uv_b = vec_mergel(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
517 vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
518 vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
519 vector unsigned char v_uyvy_2 = vec_mergeh(v_uv_b, v_y2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
520 vector unsigned char v_uyvy_3 = vec_mergel(v_uv_b, v_y2);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
521 vec_st(v_uyvy_0, (i << 1), dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
522 vec_st(v_uyvy_1, (i << 1) + 16, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
523 vec_st(v_uyvy_2, (i << 1) + 32, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
524 vec_st(v_uyvy_3, (i << 1) + 48, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
525 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
526 if (i < width) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
527 const unsigned int j = i >> 1;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
528 vector unsigned char v_y1 = vec_ld(i, ysrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
529 vector unsigned char v_u = vec_ld(j, usrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
530 vector unsigned char v_v = vec_ld(j, vsrc);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
531 vector unsigned char v_uv_a = vec_mergeh(v_u, v_v);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
532 vector unsigned char v_uyvy_0 = vec_mergeh(v_uv_a, v_y1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
533 vector unsigned char v_uyvy_1 = vec_mergel(v_uv_a, v_y1);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
534 vec_st(v_uyvy_0, (i << 1), dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
535 vec_st(v_uyvy_1, (i << 1) + 16, dst);
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
536 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
537 if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
538 usrc += chromStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
539 vsrc += chromStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
540 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
541 ysrc += lumStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
542 dst += dstStride;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
543 }
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
544 return srcSliceH;
e7f277bf38b5 Move swscale AltiVec template code to ppc subdirectory.
diego
parents:
diff changeset
545 }