Mercurial > libavcodec.hg
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 |
rev | line source |
---|---|
11392 | 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 #include "libavutil/mem.h" | |
20 #include "avfft.h" | |
21 #include "fft.h" | |
22 | |
23 /* FFT */ | |
24 | |
25 FFTContext *av_fft_init(int nbits, int inverse) | |
26 { | |
27 FFTContext *s = av_malloc(sizeof(*s)); | |
28 | |
29 if (s) | |
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 | 33 |
34 return s; | |
35 } | |
36 | |
37 void av_fft_permute(FFTContext *s, FFTComplex *z) | |
38 { | |
39 s->fft_permute(s, z); | |
40 } | |
41 | |
42 void av_fft_calc(FFTContext *s, FFTComplex *z) | |
43 { | |
44 s->fft_calc(s, z); | |
45 } | |
46 | |
47 void av_fft_end(FFTContext *s) | |
48 { | |
49 if (s) { | |
50 ff_fft_end(s); | |
51 av_free(s); | |
52 } | |
53 } | |
54 | |
55 #if CONFIG_MDCT | |
56 | |
57 FFTContext *av_mdct_init(int nbits, int inverse, double scale) | |
58 { | |
59 FFTContext *s = av_malloc(sizeof(*s)); | |
60 | |
61 if (s) | |
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 | 65 |
66 return s; | |
67 } | |
68 | |
69 void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) | |
70 { | |
71 s->imdct_calc(s, output, input); | |
72 } | |
73 | |
74 void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) | |
75 { | |
76 s->imdct_half(s, output, input); | |
77 } | |
78 | |
79 void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) | |
80 { | |
81 s->mdct_calc(s, output, input); | |
82 } | |
83 | |
84 void av_mdct_end(FFTContext *s) | |
85 { | |
86 if (s) { | |
87 ff_mdct_end(s); | |
88 av_free(s); | |
89 } | |
90 } | |
91 | |
92 #endif /* CONFIG_MDCT */ | |
93 | |
94 #if CONFIG_RDFT | |
95 | |
96 RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) | |
97 { | |
98 RDFTContext *s = av_malloc(sizeof(*s)); | |
99 | |
100 if (s) | |
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 | 104 |
105 return s; | |
106 } | |
107 | |
108 void av_rdft_calc(RDFTContext *s, FFTSample *data) | |
109 { | |
110 ff_rdft_calc(s, data); | |
111 } | |
112 | |
113 void av_rdft_end(RDFTContext *s) | |
114 { | |
115 if (s) { | |
116 ff_rdft_end(s); | |
117 av_free(s); | |
118 } | |
119 } | |
120 | |
121 #endif /* CONFIG_RDFT */ | |
122 | |
123 #if CONFIG_DCT | |
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 | 126 { |
127 DCTContext *s = av_malloc(sizeof(*s)); | |
128 | |
129 if (s) | |
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 | 133 |
134 return s; | |
135 } | |
136 | |
137 void av_dct_calc(DCTContext *s, FFTSample *data) | |
138 { | |
139 ff_dct_calc(s, data); | |
140 } | |
141 | |
142 void av_dct_end(DCTContext *s) | |
143 { | |
144 if (s) { | |
145 ff_dct_end(s); | |
146 av_free(s); | |
147 } | |
148 } | |
149 | |
150 #endif /* CONFIG_DCT */ |