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

libavcodec/ppc/util_altivec.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of FFmpeg.
00003  *
00004  * FFmpeg is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * FFmpeg is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with FFmpeg; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017  */
00018 
00024 #ifndef AVCODEC_PPC_UTIL_ALTIVEC_H
00025 #define AVCODEC_PPC_UTIL_ALTIVEC_H
00026 
00027 #include <stdint.h>
00028 
00029 #include "config.h"
00030 
00031 #if HAVE_ALTIVEC_H
00032 #include <altivec.h>
00033 #endif
00034 
00035 // used to build registers permutation vectors (vcprm)
00036 // the 's' are for words in the _s_econd vector
00037 #define WORD_0 0x00,0x01,0x02,0x03
00038 #define WORD_1 0x04,0x05,0x06,0x07
00039 #define WORD_2 0x08,0x09,0x0a,0x0b
00040 #define WORD_3 0x0c,0x0d,0x0e,0x0f
00041 #define WORD_s0 0x10,0x11,0x12,0x13
00042 #define WORD_s1 0x14,0x15,0x16,0x17
00043 #define WORD_s2 0x18,0x19,0x1a,0x1b
00044 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
00045 
00046 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
00047 #define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d}
00048 
00049 // vcprmle is used to keep the same index as in the SSE version.
00050 // it's the same as vcprm, with the index inversed
00051 // ('le' is Little Endian)
00052 #define vcprmle(a,b,c,d) vcprm(d,c,b,a)
00053 
00054 // used to build inverse/identity vectors (vcii)
00055 // n is _n_egative, p is _p_ositive
00056 #define FLOAT_n -1.
00057 #define FLOAT_p 1.
00058 
00059 
00060 // Transpose 8x8 matrix of 16-bit elements (in-place)
00061 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
00062 do { \
00063     vector signed short A1, B1, C1, D1, E1, F1, G1, H1; \
00064     vector signed short A2, B2, C2, D2, E2, F2, G2, H2; \
00065  \
00066     A1 = vec_mergeh (a, e); \
00067     B1 = vec_mergel (a, e); \
00068     C1 = vec_mergeh (b, f); \
00069     D1 = vec_mergel (b, f); \
00070     E1 = vec_mergeh (c, g); \
00071     F1 = vec_mergel (c, g); \
00072     G1 = vec_mergeh (d, h); \
00073     H1 = vec_mergel (d, h); \
00074  \
00075     A2 = vec_mergeh (A1, E1); \
00076     B2 = vec_mergel (A1, E1); \
00077     C2 = vec_mergeh (B1, F1); \
00078     D2 = vec_mergel (B1, F1); \
00079     E2 = vec_mergeh (C1, G1); \
00080     F2 = vec_mergel (C1, G1); \
00081     G2 = vec_mergeh (D1, H1); \
00082     H2 = vec_mergel (D1, H1); \
00083  \
00084     a = vec_mergeh (A2, E2); \
00085     b = vec_mergel (A2, E2); \
00086     c = vec_mergeh (B2, F2); \
00087     d = vec_mergel (B2, F2); \
00088     e = vec_mergeh (C2, G2); \
00089     f = vec_mergel (C2, G2); \
00090     g = vec_mergeh (D2, H2); \
00091     h = vec_mergel (D2, H2); \
00092 } while (0)
00093 
00094 
00097 static inline vector unsigned char unaligned_load(int offset, uint8_t *src)
00098 {
00099     register vector unsigned char first = vec_ld(offset, src);
00100     register vector unsigned char second = vec_ld(offset+15, src);
00101     register vector unsigned char mask = vec_lvsl(offset, src);
00102     return vec_perm(first, second, mask);
00103 }
00104 
00105 #endif /* AVCODEC_PPC_UTIL_ALTIVEC_H */

Generated on Fri Sep 16 2011 17:17:41 for FFmpeg by  doxygen 1.7.1