• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/ppc/gcc_fixes.h

Go to the documentation of this file.
00001 /*
00002  * gcc fixes for altivec.
00003  * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
00004  * and to stay somewhat compatible with Darwin.
00005  *
00006  * This file is part of FFmpeg.
00007  *
00008  * FFmpeg is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * FFmpeg is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with FFmpeg; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 #ifndef AVCODEC_PPC_GCC_FIXES_H
00024 #define AVCODEC_PPC_GCC_FIXES_H
00025 
00026 #include "config.h"
00027 
00028 #if HAVE_ALTIVEC_H
00029 #include <altivec.h>
00030 #endif
00031 
00032 #if (__GNUC__ < 4)
00033 # define REG_v(a)
00034 #else
00035 # define REG_v(a) __asm__ ( #a )
00036 #endif
00037 
00038 #if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
00039 
00040 /* This code was provided to me by Bartosch Pixa
00041  * as a separate header file (broken_mergel.h).
00042  * thanks to lu_zero for the workaround.
00043  *
00044  * See this mail for more information:
00045  * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
00046  */
00047 
00048 static inline vector signed char ff_vmrglb (vector signed char const A,
00049                                           vector signed char const B)
00050 {
00051     static const vector unsigned char lowbyte = {
00052         0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b,  0x1b,
00053         0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
00054     };
00055     return vec_perm (A, B, lowbyte);
00056 }
00057 
00058 static inline vector signed short ff_vmrglh (vector signed short const A,
00059                                           vector signed short const B)
00060 {
00061     static const vector unsigned char lowhalf = {
00062         0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
00063         0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
00064     };
00065     return vec_perm (A, B, lowhalf);
00066 }
00067 
00068 static inline vector signed int ff_vmrglw (vector signed int const A,
00069                                           vector signed int const B)
00070 {
00071     static const vector unsigned char lowword = {
00072         0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
00073         0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
00074     };
00075     return vec_perm (A, B, lowword);
00076 }
00077 /*#define ff_vmrglb ff_vmrglb
00078 #define ff_vmrglh ff_vmrglh
00079 #define ff_vmrglw ff_vmrglw
00080 */
00081 #undef vec_mergel
00082 
00083 #define vec_mergel(a1, a2) \
00084 __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
00085       ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
00086 __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
00087       ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
00088 __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
00089       ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
00090 __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
00091       ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
00092 __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
00093       ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
00094 __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
00095       ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
00096 __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
00097       ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
00098     __altivec_link_error_invalid_argument ())))))))
00099 
00100 #endif /* (__GNUC__ == 3 && __GNUC_MINOR__ < 3) */
00101 
00102 #endif /* AVCODEC_PPC_GCC_FIXES_H */

Generated on Sat Feb 16 2013 09:23:13 for ffmpeg by  doxygen 1.7.1