|
808
|
1 /*
|
|
|
2 * gcc fixes for altivec.
|
|
|
3 * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
|
|
|
4 * and to stay somewhat compatible with Darwin.
|
|
|
5 *
|
|
|
6 * This file is part of FFmpeg.
|
|
|
7 *
|
|
|
8 * FFmpeg is free software; you can redistribute it and/or
|
|
|
9 * modify it under the terms of the GNU Lesser General Public
|
|
|
10 * License as published by the Free Software Foundation; either
|
|
|
11 * version 2.1 of the License, or (at your option) any later version.
|
|
|
12 *
|
|
|
13 * FFmpeg is distributed in the hope that it will be useful,
|
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
16 * Lesser General Public License for more details.
|
|
|
17 *
|
|
|
18 * You should have received a copy of the GNU Lesser General Public
|
|
|
19 * License along with FFmpeg; if not, write to the Free Software
|
|
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
21 */
|
|
|
22
|
|
|
23 #ifndef _GCC_FIXES_
|
|
|
24 #define _GCC_FIXES_
|
|
|
25
|
|
|
26 #ifdef HAVE_ALTIVEC_H
|
|
|
27 #include <altivec.h>
|
|
|
28 #endif
|
|
|
29
|
|
|
30 #ifdef CONFIG_DARWIN
|
|
|
31 # ifndef __MWERKS__
|
|
|
32 # define AVV(x...) (x)
|
|
|
33 # else
|
|
|
34 # define AVV
|
|
|
35 # endif
|
|
|
36 #define REG_v(a) asm ( #a )
|
|
|
37 #else
|
|
|
38
|
|
|
39 #define AVV(x...) {x}
|
|
|
40
|
|
|
41 #if (__GNUC__ < 4)
|
|
|
42 # define REG_v(a)
|
|
|
43 #else
|
|
|
44 # define REG_v(a) asm ( #a )
|
|
|
45 #endif
|
|
|
46
|
|
|
47 #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
|
|
|
48
|
|
|
49 /* This code was provided to me by Bartosch Pixa
|
|
|
50 * as a separate header file (broken_mergel.h).
|
|
|
51 * thanks to lu_zero for the workaround.
|
|
|
52 *
|
|
|
53 * See this mail for more information:
|
|
|
54 * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
|
|
|
55 */
|
|
|
56
|
|
|
57 static inline vector signed char ff_vmrglb (vector signed char const A,
|
|
|
58 vector signed char const B)
|
|
|
59 {
|
|
|
60 static const vector unsigned char lowbyte = {
|
|
|
61 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
|
|
|
62 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
|
|
|
63 };
|
|
|
64 return vec_perm (A, B, lowbyte);
|
|
|
65 }
|
|
|
66
|
|
|
67 static inline vector signed short ff_vmrglh (vector signed short const A,
|
|
|
68 vector signed short const B)
|
|
|
69 {
|
|
|
70 static const vector unsigned char lowhalf = {
|
|
|
71 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
|
|
|
72 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
|
|
|
73 };
|
|
|
74 return vec_perm (A, B, lowhalf);
|
|
|
75 }
|
|
|
76
|
|
|
77 static inline vector signed int ff_vmrglw (vector signed int const A,
|
|
|
78 vector signed int const B)
|
|
|
79 {
|
|
|
80 static const vector unsigned char lowword = {
|
|
|
81 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
|
|
|
82 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
|
|
|
83 };
|
|
|
84 return vec_perm (A, B, lowword);
|
|
|
85 }
|
|
|
86 /*#define ff_vmrglb ff_vmrglb
|
|
|
87 #define ff_vmrglh ff_vmrglh
|
|
|
88 #define ff_vmrglw ff_vmrglw
|
|
|
89 */
|
|
|
90 #undef vec_mergel
|
|
|
91
|
|
|
92 #define vec_mergel(a1, a2) \
|
|
|
93 __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
|
|
|
94 ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
|
|
|
95 __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
|
|
|
96 ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
|
|
|
97 __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
|
|
|
98 ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
|
|
|
99 __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
|
|
|
100 ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
|
|
|
101 __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
|
|
|
102 ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
|
|
103 __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
|
|
|
104 ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
|
|
105 __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
|
|
|
106 ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
|
|
107 __altivec_link_error_invalid_argument ())))))))
|
|
|
108
|
|
|
109 #endif
|
|
|
110
|
|
|
111 #endif /* CONFIG_DARWIN */
|
|
|
112
|
|
|
113 #ifndef __MWERKS__
|
|
|
114 #define const_vector const vector
|
|
|
115 #else
|
|
|
116 #define const_vector vector
|
|
|
117 #endif
|
|
|
118
|
|
|
119 #endif /* _GCC_FIXES_ */
|