annotate libpostproc/postprocess_altivec_template.c @ 3198:6b9f0c4fbdbe libavcodec

First part of a series of speed-enchancing patches. This one sets up a snow.h and makes snow use the dsputil function pointer framework to access the three functions that will be implemented in asm in the other parts of the patchset. Patch by Robert Edele < yartrebo AH earthlink POIS net> Original thread: Subject: [Ffmpeg-devel] [PATCH] Snow mmx+sse2 asm optimizations Date: Sun, 05 Feb 2006 12:47:14 -0500
author gpoirier
date Thu, 16 Mar 2006 19:18:18 +0000
parents 0b546eab515d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
1 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
2 AltiVec optimizations (C) 2004 Romain Dolbeau <romain@dolbeau.org>
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
3
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
4 based on code by Copyright (C) 2001-2003 Michael Niedermayer (michaelni@gmx.at)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
5
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
9 (at your option) any later version.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
10
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
14 GNU General Public License for more details.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
15
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
17 along with this program; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
19 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
20
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
21
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
22 #ifdef CONFIG_DARWIN
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
23 #define AVV(x...) (x)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
24 #else
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
25 #define AVV(x...) {x}
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
26 #endif
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
27
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
28 #define ALTIVEC_TRANSPOSE_8x8_SHORT(src_a,src_b,src_c,src_d,src_e,src_f,src_g,src_h) \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
29 do { \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
30 __typeof__(src_a) tempA1, tempB1, tempC1, tempD1; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
31 __typeof__(src_a) tempE1, tempF1, tempG1, tempH1; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
32 __typeof__(src_a) tempA2, tempB2, tempC2, tempD2; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
33 __typeof__(src_a) tempE2, tempF2, tempG2, tempH2; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
34 tempA1 = vec_mergeh (src_a, src_e); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
35 tempB1 = vec_mergel (src_a, src_e); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
36 tempC1 = vec_mergeh (src_b, src_f); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
37 tempD1 = vec_mergel (src_b, src_f); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
38 tempE1 = vec_mergeh (src_c, src_g); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
39 tempF1 = vec_mergel (src_c, src_g); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
40 tempG1 = vec_mergeh (src_d, src_h); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
41 tempH1 = vec_mergel (src_d, src_h); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
42 tempA2 = vec_mergeh (tempA1, tempE1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
43 tempB2 = vec_mergel (tempA1, tempE1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
44 tempC2 = vec_mergeh (tempB1, tempF1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
45 tempD2 = vec_mergel (tempB1, tempF1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
46 tempE2 = vec_mergeh (tempC1, tempG1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
47 tempF2 = vec_mergel (tempC1, tempG1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
48 tempG2 = vec_mergeh (tempD1, tempH1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
49 tempH2 = vec_mergel (tempD1, tempH1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
50 src_a = vec_mergeh (tempA2, tempE2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
51 src_b = vec_mergel (tempA2, tempE2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
52 src_c = vec_mergeh (tempB2, tempF2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
53 src_d = vec_mergel (tempB2, tempF2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
54 src_e = vec_mergeh (tempC2, tempG2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
55 src_f = vec_mergel (tempC2, tempG2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
56 src_g = vec_mergeh (tempD2, tempH2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
57 src_h = vec_mergel (tempD2, tempH2); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
58 } while (0)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
59
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
60
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
61 static inline int vertClassify_altivec(uint8_t src[], int stride, PPContext *c) {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
62 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
63 this code makes no assumption on src or stride.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
64 One could remove the recomputation of the perm
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
65 vector by assuming (stride % 16) == 0, unfortunately
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
66 this is not always true.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
67 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
68 register int y;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
69 short __attribute__ ((aligned(16))) data[8];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
70 int numEq;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
71 uint8_t *src2 = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
72 vector signed short v_dcOffset;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
73 vector signed short v2QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
74 vector unsigned short v4QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
75 vector unsigned short v_dcThreshold;
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
76 const int properStride = (stride % 16);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
77 const int srcAlign = ((unsigned long)src2 % 16);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
78 const int two_vectors = ((srcAlign > 8) || properStride) ? 1 : 0;
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
79 const vector signed int zero = vec_splat_s32(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
80 const vector signed short mask = vec_splat_s16(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
81 vector signed int v_numEq = vec_splat_s32(0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
82
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
83 data[0] = ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
84 data[1] = data[0] * 2 + 1;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
85 data[2] = c->QP * 2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
86 data[3] = c->QP * 4;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
87 vector signed short v_data = vec_ld(0, data);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
88 v_dcOffset = vec_splat(v_data, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
89 v_dcThreshold = (vector unsigned short)vec_splat(v_data, 1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
90 v2QP = vec_splat(v_data, 2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
91 v4QP = (vector unsigned short)vec_splat(v_data, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
92
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
93 src2 += stride * 4;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
94
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
95 vector signed short v_srcAss0, v_srcAss1, v_srcAss2, v_srcAss3, v_srcAss4, v_srcAss5, v_srcAss6, v_srcAss7;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
96
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
97 #define LOAD_LINE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
98 register int j##i = i * stride; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
99 vector unsigned char perm##i = vec_lvsl(j##i, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
100 const vector unsigned char v_srcA1##i = vec_ld(j##i, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
101 vector unsigned char v_srcA2##i; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
102 if (two_vectors) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
103 v_srcA2##i = vec_ld(j##i + 16, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
104 const vector unsigned char v_srcA##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
105 vec_perm(v_srcA1##i, v_srcA2##i, perm##i); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
106 v_srcAss##i = \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
107 (vector signed short)vec_mergeh((vector signed char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
108 (vector signed char)v_srcA##i)
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
109
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
110 #define LOAD_LINE_ALIGNED(i) \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
111 register int j##i = i * stride; \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
112 const vector unsigned char v_srcA##i = vec_ld(j##i, src2); \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
113 v_srcAss##i = \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
114 (vector signed short)vec_mergeh((vector signed char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
115 (vector signed char)v_srcA##i)
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
116
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
117 // special casing the aligned case is worthwhile, as all call from
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
118 // the (transposed) horizontable deblocks will be aligned, i naddition
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
119 // to the naturraly aligned vertical deblocks.
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
120 if (properStride && srcAlign) {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
121 LOAD_LINE_ALIGNED(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
122 LOAD_LINE_ALIGNED(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
123 LOAD_LINE_ALIGNED(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
124 LOAD_LINE_ALIGNED(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
125 LOAD_LINE_ALIGNED(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
126 LOAD_LINE_ALIGNED(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
127 LOAD_LINE_ALIGNED(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
128 LOAD_LINE_ALIGNED(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
129 } else {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
130 LOAD_LINE(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
131 LOAD_LINE(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
132 LOAD_LINE(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
133 LOAD_LINE(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
134 LOAD_LINE(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
135 LOAD_LINE(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
136 LOAD_LINE(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
137 LOAD_LINE(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
138 }
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
139 #undef LOAD_LINE
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
140 #undef LOAD_LINE_ALIGNED
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
141
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
142 #define ITER(i, j) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
143 const vector signed short v_diff##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
144 vec_sub(v_srcAss##i, v_srcAss##j); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
145 const vector signed short v_sum##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
146 vec_add(v_diff##i, v_dcOffset); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
147 const vector signed short v_comp##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
148 (vector signed short)vec_cmplt((vector unsigned short)v_sum##i, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
149 v_dcThreshold); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
150 const vector signed short v_part##i = vec_and(mask, v_comp##i); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
151 v_numEq = vec_sum4s(v_part##i, v_numEq);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
152
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
153 ITER(0, 1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
154 ITER(1, 2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
155 ITER(2, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
156 ITER(3, 4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
157 ITER(4, 5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
158 ITER(5, 6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
159 ITER(6, 7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
160 #undef ITER
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
161
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
162 v_numEq = vec_sums(v_numEq, zero);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
163
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
164 v_numEq = vec_splat(v_numEq, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
165 vec_ste(v_numEq, 0, &numEq);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
166
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
167 if (numEq > c->ppMode.flatnessThreshold)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
168 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
169 const vector unsigned char mmoP1 = (const vector unsigned char)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
170 AVV(0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
171 0x00, 0x01, 0x12, 0x13, 0x08, 0x09, 0x1A, 0x1B);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
172 const vector unsigned char mmoP2 = (const vector unsigned char)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
173 AVV(0x04, 0x05, 0x16, 0x17, 0x0C, 0x0D, 0x1E, 0x1F,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
174 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
175 const vector unsigned char mmoP = (const vector unsigned char)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
176 vec_lvsl(8, (unsigned char*)0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
177
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
178 vector signed short mmoL1 = vec_perm(v_srcAss0, v_srcAss2, mmoP1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
179 vector signed short mmoL2 = vec_perm(v_srcAss4, v_srcAss6, mmoP2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
180 vector signed short mmoL = vec_perm(mmoL1, mmoL2, mmoP);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
181 vector signed short mmoR1 = vec_perm(v_srcAss5, v_srcAss7, mmoP1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
182 vector signed short mmoR2 = vec_perm(v_srcAss1, v_srcAss3, mmoP2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
183 vector signed short mmoR = vec_perm(mmoR1, mmoR2, mmoP);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
184 vector signed short mmoDiff = vec_sub(mmoL, mmoR);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
185 vector unsigned short mmoSum = (vector unsigned short)vec_add(mmoDiff, v2QP);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
186
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
187 if (vec_any_gt(mmoSum, v4QP))
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
188 return 0;
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
189 else
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
190 return 1;
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
191 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
192 else return 2;
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
193 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
194
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
195 static inline void doVertLowPass_altivec(uint8_t *src, int stride, PPContext *c) {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
196 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
197 this code makes no assumption on src or stride.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
198 One could remove the recomputation of the perm
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
199 vector by assuming (stride % 16) == 0, unfortunately
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
200 this is not always true. Quite a lot of load/stores
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
201 can be removed by assuming proper alignement of
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
202 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
203 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
204 uint8_t *src2 = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
205 const vector signed int zero = vec_splat_s32(0);
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
206 const int properStride = (stride % 16);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
207 const int srcAlign = ((unsigned long)src2 % 16);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
208 short __attribute__ ((aligned(16))) qp[8];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
209 qp[0] = c->QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
210 vector signed short vqp = vec_ld(0, qp);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
211 vqp = vec_splat(vqp, 0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
212
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
213 src2 += stride*3;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
214
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
215 vector signed short vb0, vb1, vb2, vb3, vb4, vb5, vb6, vb7, vb8, vb9;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
216 vector unsigned char vbA0, vbA1, vbA2, vbA3, vbA4, vbA5, vbA6, vbA7, vbA8, vbA9;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
217 vector unsigned char vbB0, vbB1, vbB2, vbB3, vbB4, vbB5, vbB6, vbB7, vbB8, vbB9;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
218 vector unsigned char vbT0, vbT1, vbT2, vbT3, vbT4, vbT5, vbT6, vbT7, vbT8, vbT9;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
219
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
220 #define LOAD_LINE(i) \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
221 const vector unsigned char perml##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
222 vec_lvsl(i * stride, src2); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
223 vbA##i = vec_ld(i * stride, src2); \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
224 vbB##i = vec_ld(i * stride + 16, src2); \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
225 vbT##i = vec_perm(vbA##i, vbB##i, perml##i); \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
226 vb##i = \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
227 (vector signed short)vec_mergeh((vector unsigned char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
228 (vector unsigned char)vbT##i)
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
229
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
230 #define LOAD_LINE_ALIGNED(i) \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
231 register int j##i = i * stride; \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
232 vbT##i = vec_ld(j##i, src2); \
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
233 vb##i = \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
234 (vector signed short)vec_mergeh((vector signed char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
235 (vector signed char)vbT##i)
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
236
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
237 // special casing the aligned case is worthwhile, as all call from
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
238 // the (transposed) horizontable deblocks will be aligned, in addition
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
239 // to the naturraly aligned vertical deblocks.
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
240 if (properStride && srcAlign) {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
241 LOAD_LINE_ALIGNED(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
242 LOAD_LINE_ALIGNED(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
243 LOAD_LINE_ALIGNED(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
244 LOAD_LINE_ALIGNED(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
245 LOAD_LINE_ALIGNED(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
246 LOAD_LINE_ALIGNED(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
247 LOAD_LINE_ALIGNED(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
248 LOAD_LINE_ALIGNED(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
249 LOAD_LINE_ALIGNED(8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
250 LOAD_LINE_ALIGNED(9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
251 } else {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
252 LOAD_LINE(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
253 LOAD_LINE(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
254 LOAD_LINE(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
255 LOAD_LINE(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
256 LOAD_LINE(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
257 LOAD_LINE(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
258 LOAD_LINE(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
259 LOAD_LINE(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
260 LOAD_LINE(8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
261 LOAD_LINE(9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
262 }
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
263 #undef LOAD_LINE
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
264 #undef LOAD_LINE_ALIGNED
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
265
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
266 const vector unsigned short v_1 = vec_splat_u16(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
267 const vector unsigned short v_2 = vec_splat_u16(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
268 const vector unsigned short v_4 = vec_splat_u16(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
269
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
270 const vector signed short v_diff01 = vec_sub(vb0, vb1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
271 const vector unsigned short v_cmp01 =
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
272 (const vector unsigned short) vec_cmplt(vec_abs(v_diff01), vqp);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
273 const vector signed short v_first = vec_sel(vb1, vb0, v_cmp01);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
274 const vector signed short v_diff89 = vec_sub(vb8, vb9);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
275 const vector unsigned short v_cmp89 =
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
276 (const vector unsigned short) vec_cmplt(vec_abs(v_diff89), vqp);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
277 const vector signed short v_last = vec_sel(vb8, vb9, v_cmp89);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
278
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
279 const vector signed short temp01 = vec_mladd(v_first, (vector signed short)v_4, vb1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
280 const vector signed short temp02 = vec_add(vb2, vb3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
281 const vector signed short temp03 = vec_add(temp01, (vector signed short)v_4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
282 const vector signed short v_sumsB0 = vec_add(temp02, temp03);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
283
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
284 const vector signed short temp11 = vec_sub(v_sumsB0, v_first);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
285 const vector signed short v_sumsB1 = vec_add(temp11, vb4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
286
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
287 const vector signed short temp21 = vec_sub(v_sumsB1, v_first);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
288 const vector signed short v_sumsB2 = vec_add(temp21, vb5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
289
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
290 const vector signed short temp31 = vec_sub(v_sumsB2, v_first);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
291 const vector signed short v_sumsB3 = vec_add(temp31, vb6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
292
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
293 const vector signed short temp41 = vec_sub(v_sumsB3, v_first);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
294 const vector signed short v_sumsB4 = vec_add(temp41, vb7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
295
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
296 const vector signed short temp51 = vec_sub(v_sumsB4, vb1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
297 const vector signed short v_sumsB5 = vec_add(temp51, vb8);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
298
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
299 const vector signed short temp61 = vec_sub(v_sumsB5, vb2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
300 const vector signed short v_sumsB6 = vec_add(temp61, v_last);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
301
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
302 const vector signed short temp71 = vec_sub(v_sumsB6, vb3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
303 const vector signed short v_sumsB7 = vec_add(temp71, v_last);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
304
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
305 const vector signed short temp81 = vec_sub(v_sumsB7, vb4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
306 const vector signed short v_sumsB8 = vec_add(temp81, v_last);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
307
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
308 const vector signed short temp91 = vec_sub(v_sumsB8, vb5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
309 const vector signed short v_sumsB9 = vec_add(temp91, v_last);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
310
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
311 #define COMPUTE_VR(i, j, k) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
312 const vector signed short temps1##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
313 vec_add(v_sumsB##i, v_sumsB##k); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
314 const vector signed short temps2##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
315 vec_mladd(vb##j, (vector signed short)v_2, temps1##i); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
316 const vector signed short vr##j = vec_sra(temps2##i, v_4)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
317
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
318 COMPUTE_VR(0, 1, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
319 COMPUTE_VR(1, 2, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
320 COMPUTE_VR(2, 3, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
321 COMPUTE_VR(3, 4, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
322 COMPUTE_VR(4, 5, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
323 COMPUTE_VR(5, 6, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
324 COMPUTE_VR(6, 7, 8);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
325 COMPUTE_VR(7, 8, 9);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
326
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
327 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
328 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
329 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
330
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
331 #define PACK_AND_STORE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
332 const vector unsigned char perms##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
333 vec_lvsr(i * stride, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
334 const vector unsigned char vf##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
335 vec_packsu(vr##i, (vector signed short)zero); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
336 const vector unsigned char vg##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
337 vec_perm(vf##i, vbT##i, permHH); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
338 const vector unsigned char mask##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
339 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
340 const vector unsigned char vg2##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
341 vec_perm(vg##i, vg##i, perms##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
342 const vector unsigned char svA##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
343 vec_sel(vbA##i, vg2##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
344 const vector unsigned char svB##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
345 vec_sel(vg2##i, vbB##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
346 vec_st(svA##i, i * stride, src2); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
347 vec_st(svB##i, i * stride + 16, src2)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
348
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
349 #define PACK_AND_STORE_ALIGNED(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
350 const vector unsigned char vf##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
351 vec_packsu(vr##i, (vector signed short)zero); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
352 const vector unsigned char vg##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
353 vec_perm(vf##i, vbT##i, permHH); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
354 vec_st(vg##i, i * stride, src2)
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
355
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
356 // special casing the aligned case is worthwhile, as all call from
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
357 // the (transposed) horizontable deblocks will be aligned, in addition
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
358 // to the naturraly aligned vertical deblocks.
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
359 if (properStride && srcAlign) {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
360 PACK_AND_STORE_ALIGNED(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
361 PACK_AND_STORE_ALIGNED(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
362 PACK_AND_STORE_ALIGNED(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
363 PACK_AND_STORE_ALIGNED(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
364 PACK_AND_STORE_ALIGNED(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
365 PACK_AND_STORE_ALIGNED(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
366 PACK_AND_STORE_ALIGNED(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
367 PACK_AND_STORE_ALIGNED(8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
368 } else {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
369 PACK_AND_STORE(1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
370 PACK_AND_STORE(2);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
371 PACK_AND_STORE(3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
372 PACK_AND_STORE(4);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
373 PACK_AND_STORE(5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
374 PACK_AND_STORE(6);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
375 PACK_AND_STORE(7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
376 PACK_AND_STORE(8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
377 }
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
378 #undef PACK_AND_STORE
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
379 #undef PACK_AND_STORE_ALIGNED
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
380 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
381
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
382
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
383
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
384 static inline void doVertDefFilter_altivec(uint8_t src[], int stride, PPContext *c) {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
385 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
386 this code makes no assumption on src or stride.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
387 One could remove the recomputation of the perm
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
388 vector by assuming (stride % 16) == 0, unfortunately
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
389 this is not always true. Quite a lot of load/stores
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
390 can be removed by assuming proper alignement of
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
391 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
392 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
393 uint8_t *src2 = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
394 const vector signed int zero = vec_splat_s32(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
395 short __attribute__ ((aligned(16))) qp[8];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
396 qp[0] = 8*c->QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
397 vector signed short vqp = vec_ld(0, qp);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
398 vqp = vec_splat(vqp, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
399
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
400 #define LOAD_LINE(i) \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
401 const vector unsigned char perm##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
402 vec_lvsl(i * stride, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
403 const vector unsigned char vbA##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
404 vec_ld(i * stride, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
405 const vector unsigned char vbB##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
406 vec_ld(i * stride + 16, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
407 const vector unsigned char vbT##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
408 vec_perm(vbA##i, vbB##i, perm##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
409 const vector signed short vb##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
410 (vector signed short)vec_mergeh((vector unsigned char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
411 (vector unsigned char)vbT##i)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
412
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
413 src2 += stride*3;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
414
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
415 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
416 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
417 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
418 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
419 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
420 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
421 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
422 LOAD_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
423 #undef LOAD_LINE
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
424
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
425 const vector signed short v_1 = vec_splat_s16(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
426 const vector signed short v_2 = vec_splat_s16(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
427 const vector signed short v_5 = vec_splat_s16(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
428 const vector signed short v_32 = vec_sl(v_1,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
429 (vector unsigned short)v_5);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
430 /* middle energy */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
431 const vector signed short l3minusl6 = vec_sub(vb3, vb6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
432 const vector signed short l5minusl4 = vec_sub(vb5, vb4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
433 const vector signed short twotimes_l3minusl6 = vec_mladd(v_2, l3minusl6, (vector signed short)zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
434 const vector signed short mE = vec_mladd(v_5, l5minusl4, twotimes_l3minusl6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
435 const vector signed short absmE = vec_abs(mE);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
436 /* left & right energy */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
437 const vector signed short l1minusl4 = vec_sub(vb1, vb4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
438 const vector signed short l3minusl2 = vec_sub(vb3, vb2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
439 const vector signed short l5minusl8 = vec_sub(vb5, vb8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
440 const vector signed short l7minusl6 = vec_sub(vb7, vb6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
441 const vector signed short twotimes_l1minusl4 = vec_mladd(v_2, l1minusl4, (vector signed short)zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
442 const vector signed short twotimes_l5minusl8 = vec_mladd(v_2, l5minusl8, (vector signed short)zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
443 const vector signed short lE = vec_mladd(v_5, l3minusl2, twotimes_l1minusl4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
444 const vector signed short rE = vec_mladd(v_5, l7minusl6, twotimes_l5minusl8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
445 /* d */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
446 const vector signed short ddiff = vec_sub(absmE,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
447 vec_min(vec_abs(lE),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
448 vec_abs(rE)));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
449 const vector signed short ddiffclamp = vec_max(ddiff, (vector signed short)zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
450 const vector signed short dtimes64 = vec_mladd(v_5, ddiffclamp, v_32);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
451 const vector signed short d = vec_sra(dtimes64, vec_splat_u16(6));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
452 const vector signed short minusd = vec_sub((vector signed short)zero, d);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
453 const vector signed short finald = vec_sel(minusd,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
454 d,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
455 vec_cmpgt(vec_sub((vector signed short)zero, mE),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
456 (vector signed short)zero));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
457 /* q */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
458 const vector signed short qtimes2 = vec_sub(vb4, vb5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
459 /* for a shift right to behave like /2, we need to add one
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
460 to all negative integer */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
461 const vector signed short rounddown = vec_sel((vector signed short)zero,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
462 v_1,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
463 vec_cmplt(qtimes2, (vector signed short)zero));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
464 const vector signed short q = vec_sra(vec_add(qtimes2, rounddown), vec_splat_u16(1));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
465 /* clamp */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
466 const vector signed short dclamp_P1 = vec_max((vector signed short)zero, finald);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
467 const vector signed short dclamp_P = vec_min(dclamp_P1, q);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
468 const vector signed short dclamp_N1 = vec_min((vector signed short)zero, finald);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
469 const vector signed short dclamp_N = vec_max(dclamp_N1, q);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
470
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
471 const vector signed short dclampedfinal = vec_sel(dclamp_N,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
472 dclamp_P,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
473 vec_cmpgt(q, (vector signed short)zero));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
474 const vector signed short dornotd = vec_sel((vector signed short)zero,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
475 dclampedfinal,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
476 vec_cmplt(absmE, vqp));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
477 /* add/substract to l4 and l5 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
478 const vector signed short vb4minusd = vec_sub(vb4, dornotd);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
479 const vector signed short vb5plusd = vec_add(vb5, dornotd);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
480 /* finally, stores */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
481 const vector unsigned char st4 = vec_packsu(vb4minusd, (vector signed short)zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
482 const vector unsigned char st5 = vec_packsu(vb5plusd, (vector signed short)zero);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
483
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
484 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
485 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
486 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
487
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
488 #define STORE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
489 const vector unsigned char perms##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
490 vec_lvsr(i * stride, src2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
491 const vector unsigned char vg##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
492 vec_perm(st##i, vbT##i, permHH); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
493 const vector unsigned char mask##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
494 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
495 const vector unsigned char vg2##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
496 vec_perm(vg##i, vg##i, perms##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
497 const vector unsigned char svA##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
498 vec_sel(vbA##i, vg2##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
499 const vector unsigned char svB##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
500 vec_sel(vg2##i, vbB##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
501 vec_st(svA##i, i * stride, src2); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
502 vec_st(svB##i, i * stride + 16, src2)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
503
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
504 STORE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
505 STORE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
506 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
507
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
508 static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
509 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
510 this code makes no assumption on src or stride.
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
511 One could remove the recomputation of the perm
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
512 vector by assuming (stride % 16) == 0, unfortunately
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
513 this is not always true. Quite a lot of load/stores
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
514 can be removed by assuming proper alignement of
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
515 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
516 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
517 uint8_t *srcCopy = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
518 uint8_t __attribute__((aligned(16))) dt[16];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
519 const vector unsigned char vuint8_1 = vec_splat_u8(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
520 const vector signed int zero = vec_splat_s32(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
521 vector unsigned char v_dt;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
522 dt[0] = deringThreshold;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
523 v_dt = vec_splat(vec_ld(0, dt), 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
524
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
525 #define LOAD_LINE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
526 const vector unsigned char perm##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
527 vec_lvsl(i * stride, srcCopy); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
528 vector unsigned char sA##i = vec_ld(i * stride, srcCopy); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
529 vector unsigned char sB##i = vec_ld(i * stride + 16, srcCopy); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
530 vector unsigned char src##i = vec_perm(sA##i, sB##i, perm##i)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
531
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
532 LOAD_LINE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
533 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
534 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
535 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
536 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
537 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
538 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
539 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
540 LOAD_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
541 LOAD_LINE(9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
542 #undef LOAD_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
543
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
544 vector unsigned char v_avg;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
545 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
546 const vector unsigned char trunc_perm = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
547 AVV(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
548 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
549 const vector unsigned char trunc_src12 = vec_perm(src1, src2, trunc_perm);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
550 const vector unsigned char trunc_src34 = vec_perm(src3, src4, trunc_perm);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
551 const vector unsigned char trunc_src56 = vec_perm(src5, src6, trunc_perm);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
552 const vector unsigned char trunc_src78 = vec_perm(src7, src8, trunc_perm);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
553
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
554 #define EXTRACT(op) do { \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
555 const vector unsigned char s##op##_1 = vec_##op(trunc_src12, trunc_src34); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
556 const vector unsigned char s##op##_2 = vec_##op(trunc_src56, trunc_src78); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
557 const vector unsigned char s##op##_6 = vec_##op(s##op##_1, s##op##_2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
558 const vector unsigned char s##op##_8h = vec_mergeh(s##op##_6, s##op##_6); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
559 const vector unsigned char s##op##_8l = vec_mergel(s##op##_6, s##op##_6); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
560 const vector unsigned char s##op##_9 = vec_##op(s##op##_8h, s##op##_8l); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
561 const vector unsigned char s##op##_9h = vec_mergeh(s##op##_9, s##op##_9); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
562 const vector unsigned char s##op##_9l = vec_mergel(s##op##_9, s##op##_9); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
563 const vector unsigned char s##op##_10 = vec_##op(s##op##_9h, s##op##_9l); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
564 const vector unsigned char s##op##_10h = vec_mergeh(s##op##_10, s##op##_10); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
565 const vector unsigned char s##op##_10l = vec_mergel(s##op##_10, s##op##_10); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
566 const vector unsigned char s##op##_11 = vec_##op(s##op##_10h, s##op##_10l); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
567 const vector unsigned char s##op##_11h = vec_mergeh(s##op##_11, s##op##_11); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
568 const vector unsigned char s##op##_11l = vec_mergel(s##op##_11, s##op##_11); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
569 v_##op = vec_##op(s##op##_11h, s##op##_11l); } while (0)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
570
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
571 vector unsigned char v_min;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
572 vector unsigned char v_max;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
573 EXTRACT(min);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
574 EXTRACT(max);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
575 #undef EXTRACT
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
576
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
577 if (vec_all_lt(vec_sub(v_max, v_min), v_dt))
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
578 return;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
579
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
580 v_avg = vec_avg(v_min, v_max);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
581 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
582
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
583 signed int __attribute__((aligned(16))) S[8];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
584 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
585 const vector unsigned short mask1 = (vector unsigned short)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
586 AVV(0x0001, 0x0002, 0x0004, 0x0008,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
587 0x0010, 0x0020, 0x0040, 0x0080);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
588 const vector unsigned short mask2 = (vector unsigned short)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
589 AVV(0x0100, 0x0200, 0x0000, 0x0000,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
590 0x0000, 0x0000, 0x0000, 0x0000);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
591
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
592 const vector unsigned int vuint32_16 = vec_sl(vec_splat_u32(1), vec_splat_u32(4));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
593 const vector unsigned int vuint32_1 = vec_splat_u32(1);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
594
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
595 #define COMPARE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
596 vector signed int sum##i; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
597 do { \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
598 const vector unsigned char cmp##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
599 (vector unsigned char)vec_cmpgt(src##i, v_avg); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
600 const vector unsigned short cmpHi##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
601 (vector unsigned short)vec_mergeh(cmp##i, cmp##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
602 const vector unsigned short cmpLi##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
603 (vector unsigned short)vec_mergel(cmp##i, cmp##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
604 const vector signed short cmpHf##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
605 (vector signed short)vec_and(cmpHi##i, mask1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
606 const vector signed short cmpLf##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
607 (vector signed short)vec_and(cmpLi##i, mask2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
608 const vector signed int sump##i = vec_sum4s(cmpHf##i, zero); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
609 const vector signed int sumq##i = vec_sum4s(cmpLf##i, sump##i); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
610 sum##i = vec_sums(sumq##i, zero); } while (0)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
611
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
612 COMPARE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
613 COMPARE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
614 COMPARE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
615 COMPARE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
616 COMPARE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
617 COMPARE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
618 COMPARE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
619 COMPARE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
620 COMPARE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
621 COMPARE(9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
622 #undef COMPARE
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
623
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
624 vector signed int sumA2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
625 vector signed int sumB2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
626 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
627 const vector signed int sump02 = vec_mergel(sum0, sum2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
628 const vector signed int sump13 = vec_mergel(sum1, sum3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
629 const vector signed int sumA = vec_mergel(sump02, sump13);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
630
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
631 const vector signed int sump46 = vec_mergel(sum4, sum6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
632 const vector signed int sump57 = vec_mergel(sum5, sum7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
633 const vector signed int sumB = vec_mergel(sump46, sump57);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
634
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
635 const vector signed int sump8A = vec_mergel(sum8, zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
636 const vector signed int sump9B = vec_mergel(sum9, zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
637 const vector signed int sumC = vec_mergel(sump8A, sump9B);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
638
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
639 const vector signed int tA = vec_sl(vec_nor(zero, sumA), vuint32_16);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
640 const vector signed int tB = vec_sl(vec_nor(zero, sumB), vuint32_16);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
641 const vector signed int tC = vec_sl(vec_nor(zero, sumC), vuint32_16);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
642 const vector signed int t2A = vec_or(sumA, tA);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
643 const vector signed int t2B = vec_or(sumB, tB);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
644 const vector signed int t2C = vec_or(sumC, tC);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
645 const vector signed int t3A = vec_and(vec_sra(t2A, vuint32_1),
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
646 vec_sl(t2A, vuint32_1));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
647 const vector signed int t3B = vec_and(vec_sra(t2B, vuint32_1),
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
648 vec_sl(t2B, vuint32_1));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
649 const vector signed int t3C = vec_and(vec_sra(t2C, vuint32_1),
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
650 vec_sl(t2C, vuint32_1));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
651 const vector signed int yA = vec_and(t2A, t3A);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
652 const vector signed int yB = vec_and(t2B, t3B);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
653 const vector signed int yC = vec_and(t2C, t3C);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
654
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
655 const vector unsigned char strangeperm1 = vec_lvsl(4, (unsigned char*)0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
656 const vector unsigned char strangeperm2 = vec_lvsl(8, (unsigned char*)0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
657 const vector signed int sumAd4 = vec_perm(yA, yB, strangeperm1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
658 const vector signed int sumAd8 = vec_perm(yA, yB, strangeperm2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
659 const vector signed int sumBd4 = vec_perm(yB, yC, strangeperm1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
660 const vector signed int sumBd8 = vec_perm(yB, yC, strangeperm2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
661 const vector signed int sumAp = vec_and(yA,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
662 vec_and(sumAd4,sumAd8));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
663 const vector signed int sumBp = vec_and(yB,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
664 vec_and(sumBd4,sumBd8));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
665 sumA2 = vec_or(sumAp,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
666 vec_sra(sumAp,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
667 vuint32_16));
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
668 sumB2 = vec_or(sumBp,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
669 vec_sra(sumBp,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
670 vuint32_16));
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
671 }
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
672 vec_st(sumA2, 0, S);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
673 vec_st(sumB2, 16, S);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
674 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
675
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
676 /* I'm not sure the following is actually faster
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
677 than straight, unvectorized C code :-( */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
678
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
679 int __attribute__((aligned(16))) tQP2[4];
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
680 tQP2[0]= c->QP/2 + 1;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
681 vector signed int vQP2 = vec_ld(0, tQP2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
682 vQP2 = vec_splat(vQP2, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
683 const vector unsigned char vuint8_2 = vec_splat_u8(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
684 const vector signed int vsint32_8 = vec_splat_s32(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
685 const vector unsigned int vuint32_4 = vec_splat_u32(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
686
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
687 const vector unsigned char permA1 = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
688 AVV(0x00, 0x01, 0x02, 0x10, 0x11, 0x12, 0x1F, 0x1F,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
689 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
690 const vector unsigned char permA2 = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
691 AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, 0x11,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
692 0x12, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
693 const vector unsigned char permA1inc = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
694 AVV(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
695 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
696 const vector unsigned char permA2inc = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
697 AVV(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
698 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
699 const vector unsigned char magic = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
700 AVV(0x01, 0x02, 0x01, 0x02, 0x04, 0x02, 0x01, 0x02,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
701 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
702 const vector unsigned char extractPerm = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
703 AVV(0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
704 0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
705 const vector unsigned char extractPermInc = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
706 AVV(0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
707 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
708 const vector unsigned char identity = vec_lvsl(0,(unsigned char *)0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
709 const vector unsigned char tenRight = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
710 AVV(0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
711 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
712 const vector unsigned char eightLeft = (vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
713 AVV(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
715
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
716
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
717 #define F_INIT(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
718 vector unsigned char tenRightM##i = tenRight; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
719 vector unsigned char permA1M##i = permA1; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
720 vector unsigned char permA2M##i = permA2; \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
721 vector unsigned char extractPermM##i = extractPerm
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
722
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
723 #define F2(i, j, k, l) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
724 if (S[i] & (1 << (l+1))) { \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
725 const vector unsigned char a_##j##_A##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
726 vec_perm(src##i, src##j, permA1M##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
727 const vector unsigned char a_##j##_B##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
728 vec_perm(a_##j##_A##l, src##k, permA2M##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
729 const vector signed int a_##j##_sump##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
730 (vector signed int)vec_msum(a_##j##_B##l, magic, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
731 (vector unsigned int)zero); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
732 vector signed int F_##j##_##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
733 vec_sr(vec_sums(a_##j##_sump##l, vsint32_8), vuint32_4); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
734 F_##j##_##l = vec_splat(F_##j##_##l, 3); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
735 const vector signed int p_##j##_##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
736 (vector signed int)vec_perm(src##j, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
737 (vector unsigned char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
738 extractPermM##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
739 const vector signed int sum_##j##_##l = vec_add( p_##j##_##l, vQP2);\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
740 const vector signed int diff_##j##_##l = vec_sub( p_##j##_##l, vQP2);\
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
741 vector signed int newpm_##j##_##l; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
742 if (vec_all_lt(sum_##j##_##l, F_##j##_##l)) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
743 newpm_##j##_##l = sum_##j##_##l; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
744 else if (vec_all_gt(diff_##j##_##l, F_##j##_##l)) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
745 newpm_##j##_##l = diff_##j##_##l; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
746 else newpm_##j##_##l = F_##j##_##l; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
747 const vector unsigned char newpm2_##j##_##l = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
748 vec_splat((vector unsigned char)newpm_##j##_##l, 15); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
749 const vector unsigned char mask##j##l = vec_add(identity, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
750 tenRightM##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
751 src##j = vec_perm(src##j, newpm2_##j##_##l, mask##j##l); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
752 } \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
753 permA1M##i = vec_add(permA1M##i, permA1inc); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
754 permA2M##i = vec_add(permA2M##i, permA2inc); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
755 tenRightM##i = vec_sro(tenRightM##i, eightLeft); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
756 extractPermM##i = vec_add(extractPermM##i, extractPermInc)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
757
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
758 #define ITER(i, j, k) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
759 F_INIT(i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
760 F2(i, j, k, 0); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
761 F2(i, j, k, 1); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
762 F2(i, j, k, 2); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
763 F2(i, j, k, 3); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
764 F2(i, j, k, 4); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
765 F2(i, j, k, 5); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
766 F2(i, j, k, 6); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
767 F2(i, j, k, 7)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
768
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
769 ITER(0, 1, 2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
770 ITER(1, 2, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
771 ITER(2, 3, 4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
772 ITER(3, 4, 5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
773 ITER(4, 5, 6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
774 ITER(5, 6, 7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
775 ITER(6, 7, 8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
776 ITER(7, 8, 9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
777
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
778 const vector signed char neg1 = vec_splat_s8(-1);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
779
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
780 #define STORE_LINE(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
781 const vector unsigned char permST##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
782 vec_lvsr(i * stride, srcCopy); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
783 const vector unsigned char maskST##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
784 vec_perm((vector unsigned char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
785 (vector unsigned char)neg1, permST##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
786 src##i = vec_perm(src##i ,src##i, permST##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
787 sA##i= vec_sel(sA##i, src##i, maskST##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
788 sB##i= vec_sel(src##i, sB##i, maskST##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
789 vec_st(sA##i, i * stride, srcCopy); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
790 vec_st(sB##i, i * stride + 16, srcCopy)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
791
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
792 STORE_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
793 STORE_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
794 STORE_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
795 STORE_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
796 STORE_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
797 STORE_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
798 STORE_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
799 STORE_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
800
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
801 #undef STORE_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
802 #undef ITER
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
803 #undef F2
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
804 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
805
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
806 #define doHorizLowPass_altivec(a...) doHorizLowPass_C(a)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
807 #define doHorizDefFilter_altivec(a...) doHorizDefFilter_C(a)
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
808 #define do_a_deblock_altivec(a...) do_a_deblock_C(a)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
809
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
810 static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
811 uint8_t *tempBlured, uint32_t *tempBluredPast, int *maxNoise)
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
812 {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
813 const vector signed int zero = vec_splat_s32(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
814 const vector signed short vsint16_1 = vec_splat_s16(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
815 vector signed int v_dp = zero;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
816 vector signed int v_sysdp = zero;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
817 int d, sysd, i;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
818
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
819 tempBluredPast[127]= maxNoise[0];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
820 tempBluredPast[128]= maxNoise[1];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
821 tempBluredPast[129]= maxNoise[2];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
822
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
823 #define LOAD_LINE(src, i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
824 register int j##src##i = i * stride; \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
825 vector unsigned char perm##src##i = vec_lvsl(j##src##i, src); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
826 const vector unsigned char v_##src##A1##i = vec_ld(j##src##i, src); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
827 const vector unsigned char v_##src##A2##i = vec_ld(j##src##i + 16, src); \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
828 const vector unsigned char v_##src##A##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
829 vec_perm(v_##src##A1##i, v_##src##A2##i, perm##src##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
830 vector signed short v_##src##Ass##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
831 (vector signed short)vec_mergeh((vector signed char)zero, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
832 (vector signed char)v_##src##A##i)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
833
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
834 LOAD_LINE(src, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
835 LOAD_LINE(src, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
836 LOAD_LINE(src, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
837 LOAD_LINE(src, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
838 LOAD_LINE(src, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
839 LOAD_LINE(src, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
840 LOAD_LINE(src, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
841 LOAD_LINE(src, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
842
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
843 LOAD_LINE(tempBlured, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
844 LOAD_LINE(tempBlured, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
845 LOAD_LINE(tempBlured, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
846 LOAD_LINE(tempBlured, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
847 LOAD_LINE(tempBlured, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
848 LOAD_LINE(tempBlured, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
849 LOAD_LINE(tempBlured, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
850 LOAD_LINE(tempBlured, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
851 #undef LOAD_LINE
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
852
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
853 #define ACCUMULATE_DIFFS(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
854 vector signed short v_d##i = vec_sub(v_tempBluredAss##i, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
855 v_srcAss##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
856 v_dp = vec_msums(v_d##i, v_d##i, v_dp); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
857 v_sysdp = vec_msums(v_d##i, vsint16_1, v_sysdp)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
858
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
859 ACCUMULATE_DIFFS(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
860 ACCUMULATE_DIFFS(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
861 ACCUMULATE_DIFFS(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
862 ACCUMULATE_DIFFS(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
863 ACCUMULATE_DIFFS(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
864 ACCUMULATE_DIFFS(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
865 ACCUMULATE_DIFFS(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
866 ACCUMULATE_DIFFS(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
867 #undef ACCUMULATE_DIFFS
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
868
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
869 v_dp = vec_sums(v_dp, zero);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
870 v_sysdp = vec_sums(v_sysdp, zero);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
871
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
872 v_dp = vec_splat(v_dp, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
873 v_sysdp = vec_splat(v_sysdp, 3);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
874
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
875 vec_ste(v_dp, 0, &d);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
876 vec_ste(v_sysdp, 0, &sysd);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
877
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
878 i = d;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
879 d = (4*d
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
880 +(*(tempBluredPast-256))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
881 +(*(tempBluredPast-1))+ (*(tempBluredPast+1))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
882 +(*(tempBluredPast+256))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
883 +4)>>3;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
884
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
885 *tempBluredPast=i;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
886
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
887 if (d > maxNoise[1]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
888 if (d < maxNoise[2]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
889 #define OP(i) v_tempBluredAss##i = vec_avg(v_tempBluredAss##i, v_srcAss##i);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
890
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
891 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
892 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
893 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
894 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
895 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
896 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
897 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
898 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
899 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
900 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
901 #define OP(i) v_tempBluredAss##i = v_srcAss##i;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
902
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
903 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
904 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
905 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
906 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
907 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
908 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
909 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
910 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
911 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
912 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
913 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
914 if (d < maxNoise[0]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
915 const vector signed short vsint16_7 = vec_splat_s16(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
916 const vector signed short vsint16_4 = vec_splat_s16(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
917 const vector unsigned short vuint16_3 = vec_splat_u16(3);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
918
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
919 #define OP(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
920 const vector signed short v_temp##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
921 vec_mladd(v_tempBluredAss##i, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
922 vsint16_7, v_srcAss##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
923 const vector signed short v_temp2##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
924 vec_add(v_temp##i, vsint16_4); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
925 v_tempBluredAss##i = vec_sr(v_temp2##i, vuint16_3)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
926
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
927 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
928 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
929 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
930 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
931 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
932 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
933 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
934 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
935 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
936 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
937 const vector signed short vsint16_3 = vec_splat_s16(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
938 const vector signed short vsint16_2 = vec_splat_s16(2);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
939
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
940 #define OP(i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
941 const vector signed short v_temp##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
942 vec_mladd(v_tempBluredAss##i, \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
943 vsint16_3, v_srcAss##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
944 const vector signed short v_temp2##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
945 vec_add(v_temp##i, vsint16_2); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
946 v_tempBluredAss##i = vec_sr(v_temp2##i, (vector unsigned short)vsint16_2)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
947
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
948 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
949 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
950 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
951 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
952 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
953 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
954 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
955 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
956 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
957 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
958 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
959
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
960 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
961 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
962 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
963
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
964 #define PACK_AND_STORE(src, i) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
965 const vector unsigned char perms##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
966 vec_lvsr(i * stride, src); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
967 const vector unsigned char vf##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
968 vec_packsu(v_tempBluredAss##i, (vector signed short)zero); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
969 const vector unsigned char vg##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
970 vec_perm(vf##src##i, v_##src##A##i, permHH); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
971 const vector unsigned char mask##src##i = \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
972 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##src##i); \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
973 const vector unsigned char vg2##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
974 vec_perm(vg##src##i, vg##src##i, perms##src##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
975 const vector unsigned char svA##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
976 vec_sel(v_##src##A1##i, vg2##src##i, mask##src##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
977 const vector unsigned char svB##src##i = \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
978 vec_sel(vg2##src##i, v_##src##A2##i, mask##src##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
979 vec_st(svA##src##i, i * stride, src); \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
980 vec_st(svB##src##i, i * stride + 16, src)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
981
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
982 PACK_AND_STORE(src, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
983 PACK_AND_STORE(src, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
984 PACK_AND_STORE(src, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
985 PACK_AND_STORE(src, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
986 PACK_AND_STORE(src, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
987 PACK_AND_STORE(src, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
988 PACK_AND_STORE(src, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
989 PACK_AND_STORE(src, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
990 PACK_AND_STORE(tempBlured, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
991 PACK_AND_STORE(tempBlured, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
992 PACK_AND_STORE(tempBlured, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
993 PACK_AND_STORE(tempBlured, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
994 PACK_AND_STORE(tempBlured, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
995 PACK_AND_STORE(tempBlured, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
996 PACK_AND_STORE(tempBlured, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
997 PACK_AND_STORE(tempBlured, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
998 #undef PACK_AND_STORE
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
999 }
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1000
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1001 static inline void transpose_16x8_char_toPackedAlign_altivec(unsigned char* dst, unsigned char* src, int stride) {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1002 const vector unsigned char zero = vec_splat_u8(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1003
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1004 #define LOAD_DOUBLE_LINE(i, j) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1005 vector unsigned char perm1##i = vec_lvsl(i * stride, src); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1006 vector unsigned char perm2##i = vec_lvsl(j * stride, src); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1007 vector unsigned char srcA##i = vec_ld(i * stride, src); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1008 vector unsigned char srcB##i = vec_ld(i * stride + 16, src); \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1009 vector unsigned char srcC##i = vec_ld(j * stride, src); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1010 vector unsigned char srcD##i = vec_ld(j * stride+ 16, src); \
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1011 vector unsigned char src##i = vec_perm(srcA##i, srcB##i, perm1##i); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1012 vector unsigned char src##j = vec_perm(srcC##i, srcD##i, perm2##i)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
1013
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1014 LOAD_DOUBLE_LINE(0, 1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1015 LOAD_DOUBLE_LINE(2, 3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1016 LOAD_DOUBLE_LINE(4, 5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1017 LOAD_DOUBLE_LINE(6, 7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1018 #undef LOAD_DOUBLE_LINE
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1019
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1020 vector unsigned char tempA = vec_mergeh(src0, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1021 vector unsigned char tempB = vec_mergel(src0, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1022 vector unsigned char tempC = vec_mergeh(src1, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1023 vector unsigned char tempD = vec_mergel(src1, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1024 vector unsigned char tempE = vec_mergeh(src2, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1025 vector unsigned char tempF = vec_mergel(src2, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1026 vector unsigned char tempG = vec_mergeh(src3, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1027 vector unsigned char tempH = vec_mergel(src3, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1028 vector unsigned char tempI = vec_mergeh(src4, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1029 vector unsigned char tempJ = vec_mergel(src4, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1030 vector unsigned char tempK = vec_mergeh(src5, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1031 vector unsigned char tempL = vec_mergel(src5, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1032 vector unsigned char tempM = vec_mergeh(src6, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1033 vector unsigned char tempN = vec_mergel(src6, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1034 vector unsigned char tempO = vec_mergeh(src7, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1035 vector unsigned char tempP = vec_mergel(src7, zero);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1036
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1037 vector unsigned char temp0 = vec_mergeh(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1038 vector unsigned char temp1 = vec_mergel(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1039 vector unsigned char temp2 = vec_mergeh(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1040 vector unsigned char temp3 = vec_mergel(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1041 vector unsigned char temp4 = vec_mergeh(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1042 vector unsigned char temp5 = vec_mergel(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1043 vector unsigned char temp6 = vec_mergeh(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1044 vector unsigned char temp7 = vec_mergel(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1045 vector unsigned char temp8 = vec_mergeh(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1046 vector unsigned char temp9 = vec_mergel(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1047 vector unsigned char temp10 = vec_mergeh(tempF, tempN);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1048 vector unsigned char temp11 = vec_mergel(tempF, tempN);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1049 vector unsigned char temp12 = vec_mergeh(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1050 vector unsigned char temp13 = vec_mergel(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1051 vector unsigned char temp14 = vec_mergeh(tempH, tempP);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1052 vector unsigned char temp15 = vec_mergel(tempH, tempP);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1053
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1054 tempA = vec_mergeh(temp0, temp8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1055 tempB = vec_mergel(temp0, temp8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1056 tempC = vec_mergeh(temp1, temp9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1057 tempD = vec_mergel(temp1, temp9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1058 tempE = vec_mergeh(temp2, temp10);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1059 tempF = vec_mergel(temp2, temp10);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1060 tempG = vec_mergeh(temp3, temp11);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1061 tempH = vec_mergel(temp3, temp11);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1062 tempI = vec_mergeh(temp4, temp12);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1063 tempJ = vec_mergel(temp4, temp12);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1064 tempK = vec_mergeh(temp5, temp13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1065 tempL = vec_mergel(temp5, temp13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1066 tempM = vec_mergeh(temp6, temp14);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1067 tempN = vec_mergel(temp6, temp14);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1068 tempO = vec_mergeh(temp7, temp15);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1069 tempP = vec_mergel(temp7, temp15);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1070
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1071 temp0 = vec_mergeh(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1072 temp1 = vec_mergel(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1073 temp2 = vec_mergeh(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1074 temp3 = vec_mergel(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1075 temp4 = vec_mergeh(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1076 temp5 = vec_mergel(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1077 temp6 = vec_mergeh(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1078 temp7 = vec_mergel(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1079 temp8 = vec_mergeh(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1080 temp9 = vec_mergel(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1081 temp10 = vec_mergeh(tempF, tempN);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1082 temp11 = vec_mergel(tempF, tempN);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1083 temp12 = vec_mergeh(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1084 temp13 = vec_mergel(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1085 temp14 = vec_mergeh(tempH, tempP);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1086 temp15 = vec_mergel(tempH, tempP);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1087
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1088 vec_st(temp0, 0, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1089 vec_st(temp1, 16, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1090 vec_st(temp2, 32, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1091 vec_st(temp3, 48, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1092 vec_st(temp4, 64, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1093 vec_st(temp5, 80, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1094 vec_st(temp6, 96, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1095 vec_st(temp7, 112, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1096 vec_st(temp8, 128, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1097 vec_st(temp9, 144, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1098 vec_st(temp10, 160, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1099 vec_st(temp11, 176, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1100 vec_st(temp12, 192, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1101 vec_st(temp13, 208, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1102 vec_st(temp14, 224, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1103 vec_st(temp15, 240, dst);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1104 }
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1105
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1106 static inline void transpose_8x16_char_fromPackedAlign_altivec(unsigned char* dst, unsigned char* src, int stride) {
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1107 const vector unsigned char zero = vec_splat_u8(0);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1108 const vector unsigned char magic_perm = (const vector unsigned char)
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1109 AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1110 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2043
diff changeset
1111
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1112 #define LOAD_DOUBLE_LINE(i, j) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1113 vector unsigned char src##i = vec_ld(i * 16, src); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1114 vector unsigned char src##j = vec_ld(j * 16, src)
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1115
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1116 LOAD_DOUBLE_LINE(0, 1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1117 LOAD_DOUBLE_LINE(2, 3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1118 LOAD_DOUBLE_LINE(4, 5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1119 LOAD_DOUBLE_LINE(6, 7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1120 LOAD_DOUBLE_LINE(8, 9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1121 LOAD_DOUBLE_LINE(10, 11);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1122 LOAD_DOUBLE_LINE(12, 13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1123 LOAD_DOUBLE_LINE(14, 15);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1124 #undef LOAD_DOUBLE_LINE
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1125
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1126 vector unsigned char tempA = vec_mergeh(src0, src8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1127 vector unsigned char tempB;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1128 vector unsigned char tempC = vec_mergeh(src1, src9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1129 vector unsigned char tempD;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1130 vector unsigned char tempE = vec_mergeh(src2, src10);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1131 vector unsigned char tempG = vec_mergeh(src3, src11);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1132 vector unsigned char tempI = vec_mergeh(src4, src12);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1133 vector unsigned char tempJ;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1134 vector unsigned char tempK = vec_mergeh(src5, src13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1135 vector unsigned char tempL;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1136 vector unsigned char tempM = vec_mergeh(src6, src14);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1137 vector unsigned char tempO = vec_mergeh(src7, src15);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1138
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1139 vector unsigned char temp0 = vec_mergeh(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1140 vector unsigned char temp1 = vec_mergel(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1141 vector unsigned char temp2;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1142 vector unsigned char temp3;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1143 vector unsigned char temp4 = vec_mergeh(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1144 vector unsigned char temp5 = vec_mergel(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1145 vector unsigned char temp6;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1146 vector unsigned char temp7;
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1147 vector unsigned char temp8 = vec_mergeh(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1148 vector unsigned char temp9 = vec_mergel(tempE, tempM);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1149 vector unsigned char temp12 = vec_mergeh(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1150 vector unsigned char temp13 = vec_mergel(tempG, tempO);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1151
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1152 tempA = vec_mergeh(temp0, temp8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1153 tempB = vec_mergel(temp0, temp8);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1154 tempC = vec_mergeh(temp1, temp9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1155 tempD = vec_mergel(temp1, temp9);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1156 tempI = vec_mergeh(temp4, temp12);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1157 tempJ = vec_mergel(temp4, temp12);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1158 tempK = vec_mergeh(temp5, temp13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1159 tempL = vec_mergel(temp5, temp13);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1160
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1161 temp0 = vec_mergeh(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1162 temp1 = vec_mergel(tempA, tempI);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1163 temp2 = vec_mergeh(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1164 temp3 = vec_mergel(tempB, tempJ);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1165 temp4 = vec_mergeh(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1166 temp5 = vec_mergel(tempC, tempK);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1167 temp6 = vec_mergeh(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1168 temp7 = vec_mergel(tempD, tempL);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1169
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1170
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1171 const vector signed char neg1 = vec_splat_s8(-1);
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1172 #define STORE_DOUBLE_LINE(i, j) \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1173 vector unsigned char dstA##i = vec_ld(i * stride, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1174 vector unsigned char dstB##i = vec_ld(i * stride + 16, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1175 vector unsigned char dstA##j = vec_ld(j * stride, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1176 vector unsigned char dstB##j = vec_ld(j * stride+ 16, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1177 vector unsigned char align##i = vec_lvsr(i * stride, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1178 vector unsigned char align##j = vec_lvsr(j * stride, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1179 vector unsigned char mask##i = vec_perm(zero, (vector unsigned char)neg1, align##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1180 vector unsigned char mask##j = vec_perm(zero, (vector unsigned char)neg1, align##j); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1181 vector unsigned char dstR##i = vec_perm(temp##i, temp##i, align##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1182 vector unsigned char dstR##j = vec_perm(temp##j, temp##j, align##j); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1183 vector unsigned char dstAF##i = vec_sel(dstA##i, dstR##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1184 vector unsigned char dstBF##i = vec_sel(dstR##i, dstB##i, mask##i); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1185 vector unsigned char dstAF##j = vec_sel(dstA##j, dstR##j, mask##j); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1186 vector unsigned char dstBF##j = vec_sel(dstR##j, dstB##j, mask##j); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1187 vec_st(dstAF##i, i * stride, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1188 vec_st(dstBF##i, i * stride + 16, dst); \
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
1189 vec_st(dstAF##j, j * stride, dst); \
2043
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1190 vec_st(dstBF##j, j * stride + 16, dst)
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1191
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1192 STORE_DOUBLE_LINE(0,1);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1193 STORE_DOUBLE_LINE(2,3);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1194 STORE_DOUBLE_LINE(4,5);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1195 STORE_DOUBLE_LINE(6,7);
703b80c99891 Another (final?) patch for libpostproc.
michael
parents: 2041
diff changeset
1196 }