annotate avfft.c @ 12151:fb37ee915b73 libavcodec

avfft: make init functions return NULL on failure as intended
author mru
date Mon, 12 Jul 2010 19:54:16 +0000
parents f468aac92300
children 65462b406d6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
1 /*
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
2 * This file is part of FFmpeg.
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
3 *
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
4 * FFmpeg is free software; you can redistribute it and/or
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
7 * version 2.1 of the License, or (at your option) any later version.
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
8 *
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
9 * FFmpeg is distributed in the hope that it will be useful,
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
12 * Lesser General Public License for more details.
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
13 *
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
15 * License along with FFmpeg; if not, write to the Free Software
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
17 */
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
18
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
19 #include "libavutil/mem.h"
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
20 #include "avfft.h"
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
21 #include "fft.h"
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
22
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
23 /* FFT */
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
24
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
25 FFTContext *av_fft_init(int nbits, int inverse)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
26 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
27 FFTContext *s = av_malloc(sizeof(*s));
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
28
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
29 if (s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
30 ff_fft_init(s, nbits, inverse);
12151
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
31 else
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
32 av_freep(&s);
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
33
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
34 return s;
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
35 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
36
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
37 void av_fft_permute(FFTContext *s, FFTComplex *z)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
38 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
39 s->fft_permute(s, z);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
40 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
41
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
42 void av_fft_calc(FFTContext *s, FFTComplex *z)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
43 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
44 s->fft_calc(s, z);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
45 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
46
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
47 void av_fft_end(FFTContext *s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
48 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
49 if (s) {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
50 ff_fft_end(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
51 av_free(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
52 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
53 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
54
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
55 #if CONFIG_MDCT
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
56
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
57 FFTContext *av_mdct_init(int nbits, int inverse, double scale)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
58 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
59 FFTContext *s = av_malloc(sizeof(*s));
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
60
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
61 if (s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
62 ff_mdct_init(s, nbits, inverse, scale);
12151
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
63 else
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
64 av_freep(&s);
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
65
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
66 return s;
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
67 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
68
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
69 void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
70 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
71 s->imdct_calc(s, output, input);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
72 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
73
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
74 void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
75 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
76 s->imdct_half(s, output, input);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
77 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
78
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
79 void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
80 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
81 s->mdct_calc(s, output, input);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
82 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
83
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
84 void av_mdct_end(FFTContext *s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
85 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
86 if (s) {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
87 ff_mdct_end(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
88 av_free(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
89 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
90 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
91
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
92 #endif /* CONFIG_MDCT */
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
93
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
94 #if CONFIG_RDFT
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
95
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
96 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
97 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
98 RDFTContext *s = av_malloc(sizeof(*s));
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
99
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
100 if (s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
101 ff_rdft_init(s, nbits, trans);
12151
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
102 else
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
103 av_freep(&s);
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
104
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
105 return s;
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
106 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
107
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
108 void av_rdft_calc(RDFTContext *s, FFTSample *data)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
109 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
110 ff_rdft_calc(s, data);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
111 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
112
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
113 void av_rdft_end(RDFTContext *s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
114 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
115 if (s) {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
116 ff_rdft_end(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
117 av_free(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
118 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
119 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
120
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
121 #endif /* CONFIG_RDFT */
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
122
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
123 #if CONFIG_DCT
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
124
11535
f468aac92300 Implement the discrete sine/cosine transforms DCT-I and DST-I
vitor
parents: 11392
diff changeset
125 DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
126 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
127 DCTContext *s = av_malloc(sizeof(*s));
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
128
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
129 if (s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
130 ff_dct_init(s, nbits, inverse);
12151
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
131 else
fb37ee915b73 avfft: make init functions return NULL on failure as intended
mru
parents: 11535
diff changeset
132 av_freep(&s);
11392
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
133
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
134 return s;
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
135 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
136
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
137 void av_dct_calc(DCTContext *s, FFTSample *data)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
138 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
139 ff_dct_calc(s, data);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
140 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
141
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
142 void av_dct_end(DCTContext *s)
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
143 {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
144 if (s) {
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
145 ff_dct_end(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
146 av_free(s);
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
147 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
148 }
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
149
384d803faff4 Create a public API for FFT family of functions
mru
parents:
diff changeset
150 #endif /* CONFIG_DCT */