annotate libpostproc/postprocess_altivec_template.c @ 2041:b996fbe0a7e7 libavcodec

Newer version, using a vectorized version of the new organisation of code in doVertLowPass. it seems to be faster in AltiVec also... Also includes a compile fix for the new do_a_deblock when using AltiVec. patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
author michael
date Fri, 28 May 2004 13:31:38 +0000
parents 6a6c678517b3
children 703b80c99891
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
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
29 do { \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
30 __typeof__(src_a) tempA1, tempB1, tempC1, tempD1; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
31 __typeof__(src_a) tempE1, tempF1, tempG1, tempH1; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
32 __typeof__(src_a) tempA2, tempB2, tempC2, tempD2; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
33 __typeof__(src_a) tempE2, tempF2, tempG2, tempH2; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
34 tempA1 = vec_mergeh (src_a, src_e); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
35 tempB1 = vec_mergel (src_a, src_e); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
36 tempC1 = vec_mergeh (src_b, src_f); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
37 tempD1 = vec_mergel (src_b, src_f); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
38 tempE1 = vec_mergeh (src_c, src_g); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
39 tempF1 = vec_mergel (src_c, src_g); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
40 tempG1 = vec_mergeh (src_d, src_h); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
41 tempH1 = vec_mergel (src_d, src_h); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
42 tempA2 = vec_mergeh (tempA1, tempE1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
43 tempB2 = vec_mergel (tempA1, tempE1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
44 tempC2 = vec_mergeh (tempB1, tempF1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
45 tempD2 = vec_mergel (tempB1, tempF1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
46 tempE2 = vec_mergeh (tempC1, tempG1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
47 tempF2 = vec_mergel (tempC1, tempG1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
48 tempG2 = vec_mergeh (tempD1, tempH1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
49 tempH2 = vec_mergel (tempD1, tempH1); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
50 src_a = vec_mergeh (tempA2, tempE2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
51 src_b = vec_mergel (tempA2, tempE2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
52 src_c = vec_mergeh (tempB2, tempF2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
53 src_d = vec_mergel (tempB2, tempF2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
54 src_e = vec_mergeh (tempC2, tempG2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
55 src_f = vec_mergel (tempC2, tempG2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
56 src_g = vec_mergeh (tempD2, tempH2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
57 src_h = vec_mergel (tempD2, tempH2); \
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;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
76 int two_vectors = ((((unsigned long)src2 % 16) > 8) || (stride % 16)) ? 1 : 0;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
77 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
78 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
79 vector signed int v_numEq = vec_splat_s32(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
80
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
81 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
82 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
83 data[2] = c->QP * 2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
84 data[3] = c->QP * 4;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
85 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
86 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
87 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
88 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
89 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
90
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
91 src2 += stride * 4;
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 #define LOAD_LINE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
94 register int j##i = i * stride; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
95 vector unsigned char perm##i = vec_lvsl(j##i, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
96 const vector unsigned char v_srcA1##i = vec_ld(j##i, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
97 vector unsigned char v_srcA2##i; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
98 if (two_vectors) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
99 v_srcA2##i = vec_ld(j##i + 16, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
100 const vector unsigned char v_srcA##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
101 vec_perm(v_srcA1##i, v_srcA2##i, perm##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
102 vector signed short v_srcAss##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
103 (vector signed short)vec_mergeh((vector signed char)zero, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
104 (vector signed char)v_srcA##i)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
105
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
106 LOAD_LINE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
107 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
108 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
109 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
110 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
111 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
112 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
113 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
114 #undef LOAD_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
115
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
116 #define ITER(i, j) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
117 const vector signed short v_diff##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
118 vec_sub(v_srcAss##i, v_srcAss##j); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
119 const vector signed short v_sum##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
120 vec_add(v_diff##i, v_dcOffset); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
121 const vector signed short v_comp##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
122 (vector signed short)vec_cmplt((vector unsigned short)v_sum##i, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
123 v_dcThreshold); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
124 const vector signed short v_part##i = vec_and(mask, v_comp##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
125 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
126
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
127 ITER(0, 1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
128 ITER(1, 2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
129 ITER(2, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
130 ITER(3, 4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
131 ITER(4, 5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
132 ITER(5, 6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
133 ITER(6, 7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
134 #undef ITER
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
135
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
136 v_numEq = vec_sums(v_numEq, zero);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
137
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
138 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
139 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
140
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
141 if (numEq > c->ppMode.flatnessThreshold)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
142 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
143 const vector unsigned char mmoP1 = (const vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
144 AVV(0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
145 0x00, 0x01, 0x12, 0x13, 0x08, 0x09, 0x1A, 0x1B);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
146 const vector unsigned char mmoP2 = (const vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
147 AVV(0x04, 0x05, 0x16, 0x17, 0x0C, 0x0D, 0x1E, 0x1F,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
148 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
149 const vector unsigned char mmoP = (const vector unsigned char)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
150 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
151
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 vector unsigned short mmoSum = (vector unsigned short)vec_add(mmoDiff, v2QP);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
160
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
161 if (vec_any_gt(mmoSum, v4QP))
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
162 return 0;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
163 else
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
164 return 1;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
165 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
166 else return 2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
167 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
168
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
169 /* this is the same as vertClassify_altivec,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
170 with an added 8x8 transpose after the loading,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
171 and w/o the stride*4 offset */
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
172 static inline int horizClassify_altivec(uint8_t src[], int stride, PPContext *c) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
173 /*
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
174 this code makes no assumption on src or stride.
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
175 One could remove the recomputation of the perm
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
176 vector by assuming (stride % 16) == 0, unfortunately
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
177 this is not always true.
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
178 */
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
179 register int y;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
180 short __attribute__ ((aligned(16))) data[8];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
181 int numEq;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
182 uint8_t *src2 = src;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
183 vector signed short v_dcOffset;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
184 vector signed short v2QP;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
185 vector unsigned short v4QP;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
186 vector unsigned short v_dcThreshold;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
187 int two_vectors = ((((unsigned long)src2 % 16) > 8) || (stride % 16)) ? 1 : 0;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
188 const vector signed int zero = vec_splat_s32(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
189 const vector signed short mask = vec_splat_s16(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
190 vector signed int v_numEq = vec_splat_s32(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
191
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
192 data[0] = ((c->nonBQP*c->ppMode.baseDcDiff)>>8) + 1;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
193 data[1] = data[0] * 2 + 1;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
194 data[2] = c->QP * 2;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
195 data[3] = c->QP * 4;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
196 vector signed short v_data = vec_ld(0, data);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
197 v_dcOffset = vec_splat(v_data, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
198 v_dcThreshold = (vector unsigned short)vec_splat(v_data, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
199 v2QP = vec_splat(v_data, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
200 v4QP = (vector unsigned short)vec_splat(v_data, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
201
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
202 // src2 += stride * 4;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
203
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
204 #define LOAD_LINE(i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
205 register int j##i = i * stride; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
206 vector unsigned char perm##i = vec_lvsl(j##i, src2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
207 const vector unsigned char v_srcA1##i = vec_ld(j##i, src2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
208 vector unsigned char v_srcA2##i; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
209 if (two_vectors) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
210 v_srcA2##i = vec_ld(j##i + 16, src2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
211 const vector unsigned char v_srcA##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
212 vec_perm(v_srcA1##i, v_srcA2##i, perm##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
213 vector signed short v_srcAss##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
214 (vector signed short)vec_mergeh((vector signed char)zero, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
215 (vector signed char)v_srcA##i)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
216
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
217 LOAD_LINE(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
218 LOAD_LINE(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
219 LOAD_LINE(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
220 LOAD_LINE(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
221 LOAD_LINE(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
222 LOAD_LINE(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
223 LOAD_LINE(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
224 LOAD_LINE(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
225 #undef LOAD_LINE
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
226
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
227 ALTIVEC_TRANSPOSE_8x8_SHORT(v_srcAss0,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
228 v_srcAss1,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
229 v_srcAss2,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
230 v_srcAss3,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
231 v_srcAss4,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
232 v_srcAss5,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
233 v_srcAss6,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
234 v_srcAss7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
235
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
236 #define ITER(i, j) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
237 const vector signed short v_diff##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
238 vec_sub(v_srcAss##i, v_srcAss##j); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
239 const vector signed short v_sum##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
240 vec_add(v_diff##i, v_dcOffset); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
241 const vector signed short v_comp##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
242 (vector signed short)vec_cmplt((vector unsigned short)v_sum##i, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
243 v_dcThreshold); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
244 const vector signed short v_part##i = vec_and(mask, v_comp##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
245 v_numEq = vec_sum4s(v_part##i, v_numEq);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
246
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
247 ITER(0, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
248 ITER(1, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
249 ITER(2, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
250 ITER(3, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
251 ITER(4, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
252 ITER(5, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
253 ITER(6, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
254 #undef ITER
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
255
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
256 v_numEq = vec_sums(v_numEq, zero);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
257
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
258 v_numEq = vec_splat(v_numEq, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
259 vec_ste(v_numEq, 0, &numEq);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
260
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
261 if (numEq > c->ppMode.flatnessThreshold)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
262 {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
263 const vector unsigned char mmoP1 = (const vector unsigned char)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
264 AVV(0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
265 0x00, 0x01, 0x12, 0x13, 0x08, 0x09, 0x1A, 0x1B);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
266 const vector unsigned char mmoP2 = (const vector unsigned char)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
267 AVV(0x04, 0x05, 0x16, 0x17, 0x0C, 0x0D, 0x1E, 0x1F,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
268 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
269 const vector unsigned char mmoP = (const vector unsigned char)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
270 vec_lvsl(8, (unsigned char*)0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
271
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
272 vector signed short mmoL1 = vec_perm(v_srcAss0, v_srcAss2, mmoP1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
273 vector signed short mmoL2 = vec_perm(v_srcAss4, v_srcAss6, mmoP2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
274 vector signed short mmoL = vec_perm(mmoL1, mmoL2, mmoP);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
275 vector signed short mmoR1 = vec_perm(v_srcAss5, v_srcAss7, mmoP1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
276 vector signed short mmoR2 = vec_perm(v_srcAss1, v_srcAss3, mmoP2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
277 vector signed short mmoR = vec_perm(mmoR1, mmoR2, mmoP);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
278 vector signed short mmoDiff = vec_sub(mmoL, mmoR);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
279 vector unsigned short mmoSum = (vector unsigned short)vec_add(mmoDiff, v2QP);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
280
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
281 if (vec_any_gt(mmoSum, v4QP))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
282 return 0;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
283 else
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
284 return 1;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
285 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
286 else return 2;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
287 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
288
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
289
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
290 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
291 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
292 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
293 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
294 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
295 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
296 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
297 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
298 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
299 uint8_t *src2 = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
300 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
301 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
302 qp[0] = c->QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
303 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
304 vqp = vec_splat(vqp, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
305
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
306 #define LOAD_LINE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
307 const vector unsigned char perml##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
308 vec_lvsl(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
309 const vector unsigned char vbA##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
310 vec_ld(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
311 const vector unsigned char vbB##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
312 vec_ld(i * stride + 16, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
313 const vector unsigned char vbT##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
314 vec_perm(vbA##i, vbB##i, perml##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
315 const vector signed short vb##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
316 (vector signed short)vec_mergeh((vector unsigned char)zero, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
317 (vector unsigned char)vbT##i)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
318
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
319 src2 += stride*3;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
320
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
321 LOAD_LINE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
322 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
323 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
324 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
325 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
326 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
327 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
328 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
329 LOAD_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
330 LOAD_LINE(9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
331 #undef LOAD_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
332
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
333 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
334 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
335 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
336
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
337 const vector signed short v_diff01 = vec_sub(vb0, vb1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
338 const vector unsigned short v_cmp01 =
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
339 (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
340 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
341 const vector signed short v_diff89 = vec_sub(vb8, vb9);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
342 const vector unsigned short v_cmp89 =
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
343 (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
344 const vector signed short v_last = vec_sel(vb8, vb9, v_cmp89);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
345
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
346 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
347 const vector signed short temp02 = vec_add(vb2, vb3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
348 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
349 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
350
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
351 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
352 const vector signed short v_sumsB1 = vec_add(temp11, vb4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
353
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
354 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
355 const vector signed short v_sumsB2 = vec_add(temp21, vb5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
356
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
357 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
358 const vector signed short v_sumsB3 = vec_add(temp31, vb6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
359
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
360 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
361 const vector signed short v_sumsB4 = vec_add(temp41, vb7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
362
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
363 const vector signed short temp51 = vec_sub(v_sumsB4, vb1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
364 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
365
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
366 const vector signed short temp61 = vec_sub(v_sumsB5, vb2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
367 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
368
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
369 const vector signed short temp71 = vec_sub(v_sumsB6, vb3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
370 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
371
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
372 const vector signed short temp81 = vec_sub(v_sumsB7, vb4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
373 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
374
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
375 const vector signed short temp91 = vec_sub(v_sumsB8, vb5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
376 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
377
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
378 #define COMPUTE_VR(i, j, k) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
379 const vector signed short temps1##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
380 vec_add(v_sumsB##i, v_sumsB##k); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
381 const vector signed short temps2##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
382 vec_mladd(vb##j, (vector signed short)v_2, temps1##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
383 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
384
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
385 COMPUTE_VR(0, 1, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
386 COMPUTE_VR(1, 2, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
387 COMPUTE_VR(2, 3, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
388 COMPUTE_VR(3, 4, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
389 COMPUTE_VR(4, 5, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
390 COMPUTE_VR(5, 6, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
391 COMPUTE_VR(6, 7, 8);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
392 COMPUTE_VR(7, 8, 9);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
393
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
394 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
395 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
396 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
397
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
398 #define PACK_AND_STORE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
399 const vector unsigned char perms##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
400 vec_lvsr(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
401 const vector unsigned char vf##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
402 vec_packsu(vr##i, (vector signed short)zero); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
403 const vector unsigned char vg##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
404 vec_perm(vf##i, vbT##i, permHH); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
405 const vector unsigned char mask##i = \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
406 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##i); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
407 const vector unsigned char vg2##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
408 vec_perm(vg##i, vg##i, perms##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
409 const vector unsigned char svA##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
410 vec_sel(vbA##i, vg2##i, mask##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
411 const vector unsigned char svB##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
412 vec_sel(vg2##i, vbB##i, mask##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
413 vec_st(svA##i, i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
414 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
415
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
416 PACK_AND_STORE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
417 PACK_AND_STORE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
418 PACK_AND_STORE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
419 PACK_AND_STORE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
420 PACK_AND_STORE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
421 PACK_AND_STORE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
422 PACK_AND_STORE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
423 PACK_AND_STORE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
424
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
425 #undef PACK_AND_STORE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
426 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
427
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
428
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
429
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
430 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
431 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
432 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
433 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
434 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
435 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
436 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
437 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
438 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
439 uint8_t *src2 = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
440 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
441 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
442 qp[0] = 8*c->QP;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
443 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
444 vqp = vec_splat(vqp, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
445
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
446 #define LOAD_LINE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
447 const vector unsigned char perm##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
448 vec_lvsl(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
449 const vector unsigned char vbA##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
450 vec_ld(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
451 const vector unsigned char vbB##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
452 vec_ld(i * stride + 16, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
453 const vector unsigned char vbT##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
454 vec_perm(vbA##i, vbB##i, perm##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
455 const vector signed short vb##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
456 (vector signed short)vec_mergeh((vector unsigned char)zero, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
457 (vector unsigned char)vbT##i)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
458
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
459 src2 += stride*3;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
460
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
461 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
462 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
463 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
464 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
465 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
466 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
467 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
468 LOAD_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
469 #undef LOAD_LINE
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 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
472 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
473 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
474 const vector signed short v_32 = vec_sl(v_1,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
475 (vector unsigned short)v_5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
476 /* middle energy */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
477 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
478 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
479 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
480 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
481 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
482 /* left & right energy */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
483 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
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 /* d */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
492 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
493 vec_min(vec_abs(lE),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
494 vec_abs(rE)));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
495 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
496 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
497 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
498 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
499 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
500 d,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
501 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
502 (vector signed short)zero));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
503 /* q */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
504 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
505 /* 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
506 to all negative integer */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
507 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
508 v_1,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
509 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
510 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
511 /* clamp */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
512 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
513 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
514 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
515 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
516
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
517 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
518 dclamp_P,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
519 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
520 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
521 dclampedfinal,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
522 vec_cmplt(absmE, vqp));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
523 /* 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
524 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
525 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
526 /* finally, stores */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
527 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
528 const vector unsigned char st5 = vec_packsu(vb5plusd, (vector signed short)zero);
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
529
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
530 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
531 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
532 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
533
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
534 #define STORE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
535 const vector unsigned char perms##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
536 vec_lvsr(i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
537 const vector unsigned char vg##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
538 vec_perm(st##i, vbT##i, permHH); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
539 const vector unsigned char mask##i = \
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
540 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##i); \
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
541 const vector unsigned char vg2##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
542 vec_perm(vg##i, vg##i, perms##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
543 const vector unsigned char svA##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
544 vec_sel(vbA##i, vg2##i, mask##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
545 const vector unsigned char svB##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
546 vec_sel(vg2##i, vbB##i, mask##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
547 vec_st(svA##i, i * stride, src2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
548 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
549
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
550 STORE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
551 STORE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
552 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
553
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
554 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
555 /*
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
556 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
557 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
558 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
559 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
560 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
561 src & stride :-(
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
562 */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
563 uint8_t *srcCopy = src;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
564 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
565 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
566 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
567 vector unsigned char v_dt;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
568 dt[0] = deringThreshold;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
569 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
570
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
571 #define LOAD_LINE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
572 const vector unsigned char perm##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
573 vec_lvsl(i * stride, srcCopy); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
574 vector unsigned char sA##i = vec_ld(i * stride, srcCopy); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
575 vector unsigned char sB##i = vec_ld(i * stride + 16, srcCopy); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
576 vector unsigned char src##i = vec_perm(sA##i, sB##i, perm##i)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
577
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
578 LOAD_LINE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
579 LOAD_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
580 LOAD_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
581 LOAD_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
582 LOAD_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
583 LOAD_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
584 LOAD_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
585 LOAD_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
586 LOAD_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
587 LOAD_LINE(9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
588 #undef LOAD_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
589
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
590 vector unsigned char v_avg;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
591 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
592 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
593 AVV(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
594 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
595 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
596 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
597 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
598 const vector unsigned char trunc_src78 = vec_perm(src7, src8, trunc_perm);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
599
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
600 #define EXTRACT(op) do { \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
601 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
602 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
603 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
604 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
605 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
606 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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 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
615 v_##op = vec_##op(s##op##_11h, s##op##_11l); } while (0)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
616
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
617 vector unsigned char v_min;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
618 vector unsigned char v_max;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
619 EXTRACT(min);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
620 EXTRACT(max);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
621 #undef EXTRACT
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
622
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
623 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
624 return;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
625
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
626 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
627 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
628
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
629 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
630 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
631 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
632 AVV(0x0001, 0x0002, 0x0004, 0x0008,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
633 0x0010, 0x0020, 0x0040, 0x0080);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
634 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
635 AVV(0x0100, 0x0200, 0x0000, 0x0000,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
636 0x0000, 0x0000, 0x0000, 0x0000);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
637
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
638 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
639 const vector unsigned int vuint32_1 = vec_splat_u32(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
640
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
641 #define COMPARE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
642 vector signed int sum##i; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
643 do { \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
644 const vector unsigned char cmp##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
645 (vector unsigned char)vec_cmpgt(src##i, v_avg); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
646 const vector unsigned short cmpHi##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
647 (vector unsigned short)vec_mergeh(cmp##i, cmp##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
648 const vector unsigned short cmpLi##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
649 (vector unsigned short)vec_mergel(cmp##i, cmp##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
650 const vector signed short cmpHf##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
651 (vector signed short)vec_and(cmpHi##i, mask1); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
652 const vector signed short cmpLf##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
653 (vector signed short)vec_and(cmpLi##i, mask2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
654 const vector signed int sump##i = vec_sum4s(cmpHf##i, zero); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
655 const vector signed int sumq##i = vec_sum4s(cmpLf##i, sump##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
656 sum##i = vec_sums(sumq##i, zero); } while (0)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
657
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
658 COMPARE(0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
659 COMPARE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
660 COMPARE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
661 COMPARE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
662 COMPARE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
663 COMPARE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
664 COMPARE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
665 COMPARE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
666 COMPARE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
667 COMPARE(9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
668 #undef COMPARE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
669
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
670 vector signed int sumA2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
671 vector signed int sumB2;
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
672 {
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
673 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
674 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
675 const vector signed int sumA = vec_mergel(sump02, sump13);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
676
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
677 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
678 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
679 const vector signed int sumB = vec_mergel(sump46, sump57);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
680
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
681 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
682 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
683 const vector signed int sumC = vec_mergel(sump8A, sump9B);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
684
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
685 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
686 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
687 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
688 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
689 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
690 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
691 const vector signed int t3A = vec_and(vec_sra(t2A, vuint32_1),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
692 vec_sl(t2A, vuint32_1));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
693 const vector signed int t3B = vec_and(vec_sra(t2B, vuint32_1),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
694 vec_sl(t2B, vuint32_1));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
695 const vector signed int t3C = vec_and(vec_sra(t2C, vuint32_1),
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
696 vec_sl(t2C, vuint32_1));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
697 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
698 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
699 const vector signed int yC = vec_and(t2C, t3C);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
700
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
701 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
702 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
703 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
704 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
705 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
706 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
707 const vector signed int sumAp = vec_and(yA,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
708 vec_and(sumAd4,sumAd8));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
709 const vector signed int sumBp = vec_and(yB,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
710 vec_and(sumBd4,sumBd8));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
711 sumA2 = vec_or(sumAp,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
712 vec_sra(sumAp,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
713 vuint32_16));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
714 sumB2 = vec_or(sumBp,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
715 vec_sra(sumBp,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
716 vuint32_16));
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
717 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
718 vec_st(sumA2, 0, S);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
719 vec_st(sumB2, 16, S);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
720 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
721
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
722 /* 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
723 than straight, unvectorized C code :-( */
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
724
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
725 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
726 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
727 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
728 vQP2 = vec_splat(vQP2, 0);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
729 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
730 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
731 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
732
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
733 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
734 AVV(0x00, 0x01, 0x02, 0x10, 0x11, 0x12, 0x1F, 0x1F,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
735 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
736 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
737 AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, 0x11,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
738 0x12, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
739 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
740 AVV(0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
741 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
742 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
743 AVV(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
744 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
745 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
746 AVV(0x01, 0x02, 0x01, 0x02, 0x04, 0x02, 0x01, 0x02,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
747 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
748 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
749 AVV(0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
750 0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
751 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
752 AVV(0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
753 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
754 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
755 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
756 AVV(0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
757 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
758 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
759 AVV(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
760 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
761
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
762
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
763 #define F_INIT(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
764 vector unsigned char tenRightM##i = tenRight; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
765 vector unsigned char permA1M##i = permA1; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
766 vector unsigned char permA2M##i = permA2; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
767 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
768
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
769 #define F2(i, j, k, l) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
770 if (S[i] & (1 << (l+1))) { \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
771 const vector unsigned char a_##j##_A##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
772 vec_perm(src##i, src##j, permA1M##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
773 const vector unsigned char a_##j##_B##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
774 vec_perm(a_##j##_A##l, src##k, permA2M##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
775 const vector signed int a_##j##_sump##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
776 (vector signed int)vec_msum(a_##j##_B##l, magic, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
777 (vector unsigned int)zero); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
778 vector signed int F_##j##_##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
779 vec_sr(vec_sums(a_##j##_sump##l, vsint32_8), vuint32_4); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
780 F_##j##_##l = vec_splat(F_##j##_##l, 3); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
781 const vector signed int p_##j##_##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
782 (vector signed int)vec_perm(src##j, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
783 (vector unsigned char)zero, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
784 extractPermM##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
785 const vector signed int sum_##j##_##l = vec_add( p_##j##_##l, vQP2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
786 const vector signed int diff_##j##_##l = vec_sub( p_##j##_##l, vQP2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
787 vector signed int newpm_##j##_##l; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
788 if (vec_all_lt(sum_##j##_##l, F_##j##_##l)) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
789 newpm_##j##_##l = sum_##j##_##l; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
790 else if (vec_all_gt(diff_##j##_##l, F_##j##_##l)) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
791 newpm_##j##_##l = diff_##j##_##l; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
792 else newpm_##j##_##l = F_##j##_##l; \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
793 const vector unsigned char newpm2_##j##_##l = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
794 vec_splat((vector unsigned char)newpm_##j##_##l, 15); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
795 const vector unsigned char mask##j##l = vec_add(identity, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
796 tenRightM##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
797 src##j = vec_perm(src##j, newpm2_##j##_##l, mask##j##l); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
798 } \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
799 permA1M##i = vec_add(permA1M##i, permA1inc); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
800 permA2M##i = vec_add(permA2M##i, permA2inc); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
801 tenRightM##i = vec_sro(tenRightM##i, eightLeft); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
802 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
803
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
804 #define ITER(i, j, k) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
805 F_INIT(i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
806 F2(i, j, k, 0); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
807 F2(i, j, k, 1); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
808 F2(i, j, k, 2); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
809 F2(i, j, k, 3); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
810 F2(i, j, k, 4); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
811 F2(i, j, k, 5); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
812 F2(i, j, k, 6); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
813 F2(i, j, k, 7)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
814
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
815 ITER(0, 1, 2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
816 ITER(1, 2, 3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
817 ITER(2, 3, 4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
818 ITER(3, 4, 5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
819 ITER(4, 5, 6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
820 ITER(5, 6, 7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
821 ITER(6, 7, 8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
822 ITER(7, 8, 9);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
823
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
824 const vector signed char neg1 = vec_splat_s8(-1);
2036
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
825
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
826 #define STORE_LINE(i) \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
827 const vector unsigned char permST##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
828 vec_lvsr(i * stride, srcCopy); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
829 const vector unsigned char maskST##i = \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
830 vec_perm((vector unsigned char)zero, \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
831 (vector unsigned char)neg1, permST##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
832 src##i = vec_perm(src##i ,src##i, permST##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
833 sA##i= vec_sel(sA##i, src##i, maskST##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
834 sB##i= vec_sel(src##i, sB##i, maskST##i); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
835 vec_st(sA##i, i * stride, srcCopy); \
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
836 vec_st(sB##i, i * stride + 16, srcCopy)
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
837
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
838 STORE_LINE(1);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
839 STORE_LINE(2);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
840 STORE_LINE(3);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
841 STORE_LINE(4);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
842 STORE_LINE(5);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
843 STORE_LINE(6);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
844 STORE_LINE(7);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
845 STORE_LINE(8);
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
846
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
847 #undef STORE_LINE
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
848 #undef ITER
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
849 #undef F2
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
850 }
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
851
6a6c678517b3 altivec optimizations and horizontal filter fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
diff changeset
852 #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
853 #define doHorizDefFilter_altivec(a...) doHorizDefFilter_C(a)
2041
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
854 #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
855
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
856 static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
857 uint8_t *tempBlured, uint32_t *tempBluredPast, int *maxNoise)
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 const vector signed int zero = vec_splat_s32(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
860 const vector signed short vsint16_1 = vec_splat_s16(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
861 vector signed int v_dp = zero;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
862 vector signed int v_sysdp = zero;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
863 int d, sysd, i;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
864
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
865 tempBluredPast[127]= maxNoise[0];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
866 tempBluredPast[128]= maxNoise[1];
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
867 tempBluredPast[129]= maxNoise[2];
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 #define LOAD_LINE(src, i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
870 register int j##src##i = i * stride; \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
871 vector unsigned char perm##src##i = vec_lvsl(j##src##i, src); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
872 const vector unsigned char v_##src##A1##i = vec_ld(j##src##i, src); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
873 const vector unsigned char v_##src##A2##i = vec_ld(j##src##i + 16, src); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
874 const vector unsigned char v_##src##A##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
875 vec_perm(v_##src##A1##i, v_##src##A2##i, perm##src##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
876 vector signed short v_##src##Ass##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
877 (vector signed short)vec_mergeh((vector signed char)zero, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
878 (vector signed char)v_##src##A##i)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
879
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
880 LOAD_LINE(src, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
881 LOAD_LINE(src, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
882 LOAD_LINE(src, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
883 LOAD_LINE(src, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
884 LOAD_LINE(src, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
885 LOAD_LINE(src, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
886 LOAD_LINE(src, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
887 LOAD_LINE(src, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
888
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
889 LOAD_LINE(tempBlured, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
890 LOAD_LINE(tempBlured, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
891 LOAD_LINE(tempBlured, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
892 LOAD_LINE(tempBlured, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
893 LOAD_LINE(tempBlured, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
894 LOAD_LINE(tempBlured, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
895 LOAD_LINE(tempBlured, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
896 LOAD_LINE(tempBlured, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
897 #undef LOAD_LINE
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
898
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
899 #define ACCUMULATE_DIFFS(i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
900 vector signed short v_d##i = vec_sub(v_tempBluredAss##i, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
901 v_srcAss##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
902 v_dp = vec_msums(v_d##i, v_d##i, v_dp); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
903 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
904
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
905 ACCUMULATE_DIFFS(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
906 ACCUMULATE_DIFFS(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
907 ACCUMULATE_DIFFS(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
908 ACCUMULATE_DIFFS(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
909 ACCUMULATE_DIFFS(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
910 ACCUMULATE_DIFFS(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
911 ACCUMULATE_DIFFS(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
912 ACCUMULATE_DIFFS(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
913 #undef ACCUMULATE_DIFFS
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
914
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
915 v_dp = vec_sums(v_dp, zero);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
916 v_sysdp = vec_sums(v_sysdp, zero);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
917
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
918 v_dp = vec_splat(v_dp, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
919 v_sysdp = vec_splat(v_sysdp, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
920
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
921 vec_ste(v_dp, 0, &d);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
922 vec_ste(v_sysdp, 0, &sysd);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
923
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
924 i = d;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
925 d = (4*d
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
926 +(*(tempBluredPast-256))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
927 +(*(tempBluredPast-1))+ (*(tempBluredPast+1))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
928 +(*(tempBluredPast+256))
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
929 +4)>>3;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
930
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
931 *tempBluredPast=i;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
932
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
933 if (d > maxNoise[1]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
934 if (d < maxNoise[2]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
935 #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
936
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
937 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
938 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
939 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
940 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
941 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
942 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
943 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
944 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
945 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
946 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
947 #define OP(i) v_tempBluredAss##i = v_srcAss##i;
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
948
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
949 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
950 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
951 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
952 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
953 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
954 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
955 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
956 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
957 #undef OP
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 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
960 if (d < maxNoise[0]) {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
961 const vector signed short vsint16_7 = vec_splat_s16(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
962 const vector signed short vsint16_4 = vec_splat_s16(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
963 const vector unsigned short vuint16_3 = vec_splat_u16(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
964
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
965 #define OP(i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
966 const vector signed short v_temp##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
967 vec_mladd(v_tempBluredAss##i, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
968 vsint16_7, v_srcAss##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
969 const vector signed short v_temp2##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
970 vec_add(v_temp##i, vsint16_4); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
971 v_tempBluredAss##i = vec_sr(v_temp2##i, vuint16_3)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
972
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
973 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
974 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
975 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
976 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
977 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
978 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
979 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
980 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
981 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
982 } else {
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
983 const vector signed short vsint16_3 = vec_splat_s16(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
984 const vector signed short vsint16_2 = vec_splat_s16(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
985
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
986 #define OP(i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
987 const vector signed short v_temp##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
988 vec_mladd(v_tempBluredAss##i, \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
989 vsint16_3, v_srcAss##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
990 const vector signed short v_temp2##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
991 vec_add(v_temp##i, vsint16_2); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
992 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
993
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
994 OP(0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
995 OP(1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
996 OP(2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
997 OP(3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
998 OP(4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
999 OP(5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1000 OP(6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1001 OP(7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1002 #undef OP
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1003 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1004 }
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1005
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1006 const vector signed char neg1 = vec_splat_s8(-1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1007 const vector unsigned char permHH = (const vector unsigned char)AVV(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1008 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1009
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1010 #define PACK_AND_STORE(src, i) \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1011 const vector unsigned char perms##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1012 vec_lvsr(i * stride, src); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1013 const vector unsigned char vf##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1014 vec_packsu(v_tempBluredAss##i, (vector signed short)zero); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1015 const vector unsigned char vg##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1016 vec_perm(vf##src##i, v_##src##A##i, permHH); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1017 const vector unsigned char mask##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1018 vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##src##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1019 const vector unsigned char vg2##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1020 vec_perm(vg##src##i, vg##src##i, perms##src##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1021 const vector unsigned char svA##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1022 vec_sel(v_##src##A1##i, vg2##src##i, mask##src##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1023 const vector unsigned char svB##src##i = \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1024 vec_sel(vg2##src##i, v_##src##A2##i, mask##src##i); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1025 vec_st(svA##src##i, i * stride, src); \
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1026 vec_st(svB##src##i, i * stride + 16, src)
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1027
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1028 PACK_AND_STORE(src, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1029 PACK_AND_STORE(src, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1030 PACK_AND_STORE(src, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1031 PACK_AND_STORE(src, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1032 PACK_AND_STORE(src, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1033 PACK_AND_STORE(src, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1034 PACK_AND_STORE(src, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1035 PACK_AND_STORE(src, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1036 PACK_AND_STORE(tempBlured, 0);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1037 PACK_AND_STORE(tempBlured, 1);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1038 PACK_AND_STORE(tempBlured, 2);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1039 PACK_AND_STORE(tempBlured, 3);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1040 PACK_AND_STORE(tempBlured, 4);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1041 PACK_AND_STORE(tempBlured, 5);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1042 PACK_AND_STORE(tempBlured, 6);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1043 PACK_AND_STORE(tempBlured, 7);
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1044 #undef PACK_AND_STORE
b996fbe0a7e7 Newer version, using a vectorized version of the
michael
parents: 2036
diff changeset
1045 }