Statistics
| Branch: | Revision:

ffmpeg / libavcodec / ppc / gcc_fixes.h @ 20646267

History | View | Annotate | Download (3.04 KB)

1 a9a07762 Michael Niedermayer
/*
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
7
#ifndef _GCC_FIXES_
8
#define _GCC_FIXES_
9
10
#ifdef HAVE_ALTIVEC_H
11
#include <altivec.h>
12
#endif
13
14
#ifdef CONFIG_DARWIN
15 aab34ca0 Michael Niedermayer
# ifndef __MWERKS__
16
#  define AVV(x...) (x)
17
# else
18
#  define AVV
19
# endif
20 a9a07762 Michael Niedermayer
#else
21
#define AVV(x...) {x}
22
#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)  
23
24
/* This code was provided to me by Bartosch Pixa
25
 * as a separate header file (broken_mergel.h).
26
 * thanks to lu_zero for the workaround.
27
 *
28
 * See this mail for more information:
29
 * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
30
 */
31
32 782b80d9 Michael Niedermayer
static inline vector signed char ff_vmrglb (vector signed char const A,
33 a9a07762 Michael Niedermayer
                                          vector signed char const B)
34
{
35
    static const vector unsigned char lowbyte = {
36
        0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b,  0x1b,
37
        0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
38
    };
39
    return vec_perm (A, B, lowbyte);
40
}
41
42 782b80d9 Michael Niedermayer
static inline vector signed short ff_vmrglh (vector signed short const A,
43 a9a07762 Michael Niedermayer
                                          vector signed short const B)
44
{
45
    static const vector unsigned char lowhalf = {
46
            0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
47
        0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
48
    };
49
    return vec_perm (A, B, lowhalf);
50
}
51
52 782b80d9 Michael Niedermayer
static inline vector signed int ff_vmrglw (vector signed int const A,
53 a9a07762 Michael Niedermayer
                                          vector signed int const B)
54
{
55
    static const vector unsigned char lowword = {
56
            0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
57
        0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
58
    };
59
    return vec_perm (A, B, lowword);
60
}
61 782b80d9 Michael Niedermayer
/*#define ff_vmrglb ff_vmrglb 
62
#define ff_vmrglh ff_vmrglh 
63
#define ff_vmrglw ff_vmrglw 
64 a9a07762 Michael Niedermayer
*/
65
#undef vec_mergel
66
67
#define vec_mergel(a1, a2) \
68
__ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
69 782b80d9 Michael Niedermayer
      ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
70 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
71 782b80d9 Michael Niedermayer
      ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
72 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
73 782b80d9 Michael Niedermayer
      ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
74 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
75 782b80d9 Michael Niedermayer
      ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
76 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
77 782b80d9 Michael Niedermayer
      ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
78 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
79 782b80d9 Michael Niedermayer
      ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
80 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
81 782b80d9 Michael Niedermayer
      ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
82 a9a07762 Michael Niedermayer
    __altivec_link_error_invalid_argument ())))))))
83
84
#endif
85
86
#endif /* CONFIG_DARWIN */
87
88 aab34ca0 Michael Niedermayer
#ifndef __MWERKS__
89
#define const_vector const vector
90
#else
91
#define const_vector vector
92
#endif
93
94 a9a07762 Michael Niedermayer
#endif /* _GCC_FIXES_ */