Mercurial > libavcodec.hg
annotate ppc/dsputil_altivec.c @ 8534:b80cf351176e libavcodec
1l: Forgot to rename header guard.
author | cehoyos |
---|---|
date | Tue, 06 Jan 2009 10:13:25 +0000 |
parents | bf5bc1f4cba0 |
children | 68e959302527 |
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 |
6763 | 23 #include "libavcodec/dsputil.h" |
1277
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
24 |
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
25 #include "gcc_fixes.h" |
f3152eb76f1a
altivec gcc-3 fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents:
1064
diff
changeset
|
26 |
6105
33674fb857b5
Change some files to only include the necessary headers.
diego
parents:
5964
diff
changeset
|
27 #include "dsputil_ppc.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" |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
30 |
1708 | 31 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
|
32 { |
981 | 33 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
34 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
35 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
981 | 36 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
37 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
|
38 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
39 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
40 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
41 s = 0; |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
42 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
|
43 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
44 /* 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
|
45 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
46 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
|
47 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
48 pix1v = vec_perm(tv[0], tv[1], vec_lvsl(0, pix1)); |
2967 | 49 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
50 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
|
51 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
|
52 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
53 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
|
54 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
|
55 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
56 /* Calculate the average vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
57 avgv = vec_avg(pix2v, pix2iv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
58 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
59 /* 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
|
60 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
|
61 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
62 /* 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
|
63 sad = vec_sum4s(t5, sad); |
2967 | 64 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
65 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
66 pix2 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
67 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
68 /* 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
|
69 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
|
70 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
71 vec_ste(sumdiffs, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
72 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
73 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
74 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
75 |
1708 | 76 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
|
77 { |
981 | 78 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
79 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
80 const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); |
981 | 81 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
82 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
|
83 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
84 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
85 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
|
86 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
87 s = 0; |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
88 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
|
89 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
90 /* 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
|
91 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
|
92 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
|
93 time around the loop. |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
94 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
|
95 pix2v: pix2[0]-pix2[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
96 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
|
97 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
|
98 pix2v = vec_perm(tv[0], tv[1], vec_lvsl(0, &pix2[0])); |
2967 | 99 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
100 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
101 /* 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
|
102 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
103 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
|
104 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
105 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
|
106 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
107 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
|
108 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
|
109 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
110 /* Calculate the average vector */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
111 avgv = vec_avg(pix2v, pix3v); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
112 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
113 /* 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
|
114 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
|
115 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
116 /* 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
|
117 sad = vec_sum4s(t5, sad); |
2967 | 118 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
119 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
120 pix2v = pix3v; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
121 pix3 += line_size; |
2967 | 122 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
123 } |
2967 | 124 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
125 /* 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
|
126 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
|
127 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
128 vec_ste(sumdiffs, 0, &s); |
2967 | 129 return s; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
130 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
131 |
1708 | 132 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
|
133 { |
981 | 134 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
135 DECLARE_ALIGNED_16(int, s); |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
136 uint8_t *pix3 = pix2 + line_size; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
137 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
|
138 const vector unsigned short two = (const vector unsigned short)vec_splat_u16(2); |
981 | 139 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
|
140 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
|
141 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
|
142 vector unsigned short pix3lv, pix3hv, pix3ilv, pix3ihv; |
981 | 143 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
|
144 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
|
145 vector unsigned int sad; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
146 vector signed int sumdiffs; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
147 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
148 sad = (vector unsigned int)vec_splat_u32(0); |
2967 | 149 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
150 s = 0; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
151 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
152 /* 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
|
153 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
|
154 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
|
155 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
|
156 Read unaligned pixels into our vectors. The vectors are as follows: |
2979 | 157 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
|
158 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
|
159 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
|
160 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
|
161 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
162 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
|
163 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
|
164 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 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
|
169 t1 = vec_add(pix2hv, pix2ihv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
170 t2 = vec_add(pix2lv, pix2ilv); |
2967 | 171 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
172 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
173 /* 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
|
174 pix1v: pix1[0]-pix1[15] |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
175 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
|
176 tv = (vector unsigned char *) pix1; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
177 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
|
178 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
179 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
|
180 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
|
181 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
182 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
|
183 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
|
184 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
185 /* 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
191 /* Split the pixel vectors into shorts */ |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
192 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
|
193 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
|
194 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
|
195 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
|
196 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
197 /* Do the averaging on them */ |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
198 t3 = vec_add(pix3hv, pix3ihv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
199 t4 = vec_add(pix3lv, pix3ilv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
200 |
884 | 201 avghv = vec_sr(vec_add(vec_add(t1, t3), two), two); |
202 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
|
203 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
204 /* 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
|
205 avgv = vec_pack(avghv, avglv); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
206 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
207 /* 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
|
208 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
|
209 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
210 /* 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
|
211 sad = vec_sum4s(t5, sad); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
212 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
213 pix1 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
214 pix3 += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
215 /* 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
|
216 t1 = t3; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
217 t2 = t4; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
218 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
219 /* 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
|
220 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
|
221 sumdiffs = vec_splat(sumdiffs, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
222 vec_ste(sumdiffs, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
223 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
224 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
225 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
226 |
1708 | 227 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
|
228 { |
981 | 229 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
230 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
231 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
|
232 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
|
233 vector unsigned char t1, t2, t3,t4, t5; |
981 | 234 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
|
235 vector signed int sumdiffs; |
2967 | 236 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
237 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
|
238 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
239 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
240 for (i = 0; i < h; i++) { |
2979 | 241 /* 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 t2 = vec_perm(pix2v[0], pix2v[1], perm2); |
2967 | 248 |
2979 | 249 /* 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
|
250 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
|
251 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
|
252 t5 = vec_sub(t3, t4); |
2967 | 253 |
2979 | 254 /* 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
|
255 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
|
256 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
257 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
|
258 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
|
259 } |
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 /* 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
|
262 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
|
263 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
|
264 vec_ste(sumdiffs, 0, &s); |
2967 | 265 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
266 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
|
267 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
268 |
1708 | 269 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
|
270 { |
981 | 271 int i; |
5584
e831a81fb25e
Fix trivial mixed declarations and code warning caused by a double semicolon.
diego
parents:
5573
diff
changeset
|
272 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
273 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
|
274 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
|
275 vector unsigned char t1, t2, t3,t4, t5; |
981 | 276 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
|
277 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
|
278 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
279 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
|
280 |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
281 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
|
282 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
283 for (i = 0; i < h; i++) { |
2979 | 284 /* Read potentially unaligned pixels into t1 and t2 |
285 Since we're reading 16 pixels, and actually only want 8, | |
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 |
2979 | 294 /* 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
|
295 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
|
296 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
|
297 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
|
298 |
2979 | 299 /* 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
|
300 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
|
301 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
302 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
|
303 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
|
304 } |
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 /* 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
|
307 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
|
308 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
|
309 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
|
310 |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
311 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
|
312 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
313 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
314 int pix_norm1_altivec(uint8_t *pix, int line_size) |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
315 { |
981 | 316 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
317 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
318 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 319 vector unsigned char *tv; |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
320 vector unsigned char pixv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
321 vector unsigned int sv; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
322 vector signed int sum; |
2967 | 323 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
324 sv = (vector unsigned int)vec_splat_u32(0); |
2967 | 325 |
878
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
326 s = 0; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
327 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
|
328 /* 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
|
329 tv = (vector unsigned char *) pix; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
330 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
|
331 |
884 | 332 /* Square the values, and add them to our sum */ |
333 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
|
334 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
335 pix += line_size; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
336 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
337 /* 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
|
338 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
|
339 sum = vec_splat(sum, 3); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
340 vec_ste(sum, 0, &s); |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
341 |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
342 return s; |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
343 } |
6ea69518e5f7
altivec optimizations patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
828
diff
changeset
|
344 |
981 | 345 /** |
346 * Sum of Squared Errors for a 8x8 block. | |
347 * AltiVec-enhanced. | |
1708 | 348 * It's the sad8_altivec code above w/ squaring added. |
981 | 349 */ |
1708 | 350 int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
981 | 351 { |
352 int i; | |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
353 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
354 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 355 vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v; |
356 vector unsigned char t1, t2, t3,t4, t5; | |
357 vector unsigned int sum; | |
358 vector signed int sumsqr; | |
2967 | 359 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
360 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
|
361 |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
362 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
|
363 |
2967 | 364 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
365 for (i = 0; i < h; i++) { |
2979 | 366 /* Read potentially unaligned pixels into t1 and t2 |
367 Since we're reading 16 pixels, and actually only want 8, | |
368 mask out the last 8 pixels. The 0s don't change the sum. */ | |
981 | 369 perm1 = vec_lvsl(0, pix1); |
370 pix1v = (vector unsigned char *) pix1; | |
371 perm2 = vec_lvsl(0, pix2); | |
372 pix2v = (vector unsigned char *) pix2; | |
373 t1 = vec_and(vec_perm(pix1v[0], pix1v[1], perm1), permclear); | |
374 t2 = vec_and(vec_perm(pix2v[0], pix2v[1], perm2), permclear); | |
375 | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
376 /* 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
|
377 of the fact that abs(a-b)^2 = (a-b)^2. */ |
2967 | 378 |
2979 | 379 /* Calculate abs differences vector */ |
981 | 380 t3 = vec_max(t1, t2); |
381 t4 = vec_min(t1, t2); | |
382 t5 = vec_sub(t3, t4); | |
2967 | 383 |
981 | 384 /* Square the values and add them to our sum */ |
385 sum = vec_msum(t5, t5, sum); | |
2967 | 386 |
981 | 387 pix1 += line_size; |
388 pix2 += line_size; | |
389 } | |
2967 | 390 |
981 | 391 /* Sum up the four partial sums, and put the result into s */ |
392 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero); | |
393 sumsqr = vec_splat(sumsqr, 3); | |
394 vec_ste(sumsqr, 0, &s); | |
2967 | 395 |
981 | 396 return s; |
397 } | |
398 | |
399 /** | |
400 * Sum of Squared Errors for a 16x16 block. | |
401 * AltiVec-enhanced. | |
1708 | 402 * It's the sad16_altivec code above w/ squaring added. |
981 | 403 */ |
1708 | 404 int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) |
981 | 405 { |
406 int i; | |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
407 DECLARE_ALIGNED_16(int, s); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
408 const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0); |
981 | 409 vector unsigned char perm1, perm2, *pix1v, *pix2v; |
410 vector unsigned char t1, t2, t3,t4, t5; | |
411 vector unsigned int sum; | |
412 vector signed int sumsqr; | |
2967 | 413 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
414 sum = (vector unsigned int)vec_splat_u32(0); |
2967 | 415 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
416 for (i = 0; i < h; i++) { |
2979 | 417 /* Read potentially unaligned pixels into t1 and t2 */ |
981 | 418 perm1 = vec_lvsl(0, pix1); |
419 pix1v = (vector unsigned char *) pix1; | |
420 perm2 = vec_lvsl(0, pix2); | |
421 pix2v = (vector unsigned char *) pix2; | |
422 t1 = vec_perm(pix1v[0], pix1v[1], perm1); | |
423 t2 = vec_perm(pix2v[0], pix2v[1], perm2); | |
424 | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
425 /* 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
|
426 of the fact that abs(a-b)^2 = (a-b)^2. */ |
2967 | 427 |
2979 | 428 /* Calculate abs differences vector */ |
981 | 429 t3 = vec_max(t1, t2); |
430 t4 = vec_min(t1, t2); | |
431 t5 = vec_sub(t3, t4); | |
2967 | 432 |
981 | 433 /* Square the values and add them to our sum */ |
434 sum = vec_msum(t5, t5, sum); | |
2967 | 435 |
981 | 436 pix1 += line_size; |
437 pix2 += line_size; | |
438 } | |
2967 | 439 |
981 | 440 /* Sum up the four partial sums, and put the result into s */ |
441 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero); | |
442 sumsqr = vec_splat(sumsqr, 3); | |
443 vec_ste(sumsqr, 0, &s); | |
2967 | 444 |
981 | 445 return s; |
446 } | |
447 | |
1064 | 448 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
|
449 { |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
450 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
|
451 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
|
452 vector unsigned char t1; |
981 | 453 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
|
454 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
|
455 |
981 | 456 int i; |
5019
41cabe79ba25
use macro Use DECLARE_ALIGNED_16 to align stack-allocated variables
gpoirier
parents:
5010
diff
changeset
|
457 DECLARE_ALIGNED_16(int, s); |
2967 | 458 |
1033
b4172ff70d27
Altivec on non darwin systems patch by Romain Dolbeau
bellard
parents:
1024
diff
changeset
|
459 sad = (vector unsigned int)vec_splat_u32(0); |
2967 | 460 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
461 for (i = 0; i < 16; i++) { |
2979 | 462 /* 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
|
463 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
|
464 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
|
465 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
|
466 |
2979 | 467 /* 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
|
468 sad = vec_sum4s(t1, sad); |
2967 | 469 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
470 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
|
471 } |
2967 | 472 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
473 /* 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
|
474 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
|
475 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
|
476 vec_ste(sumdiffs, 0, &s); |
2967 | 477 |
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
478 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
|
479 } |
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
diff
changeset
|
480 |
1064 | 481 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
|
482 { |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
483 int i; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
484 vector unsigned char perm, bytes, *pixv; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
485 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
|
486 vector signed short shorts; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
487 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
488 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
|
489 // Read potentially unaligned pixels. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
490 // 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
|
491 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
492 perm = vec_lvsl(0, pixels); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
493 pixv = (vector unsigned char *) pixels; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
494 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
|
495 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
496 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
497 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
|
498 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
499 // 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
|
500 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
|
501 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
502 pixels += line_size; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
503 } |
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 |
1064 | 506 void diff_pixels_altivec(DCTELEM *restrict block, const uint8_t *s1, |
507 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
|
508 { |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
509 int i; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
510 vector unsigned char perm, bytes, *pixv; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
511 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
|
512 vector signed short shorts1, shorts2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
513 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
514 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
|
515 // Read potentially unaligned pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
516 // 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
|
517 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
518 perm = vec_lvsl(0, s1); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
519 pixv = (vector unsigned char *) s1; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
520 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
|
521 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
522 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
523 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
|
524 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
525 // 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
|
526 perm = vec_lvsl(0, s2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
527 pixv = (vector unsigned char *) s2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
528 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
|
529 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
530 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
531 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
|
532 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
533 // Do the subtraction |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
534 shorts1 = vec_sub(shorts1, shorts2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
535 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
536 // 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
|
537 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
|
538 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
539 s1 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
540 s2 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
541 block += 8; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
542 |
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 // 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
|
545 // unroll. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
546 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
547 // Read potentially unaligned pixels |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
548 // 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
|
549 // but we simply ignore the extras. |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
550 perm = vec_lvsl(0, s1); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
551 pixv = (vector unsigned char *) s1; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
552 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
|
553 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
554 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
555 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
|
556 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
557 // 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
|
558 perm = vec_lvsl(0, s2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
559 pixv = (vector unsigned char *) s2; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
560 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
|
561 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
562 // convert the bytes into shorts |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
563 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
|
564 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
565 // Do the subtraction |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
566 shorts1 = vec_sub(shorts1, shorts2); |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
567 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
568 // 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
|
569 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
|
570 |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
571 s1 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
572 s2 += stride; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
573 block += 8; |
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
574 } |
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 |
8307 | 577 |
578 static void clear_block_altivec(DCTELEM *block) { | |
579 LOAD_ZERO; | |
580 vec_st(zero_s16v, 0, block); | |
581 vec_st(zero_s16v, 16, block); | |
582 vec_st(zero_s16v, 32, block); | |
583 vec_st(zero_s16v, 48, block); | |
584 vec_st(zero_s16v, 64, block); | |
585 vec_st(zero_s16v, 80, block); | |
586 vec_st(zero_s16v, 96, block); | |
587 vec_st(zero_s16v, 112, block); | |
588 } | |
589 | |
590 | |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
591 void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) { |
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
592 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
|
593 register vector unsigned char vdst, vsrc; |
2967 | 594 |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
595 /* 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
|
596 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
|
597 vdst = vec_ld(i, (unsigned char*)dst); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
598 vsrc = vec_ld(i, (unsigned char*)src); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
599 vdst = vec_add(vsrc, vdst); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
600 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
|
601 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
602 /* 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
|
603 for (; (i < w) ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
604 dst[i] = src[i]; |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
605 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
606 } |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
607 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
608 /* 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
|
609 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
|
610 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
611 POWERPC_PERF_DECLARE(altivec_put_pixels16_num, 1); |
1009
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 POWERPC_PERF_START_COUNT(altivec_put_pixels16_num, 1); |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
624 // 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
|
625 // 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
|
626 // 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
|
627 // -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
|
628 // 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
|
629 #if 0 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
630 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
631 pixelsv1 = vec_ld(0, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
632 pixelsv2 = vec_ld(16, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
633 vec_st(vec_perm(pixelsv1, pixelsv2, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
634 0, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
635 pixels+=line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
636 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
|
637 } |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
638 #else |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
639 for (i = 0; i < h; i += 4) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
640 pixelsv1 = vec_ld(0, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
641 pixelsv2 = vec_ld(15, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
642 pixelsv1B = vec_ld(line_size, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
643 pixelsv2B = vec_ld(15 + line_size, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
644 pixelsv1C = vec_ld(line_size_2, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
645 pixelsv2C = vec_ld(15 + line_size_2, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
646 pixelsv1D = vec_ld(line_size_3, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
647 pixelsv2D = vec_ld(15 + line_size_3, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
648 vec_st(vec_perm(pixelsv1, pixelsv2, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
649 0, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
650 vec_st(vec_perm(pixelsv1B, pixelsv2B, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
651 line_size, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
652 vec_st(vec_perm(pixelsv1C, pixelsv2C, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
653 line_size_2, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
654 vec_st(vec_perm(pixelsv1D, pixelsv2D, perm), |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
655 line_size_3, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
656 pixels+=line_size_4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
657 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
|
658 } |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
659 #endif |
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
660 POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_num, 1); |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
661 } |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
662 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
663 /* 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
|
664 #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
|
665 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
|
666 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
667 POWERPC_PERF_DECLARE(altivec_avg_pixels16_num, 1); |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
672 POWERPC_PERF_START_COUNT(altivec_avg_pixels16_num, 1); |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
673 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
674 for (i = 0; i < h; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
675 pixelsv1 = vec_ld(0, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
676 pixelsv2 = vec_ld(16, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
677 blockv = vec_ld(0, block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
678 pixelsv = vec_perm(pixelsv1, pixelsv2, perm); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
679 blockv = vec_avg(blockv,pixelsv); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
680 vec_st(blockv, 0, (unsigned char*)block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
681 pixels+=line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
682 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
|
683 } |
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
684 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
685 POWERPC_PERF_STOP_COUNT(altivec_avg_pixels16_num, 1); |
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
|
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 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
688 /* next one assumes that ((line_size % 8) == 0) */ |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
689 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
|
690 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
691 POWERPC_PERF_DECLARE(altivec_avg_pixels8_num, 1); |
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
|
692 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
|
693 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
|
694 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
695 POWERPC_PERF_START_COUNT(altivec_avg_pixels8_num, 1); |
2967 | 696 |
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
|
697 for (i = 0; i < h; i++) { |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
698 /* 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
|
699 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
|
700 int rightside = ((unsigned long)block & 0x0000000F); |
2967 | 701 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
702 blockv = vec_ld(0, block); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
703 pixelsv1 = vec_ld(0, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
704 pixelsv2 = vec_ld(16, (unsigned char*)pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
705 pixelsv = vec_perm(pixelsv1, pixelsv2, vec_lvsl(0, pixels)); |
2967 | 706 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
707 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
708 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
|
709 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
710 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
|
711 } |
2967 | 712 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
713 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
|
714 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
715 vec_st(blockv, 0, block); |
2967 | 716 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
717 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
718 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
|
719 } |
2967 | 720 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
721 POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_num, 1); |
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
|
722 } |
1009
3b7cc8e4b83f
AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
995
diff
changeset
|
723 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
724 /* next one assumes that ((line_size % 8) == 0) */ |
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
|
725 void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
35cf2f4a0f8c
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1009
diff
changeset
|
726 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
727 POWERPC_PERF_DECLARE(altivec_put_pixels8_xy2_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
728 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
729 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
730 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
731 register vector unsigned short pixelssum1, pixelssum2, temp3; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
732 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
|
733 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
2967 | 734 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
735 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
736 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
737 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
|
738 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
739 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
740 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
741 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
|
742 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
743 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
744 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
745 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
746 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
747 pixelssum1 = vec_add(pixelssum1, vctwo); |
2967 | 748 |
749 POWERPC_PERF_START_COUNT(altivec_put_pixels8_xy2_num, 1); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
750 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
751 int rightside = ((unsigned long)block & 0x0000000F); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
752 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
|
753 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
754 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
755 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
756 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
|
757 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
|
758 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
759 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
760 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
|
761 } |
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
|
762 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
763 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
764 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
765 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
766 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
767 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
768 temp3 = vec_sra(temp3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
769 pixelssum1 = vec_add(pixelssum2, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
770 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); |
2967 | 771 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
772 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
773 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
|
774 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
775 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
|
776 } |
2967 | 777 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
778 vec_st(blockv, 0, block); |
2967 | 779 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
780 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
781 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
782 } |
2967 | 783 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
784 POWERPC_PERF_STOP_COUNT(altivec_put_pixels8_xy2_num, 1); |
995
edc10966b081
altivec jumbo patch by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents:
981
diff
changeset
|
785 } |
828
ace3ccd18dd2
Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
638
diff
changeset
|
786 |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
787 /* next one assumes that ((line_size % 8) == 0) */ |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
788 void put_no_rnd_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
789 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
790 POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels8_xy2_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
791 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
792 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
793 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
794 register vector unsigned short pixelssum1, pixelssum2, temp3; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
795 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
|
796 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
|
797 register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); |
2967 | 798 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
799 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
800 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
801 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
|
802 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
803 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
804 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
805 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
|
806 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
807 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
808 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
809 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
810 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
811 pixelssum1 = vec_add(pixelssum1, vcone); |
2967 | 812 |
813 POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); | |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
814 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
815 int rightside = ((unsigned long)block & 0x0000000F); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
816 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
|
817 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
818 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
819 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
820 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
|
821 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
|
822 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
823 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
824 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
|
825 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
826 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
827 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
828 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
829 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
830 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
831 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
832 temp3 = vec_sra(temp3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
833 pixelssum1 = vec_add(pixelssum2, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
834 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); |
2967 | 835 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
836 if (rightside) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
837 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
|
838 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
839 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
|
840 } |
2967 | 841 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
842 vec_st(blockv, 0, block); |
2967 | 843 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
844 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
845 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
846 } |
2967 | 847 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
848 POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
849 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
850 |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
851 /* next one assumes that ((line_size % 16) == 0) */ |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
852 void put_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
853 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
854 POWERPC_PERF_DECLARE(altivec_put_pixels16_xy2_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
855 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
856 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
|
857 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
858 register vector unsigned short temp3, temp4, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
859 pixelssum1, pixelssum2, pixelssum3, pixelssum4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
860 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
|
861 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
|
862 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
863 POWERPC_PERF_START_COUNT(altivec_put_pixels16_xy2_num, 1); |
2967 | 864 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
865 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
866 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
867 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
|
868 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
869 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
870 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
871 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
|
872 } |
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); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
877 pixelssum3 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
878 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
879 pixelssum3 = vec_add(pixelssum3, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
880 pixelssum1 = 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 pixelssum1 = vec_add(pixelssum1, vctwo); |
2967 | 883 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
884 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
885 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
|
886 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
887 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
888 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
889 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
|
890 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
|
891 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
892 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
893 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
|
894 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
895 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
896 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
897 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
898 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
899 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
2967 | 900 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
901 pixelssum4 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
902 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
903 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
904 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
905 temp4 = vec_add(pixelssum3, pixelssum4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
906 temp4 = vec_sra(temp4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
907 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
908 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
|
909 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
910 pixelssum3 = vec_add(pixelssum4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
911 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
|
912 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
913 blockv = vec_packsu(temp3, temp4); |
2967 | 914 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
915 vec_st(blockv, 0, block); |
2967 | 916 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
917 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
918 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
919 } |
2967 | 920 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
921 POWERPC_PERF_STOP_COUNT(altivec_put_pixels16_xy2_num, 1); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
922 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
923 |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
924 /* next one assumes that ((line_size % 16) == 0) */ |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
925 void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h) |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
926 { |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
927 POWERPC_PERF_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
928 register int i; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
929 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
|
930 register vector unsigned char blockv, temp1, temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
931 register vector unsigned short temp3, temp4, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
932 pixelssum1, pixelssum2, pixelssum3, pixelssum4; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
933 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
|
934 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
|
935 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
|
936 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
937 POWERPC_PERF_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); |
2967 | 938 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
939 temp1 = vec_ld(0, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
940 temp2 = vec_ld(16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
941 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
|
942 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
943 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
944 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
945 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
|
946 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
947 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
948 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
949 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
950 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
951 pixelssum3 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
952 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
953 pixelssum3 = vec_add(pixelssum3, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
954 pixelssum1 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
955 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
956 pixelssum1 = vec_add(pixelssum1, vcone); |
2967 | 957 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
958 for (i = 0; i < h ; i++) { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
959 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
|
960 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
961 temp1 = vec_ld(line_size, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
962 temp2 = vec_ld(line_size + 16, pixels); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
963 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
|
964 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
|
965 pixelsv2 = temp2; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
966 } else { |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
967 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
|
968 } |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
969 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
970 pixelsv3 = vec_mergel(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
971 pixelsv4 = vec_mergel(vczero, pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
972 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
973 pixelsv2 = vec_mergeh(vczero, pixelsv2); |
2967 | 974 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
975 pixelssum4 = vec_add((vector unsigned short)pixelsv3, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
976 (vector unsigned short)pixelsv4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
977 pixelssum2 = vec_add((vector unsigned short)pixelsv1, |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
978 (vector unsigned short)pixelsv2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
979 temp4 = vec_add(pixelssum3, pixelssum4); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
980 temp4 = vec_sra(temp4, vctwo); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
981 temp3 = vec_add(pixelssum1, pixelssum2); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
982 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
|
983 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
984 pixelssum3 = vec_add(pixelssum4, vcone); |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
985 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
|
986 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
987 blockv = vec_packsu(temp3, temp4); |
2967 | 988 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
989 vec_st(blockv, 0, block); |
2967 | 990 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
991 block += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
992 pixels += line_size; |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
993 } |
2967 | 994 |
1352
e8ff4783f188
1) remove TBL support in PPC performance. It's much more useful to use the
michaelni
parents:
1340
diff
changeset
|
995 POWERPC_PERF_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); |
1024
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
996 } |
9cc1031e1864
More AltiVec MC functions patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents:
1015
diff
changeset
|
997 |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
998 int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
999 POWERPC_PERF_DECLARE(altivec_hadamard8_diff8x8_num, 1); |
3554 | 1000 int sum; |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1001 register const vector unsigned char vzero = |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1002 (const vector unsigned char)vec_splat_u8(0); |
3554 | 1003 register vector signed short temp0, temp1, temp2, temp3, temp4, |
1004 temp5, temp6, temp7; | |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1005 POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1006 { |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1007 register const vector signed short vprod1 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1008 { 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
|
1009 register const vector signed short vprod2 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1010 { 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
|
1011 register const vector signed short vprod3 =(const vector signed short) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1012 { 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
|
1013 register const vector unsigned char perm1 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1014 {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1015 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
|
1016 register const vector unsigned char perm2 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1017 {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1018 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
|
1019 register const vector unsigned char perm3 = (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1020 {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1021 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
|
1022 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1023 #define ONEITERBUTTERFLY(i, res) \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1024 { \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1025 register vector unsigned char src1, src2, srcO; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1026 register vector unsigned char dst1, dst2, dstO; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1027 register vector signed short srcV, dstV; \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1028 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
|
1029 src1 = vec_ld(stride * i, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1030 src2 = vec_ld((stride * i) + 15, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1031 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
|
1032 dst1 = vec_ld(stride * i, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1033 dst2 = vec_ld((stride * i) + 15, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1034 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
|
1035 /* promote the unsigned chars to signed shorts */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1036 /* 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
|
1037 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
|
1038 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1039 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
|
1040 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1041 /* subtractions inside the first butterfly */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1042 but0 = vec_sub(srcV, dstV); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1043 op1 = vec_perm(but0, but0, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1044 but1 = vec_mladd(but0, vprod1, op1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1045 op2 = vec_perm(but1, but1, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1046 but2 = vec_mladd(but1, vprod2, op2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1047 op3 = vec_perm(but2, but2, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1048 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
|
1049 } |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1050 ONEITERBUTTERFLY(0, temp0); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1051 ONEITERBUTTERFLY(1, temp1); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1052 ONEITERBUTTERFLY(2, temp2); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1053 ONEITERBUTTERFLY(3, temp3); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1054 ONEITERBUTTERFLY(4, temp4); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1055 ONEITERBUTTERFLY(5, temp5); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1056 ONEITERBUTTERFLY(6, temp6); |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1057 ONEITERBUTTERFLY(7, temp7); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1058 } |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1059 #undef ONEITERBUTTERFLY |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1060 { |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 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
|
1066 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
|
1067 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
|
1068 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
|
1069 register vector signed short line7 = vec_sub(temp6, temp7); |
2967 | 1070 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 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
|
1077 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
|
1078 register vector signed short line7B = vec_sub(line5, line7); |
2967 | 1079 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 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
|
1087 register vector signed short line7C = vec_sub(line3B, line7B); |
2967 | 1088 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1089 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
|
1090 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
|
1091 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
|
1092 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
|
1093 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
|
1094 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
|
1095 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
|
1096 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
|
1097 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
|
1098 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
|
1099 vec_ste(vsum, 0, &sum); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1100 } |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1101 POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff8x8_num, 1); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1102 return sum; |
1949
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1103 } |
66215baae7b9
hadamard8_diff8x8 in AltiVec, the 16bits edition by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1839
diff
changeset
|
1104 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1105 /* |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1106 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
|
1107 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
|
1108 inside hadamard8_diff16_altivec. |
2967 | 1109 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 700+ cycles to 550). |
2967 | 1115 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1116 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
|
1117 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
|
1118 instructions...) |
2967 | 1119 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1120 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
|
1121 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
|
1122 */ |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1123 |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1124 static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) { |
3554 | 1125 int sum; |
1126 register vector signed short | |
1127 temp0 REG_v(v0), | |
1128 temp1 REG_v(v1), | |
1129 temp2 REG_v(v2), | |
1130 temp3 REG_v(v3), | |
1131 temp4 REG_v(v4), | |
1132 temp5 REG_v(v5), | |
1133 temp6 REG_v(v6), | |
1134 temp7 REG_v(v7); | |
1135 register vector signed short | |
1136 temp0S REG_v(v8), | |
1137 temp1S REG_v(v9), | |
1138 temp2S REG_v(v10), | |
1139 temp3S REG_v(v11), | |
1140 temp4S REG_v(v12), | |
1141 temp5S REG_v(v13), | |
1142 temp6S REG_v(v14), | |
1143 temp7S REG_v(v15); | |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1144 register const vector unsigned char vzero REG_v(v31)= |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1145 (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
|
1146 { |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1147 register const vector signed short vprod1 REG_v(v16)= |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1148 (const vector signed short){ 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
|
1149 register const vector signed short vprod2 REG_v(v17)= |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1150 (const vector signed short){ 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
|
1151 register const vector signed short vprod3 REG_v(v18)= |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1152 (const vector signed short){ 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
|
1153 register const vector unsigned char perm1 REG_v(v19)= |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1154 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1155 {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1156 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
|
1157 register const vector unsigned char perm2 REG_v(v20)= |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1158 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1159 {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1160 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
|
1161 register const vector unsigned char perm3 REG_v(v21)= |
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1162 (const vector unsigned char) |
7373
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1163 {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, |
266d4949aa15
Remove AltiVec vector declaration compiler compatibility macros.
diego
parents:
7335
diff
changeset
|
1164 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; |
1980 | 1165 |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1166 #define ONEITERBUTTERFLY(i, res1, res2) \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1167 { \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1168 register vector unsigned char src1 REG_v(v22), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1169 src2 REG_v(v23), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1170 dst1 REG_v(v24), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1171 dst2 REG_v(v25), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1172 srcO REG_v(v22), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1173 dstO REG_v(v23); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1174 \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1175 register vector signed short srcV REG_v(v24), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1176 dstV REG_v(v25), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1177 srcW REG_v(v26), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1178 dstW REG_v(v27), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1179 but0 REG_v(v28), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1180 but0S REG_v(v29), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1181 op1 REG_v(v30), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1182 but1 REG_v(v22), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1183 op1S REG_v(v23), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1184 but1S REG_v(v24), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1185 op2 REG_v(v25), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1186 but2 REG_v(v26), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1187 op2S REG_v(v27), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1188 but2S REG_v(v28), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1189 op3 REG_v(v29), \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1190 op3S REG_v(v30); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1191 \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1192 src1 = vec_ld(stride * i, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1193 src2 = vec_ld((stride * i) + 16, src); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1194 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
|
1195 dst1 = vec_ld(stride * i, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1196 dst2 = vec_ld((stride * i) + 16, dst); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1197 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
|
1198 /* promote the unsigned chars to signed shorts */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1199 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
|
1200 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1201 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
|
1202 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1203 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
|
1204 (vector signed char)srcO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1205 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
|
1206 (vector signed char)dstO); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1207 /* subtractions inside the first butterfly */ \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1208 but0 = vec_sub(srcV, dstV); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1209 but0S = vec_sub(srcW, dstW); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1210 op1 = vec_perm(but0, but0, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1211 but1 = vec_mladd(but0, vprod1, op1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1212 op1S = vec_perm(but0S, but0S, perm1); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1213 but1S = vec_mladd(but0S, vprod1, op1S); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1214 op2 = vec_perm(but1, but1, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1215 but2 = vec_mladd(but1, vprod2, op2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1216 op2S = vec_perm(but1S, but1S, perm2); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1217 but2S = vec_mladd(but1S, vprod2, op2S); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1218 op3 = vec_perm(but2, but2, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1219 res1 = vec_mladd(but2, vprod3, op3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1220 op3S = vec_perm(but2S, but2S, perm3); \ |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1221 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
|
1222 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 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
|
1230 ONEITERBUTTERFLY(7, temp7, temp7S); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1231 } |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1232 #undef ONEITERBUTTERFLY |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1233 { |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1234 register vector signed int vsum; |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1235 register vector signed short line0S, line1S, line2S, line3S, line4S, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1236 line5S, line6S, line7S, line0BS,line2BS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1237 line1BS,line3BS,line4BS,line6BS,line5BS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1238 line7BS,line0CS,line4CS,line1CS,line5CS, |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1239 line2CS,line6CS,line3CS,line7CS; |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1240 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1241 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
|
1242 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
|
1243 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
|
1244 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
|
1245 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
|
1246 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
|
1247 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
|
1248 register vector signed short line7 = vec_sub(temp6, temp7); |
2967 | 1249 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1250 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
|
1251 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
|
1252 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
|
1253 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
|
1254 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
|
1255 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
|
1256 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
|
1257 register vector signed short line7B = vec_sub(line5, line7); |
2967 | 1258 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1259 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
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 register vector signed short line7C = vec_sub(line3B, line7B); |
2967 | 1267 |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 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
|
1273 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
|
1274 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
|
1275 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
|
1276 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1277 line0S = vec_add(temp0S, temp1S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1278 line1S = vec_sub(temp0S, temp1S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1279 line2S = vec_add(temp2S, temp3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1280 line3S = vec_sub(temp2S, temp3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1281 line4S = vec_add(temp4S, temp5S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1282 line5S = vec_sub(temp4S, temp5S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1283 line6S = vec_add(temp6S, temp7S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1284 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
|
1285 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1286 line0BS = vec_add(line0S, line2S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1287 line2BS = vec_sub(line0S, line2S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1288 line1BS = vec_add(line1S, line3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1289 line3BS = vec_sub(line1S, line3S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1290 line4BS = vec_add(line4S, line6S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1291 line6BS = vec_sub(line4S, line6S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1292 line5BS = vec_add(line5S, line7S); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1293 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
|
1294 |
3346
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1295 line0CS = vec_add(line0BS, line4BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1296 line4CS = vec_sub(line0BS, line4BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1297 line1CS = vec_add(line1BS, line5BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1298 line5CS = vec_sub(line1BS, line5BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1299 line2CS = vec_add(line2BS, line6BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1300 line6CS = vec_sub(line2BS, line6BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1301 line3CS = vec_add(line3BS, line7BS); |
052765f11f1c
Cosmetics: should not hurt performance, scream if are
lu_zero
parents:
3252
diff
changeset
|
1302 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
|
1303 |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1304 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
|
1305 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
|
1306 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
|
1307 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
|
1308 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
|
1309 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
|
1310 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
|
1311 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
|
1312 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
|
1313 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
|
1314 vec_ste(vsum, 0, &sum); |
7335
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1315 } |
d463d8ee7755
cosmetics: Make libavcodec/ppc/dsputil_altivec.c conform to style guidelines.
diego
parents:
6763
diff
changeset
|
1316 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
|
1317 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1318 |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1319 int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1320 POWERPC_PERF_DECLARE(altivec_hadamard8_diff16_num, 1); |
3554 | 1321 int score; |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1322 POWERPC_PERF_START_COUNT(altivec_hadamard8_diff16_num, 1); |
3554 | 1323 score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8); |
1324 if (h==16) { | |
1325 dst += 8*stride; | |
1326 src += 8*stride; | |
1327 score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8); | |
1328 } | |
1951
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1329 POWERPC_PERF_STOP_COUNT(altivec_hadamard8_diff16_num, 1); |
3554 | 1330 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
|
1331 } |
2599b8444831
better hadamard8_diff16 in AltiVec, and more patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents:
1949
diff
changeset
|
1332 |
3543 | 1333 static void vorbis_inverse_coupling_altivec(float *mag, float *ang, |
1334 int blocksize) | |
1335 { | |
1336 int i; | |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1337 vector float m, a; |
3543 | 1338 vector bool int t0, t1; |
1339 const vector unsigned int v_31 = //XXX | |
1340 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
|
1341 for (i = 0; i < blocksize; i += 4) { |
3543 | 1342 m = vec_ld(0, mag+i); |
1343 a = vec_ld(0, ang+i); | |
1344 t0 = vec_cmple(m, (vector float)vec_splat_u32(0)); | |
1345 t1 = vec_cmple(a, (vector float)vec_splat_u32(0)); | |
3545 | 1346 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
|
1347 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
|
1348 t1 = (vector bool int)vec_andc(a, t1); |
3550 | 1349 a = vec_sub(m, (vector float)t1); |
1350 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
|
1351 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
|
1352 vec_stl(m, 0, mag+i); |
3543 | 1353 } |
1354 } | |
1355 | |
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
|
1356 /* next one assumes that ((line_size % 8) == 0) */ |
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
|
1357 void avg_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) |
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
|
1358 { |
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 POWERPC_PERF_DECLARE(altivec_avg_pixels8_xy2_num, 1); |
3554 | 1360 register int i; |
1361 register vector unsigned char pixelsv1, pixelsv2, pixelsavg; | |
1362 register vector unsigned char blockv, temp1, temp2, blocktemp; | |
1363 register vector unsigned short pixelssum1, pixelssum2, temp3; | |
1364 | |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1365 register const vector unsigned char vczero = (const vector unsigned char) |
3554 | 1366 vec_splat_u8(0); |
5746
55ed6dc5d476
Remove const vector macro indirection that is useless and obfuscating
diego
parents:
5609
diff
changeset
|
1367 register const vector unsigned short vctwo = (const vector unsigned short) |
3554 | 1368 vec_splat_u16(2); |
2967 | 1369 |
3554 | 1370 temp1 = vec_ld(0, pixels); |
1371 temp2 = vec_ld(16, pixels); | |
1372 pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); | |
1373 if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { | |
1374 pixelsv2 = temp2; | |
1375 } else { | |
1376 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); | |
1377 } | |
1378 pixelsv1 = vec_mergeh(vczero, pixelsv1); | |
1379 pixelsv2 = vec_mergeh(vczero, pixelsv2); | |
1380 pixelssum1 = vec_add((vector unsigned short)pixelsv1, | |
1381 (vector unsigned short)pixelsv2); | |
1382 pixelssum1 = vec_add(pixelssum1, vctwo); | |
2967 | 1383 |
1384 POWERPC_PERF_START_COUNT(altivec_avg_pixels8_xy2_num, 1); | |
3554 | 1385 for (i = 0; i < h ; i++) { |
1386 int rightside = ((unsigned long)block & 0x0000000F); | |
1387 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
|
1388 |
3554 | 1389 temp1 = vec_ld(line_size, pixels); |
1390 temp2 = vec_ld(line_size + 16, pixels); | |
1391 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
|
1392 if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { |
3554 | 1393 pixelsv2 = temp2; |
1394 } else { | |
1395 pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); | |
1396 } | |
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
|
1397 |
3554 | 1398 pixelsv1 = vec_mergeh(vczero, pixelsv1); |
1399 pixelsv2 = vec_mergeh(vczero, pixelsv2); | |
1400 pixelssum2 = vec_add((vector unsigned short)pixelsv1, | |
1401 (vector unsigned short)pixelsv2); | |
1402 temp3 = vec_add(pixelssum1, pixelssum2); | |
1403 temp3 = vec_sra(temp3, vctwo); | |
1404 pixelssum1 = vec_add(pixelssum2, vctwo); | |
1405 pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); | |
2967 | 1406 |
3554 | 1407 if (rightside) { |
1408 blocktemp = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); | |
1409 } else { | |
1410 blocktemp = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); | |
1411 } | |
2967 | 1412 |
3554 | 1413 blockv = vec_avg(blocktemp, blockv); |
1414 vec_st(blockv, 0, block); | |
2967 | 1415 |
3554 | 1416 block += line_size; |
1417 pixels += line_size; | |
1418 } | |
2967 | 1419 |
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
|
1420 POWERPC_PERF_STOP_COUNT(altivec_avg_pixels8_xy2_num, 1); |
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
|
1421 } |
3546
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1422 |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1423 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
|
1424 { |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 c->sad[0]= sad16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1431 c->sad[1]= sad8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1432 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
|
1433 c->sse[1]= sse8_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1434 c->sse[0]= sse16_altivec; |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1435 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
|
1436 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
|
1437 c->get_pixels = get_pixels_altivec; |
8307 | 1438 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
|
1439 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
|
1440 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
|
1441 /* 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
|
1442 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
|
1443 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
|
1444 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
|
1445 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
|
1446 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
|
1447 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
|
1448 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
|
1449 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
|
1450 |
5f97ba9a4eaa
Almost cosmetic changes in dsputil_init_ppc and vorbis_inverse_coupling_altivec:
lu_zero
parents:
3545
diff
changeset
|
1451 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
|
1452 c->hadamard8_diff[1] = hadamard8_diff8x8_altivec; |
5752
af20477e9994
Replace CONFIG_VORBIS_DECODER #ifdef by if (ENABLE_VORBIS_DECODER).
diego
parents:
5750
diff
changeset
|
1453 if (ENABLE_VORBIS_DECODER) |
5753 | 1454 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
|
1455 } |