1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 module ffmpeg.libavcodec.avfft;
20 
21 extern (C):
22 import ffmpeg; @nogc nothrow:
23 
24 /**
25  * @file
26  * @ingroup lavc_fft
27  * FFT functions
28  */
29 
30 /**
31  * @defgroup lavc_fft FFT functions
32  * @ingroup lavc_misc
33  *
34  * @{
35  */
36 
37 alias FFTSample = float;
38 
39 struct FFTComplex
40 {
41     FFTSample re;
42     FFTSample im;
43 }
44 
45 struct FFTContext;
46 
47 /**
48  * Set up a complex FFT.
49  * @param nbits           log2 of the length of the input array
50  * @param inverse         if 0 perform the forward transform, if 1 perform the inverse
51  */
52 FFTContext* av_fft_init (int nbits, int inverse);
53 
54 /**
55  * Do the permutation needed BEFORE calling ff_fft_calc().
56  */
57 void av_fft_permute (FFTContext* s, FFTComplex* z);
58 
59 /**
60  * Do a complex FFT with the parameters defined in av_fft_init(). The
61  * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
62  */
63 void av_fft_calc (FFTContext* s, FFTComplex* z);
64 
65 void av_fft_end (FFTContext* s);
66 
67 FFTContext* av_mdct_init (int nbits, int inverse, double scale);
68 void av_imdct_calc (FFTContext* s, FFTSample* output, const(FFTSample)* input);
69 void av_imdct_half (FFTContext* s, FFTSample* output, const(FFTSample)* input);
70 void av_mdct_calc (FFTContext* s, FFTSample* output, const(FFTSample)* input);
71 void av_mdct_end (FFTContext* s);
72 
73 /* Real Discrete Fourier Transform */
74 
75 enum RDFTransformType
76 {
77     DFT_R2C = 0,
78     IDFT_C2R = 1,
79     IDFT_R2C = 2,
80     DFT_C2R = 3
81 }
82 
83 struct RDFTContext;
84 
85 /**
86  * Set up a real FFT.
87  * @param nbits           log2 of the length of the input array
88  * @param trans           the type of transform
89  */
90 RDFTContext* av_rdft_init (int nbits, RDFTransformType trans);
91 void av_rdft_calc (RDFTContext* s, FFTSample* data);
92 void av_rdft_end (RDFTContext* s);
93 
94 /* Discrete Cosine Transform */
95 
96 struct DCTContext;
97 
98 enum DCTTransformType
99 {
100     DCT_II = 0,
101     DCT_III = 1,
102     DCT_I = 2,
103     DST_I = 3
104 }
105 
106 /**
107  * Set up DCT.
108  *
109  * @param nbits           size of the input array:
110  *                        (1 << nbits)     for DCT-II, DCT-III and DST-I
111  *                        (1 << nbits) + 1 for DCT-I
112  * @param type            the type of transform
113  *
114  * @note the first element of the input of DST-I is ignored
115  */
116 DCTContext* av_dct_init (int nbits, DCTTransformType type);
117 void av_dct_calc (DCTContext* s, FFTSample* data);
118 void av_dct_end (DCTContext* s);
119 
120 /**
121  * @}
122  */
123 
124 /* AVCODEC_AVFFT_H */