comparison ppc/fft_altivec.c @ 981:8bec850dc9c7 libavcodec

altivec patches by Romain Dolbeau
author bellard
date Wed, 08 Jan 2003 18:47:49 +0000
parents e05d525505c5
children edc10966b081
comparison
equal deleted inserted replaced
980:0c32f81b42b2 981:8bec850dc9c7
1 /* 1 /*
2 * FFT/IFFT transforms 2 * FFT/IFFT transforms
3 * AltiVec-enabled 3 * AltiVec-enabled
4 * Copyright (c) 2002 Romain Dolbeau <romain@dolbeau.org> 4 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
5 * Based on code Copyright (c) 2002 Fabrice Bellard. 5 * Based on code Copyright (c) 2002 Fabrice Bellard.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
20 */ 20 */
21 #include "../dsputil.h" 21 #include "../dsputil.h"
22 22
23 #include "dsputil_altivec.h" 23 #include "dsputil_altivec.h"
24 24
25 // used to build registers permutation vectors (vcprm)
26 // the 's' are for words in the _s_econd vector
27 #define WORD_0 0x00,0x01,0x02,0x03
28 #define WORD_1 0x04,0x05,0x06,0x07
29 #define WORD_2 0x08,0x09,0x0a,0x0b
30 #define WORD_3 0x0c,0x0d,0x0e,0x0f
31 #define WORD_s0 0x10,0x11,0x12,0x13
32 #define WORD_s1 0x14,0x15,0x16,0x17
33 #define WORD_s2 0x18,0x19,0x1a,0x1b
34 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
35
36 #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d)
37
38 // vcprmle is used to keep the same index as in the SSE version.
39 // it's the same as vcprm, with the index inversed
40 // ('le' is Little Endian)
41 #define vcprmle(a,b,c,d) vcprm(d,c,b,a)
42
43 // used to build inverse/identity vectors (vcii)
44 // n is _n_egative, p is _p_ositive
45 #define FLOAT_n -1.
46 #define FLOAT_p 1.
47
48 #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d)
49
50 /** 25 /**
51 * Do a complex FFT with the parameters defined in fft_init(). The 26 * Do a complex FFT with the parameters defined in fft_init(). The
52 * input data must be permuted before with s->revtab table. No 27 * input data must be permuted before with s->revtab table. No
53 * 1.0/sqrt(n) normalization is done. 28 * 1.0/sqrt(n) normalization is done.
54 * AltiVec-enabled 29 * AltiVec-enabled
55 * This code assumes that the 'z' pointer is 16 bytes-aligned 30 * This code assumes that the 'z' pointer is 16 bytes-aligned
56 * It also assumes all FFTComplex are 8 bytes-aligned pair of float 31 * It also assumes all FFTComplex are 8 bytes-aligned pair of float
57 * The code is exactly the same as the SSE version, except 32 * The code is exactly the same as the SSE version, except
58 * that successive MUL + ADD/SUB have been fusionned into 33 * that successive MUL + ADD/SUB have been merged into
59 * fused multiply-add ('vec_madd' in altivec) 34 * fused multiply-add ('vec_madd' in altivec)
60 *
61 * To test this code you can use fft-test in libavcodec ; use
62 * the following line in libavcodec to compile (MacOS X):
63 * #####
64 * gcc -I. -Ippc -no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic -Wall
65 * -faltivec -DARCH_POWERPC -DHAVE_ALTIVEC -DCONFIG_DARWIN fft-test.c fft.c
66 * ppc/fft_altivec.c ppc/dsputil_altivec.c mdct.c -DHAVE_LRINTF -o fft-test
67 * #####
68 */ 35 */
69 void fft_calc_altivec(FFTContext *s, FFTComplex *z) 36 void fft_calc_altivec(FFTContext *s, FFTComplex *z)
70 { 37 {
71 register const vector float vczero = (vector float)( 0., 0., 0., 0.); 38 register const vector float vczero = (vector float)( 0., 0., 0., 0.);
72 39