Statistics
| Branch: | Revision:

ffmpeg / libavcodec / ppc / gcc_fixes.h @ be449fca

History | View | Annotate | Download (3.85 KB)

1 a9a07762 Michael Niedermayer
/*
2
 * gcc fixes for altivec.
3 115329f1 Diego Biurrun
 * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
4 a9a07762 Michael Niedermayer
 * and to stay somewhat compatible with Darwin.
5 04d7f601 Diego Biurrun
 *
6 b78e7197 Diego Biurrun
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9 04d7f601 Diego Biurrun
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11 b78e7197 Diego Biurrun
 * version 2.1 of the License, or (at your option) any later version.
12 04d7f601 Diego Biurrun
 *
13 b78e7197 Diego Biurrun
 * FFmpeg is distributed in the hope that it will be useful,
14 04d7f601 Diego Biurrun
 * 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 b78e7197 Diego Biurrun
 * License along with FFmpeg; if not, write to the Free Software
20 04d7f601 Diego Biurrun
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 a9a07762 Michael Niedermayer
 */
22
23 98790382 Stefano Sabatini
#ifndef AVCODEC_PPC_GCC_FIXES_H
24
#define AVCODEC_PPC_GCC_FIXES_H
25 a9a07762 Michael Niedermayer
26 35562dc9 Diego Biurrun
#include "config.h"
27
28 a9a07762 Michael Niedermayer
#ifdef HAVE_ALTIVEC_H
29
#include <altivec.h>
30
#endif
31
32 a01e08ee Luca Barbato
#if (__GNUC__ < 4)
33
# define REG_v(a)
34 fd925db3 Luca Barbato
#else
35 be449fca Diego Pettenò
# define REG_v(a) __asm__ ( #a )
36 a01e08ee Luca Barbato
#endif
37
38 61dbf4e5 Diego Biurrun
#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
39 a9a07762 Michael Niedermayer
40
/* This code was provided to me by Bartosch Pixa
41
 * as a separate header file (broken_mergel.h).
42
 * thanks to lu_zero for the workaround.
43
 *
44
 * See this mail for more information:
45
 * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
46
 */
47
48 782b80d9 Michael Niedermayer
static inline vector signed char ff_vmrglb (vector signed char const A,
49 bb270c08 Diego Biurrun
                                          vector signed char const B)
50 a9a07762 Michael Niedermayer
{
51
    static const vector unsigned char lowbyte = {
52 bb270c08 Diego Biurrun
        0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b,  0x1b,
53
        0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
54 a9a07762 Michael Niedermayer
    };
55
    return vec_perm (A, B, lowbyte);
56
}
57
58 782b80d9 Michael Niedermayer
static inline vector signed short ff_vmrglh (vector signed short const A,
59 bb270c08 Diego Biurrun
                                          vector signed short const B)
60 a9a07762 Michael Niedermayer
{
61
    static const vector unsigned char lowhalf = {
62 bb270c08 Diego Biurrun
        0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
63
        0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
64 a9a07762 Michael Niedermayer
    };
65
    return vec_perm (A, B, lowhalf);
66
}
67
68 782b80d9 Michael Niedermayer
static inline vector signed int ff_vmrglw (vector signed int const A,
69 bb270c08 Diego Biurrun
                                          vector signed int const B)
70 a9a07762 Michael Niedermayer
{
71
    static const vector unsigned char lowword = {
72 bb270c08 Diego Biurrun
        0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
73
        0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
74 a9a07762 Michael Niedermayer
    };
75
    return vec_perm (A, B, lowword);
76
}
77 115329f1 Diego Biurrun
/*#define ff_vmrglb ff_vmrglb
78
#define ff_vmrglh ff_vmrglh
79
#define ff_vmrglw ff_vmrglw
80 a9a07762 Michael Niedermayer
*/
81
#undef vec_mergel
82
83
#define vec_mergel(a1, a2) \
84
__ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
85 782b80d9 Michael Niedermayer
      ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
86 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
87 782b80d9 Michael Niedermayer
      ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
88 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
89 782b80d9 Michael Niedermayer
      ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
90 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
91 782b80d9 Michael Niedermayer
      ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
92 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
93 782b80d9 Michael Niedermayer
      ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
94 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
95 782b80d9 Michael Niedermayer
      ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
96 a9a07762 Michael Niedermayer
__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
97 782b80d9 Michael Niedermayer
      ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
98 a9a07762 Michael Niedermayer
    __altivec_link_error_invalid_argument ())))))))
99
100 61dbf4e5 Diego Biurrun
#endif /* (__GNUC__ == 3 && __GNUC_MINOR__ < 3) */
101 a9a07762 Michael Niedermayer
102 98790382 Stefano Sabatini
#endif /* AVCODEC_PPC_GCC_FIXES_H */