Mercurial > libavcodec.hg
annotate ppc/dsputil_altivec.c @ 12253:112b3a0db187 libavcodec
Decode DCT tokens by branching to a different code path for each branch
on the huffman tree, instead of traversing the tree in a while loop.
Based on the similar optimization in libvpx's detokenize.c
10% faster at normal bitrates, and 30% faster for high-bitrate intra-only
author | conrad |
---|---|
date | Fri, 23 Jul 2010 21:46:17 +0000 |
parents | 3cd4cd0509cd |
children |
rev | line source |
---|---|
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
1 /* |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
2 * Copyright (c) 2002 Brian Foley |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
3 * Copyright (c) 2002 Dieter Shirley |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
4 * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org> |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
5 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
10 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
16 * Lesser General Public License for more details. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
17 * |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3572
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
21 */ |
2967 | 22 |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
23 #include "config.h" |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
24 #if HAVE_ALTIVEC_H |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
25 #include <altivec.h> |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
26 #endif |
6763 | 27 #include "libavcodec/dsputil.h" |
5750
09f99af1db40
Sanitize altivec code so it can be built with runtime check properly
lu_zero
parents:
5749
diff
changeset
|
28 #include "util_altivec.h" |
8307 | 29 #include "types_altivec.h" |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
30 #include "dsputil_altivec.h" |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
31 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
32 static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
33 { |
981 | 34 int i; |
10082 | 35 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
36 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
981 | 37 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
38 vector unsigned char pix1v, pix2v, pix2iv, avgv, t5; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
39 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
40 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
41 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
42 s = 0; |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
43 sad = (vector unsigned int)vec_splat_u32(0); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
44 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
45 /* Read unaligned pixels into our vectors. The vectors are as follows: |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
46 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
47 pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16] */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
48 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
49 pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1)); |
2967 | 50 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
51 tv = (vector unsigned char *) &pix2[0]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
52 pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
53 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
54 tv = (vector unsigned char *) &pix2[1]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
55 pix2iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[1])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
56 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
57 /* Calculate the average vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
58 avgv = vec_avg(pix2v, pix2iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
59 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
60 /* Calculate a sum of abs differences vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
61 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
62 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
63 /* Add each 4 pixel group together and put 4 results into sad */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
64 sad = vec_sum4s(t5, sad); |
2967 | 65 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
66 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
67 pix2 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
68 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
69 /* Sum up the four partial sums, and put the result into s */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
70 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
71 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
72 vec_ste(sumdiffs, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
73 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
74 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
75 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
76 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
77 static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
78 { |
981 | 79 int i; |
10082 | 80 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
81 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
981 | 82 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
83 vector unsigned char pix1v, pix2v, pix3v, avgv, t5; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
84 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
85 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
86 uint8_t *pix3 = pix2 + line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
87 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
88 s = 0; |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
89 sad = (vector unsigned int)vec_splat_u32(0); |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
90 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
91 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
92 iteration becomes pix2 in the next iteration. We can use this |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
93 fact to avoid a potentially expensive unaligned read, each |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
94 time around the loop. |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
95 Read unaligned pixels into our vectors. The vectors are as follows: |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
96 pix2v: pix2[0]-pix2[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
97 Split the pixel vectors into shorts */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
98 tv = (vector unsigned char *) &pix2[0]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
99 pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0])); |
2967 | 100 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
101 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
102 /* Read unaligned pixels into our vectors. The vectors are as follows: |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
103 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
104 pix3v: pix3[0]-pix3[15] */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
105 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
106 pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
107 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
108 tv = (vector unsigned char *) &pix3[0]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
109 pix3v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[0])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
110 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
111 /* Calculate the average vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
112 avgv = vec_avg(pix2v, pix3v); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
113 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
114 /* Calculate a sum of abs differences vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
115 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
116 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
117 /* Add each 4 pixel group together and put 4 results into sad */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
118 sad = vec_sum4s(t5, sad); |
2967 | 119 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
120 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
121 pix2v = pix3v; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
122 pix3 += line_size; |
2967 | 123 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
124 } |
2967 | 125 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
126 /* Sum up the four partial sums, and put the result into s */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
127 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
128 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
129 vec_ste(sumdiffs, 0, &s); |
2967 | 130 return s; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
131 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
132 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
133 static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
134 { |
981 | 135 int i; |
10082 | 136 int s; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
137 uint8_t *pix3 = pix2 + line_size; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
138 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
139 const vector unsigned short two = (const vector unsigned short)vec_splat_u16(2); |
981 | 140 vector unsigned char *tv, avgv, t5; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
141 vector unsigned char pix1v, pix2v, pix3v, pix2iv, pix3iv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
142 vector unsigned short pix2lv, pix2hv, pix2ilv, pix2ihv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
143 vector unsigned short pix3lv, pix3hv, pix3ilv, pix3ihv; |
981 | 144 vector unsigned short avghv, avglv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
145 vector unsigned short t1, t2, t3, t4; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
146 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
147 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
148 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
149 sad = (vector unsigned int)vec_splat_u32(0); |
2967 | 150 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
151 s = 0; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
152 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
153 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
154 iteration becomes pix2 in the next iteration. We can use this |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
155 fact to avoid a potentially expensive unaligned read, as well |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
156 as some splitting, and vector addition each time around the loop. |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
157 Read unaligned pixels into our vectors. The vectors are as follows: |
2979 | 158 pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
159 Split the pixel vectors into shorts */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
160 tv = (vector unsigned char *) &pix2[0]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
161 pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
162 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
163 tv = (vector unsigned char *) &pix2[1]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
164 pix2iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[1])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
165 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
166 pix2hv = (vector unsigned short) vec_mergeh(zero, pix2v); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
167 pix2lv = (vector unsigned short) vec_mergel(zero, pix2v); |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
168 pix2ihv = (vector unsigned short) vec_mergeh(zero, pix2iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
169 pix2ilv = (vector unsigned short) vec_mergel(zero, pix2iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
170 t1 = vec_add(pix2hv, pix2ihv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
171 t2 = vec_add(pix2lv, pix2ilv); |
2967 | 172 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
173 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
174 /* Read unaligned pixels into our vectors. The vectors are as follows: |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
175 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
176 pix3v: pix3[0]-pix3[15] pix3iv: pix3[1]-pix3[16] */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
177 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
178 pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
179 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
180 tv = (vector unsigned char *) &pix3[0]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
181 pix3v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[0])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
182 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
183 tv = (vector unsigned char *) &pix3[1]; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
184 pix3iv = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix3[1])); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
185 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
186 /* Note that AltiVec does have vec_avg, but this works on vector pairs |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
187 and rounds up. We could do avg(avg(a,b),avg(c,d)), but the rounding |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
188 would mean that, for example, avg(3,0,0,1) = 2, when it should be 1. |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
189 Instead, we have to split the pixel vectors into vectors of shorts, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
190 and do the averaging by hand. */ |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
191 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
192 /* Split the pixel vectors into shorts */ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
193 pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
194 pix3lv = (vector unsigned short) vec_mergel(zero, pix3v); |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
195 pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
196 pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
197 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
198 /* Do the averaging on them */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
199 t3 = vec_add(pix3hv, pix3ihv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
200 t4 = vec_add(pix3lv, pix3ilv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
201 |
884 | 202 avghv = vec_sr(vec_add(vec_add(t1, t3), two), two); |
203 avglv = vec_sr(vec_add(vec_add(t2, t4), two), two); | |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
204 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
205 /* Pack the shorts back into a result */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
206 avgv = vec_pack(avghv, avglv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
207 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
208 /* Calculate a sum of abs differences vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
209 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
210 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
211 /* Add each 4 pixel group together and put 4 results into sad */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
212 sad = vec_sum4s(t5, sad); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
213 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
214 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
215 pix3 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
216 /* Transfer the calculated values for pix3 into pix2 */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
217 t1 = t3; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
218 t2 = t4; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
219 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
220 /* Sum up the four partial sums, and put the result into s */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
221 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
222 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
223 vec_ste(sumdiffs, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
224 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
225 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
226 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
227 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
228 static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
229 { |
981 | 230 int i; |
10082 | 231 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
232 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
233 vector unsigned char perm1, perm2, *pix1v, *pix2v; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
234 vector unsigned char t1, t2, t3,t4, t5; |
981 | 235 vector unsigned int sad; |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
236 vector signed int sumdiffs; |
2967 | 237 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
238 sad = (vector unsigned int)vec_splat_u32(0); |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
239 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
240 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
241 for (i = 0; i < h; i++) { |
2979 | 242 /* Read potentially unaligned pixels into t1 and t2 */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
243 perm1 = vec_lvsl(0, pix1); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
244 pix1v = (vector unsigned char *) pix1; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
245 perm2 = vec_lvsl(0, pix2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
246 pix2v = (vector unsigned char *) pix2; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
247 t1 = vec_perm(pix1v[0], pix1v[1], perm1); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
248 t2 = vec_perm(pix2v[0], pix2v[1], perm2); |
2967 | 249 |
2979 | 250 /* Calculate a sum of abs differences vector */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
251 t3 = vec_max(t1, t2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
252 t4 = vec_min(t1, t2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
253 t5 = vec_sub(t3, t4); |
2967 | 254 |
2979 | 255 /* Add each 4 pixel group together and put 4 results into sad */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
256 sad = vec_sum4s(t5, sad); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
257 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
258 pix1 += line_size; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
259 pix2 += line_size; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
260 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
261 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
262 /* Sum up the four partial sums, and put the result into s */ |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
263 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
264 sumdiffs = vec_splat(sumdiffs, 3); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
265 vec_ste(sumdiffs, 0, &s); |
2967 | 266 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
267 return s; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
268 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
269 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
270 static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
271 { |
981 | 272 int i; |
10082 | 273 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
274 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
275 vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
276 vector unsigned char t1, t2, t3,t4, t5; |
981 | 277 vector unsigned int sad; |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
278 vector signed int sumdiffs; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
279 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
280 sad = (vector unsigned int)vec_splat_u32(0); |
1277
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
281 |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
282 permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0}; |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
283 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
284 for (i = 0; i < h; i++) { |
2979 | 285 /* Read potentially unaligned pixels into t1 and t2 |
286 Since we're reading 16 pixels, and actually only want 8, | |
287 mask out the last 8 pixels. The 0s don't change the sum. */ | |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
288 perm1 = vec_lvsl(0, pix1); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
289 pix1v = (vector unsigned char *) pix1; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
290 perm2 = vec_lvsl(0, pix2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
291 pix2v = (vector unsigned char *) pix2; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
292 t1 = vec_and(vec_perm(pix1v[0], pix1v[1], perm1), permclear); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
293 t2 = vec_and(vec_perm(pix2v[0], pix2v[1], perm2), permclear); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
294 |
2979 | 295 /* Calculate a sum of abs differences vector */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
296 t3 = vec_max(t1, t2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
297 t4 = vec_min(t1, t2); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
298 t5 = vec_sub(t3, t4); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
299 |
2979 | 300 /* Add each 4 pixel group together and put 4 results into sad */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
301 sad = vec_sum4s(t5, sad); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
302 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
303 pix1 += line_size; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
304 pix2 += line_size; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
305 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
306 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
307 /* Sum up the four partial sums, and put the result into s */ |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
308 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
309 sumdiffs = vec_splat(sumdiffs, 3); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
310 vec_ste(sumdiffs, 0, &s); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
311 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
312 return s; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
313 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
314 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
315 static int pix_norm1_altivec(uint8_t *pix, int line_size) |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
316 { |
981 | 317 int i; |
10082 | 318 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
319 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 320 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
321 vector unsigned char pixv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
322 vector unsigned int sv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
323 vector signed int sum; |
2967 | 324 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
325 sv = (vector unsigned int)vec_splat_u32(0); |
2967 | 326 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
327 s = 0; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
328 for (i = 0; i < 16; i++) { |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
329 /* Read in the potentially unaligned pixels */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
330 tv = (vector unsigned char *) pix; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
331 pixv = vec_perm(tv[0], tv[1], vec_lvsl(0, pix)); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
332 |
884 | 333 /* Square the values, and add them to our sum */ |
334 sv = vec_msum(pixv, pixv, sv); | |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
335 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
336 pix += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
337 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
338 /* Sum up the four partial sums, and put the result into s */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
339 sum = vec_sums((vector signed int) sv, (vector signed int) zero); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
340 sum = vec_splat(sum, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
341 vec_ste(sum, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
342 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
343 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
344 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
345 |
981 | 346 /** |
347 * Sum of Squared Errors for a 8x8 block. | |
348 * AltiVec-enhanced. | |
1708 | 349 * It's the sad8_altivec code above w/ squaring added. |
981 | 350 */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
351 static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
981 | 352 { |
353 int i; | |
10082 | 354 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
355 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 356 vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v; |
357 vector unsigned char t1, t2, t3,t4, t5; | |
358 vector unsigned int sum; | |
359 vector signed int sumsqr; | |
2967 | 360 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
361 sum = (vector unsigned int)vec_splat_u32(0); |
1277
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
362 |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
363 permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0}; |
1277
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
364 |
2967 | 365 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
366 for (i = 0; i < h; i++) { |
2979 | 367 /* Read potentially unaligned pixels into t1 and t2 |
368 Since we're reading 16 pixels, and actually only want 8, | |
369 mask out the last 8 pixels. The 0s don't change the sum. */ | |
981 | 370 perm1 = vec_lvsl(0, pix1); |
371 pix1v = (vector unsigned char *) pix1; | |
372 perm2 = vec_lvsl(0, pix2); | |
373 pix2v = (vector unsigned char *) pix2; | |
374 t1 = vec_and(vec_perm(pix1v[0], pix1v[1], perm1), permclear); | |
375 t2 = vec_and(vec_perm(pix2v[0], pix2v[1], perm2), permclear); | |
376 | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
377 /* Since we want to use unsigned chars, we can take advantage |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
378 of the fact that abs(a-b)^2 = (a-b)^2. */ |
2967 | 379 |
2979 | 380 /* Calculate abs differences vector */ |
981 | 381 t3 = vec_max(t1, t2); |
382 t4 = vec_min(t1, t2); | |
383 t5 = vec_sub(t3, t4); | |
2967 | 384 |
981 | 385 /* Square the values and add them to our sum */ |
386 sum = vec_msum(t5, t5, sum); | |
2967 | 387 |
981 | 388 pix1 += line_size; |
389 pix2 += line_size; | |
390 } | |
2967 | 391 |
981 | 392 /* Sum up the four partial sums, and put the result into s */ |
393 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero); | |
394 sumsqr = vec_splat(sumsqr, 3); | |
395 vec_ste(sumsqr, 0, &s); | |
2967 | 396 |
981 | 397 return s; |
398 } | |
399 | |
400 /** | |
401 * Sum of Squared Errors for a 16x16 block. | |
402 * AltiVec-enhanced. | |
1708 | 403 * It's the sad16_altivec code above w/ squaring added. |
981 | 404 */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
405 static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
981 | 406 { |
407 int i; | |
10082 | 408 int s; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
409 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 410 vector unsigned char perm1, perm2, *pix1v, *pix2v; |
411 vector unsigned char t1, t2, t3,t4, t5; | |
412 vector unsigned int sum; | |
413 vector signed int sumsqr; | |
2967 | 414 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
415 sum = (vector unsigned int)vec_splat_u32(0); |
2967 | 416 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
417 for (i = 0; i < h; i++) { |
2979 | 418 /* Read potentially unaligned pixels into t1 and t2 */ |
981 | 419 perm1 = vec_lvsl(0, pix1); |
420 pix1v = (vector unsigned char *) pix1; | |
421 perm2 = vec_lvsl(0, pix2); | |
422 pix2v = (vector unsigned char *) pix2; | |
423 t1 = vec_perm(pix1v[0], pix1v[1], perm1); | |
424 t2 = vec_perm(pix2v[0], pix2v[1], perm2); | |
425 | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
426 /* Since we want to use unsigned chars, we can take advantage |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
427 of the fact that abs(a-b)^2 = (a-b)^2. */ |
2967 | 428 |
2979 | 429 /* Calculate abs differences vector */ |
981 | 430 t3 = vec_max(t1, t2); |
431 t4 = vec_min(t1, t2); | |
432 t5 = vec_sub(t3, t4); | |
2967 | 433 |
981 | 434 /* Square the values and add them to our sum */ |
435 sum = vec_msum(t5, t5, sum); | |
2967 | 436 |
981 | 437 pix1 += line_size; |
438 pix2 += line_size; | |
439 } | |
2967 | 440 |
981 | 441 /* Sum up the four partial sums, and put the result into s */ |
442 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero); | |
443 sumsqr = vec_splat(sumsqr, 3); | |
444 vec_ste(sumsqr, 0, &s); | |
2967 | 445 |
981 | 446 return s; |
447 } | |
448 | |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
449 static int pix_sum_altivec(uint8_t * pix, int line_size) |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
450 { |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
451 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
452 vector unsigned char perm, *pixv; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
453 vector unsigned char t1; |
981 | 454 vector unsigned int sad; |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
455 vector signed int sumdiffs; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
456 |
981 | 457 int i; |
10082 | 458 int s; |
2967 | 459 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
460 sad = (vector unsigned int)vec_splat_u32(0); |
2967 | 461 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
462 for (i = 0; i < 16; i++) { |
2979 | 463 /* Read the potentially unaligned 16 pixels into t1 */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
464 perm = vec_lvsl(0, pix); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
465 pixv = (vector unsigned char *) pix; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
466 t1 = vec_perm(pixv[0], pixv[1], perm); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
467 |
2979 | 468 /* Add each 4 pixel group together and put 4 results into sad */ |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
469 sad = vec_sum4s(t1, sad); |
2967 | 470 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
471 pix += line_size; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
472 } |
2967 | 473 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
474 /* Sum up the four partial sums, and put the result into s */ |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
475 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
476 sumdiffs = vec_splat(sumdiffs, 3); |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
477 vec_ste(sumdiffs, 0, &s); |
2967 | 478 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
479 return s; |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
480 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
481 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
482 static void get_pixels_altivec(DCTELEM *restrict block, const uint8_t *pixels, int line_size) |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
483 { |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
484 int i; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
485 vector unsigned char perm, bytes, *pixv; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
486 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
487 vector signed short shorts; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
488 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
489 for (i = 0; i < 8; i++) { |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
490 // Read potentially unaligned pixels. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
491 // We're reading 16 pixels, and actually only want 8, |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
492 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
493 perm = vec_lvsl(0, pixels); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
494 pixv = (vector unsigned char *) pixels; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
495 bytes = vec_perm(pixv[0], pixv[1], perm); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
496 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
497 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
498 shorts = (vector signed short)vec_mergeh(zero, bytes); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
499 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
500 // save the data to the block, we assume the block is 16-byte aligned |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
501 vec_st(shorts, i*16, (vector signed short*)block); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
502 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
503 pixels += line_size; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
504 } |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
505 } |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
506 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
507 static void diff_pixels_altivec(DCTELEM *restrict block, const uint8_t *s1, |
1064 | 508 const uint8_t *s2, int stride) |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
509 { |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
510 int i; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
511 vector unsigned char perm, bytes, *pixv; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
512 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
513 vector signed short shorts1, shorts2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
514 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
515 for (i = 0; i < 4; i++) { |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
516 // Read potentially unaligned pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
517 // We're reading 16 pixels, and actually only want 8, |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
518 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
519 perm = vec_lvsl(0, s1); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
520 pixv = (vector unsigned char *) s1; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
521 bytes = vec_perm(pixv[0], pixv[1], perm); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
522 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
523 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
524 shorts1 = (vector signed short)vec_mergeh(zero, bytes); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
525 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
526 // Do the same for the second block of pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
527 perm = vec_lvsl(0, s2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
528 pixv = (vector unsigned char *) s2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
529 bytes = vec_perm(pixv[0], pixv[1], perm); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
530 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
531 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
532 shorts2 = (vector signed short)vec_mergeh(zero, bytes); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
533 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
534 // Do the subtraction |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
535 shorts1 = vec_sub(shorts1, shorts2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
536 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
537 // save the data to the block, we assume the block is 16-byte aligned |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
538 vec_st(shorts1, 0, (vector signed short*)block); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
539 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
540 s1 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
541 s2 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
542 block += 8; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
543 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
544 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
545 // The code below is a copy of the code above... This is a manual |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
546 // unroll. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
547 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
548 // Read potentially unaligned pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
549 // We're reading 16 pixels, and actually only want 8, |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
550 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
551 perm = vec_lvsl(0, s1); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
552 pixv = (vector unsigned char *) s1; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
553 bytes = vec_perm(pixv[0], pixv[1], perm); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
554 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
555 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
556 shorts1 = (vector signed short)vec_mergeh(zero, bytes); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
557 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
558 // Do the same for the second block of pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
559 perm = vec_lvsl(0, s2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
560 pixv = (vector unsigned char *) s2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
561 bytes = vec_perm(pixv[0], pixv[1], perm); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
562 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
563 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
564 shorts2 = (vector signed short)vec_mergeh(zero, bytes); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
565 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
566 // Do the subtraction |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
567 shorts1 = vec_sub(shorts1, shorts2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
568 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
569 // save the data to the block, we assume the block is 16-byte aligned |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
570 vec_st(shorts1, 0, (vector signed short*)block); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
571 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
572 s1 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
573 s2 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
574 block += 8; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
575 } |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
576 } |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
577 |
8307 | 578 |
579 static void clear_block_altivec(DCTELEM *block) { | |
580 LOAD_ZERO; | |
581 vec_st(zero_s16v, 0, block); | |
582 vec_st(zero_s16v, 16, block); | |
583 vec_st(zero_s16v, 32, block); | |
584 vec_st(zero_s16v, 48, block); | |
585 vec_st(zero_s16v, 64, block); | |
586 vec_st(zero_s16v, 80, block); | |
587 vec_st(zero_s16v, 96, block); | |
588 vec_st(zero_s16v, 112, block); | |
589 } | |
590 | |
591 | |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
592 static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) { |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
593 register int i; |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
594 register vector unsigned char vdst, vsrc; |
2967 | 595 |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
596 /* dst and src are 16 bytes-aligned (guaranteed) */ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
597 for (i = 0 ; (i + 15) < w ; i+=16) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
598 vdst = vec_ld(i, (unsigned char*)dst); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
599 vsrc = vec_ld(i, (unsigned char*)src); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
600 vdst = vec_add(vsrc, vdst); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
601 vec_st(vdst, i, (unsigned char*)dst); |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
602 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
603 /* if w is not a multiple of 16 */ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
604 for (; (i < w) ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
605 dst[i] = src[i]; |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
606 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
607 } |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
608 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
609 /* next one assumes that ((line_size % 16) == 0) */ |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
610 void put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
611 { |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
612 register vector unsigned char pixelsv1, pixelsv2; |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
613 register vector unsigned char pixelsv1B, pixelsv2B; |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
614 register vector unsigned char pixelsv1C, pixelsv2C; |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
615 register vector unsigned char pixelsv1D, pixelsv2D; |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
616 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
617 register vector unsigned char perm = vec_lvsl(0, pixels); |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
618 int i; |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
619 register int line_size_2 = line_size << 1; |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
620 register int line_size_3 = line_size + line_size_2; |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
621 register int line_size_4 = line_size << 2; |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
622 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
623 // hand-unrolling the loop by 4 gains about 15% |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
624 // mininum execution time goes from 74 to 60 cycles |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
625 // it's faster than -funroll-loops, but using |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
626 // -funroll-loops w/ this is bad - 74 cycles again. |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
627 // all this is on a 7450, tuning for the 7450 |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
628 #if 0 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
629 for (i = 0; i < h; i++) { |
9668 | 630 pixelsv1 = vec_ld(0, pixels); |
631 pixelsv2 = vec_ld(16, pixels); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
632 vec_st(vec_perm(pixelsv1, pixelsv2, perm), |
9668 | 633 0, block); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
634 pixels+=line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
635 block +=line_size; |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
636 } |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
637 #else |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
638 for (i = 0; i < h; i += 4) { |
9668 | 639 pixelsv1 = vec_ld( 0, pixels); |
640 pixelsv2 = vec_ld(15, pixels); | |
641 pixelsv1B = vec_ld(line_size, pixels); | |
642 pixelsv2B = vec_ld(15 + line_size, pixels); | |
643 pixelsv1C = vec_ld(line_size_2, pixels); | |
644 pixelsv2C = vec_ld(15 + line_size_2, pixels); | |
645 pixelsv1D = vec_ld(line_size_3, pixels); | |
646 pixelsv2D = vec_ld(15 + line_size_3, pixels); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
647 vec_st(vec_perm(pixelsv1, pixelsv2, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
648 0, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
649 vec_st(vec_perm(pixelsv1B, pixelsv2B, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
650 line_size, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
651 vec_st(vec_perm(pixelsv1C, pixelsv2C, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
652 line_size_2, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
653 vec_st(vec_perm(pixelsv1D, pixelsv2D, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
654 line_size_3, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
655 pixels+=line_size_4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
656 block +=line_size_4; |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
657 } |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
658 #endif |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
659 } |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
660 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
661 /* next one assumes that ((line_size % 16) == 0) */ |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
662 #define op_avg(a,b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) ) |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
663 void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
664 { |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
665 register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv; |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
666 register vector unsigned char perm = vec_lvsl(0, pixels); |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
667 int i; |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
668 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
669 for (i = 0; i < h; i++) { |
9668 | 670 pixelsv1 = vec_ld( 0, pixels); |
671 pixelsv2 = vec_ld(16,pixels); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
672 blockv = vec_ld(0, block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
673 pixelsv = vec_perm(pixelsv1, pixelsv2, perm); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
674 blockv = vec_avg(blockv,pixelsv); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
675 vec_st(blockv, 0, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
676 pixels+=line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
677 block +=line_size; |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
678 } |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
679 } |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
680 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
681 /* next one assumes that ((line_size % 8) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
682 static void avg_pixels8_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
683 { |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
684 register vector unsigned char pixelsv1, pixelsv2, pixelsv, blockv; |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
685 int i; |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
686 |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
687 for (i = 0; i < h; i++) { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
688 /* block is 8 bytes-aligned, so we're either in the |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
689 left block (16 bytes-aligned) or in the right block (not) */ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
690 int rightside = ((unsigned long)block & 0x0000000F); |
2967 | 691 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
692 blockv = vec_ld(0, block); |
9668 | 693 pixelsv1 = vec_ld( 0, pixels); |
694 pixelsv2 = vec_ld(16, pixels); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
695 pixelsv = vec_perm(pixelsv1, pixelsv2, vec_lvsl(0, pixels)); |
2967 | 696 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
697 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
698 pixelsv = vec_perm(blockv, pixelsv, vcprm(0,1,s0,s1)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
699 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
700 pixelsv = vec_perm(blockv, pixelsv, vcprm(s0,s1,2,3)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
701 } |
2967 | 702 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
703 blockv = vec_avg(blockv, pixelsv); |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
704 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
705 vec_st(blockv, 0, block); |
2967 | 706 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
707 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
708 block += line_size; |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
709 } |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
710 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
711 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
712 /* next one assumes that ((line_size % 8) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
713 static void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
714 { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
715 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
716 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
717 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
718 register vector unsigned short pixelssum1, pixelssum2, temp3; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
719 register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
720 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
2967 | 721 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
722 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
723 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
724 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
725 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
726 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
727 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
728 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
729 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
730 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
731 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
732 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
733 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
734 pixelssum1 = vec_add(pixelssum1, vctwo); |
2967 | 735 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
736 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
737 int rightside = ((unsigned long)block & 0x0000000F); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
738 blockv = vec_ld(0, block); |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
739 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
740 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
741 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
742 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
743 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
744 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
745 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
746 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
747 } |
1015
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
748 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
749 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
750 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
751 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
752 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
753 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
754 temp3 = vec_sra(temp3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
755 pixelssum1 = vec_add(pixelssum2, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
756 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); |
2967 | 757 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
758 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
759 blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
760 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
761 blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
762 } |
2967 | 763 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
764 vec_st(blockv, 0, block); |
2967 | 765 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
766 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
767 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
768 } |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
769 } |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
770 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
771 /* next one assumes that ((line_size % 8) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
772 static void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
773 { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
774 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
775 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
776 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
777 register vector unsigned short pixelssum1, pixelssum2, temp3; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
778 register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
779 register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
780 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
2967 | 781 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
782 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
783 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
784 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
785 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
786 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
787 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
788 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
789 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
790 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
791 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
792 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
793 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
794 pixelssum1 = vec_add(pixelssum1, vcone); |
2967 | 795 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
796 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
797 int rightside = ((unsigned long)block & 0x0000000F); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
798 blockv = vec_ld(0, block); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
799 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
800 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
801 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
802 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
803 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
804 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
805 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
806 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
807 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
808 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
809 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
810 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
811 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
812 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
813 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
814 temp3 = vec_sra(temp3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
815 pixelssum1 = vec_add(pixelssum2, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
816 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); |
2967 | 817 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
818 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
819 blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
820 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
821 blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
822 } |
2967 | 823 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
824 vec_st(blockv, 0, block); |
2967 | 825 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
826 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
827 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
828 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
829 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
830 |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
831 /* next one assumes that ((line_size % 16) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
832 static void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
833 { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
834 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
835 register vector unsigned char pixelsv1, pixelsv2, pixelsv3, pixelsv4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
836 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
837 register vector unsigned short temp3, temp4, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
838 pixelssum1, pixelssum2, pixelssum3, pixelssum4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
839 register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
840 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
1340
09b8fe0f0139
PPC fixes & clean-up patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1277
diff
changeset
|
841 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
842 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
843 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
844 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
845 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
846 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
847 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
848 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
849 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
850 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
851 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
852 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
853 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
854 pixelssum3 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
855 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
856 pixelssum3 = vec_add(pixelssum3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
857 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
858 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
859 pixelssum1 = vec_add(pixelssum1, vctwo); |
2967 | 860 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
861 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
862 blockv = vec_ld(0, block); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
863 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
864 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
865 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
866 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
867 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
868 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
869 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
870 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
871 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
872 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
873 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
874 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
875 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
876 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
2967 | 877 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
878 pixelssum4 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
879 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
880 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
881 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
882 temp4 = vec_add(pixelssum3, pixelssum4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
883 temp4 = vec_sra(temp4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
884 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
885 temp3 = vec_sra(temp3, vctwo); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
886 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
887 pixelssum3 = vec_add(pixelssum4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
888 pixelssum1 = vec_add(pixelssum2, vctwo); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
889 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
890 blockv = vec_packsu(temp3, temp4); |
2967 | 891 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
892 vec_st(blockv, 0, block); |
2967 | 893 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
894 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
895 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
896 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
897 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
898 |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
899 /* next one assumes that ((line_size % 16) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
900 static void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
901 { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
902 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
903 register vector unsigned char pixelsv1, pixelsv2, pixelsv3, pixelsv4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
904 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
905 register vector unsigned short temp3, temp4, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
906 pixelssum1, pixelssum2, pixelssum3, pixelssum4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
907 register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
908 register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
909 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
1340
09b8fe0f0139
PPC fixes & clean-up patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1277
diff
changeset
|
910 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
911 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
912 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
913 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
914 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
915 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
916 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
917 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
918 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
919 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
920 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
921 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
922 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
923 pixelssum3 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
924 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
925 pixelssum3 = vec_add(pixelssum3, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
926 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
927 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
928 pixelssum1 = vec_add(pixelssum1, vcone); |
2967 | 929 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
930 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
931 blockv = vec_ld(0, block); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
932 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
933 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
934 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
935 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
936 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
937 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
938 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
939 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
940 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
941 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
942 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
943 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
944 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
945 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
2967 | 946 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
947 pixelssum4 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
948 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
949 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
950 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
951 temp4 = vec_add(pixelssum3, pixelssum4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
952 temp4 = vec_sra(temp4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
953 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
954 temp3 = vec_sra(temp3, vctwo); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
955 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
956 pixelssum3 = vec_add(pixelssum4, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
957 pixelssum1 = vec_add(pixelssum2, vcone); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
958 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
959 blockv = vec_packsu(temp3, temp4); |
2967 | 960 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
961 vec_st(blockv, 0, block); |
2967 | 962 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
963 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
964 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
965 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
966 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
967 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
968 static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ |
3554 | 969 int sum; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
970 register const vector unsigned char vzero = |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
971 (const vector unsigned char)vec_splat_u8(0); |
3554 | 972 register vector signed short temp0, temp1, temp2, temp3, temp4, |
973 temp5, temp6, temp7; | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
974 { |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
975 register const vector signed short vprod1 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
976 { 1,-1, 1,-1, 1,-1, 1,-1 }; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
977 register const vector signed short vprod2 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
978 { 1, 1,-1,-1, 1, 1,-1,-1 }; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
979 register const vector signed short vprod3 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
980 { 1, 1, 1, 1,-1,-1,-1,-1 }; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
981 register const vector unsigned char perm1 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
982 {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
983 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D}; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
984 register const vector unsigned char perm2 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
985 {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
986 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B}; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
987 register const vector unsigned char perm3 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
988 {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
989 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
990 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
991 #define ONEITERBUTTERFLY(i, res) \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
992 { \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
993 register vector unsigned char src1, src2, srcO; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
994 register vector unsigned char dst1, dst2, dstO; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
995 register vector signed short srcV, dstV; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
996 register vector signed short but0, but1, but2, op1, op2, op3; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
997 src1 = vec_ld(stride * i, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
998 src2 = vec_ld((stride * i) + 15, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
999 srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1000 dst1 = vec_ld(stride * i, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1001 dst2 = vec_ld((stride * i) + 15, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1002 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1003 /* promote the unsigned chars to signed shorts */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1004 /* we're in the 8x8 function, we only care for the first 8 */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1005 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1006 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1007 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1008 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1009 /* subtractions inside the first butterfly */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1010 but0 = vec_sub(srcV, dstV); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1011 op1 = vec_perm(but0, but0, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1012 but1 = vec_mladd(but0, vprod1, op1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1013 op2 = vec_perm(but1, but1, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1014 but2 = vec_mladd(but1, vprod2, op2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1015 op3 = vec_perm(but2, but2, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1016 res = vec_mladd(but2, vprod3, op3); \ |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1017 } |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1018 ONEITERBUTTERFLY(0, temp0); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1019 ONEITERBUTTERFLY(1, temp1); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1020 ONEITERBUTTERFLY(2, temp2); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1021 ONEITERBUTTERFLY(3, temp3); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1022 ONEITERBUTTERFLY(4, temp4); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1023 ONEITERBUTTERFLY(5, temp5); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1024 ONEITERBUTTERFLY(6, temp6); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1025 ONEITERBUTTERFLY(7, temp7); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1026 } |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1027 #undef ONEITERBUTTERFLY |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1028 { |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1029 register vector signed int vsum; |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1030 register vector signed short line0 = vec_add(temp0, temp1); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1031 register vector signed short line1 = vec_sub(temp0, temp1); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1032 register vector signed short line2 = vec_add(temp2, temp3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1033 register vector signed short line3 = vec_sub(temp2, temp3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1034 register vector signed short line4 = vec_add(temp4, temp5); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1035 register vector signed short line5 = vec_sub(temp4, temp5); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1036 register vector signed short line6 = vec_add(temp6, temp7); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1037 register vector signed short line7 = vec_sub(temp6, temp7); |
2967 | 1038 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1039 register vector signed short line0B = vec_add(line0, line2); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1040 register vector signed short line2B = vec_sub(line0, line2); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1041 register vector signed short line1B = vec_add(line1, line3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1042 register vector signed short line3B = vec_sub(line1, line3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1043 register vector signed short line4B = vec_add(line4, line6); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1044 register vector signed short line6B = vec_sub(line4, line6); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1045 register vector signed short line5B = vec_add(line5, line7); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1046 register vector signed short line7B = vec_sub(line5, line7); |
2967 | 1047 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1048 register vector signed short line0C = vec_add(line0B, line4B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1049 register vector signed short line4C = vec_sub(line0B, line4B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1050 register vector signed short line1C = vec_add(line1B, line5B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1051 register vector signed short line5C = vec_sub(line1B, line5B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1052 register vector signed short line2C = vec_add(line2B, line6B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1053 register vector signed short line6C = vec_sub(line2B, line6B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1054 register vector signed short line3C = vec_add(line3B, line7B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1055 register vector signed short line7C = vec_sub(line3B, line7B); |
2967 | 1056 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1057 vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0)); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1058 vsum = vec_sum4s(vec_abs(line1C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1059 vsum = vec_sum4s(vec_abs(line2C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1060 vsum = vec_sum4s(vec_abs(line3C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1061 vsum = vec_sum4s(vec_abs(line4C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1062 vsum = vec_sum4s(vec_abs(line5C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1063 vsum = vec_sum4s(vec_abs(line6C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1064 vsum = vec_sum4s(vec_abs(line7C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1065 vsum = vec_sums(vsum, (vector signed int)vzero); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1066 vsum = vec_splat(vsum, 3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1067 vec_ste(vsum, 0, &sum); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1068 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1069 return sum; |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1070 } |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1071 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1072 /* |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1073 16x8 works with 16 elements; it allows to avoid replicating loads, and |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1074 give the compiler more rooms for scheduling. It's only used from |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1075 inside hadamard8_diff16_altivec. |
2967 | 1076 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1077 Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has a LOT |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1078 of spill code, it seems gcc (unlike xlc) cannot keep everything in registers |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1079 by itself. The following code include hand-made registers allocation. It's not |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1080 clean, but on a 7450 the resulting code is much faster (best case fall from |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1081 700+ cycles to 550). |
2967 | 1082 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1083 xlc doesn't add spill code, but it doesn't know how to schedule for the 7450, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1084 and its code isn't much faster than gcc-3.3 on the 7450 (but uses 25% less |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1085 instructions...) |
2967 | 1086 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1087 On the 970, the hand-made RA is still a win (around 690 vs. around 780), but |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1088 xlc goes to around 660 on the regular C code... |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1089 */ |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1090 |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1091 static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) { |
3554 | 1092 int sum; |
1093 register vector signed short | |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1094 temp0 __asm__ ("v0"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1095 temp1 __asm__ ("v1"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1096 temp2 __asm__ ("v2"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1097 temp3 __asm__ ("v3"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1098 temp4 __asm__ ("v4"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1099 temp5 __asm__ ("v5"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1100 temp6 __asm__ ("v6"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1101 temp7 __asm__ ("v7"); |
3554 | 1102 register vector signed short |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1103 temp0S __asm__ ("v8"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1104 temp1S __asm__ ("v9"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1105 temp2S __asm__ ("v10"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1106 temp3S __asm__ ("v11"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1107 temp4S __asm__ ("v12"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1108 temp5S __asm__ ("v13"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1109 temp6S __asm__ ("v14"), |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1110 temp7S __asm__ ("v15"); |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1111 register const vector unsigned char vzero __asm__ ("v31") = |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1112 (const vector unsigned char)vec_splat_u8(0); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1113 { |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1114 register const vector signed short vprod1 __asm__ ("v16") = |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1115 (const vector signed short){ 1,-1, 1,-1, 1,-1, 1,-1 }; |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1116 register const vector signed short vprod2 __asm__ ("v17") = |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1117 (const vector signed short){ 1, 1,-1,-1, 1, 1,-1,-1 }; |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1118 register const vector signed short vprod3 __asm__ ("v18") = |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1119 (const vector signed short){ 1, 1, 1, 1,-1,-1,-1,-1 }; |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1120 register const vector unsigned char perm1 __asm__ ("v19") = |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1121 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1122 {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1123 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D}; |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1124 register const vector unsigned char perm2 __asm__ ("v20") = |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1125 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1126 {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1127 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B}; |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1128 register const vector unsigned char perm3 __asm__ ("v21") = |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1129 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1130 {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1131 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; |
1980 | 1132 |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1133 #define ONEITERBUTTERFLY(i, res1, res2) \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1134 { \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1135 register vector unsigned char src1 __asm__ ("v22"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1136 src2 __asm__ ("v23"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1137 dst1 __asm__ ("v24"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1138 dst2 __asm__ ("v25"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1139 srcO __asm__ ("v22"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1140 dstO __asm__ ("v23"); \ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1141 \ |
9421
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1142 register vector signed short srcV __asm__ ("v24"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1143 dstV __asm__ ("v25"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1144 srcW __asm__ ("v26"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1145 dstW __asm__ ("v27"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1146 but0 __asm__ ("v28"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1147 but0S __asm__ ("v29"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1148 op1 __asm__ ("v30"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1149 but1 __asm__ ("v22"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1150 op1S __asm__ ("v23"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1151 but1S __asm__ ("v24"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1152 op2 __asm__ ("v25"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1153 but2 __asm__ ("v26"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1154 op2S __asm__ ("v27"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1155 but2S __asm__ ("v28"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1156 op3 __asm__ ("v29"), \ |
dd2b5e52336a
Remove gcc_fixes.h. It only contains workarounds for unsupported gcc versions.
diego
parents:
8596
diff
changeset
|
1157 op3S __asm__ ("v30"); \ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1158 \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1159 src1 = vec_ld(stride * i, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1160 src2 = vec_ld((stride * i) + 16, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1161 srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1162 dst1 = vec_ld(stride * i, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1163 dst2 = vec_ld((stride * i) + 16, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1164 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1165 /* promote the unsigned chars to signed shorts */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1166 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1167 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1168 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1169 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1170 srcW = (vector signed short)vec_mergel((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1171 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1172 dstW = (vector signed short)vec_mergel((vector signed char)vzero, \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1173 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1174 /* subtractions inside the first butterfly */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1175 but0 = vec_sub(srcV, dstV); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1176 but0S = vec_sub(srcW, dstW); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1177 op1 = vec_perm(but0, but0, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1178 but1 = vec_mladd(but0, vprod1, op1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1179 op1S = vec_perm(but0S, but0S, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1180 but1S = vec_mladd(but0S, vprod1, op1S); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1181 op2 = vec_perm(but1, but1, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1182 but2 = vec_mladd(but1, vprod2, op2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1183 op2S = vec_perm(but1S, but1S, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1184 but2S = vec_mladd(but1S, vprod2, op2S); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1185 op3 = vec_perm(but2, but2, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1186 res1 = vec_mladd(but2, vprod3, op3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1187 op3S = vec_perm(but2S, but2S, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1188 res2 = vec_mladd(but2S, vprod3, op3S); \ |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1189 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1190 ONEITERBUTTERFLY(0, temp0, temp0S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1191 ONEITERBUTTERFLY(1, temp1, temp1S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1192 ONEITERBUTTERFLY(2, temp2, temp2S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1193 ONEITERBUTTERFLY(3, temp3, temp3S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1194 ONEITERBUTTERFLY(4, temp4, temp4S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1195 ONEITERBUTTERFLY(5, temp5, temp5S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1196 ONEITERBUTTERFLY(6, temp6, temp6S); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1197 ONEITERBUTTERFLY(7, temp7, temp7S); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1198 } |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1199 #undef ONEITERBUTTERFLY |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1200 { |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1201 register vector signed int vsum; |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1202 register vector signed short line0S, line1S, line2S, line3S, line4S, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1203 line5S, line6S, line7S, line0BS,line2BS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1204 line1BS,line3BS,line4BS,line6BS,line5BS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1205 line7BS,line0CS,line4CS,line1CS,line5CS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1206 line2CS,line6CS,line3CS,line7CS; |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1207 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1208 register vector signed short line0 = vec_add(temp0, temp1); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1209 register vector signed short line1 = vec_sub(temp0, temp1); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1210 register vector signed short line2 = vec_add(temp2, temp3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1211 register vector signed short line3 = vec_sub(temp2, temp3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1212 register vector signed short line4 = vec_add(temp4, temp5); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1213 register vector signed short line5 = vec_sub(temp4, temp5); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1214 register vector signed short line6 = vec_add(temp6, temp7); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1215 register vector signed short line7 = vec_sub(temp6, temp7); |
2967 | 1216 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1217 register vector signed short line0B = vec_add(line0, line2); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1218 register vector signed short line2B = vec_sub(line0, line2); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1219 register vector signed short line1B = vec_add(line1, line3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1220 register vector signed short line3B = vec_sub(line1, line3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1221 register vector signed short line4B = vec_add(line4, line6); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1222 register vector signed short line6B = vec_sub(line4, line6); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1223 register vector signed short line5B = vec_add(line5, line7); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1224 register vector signed short line7B = vec_sub(line5, line7); |
2967 | 1225 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1226 register vector signed short line0C = vec_add(line0B, line4B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1227 register vector signed short line4C = vec_sub(line0B, line4B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1228 register vector signed short line1C = vec_add(line1B, line5B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1229 register vector signed short line5C = vec_sub(line1B, line5B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1230 register vector signed short line2C = vec_add(line2B, line6B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1231 register vector signed short line6C = vec_sub(line2B, line6B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1232 register vector signed short line3C = vec_add(line3B, line7B); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1233 register vector signed short line7C = vec_sub(line3B, line7B); |
2967 | 1234 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1235 vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0)); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1236 vsum = vec_sum4s(vec_abs(line1C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1237 vsum = vec_sum4s(vec_abs(line2C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1238 vsum = vec_sum4s(vec_abs(line3C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1239 vsum = vec_sum4s(vec_abs(line4C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1240 vsum = vec_sum4s(vec_abs(line5C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1241 vsum = vec_sum4s(vec_abs(line6C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1242 vsum = vec_sum4s(vec_abs(line7C), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1243 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1244 line0S = vec_add(temp0S, temp1S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1245 line1S = vec_sub(temp0S, temp1S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1246 line2S = vec_add(temp2S, temp3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1247 line3S = vec_sub(temp2S, temp3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1248 line4S = vec_add(temp4S, temp5S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1249 line5S = vec_sub(temp4S, temp5S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1250 line6S = vec_add(temp6S, temp7S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1251 line7S = vec_sub(temp6S, temp7S); |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1252 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1253 line0BS = vec_add(line0S, line2S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1254 line2BS = vec_sub(line0S, line2S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1255 line1BS = vec_add(line1S, line3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1256 line3BS = vec_sub(line1S, line3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1257 line4BS = vec_add(line4S, line6S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1258 line6BS = vec_sub(line4S, line6S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1259 line5BS = vec_add(line5S, line7S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1260 line7BS = vec_sub(line5S, line7S); |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1261 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1262 line0CS = vec_add(line0BS, line4BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1263 line4CS = vec_sub(line0BS, line4BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1264 line1CS = vec_add(line1BS, line5BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1265 line5CS = vec_sub(line1BS, line5BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1266 line2CS = vec_add(line2BS, line6BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1267 line6CS = vec_sub(line2BS, line6BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1268 line3CS = vec_add(line3BS, line7BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1269 line7CS = vec_sub(line3BS, line7BS); |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1270 |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1271 vsum = vec_sum4s(vec_abs(line0CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1272 vsum = vec_sum4s(vec_abs(line1CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1273 vsum = vec_sum4s(vec_abs(line2CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1274 vsum = vec_sum4s(vec_abs(line3CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1275 vsum = vec_sum4s(vec_abs(line4CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1276 vsum = vec_sum4s(vec_abs(line5CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1277 vsum = vec_sum4s(vec_abs(line6CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1278 vsum = vec_sum4s(vec_abs(line7CS), vsum); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1279 vsum = vec_sums(vsum, (vector signed int)vzero); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1280 vsum = vec_splat(vsum, 3); |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1281 vec_ste(vsum, 0, &sum); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1282 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1283 return sum; |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1284 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1285 |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
1286 static int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ |
3554 | 1287 int score; |
1288 score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8); | |
1289 if (h==16) { | |
1290 dst += 8*stride; | |
1291 src += 8*stride; | |
1292 score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8); | |
1293 } | |
1294 return score; | |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1295 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1296 |
3543 | 1297 static void vorbis_inverse_coupling_altivec(float *mag, float *ang, |
1298 int blocksize) | |
1299 { | |
1300 int i; | |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1301 vector float m, a; |
3543 | 1302 vector bool int t0, t1; |
1303 const vector unsigned int v_31 = //XXX | |
1304 vec_add(vec_add(vec_splat_u32(15),vec_splat_u32(15)),vec_splat_u32(1)); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1305 for (i = 0; i < blocksize; i += 4) { |
3543 | 1306 m = vec_ld(0, mag+i); |
1307 a = vec_ld(0, ang+i); | |
1308 t0 = vec_cmple(m, (vector float)vec_splat_u32(0)); | |
1309 t1 = vec_cmple(a, (vector float)vec_splat_u32(0)); | |
3545 | 1310 a = vec_xor(a, (vector float) vec_sl((vector unsigned int)t0, v_31)); |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1311 t0 = (vector bool int)vec_and(a, t1); |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1312 t1 = (vector bool int)vec_andc(a, t1); |
3550 | 1313 a = vec_sub(m, (vector float)t1); |
1314 m = vec_add(m, (vector float)t0); | |
3549
7b4e34f1ff1f
Fix a stupid typo and another error, thanks to Emanuele Giaquinta <exg@gentoo.org> for pointing out the issue and the patch
lu_zero
parents:
3546
diff
changeset
|
1315 vec_stl(a, 0, ang+i); |
7b4e34f1ff1f
Fix a stupid typo and another error, thanks to Emanuele Giaquinta <exg@gentoo.org> for pointing out the issue and the patch
lu_zero
parents:
3546
diff
changeset
|
1316 vec_stl(m, 0, mag+i); |
3543 | 1317 } |
1318 } | |
1319 | |
2057
4c663228e020
avg_pixels8_xy2_altivec in AltiVec, enabling avg_pixels8_altivec, hadamard fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2056
diff
changeset
|
1320 /* next one assumes that ((line_size % 8) == 0) */ |
11382
50415a8f1451
PPC: move prototypes to headers and make some functions static
mru
parents:
10082
diff
changeset
|
1321 static void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
2057
4c663228e020
avg_pixels8_xy2_altivec in AltiVec, enabling avg_pixels8_altivec, hadamard fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2056
diff
changeset
|
1322 { |
3554 | 1323 register int i; |
1324 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; | |
1325 register vector unsigned char blockv, temp1, temp2, blocktemp; | |
1326 register vector unsigned short pixelssum1, pixelssum2, temp3; | |
1327 | |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1328 register const vector unsigned char vczero = (const vector unsigned char) |
3554 | 1329 vec_splat_u8(0); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1330 register const vector unsigned short vctwo = (const vector unsigned short) |
3554 | 1331 vec_splat_u16(2); |
2967 | 1332 |
3554 | 1333 temp1 = vec_ld(0, pixels); |
1334 temp2 = vec_ld(16, pixels); | |
1335 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); | |
1336 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { | |
1337 pixelsv2 = temp2; | |
1338 } else { | |
1339 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); | |
1340 } | |
1341 pixelsv1 = vec_mergeh(vczero, pixelsv1); | |
1342 pixelsv2 = vec_mergeh(vczero, pixelsv2); | |
1343 pixelssum1 = vec_add((vector unsigned short)pixelsv1, | |
1344 (vector unsigned short)pixelsv2); | |
1345 pixelssum1 = vec_add(pixelssum1, vctwo); | |
2967 | 1346 |
3554 | 1347 for (i = 0; i < h ; i++) { |
1348 int rightside = ((unsigned long)block & 0x0000000F); | |
1349 blockv = vec_ld(0, block); | |
2057
4c663228e020
avg_pixels8_xy2_altivec in AltiVec, enabling avg_pixels8_altivec, hadamard fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2056
diff
changeset
|
1350 |
3554 | 1351 temp1 = vec_ld(line_size, pixels); |
1352 temp2 = vec_ld(line_size + 16, pixels); | |
1353 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1354 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
3554 | 1355 pixelsv2 = temp2; |
1356 } else { | |
1357 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); | |
1358 } | |
2057
4c663228e020
avg_pixels8_xy2_altivec in AltiVec, enabling avg_pixels8_altivec, hadamard fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2056
diff
changeset
|
1359 |
3554 | 1360 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
1361 pixelsv2 = vec_mergeh(vczero, pixelsv2); | |
1362 pixelssum2 = vec_add((vector unsigned short)pixelsv1, | |
1363 (vector unsigned short)pixelsv2); | |
1364 temp3 = vec_add(pixelssum1, pixelssum2); | |
1365 temp3 = vec_sra(temp3, vctwo); | |
1366 pixelssum1 = vec_add(pixelssum2, vctwo); | |
1367 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); | |
2967 | 1368 |
3554 | 1369 if (rightside) { |
1370 blocktemp = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); | |
1371 } else { | |
1372 blocktemp = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); | |
1373 } | |
2967 | 1374 |
3554 | 1375 blockv = vec_avg(blocktemp, blockv); |
1376 vec_st(blockv, 0, block); | |
2967 | 1377 |
3554 | 1378 block += line_size; |
1379 pixels += line_size; | |
1380 } | |
2057
4c663228e020
avg_pixels8_xy2_altivec in AltiVec, enabling avg_pixels8_altivec, hadamard fix by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
2056
diff
changeset
|
1381 } |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1382 |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1383 void dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx) |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1384 { |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1385 c->pix_abs[0][1] = sad16_x2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1386 c->pix_abs[0][2] = sad16_y2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1387 c->pix_abs[0][3] = sad16_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1388 c->pix_abs[0][0] = sad16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1389 c->pix_abs[1][0] = sad8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1390 c->sad[0]= sad16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1391 c->sad[1]= sad8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1392 c->pix_norm1 = pix_norm1_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1393 c->sse[1]= sse8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1394 c->sse[0]= sse16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1395 c->pix_sum = pix_sum_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1396 c->diff_pixels = diff_pixels_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1397 c->get_pixels = get_pixels_altivec; |
8307 | 1398 c->clear_block = clear_block_altivec; |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1399 c->add_bytes= add_bytes_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1400 c->put_pixels_tab[0][0] = put_pixels16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1401 /* the two functions do the same thing, so use the same code */ |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1402 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1403 c->avg_pixels_tab[0][0] = avg_pixels16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1404 c->avg_pixels_tab[1][0] = avg_pixels8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1405 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1406 c->put_pixels_tab[1][3] = put_pixels8_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1407 c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1408 c->put_pixels_tab[0][3] = put_pixels16_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1409 c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1410 |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1411 c->hadamard8_diff[0] = hadamard8_diff16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1412 c->hadamard8_diff[1] = hadamard8_diff8x8_altivec; |
8596
68e959302527
replace all occurrence of ENABLE_ by the corresponding CONFIG_, HAVE_ or ARCH_
aurel
parents:
8307
diff
changeset
|
1413 if (CONFIG_VORBIS_DECODER) |
5753 | 1414 c->vorbis_inverse_coupling = vorbis_inverse_coupling_altivec; |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1415 } |