annotate ffmpeg/libavutil/ppc/util_altivec.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * This file is part of FFmpeg.
yading@11 3 *
yading@11 4 * FFmpeg is free software; you can redistribute it and/or
yading@11 5 * modify it under the terms of the GNU Lesser General Public
yading@11 6 * License as published by the Free Software Foundation; either
yading@11 7 * version 2.1 of the License, or (at your option) any later version.
yading@11 8 *
yading@11 9 * FFmpeg is distributed in the hope that it will be useful,
yading@11 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 12 * Lesser General Public License for more details.
yading@11 13 *
yading@11 14 * You should have received a copy of the GNU Lesser General Public
yading@11 15 * License along with FFmpeg; if not, write to the Free Software
yading@11 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 17 */
yading@11 18
yading@11 19 /**
yading@11 20 * @file
yading@11 21 * Contains misc utility macros and inline functions
yading@11 22 */
yading@11 23
yading@11 24 #ifndef AVUTIL_PPC_UTIL_ALTIVEC_H
yading@11 25 #define AVUTIL_PPC_UTIL_ALTIVEC_H
yading@11 26
yading@11 27 #include <stdint.h>
yading@11 28
yading@11 29 #include "config.h"
yading@11 30
yading@11 31 #if HAVE_ALTIVEC_H
yading@11 32 #include <altivec.h>
yading@11 33 #endif
yading@11 34
yading@11 35 #include "types_altivec.h"
yading@11 36
yading@11 37 // used to build registers permutation vectors (vcprm)
yading@11 38 // the 's' are for words in the _s_econd vector
yading@11 39 #define WORD_0 0x00,0x01,0x02,0x03
yading@11 40 #define WORD_1 0x04,0x05,0x06,0x07
yading@11 41 #define WORD_2 0x08,0x09,0x0a,0x0b
yading@11 42 #define WORD_3 0x0c,0x0d,0x0e,0x0f
yading@11 43 #define WORD_s0 0x10,0x11,0x12,0x13
yading@11 44 #define WORD_s1 0x14,0x15,0x16,0x17
yading@11 45 #define WORD_s2 0x18,0x19,0x1a,0x1b
yading@11 46 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
yading@11 47
yading@11 48 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
yading@11 49 #define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d}
yading@11 50
yading@11 51 // vcprmle is used to keep the same index as in the SSE version.
yading@11 52 // it's the same as vcprm, with the index inversed
yading@11 53 // ('le' is Little Endian)
yading@11 54 #define vcprmle(a,b,c,d) vcprm(d,c,b,a)
yading@11 55
yading@11 56 // used to build inverse/identity vectors (vcii)
yading@11 57 // n is _n_egative, p is _p_ositive
yading@11 58 #define FLOAT_n -1.
yading@11 59 #define FLOAT_p 1.
yading@11 60
yading@11 61
yading@11 62 // Transpose 8x8 matrix of 16-bit elements (in-place)
yading@11 63 #define TRANSPOSE8(a,b,c,d,e,f,g,h) \
yading@11 64 do { \
yading@11 65 vector signed short A1, B1, C1, D1, E1, F1, G1, H1; \
yading@11 66 vector signed short A2, B2, C2, D2, E2, F2, G2, H2; \
yading@11 67 \
yading@11 68 A1 = vec_mergeh (a, e); \
yading@11 69 B1 = vec_mergel (a, e); \
yading@11 70 C1 = vec_mergeh (b, f); \
yading@11 71 D1 = vec_mergel (b, f); \
yading@11 72 E1 = vec_mergeh (c, g); \
yading@11 73 F1 = vec_mergel (c, g); \
yading@11 74 G1 = vec_mergeh (d, h); \
yading@11 75 H1 = vec_mergel (d, h); \
yading@11 76 \
yading@11 77 A2 = vec_mergeh (A1, E1); \
yading@11 78 B2 = vec_mergel (A1, E1); \
yading@11 79 C2 = vec_mergeh (B1, F1); \
yading@11 80 D2 = vec_mergel (B1, F1); \
yading@11 81 E2 = vec_mergeh (C1, G1); \
yading@11 82 F2 = vec_mergel (C1, G1); \
yading@11 83 G2 = vec_mergeh (D1, H1); \
yading@11 84 H2 = vec_mergel (D1, H1); \
yading@11 85 \
yading@11 86 a = vec_mergeh (A2, E2); \
yading@11 87 b = vec_mergel (A2, E2); \
yading@11 88 c = vec_mergeh (B2, F2); \
yading@11 89 d = vec_mergel (B2, F2); \
yading@11 90 e = vec_mergeh (C2, G2); \
yading@11 91 f = vec_mergel (C2, G2); \
yading@11 92 g = vec_mergeh (D2, H2); \
yading@11 93 h = vec_mergel (D2, H2); \
yading@11 94 } while (0)
yading@11 95
yading@11 96
yading@11 97 /** @brief loads unaligned vector @a *src with offset @a offset
yading@11 98 and returns it */
yading@11 99 static inline vector unsigned char unaligned_load(int offset, uint8_t *src)
yading@11 100 {
yading@11 101 register vector unsigned char first = vec_ld(offset, src);
yading@11 102 register vector unsigned char second = vec_ld(offset+15, src);
yading@11 103 register vector unsigned char mask = vec_lvsl(offset, src);
yading@11 104 return vec_perm(first, second, mask);
yading@11 105 }
yading@11 106
yading@11 107 /**
yading@11 108 * loads vector known misalignment
yading@11 109 * @param perm_vec the align permute vector to combine the two loads from lvsl
yading@11 110 */
yading@11 111 static inline vec_u8 load_with_perm_vec(int offset, uint8_t *src, vec_u8 perm_vec)
yading@11 112 {
yading@11 113 vec_u8 a = vec_ld(offset, src);
yading@11 114 vec_u8 b = vec_ld(offset+15, src);
yading@11 115 return vec_perm(a, b, perm_vec);
yading@11 116 }
yading@11 117
yading@11 118 #endif /* AVUTIL_PPC_UTIL_ALTIVEC_H */