Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / fft / _kiss_fft_guts_f32.h
1 /*
2 Copyright (c) 2003-2004, Mark Borgerding
3
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
8     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10     * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
12 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 */
14
15 /* kiss_fft.h
16    defines kiss_fft_f32_scalar as either short or a float type
17    and defines
18    typedef struct { kiss_fft_f32_scalar r; kiss_fft_f32_scalar i; }kiss_fft_f32_cpx; */
19 #include "kiss_fft_f32.h"
20 #include <limits.h>
21
22 /* The 2*sizeof(size_t) alignment here is borrowed from
23  * GNU libc, so it should be good most everywhere.
24  * It is more conservative than is needed on some 64-bit
25  * platforms, but ia64 does require a 16-byte alignment.
26  * The SIMD extensions for x86 and ppc32 would want a
27  * larger alignment than this, but we don't need to
28  * do better than malloc.
29  *
30  * Borrowed from GLib's gobject/gtype.c
31  */
32 #define STRUCT_ALIGNMENT (2 * sizeof (size_t))
33 #define ALIGN_STRUCT(offset) \
34       ((offset + (STRUCT_ALIGNMENT - 1)) & -STRUCT_ALIGNMENT)
35
36 #define MAXFACTORS 32
37 /* e.g. an fft of length 128 has 4 factors 
38  as far as kissfft is concerned
39  4*4*4*2
40  */
41
42 struct kiss_fft_f32_state{
43     int nfft;
44     int inverse;
45     int factors[2*MAXFACTORS];
46     kiss_fft_f32_cpx twiddles[1];
47 };
48
49 /*
50   Explanation of macros dealing with complex math:
51
52    C_MUL(m,a,b)         : m = a*b
53    C_FIXDIV( c , div )  : if a fixed point impl., c /= div. noop otherwise
54    C_SUB( res, a,b)     : res = a - b
55    C_SUBFROM( res , a)  : res -= a
56    C_ADDTO( res , a)    : res += a
57  * */
58
59 #define S_MUL(a,b) ( (a)*(b) )
60 #define C_MUL(m,a,b) \
61     do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
62         (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
63 #define C_FIXDIV(c,div) /* NOOP */
64 #define C_MULBYSCALAR( c, s ) \
65     do{ (c).r *= (s);\
66         (c).i *= (s); }while(0)
67
68 #ifndef CHECK_OVERFLOW_OP
69 #  define CHECK_OVERFLOW_OP(a,op,b) /* noop */
70 #endif
71
72 #define  C_ADD( res, a,b)\
73     do { \
74             CHECK_OVERFLOW_OP((a).r,+,(b).r)\
75             CHECK_OVERFLOW_OP((a).i,+,(b).i)\
76             (res).r=(a).r+(b).r;  (res).i=(a).i+(b).i; \
77     }while(0)
78 #define  C_SUB( res, a,b)\
79     do { \
80             CHECK_OVERFLOW_OP((a).r,-,(b).r)\
81             CHECK_OVERFLOW_OP((a).i,-,(b).i)\
82             (res).r=(a).r-(b).r;  (res).i=(a).i-(b).i; \
83     }while(0)
84 #define C_ADDTO( res , a)\
85     do { \
86             CHECK_OVERFLOW_OP((res).r,+,(a).r)\
87             CHECK_OVERFLOW_OP((res).i,+,(a).i)\
88             (res).r += (a).r;  (res).i += (a).i;\
89     }while(0)
90
91 #define C_SUBFROM( res , a)\
92     do {\
93             CHECK_OVERFLOW_OP((res).r,-,(a).r)\
94             CHECK_OVERFLOW_OP((res).i,-,(a).i)\
95             (res).r -= (a).r;  (res).i -= (a).i; \
96     }while(0)
97
98
99 #define KISS_FFT_F32_COS(phase) (kiss_fft_f32_scalar) cos(phase)
100 #define KISS_FFT_F32_SIN(phase) (kiss_fft_f32_scalar) sin(phase)
101 #define HALF_OF(x) ((x)*.5)
102
103 #define  kf_cexp(x,phase) \
104         do{ \
105                 (x)->r = KISS_FFT_F32_COS(phase);\
106                 (x)->i = KISS_FFT_F32_SIN(phase);\
107         }while(0)
108
109
110 /* a debugging function */
111 #define pcpx(c)\
112     fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )