Revision 5137235e

View differences:

libavcodec/ppc/dsputil_altivec.c
20 20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 21
 */
22 22

  
23
#include "config.h"
24
#if HAVE_ALTIVEC_H
25
#include <altivec.h>
26
#endif
23 27
#include "libavcodec/dsputil.h"
24

  
25
#include "gcc_fixes.h"
26

  
27 28
#include "dsputil_ppc.h"
28 29
#include "util_altivec.h"
29 30
#include "types_altivec.h"
......
1124 1125
static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
1125 1126
    int sum;
1126 1127
    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);
1128
        temp0 __asm__ ("v0"),
1129
        temp1 __asm__ ("v1"),
1130
        temp2 __asm__ ("v2"),
1131
        temp3 __asm__ ("v3"),
1132
        temp4 __asm__ ("v4"),
1133
        temp5 __asm__ ("v5"),
1134
        temp6 __asm__ ("v6"),
1135
        temp7 __asm__ ("v7");
1135 1136
    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);
1144
    register const vector unsigned char vzero REG_v(v31)=
1137
        temp0S __asm__ ("v8"),
1138
        temp1S __asm__ ("v9"),
1139
        temp2S __asm__ ("v10"),
1140
        temp3S __asm__ ("v11"),
1141
        temp4S __asm__ ("v12"),
1142
        temp5S __asm__ ("v13"),
1143
        temp6S __asm__ ("v14"),
1144
        temp7S __asm__ ("v15");
1145
    register const vector unsigned char vzero __asm__ ("v31") =
1145 1146
        (const vector unsigned char)vec_splat_u8(0);
1146 1147
    {
1147
    register const vector signed short vprod1 REG_v(v16)=
1148
    register const vector signed short vprod1 __asm__ ("v16") =
1148 1149
        (const vector signed short){ 1,-1, 1,-1, 1,-1, 1,-1 };
1149
    register const vector signed short vprod2 REG_v(v17)=
1150
    register const vector signed short vprod2 __asm__ ("v17") =
1150 1151
        (const vector signed short){ 1, 1,-1,-1, 1, 1,-1,-1 };
1151
    register const vector signed short vprod3 REG_v(v18)=
1152
    register const vector signed short vprod3 __asm__ ("v18") =
1152 1153
        (const vector signed short){ 1, 1, 1, 1,-1,-1,-1,-1 };
1153
    register const vector unsigned char perm1 REG_v(v19)=
1154
    register const vector unsigned char perm1 __asm__ ("v19") =
1154 1155
        (const vector unsigned char)
1155 1156
        {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
1156 1157
         0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D};
1157
    register const vector unsigned char perm2 REG_v(v20)=
1158
    register const vector unsigned char perm2 __asm__ ("v20") =
1158 1159
        (const vector unsigned char)
1159 1160
        {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
1160 1161
         0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B};
1161
    register const vector unsigned char perm3 REG_v(v21)=
1162
    register const vector unsigned char perm3 __asm__ ("v21") =
1162 1163
        (const vector unsigned char)
1163 1164
        {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
1164 1165
         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
1165 1166

  
1166
#define ONEITERBUTTERFLY(i, res1, res2)                                   \
1167
    {                                                                     \
1168
    register vector unsigned char src1 REG_v(v22),                    \
1169
                                  src2 REG_v(v23),                    \
1170
                                  dst1 REG_v(v24),                    \
1171
                                  dst2 REG_v(v25),                    \
1172
                                  srcO REG_v(v22),                    \
1173
                                  dstO REG_v(v23);                    \
1167
#define ONEITERBUTTERFLY(i, res1, res2)                               \
1168
    {                                                                 \
1169
    register vector unsigned char src1 __asm__ ("v22"),               \
1170
                                  src2 __asm__ ("v23"),               \
1171
                                  dst1 __asm__ ("v24"),               \
1172
                                  dst2 __asm__ ("v25"),               \
1173
                                  srcO __asm__ ("v22"),               \
1174
                                  dstO __asm__ ("v23");               \
1174 1175
                                                                      \
1175
    register vector signed short  srcV REG_v(v24),                    \
1176
                                  dstV REG_v(v25),                    \
1177
                                  srcW REG_v(v26),                    \
1178
                                  dstW REG_v(v27),                    \
1179
                                  but0 REG_v(v28),                    \
1180
                                  but0S REG_v(v29),                   \
1181
                                  op1 REG_v(v30),                     \
1182
                                  but1 REG_v(v22),                    \
1183
                                  op1S REG_v(v23),                    \
1184
                                  but1S REG_v(v24),                   \
1185
                                  op2 REG_v(v25),                     \
1186
                                  but2 REG_v(v26),                    \
1187
                                  op2S REG_v(v27),                    \
1188
                                  but2S REG_v(v28),                   \
1189
                                  op3 REG_v(v29),                     \
1190
                                  op3S REG_v(v30);                    \
1176
    register vector signed short  srcV  __asm__ ("v24"),              \
1177
                                  dstV  __asm__ ("v25"),              \
1178
                                  srcW  __asm__ ("v26"),              \
1179
                                  dstW  __asm__ ("v27"),              \
1180
                                  but0  __asm__ ("v28"),              \
1181
                                  but0S __asm__ ("v29"),              \
1182
                                  op1   __asm__ ("v30"),              \
1183
                                  but1  __asm__ ("v22"),              \
1184
                                  op1S  __asm__ ("v23"),              \
1185
                                  but1S __asm__ ("v24"),              \
1186
                                  op2   __asm__ ("v25"),              \
1187
                                  but2  __asm__ ("v26"),              \
1188
                                  op2S  __asm__ ("v27"),              \
1189
                                  but2S __asm__ ("v28"),              \
1190
                                  op3   __asm__ ("v29"),              \
1191
                                  op3S  __asm__ ("v30");              \
1191 1192
                                                                      \
1192 1193
    src1 = vec_ld(stride * i, src);                                   \
1193 1194
    src2 = vec_ld((stride * i) + 16, src);                            \
libavcodec/ppc/fdct_altivec.c
18 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 19
 */
20 20

  
21

  
21
#include "config.h"
22
#if HAVE_ALTIVEC_H
23
#include <altivec.h>
24
#endif
22 25
#include "libavutil/common.h"
23 26
#include "libavcodec/dsputil.h"
24 27
#include "dsputil_ppc.h"
25
#include "gcc_fixes.h"
26 28

  
27 29

  
28 30
#define vs16(v) ((vector signed short)(v))
libavcodec/ppc/float_altivec.c
20 20

  
21 21
#include "libavcodec/dsputil.h"
22 22

  
23
#include "gcc_fixes.h"
24

  
25 23
#include "dsputil_altivec.h"
26 24
#include "util_altivec.h"
27 25

  
libavcodec/ppc/gcc_fixes.h
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 AVCODEC_PPC_GCC_FIXES_H
24
#define AVCODEC_PPC_GCC_FIXES_H
25

  
26
#include "config.h"
27

  
28
#if HAVE_ALTIVEC_H
29
#include <altivec.h>
30
#endif
31

  
32
#if (__GNUC__ < 4)
33
# define REG_v(a)
34
#else
35
# define REG_v(a) __asm__ ( #a )
36
#endif
37

  
38
#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
39

  
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
static inline vector signed char ff_vmrglb (vector signed char const A,
49
                                          vector signed char const B)
50
{
51
    static const vector unsigned char lowbyte = {
52
        0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b,  0x1b,
53
        0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
54
    };
55
    return vec_perm (A, B, lowbyte);
56
}
57

  
58
static inline vector signed short ff_vmrglh (vector signed short const A,
59
                                          vector signed short const B)
60
{
61
    static const vector unsigned char lowhalf = {
62
        0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
63
        0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
64
    };
65
    return vec_perm (A, B, lowhalf);
66
}
67

  
68
static inline vector signed int ff_vmrglw (vector signed int const A,
69
                                          vector signed int const B)
70
{
71
    static const vector unsigned char lowword = {
72
        0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
73
        0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
74
    };
75
    return vec_perm (A, B, lowword);
76
}
77
/*#define ff_vmrglb ff_vmrglb
78
#define ff_vmrglh ff_vmrglh
79
#define ff_vmrglw ff_vmrglw
80
*/
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
      ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
86
__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
87
      ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
88
__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
89
      ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
90
__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
91
      ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
92
__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
93
      ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
94
__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
95
      ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
96
__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
97
      ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
98
    __altivec_link_error_invalid_argument ())))))))
99

  
100
#endif /* (__GNUC__ == 3 && __GNUC_MINOR__ < 3) */
101

  
102
#endif /* AVCODEC_PPC_GCC_FIXES_H */
libavcodec/ppc/h264_altivec.c
21 21
#include "libavcodec/dsputil.h"
22 22
#include "libavcodec/h264data.h"
23 23

  
24
#include "gcc_fixes.h"
25

  
26 24
#include "dsputil_ppc.h"
27 25
#include "dsputil_altivec.h"
28 26
#include "util_altivec.h"
libavcodec/ppc/idct_altivec.c
37 37

  
38 38
#include <stdlib.h>                                      /* malloc(), free() */
39 39
#include <string.h>
40
#include "config.h"
41
#if HAVE_ALTIVEC_H
42
#include <altivec.h>
43
#endif
40 44
#include "libavcodec/dsputil.h"
41

  
42
#include "gcc_fixes.h"
43 45
#include "types_altivec.h"
44 46
#include "dsputil_ppc.h"
45 47

  
libavcodec/ppc/mpegvideo_altivec.c
26 26
#include "libavcodec/dsputil.h"
27 27
#include "libavcodec/mpegvideo.h"
28 28

  
29
#include "gcc_fixes.h"
30

  
31 29
#include "dsputil_ppc.h"
32 30
#include "util_altivec.h"
33 31
// Swaps two variables (used for altivec registers)

Also available in: Unified diff