Revision c7094831

View differences:

doc/APIchanges
12 12

  
13 13
API changes, most recent first:
14 14

  
15
2010-03-07 - r22291 - lavc 52.56.0 - avfft.h
16
  Add public FFT interface.
17

  
15 18
2010-03-06 - r22251 - lavu 50.11.0 - av_stristr()
16 19
  Add av_stristr().
17 20

  
libavcodec/Makefile
3 3
NAME = avcodec
4 4
FFLIBS = avutil
5 5

  
6
HEADERS = avcodec.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
6
HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h xvmc.h
7 7

  
8 8
OBJS = allcodecs.o                                                      \
9 9
       audioconvert.o                                                   \
......
30 30
OBJS-$(CONFIG_DCT)                     += dct.o
31 31
OBJS-$(CONFIG_DXVA2)                   += dxva2.o
32 32
FFT-OBJS-$(CONFIG_HARDCODED_TABLES)    += cos_tables.o
33
OBJS-$(CONFIG_FFT)                     += fft.o $(FFT-OBJS-yes)
33
OBJS-$(CONFIG_FFT)                     += avfft.o fft.o $(FFT-OBJS-yes)
34 34
OBJS-$(CONFIG_GOLOMB)                  += golomb.o
35 35
OBJS-$(CONFIG_LPC)                     += lpc.o
36 36
OBJS-$(CONFIG_LSP)                     += lsp.o
libavcodec/avcodec.h
30 30
#include "libavutil/avutil.h"
31 31

  
32 32
#define LIBAVCODEC_VERSION_MAJOR 52
33
#define LIBAVCODEC_VERSION_MINOR 55
33
#define LIBAVCODEC_VERSION_MINOR 56
34 34
#define LIBAVCODEC_VERSION_MICRO  0
35 35

  
36 36
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavcodec/avfft.c
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);
31

  
32
    return s;
33
}
34

  
35
void av_fft_permute(FFTContext *s, FFTComplex *z)
36
{
37
    s->fft_permute(s, z);
38
}
39

  
40
void av_fft_calc(FFTContext *s, FFTComplex *z)
41
{
42
    s->fft_calc(s, z);
43
}
44

  
45
void av_fft_end(FFTContext *s)
46
{
47
    if (s) {
48
        ff_fft_end(s);
49
        av_free(s);
50
    }
51
}
52

  
53
#if CONFIG_MDCT
54

  
55
FFTContext *av_mdct_init(int nbits, int inverse, double scale)
56
{
57
    FFTContext *s = av_malloc(sizeof(*s));
58

  
59
    if (s)
60
        ff_mdct_init(s, nbits, inverse, scale);
61

  
62
    return s;
63
}
64

  
65
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
66
{
67
    s->imdct_calc(s, output, input);
68
}
69

  
70
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
71
{
72
    s->imdct_half(s, output, input);
73
}
74

  
75
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
76
{
77
    s->mdct_calc(s, output, input);
78
}
79

  
80
void av_mdct_end(FFTContext *s)
81
{
82
    if (s) {
83
        ff_mdct_end(s);
84
        av_free(s);
85
    }
86
}
87

  
88
#endif /* CONFIG_MDCT */
89

  
90
#if CONFIG_RDFT
91

  
92
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
93
{
94
    RDFTContext *s = av_malloc(sizeof(*s));
95

  
96
    if (s)
97
        ff_rdft_init(s, nbits, trans);
98

  
99
    return s;
100
}
101

  
102
void av_rdft_calc(RDFTContext *s, FFTSample *data)
103
{
104
    ff_rdft_calc(s, data);
105
}
106

  
107
void av_rdft_end(RDFTContext *s)
108
{
109
    if (s) {
110
        ff_rdft_end(s);
111
        av_free(s);
112
    }
113
}
114

  
115
#endif /* CONFIG_RDFT */
116

  
117
#if CONFIG_DCT
118

  
119
DCTContext *av_dct_init(int nbits, int inverse)
120
{
121
    DCTContext *s = av_malloc(sizeof(*s));
122

  
123
    if (s)
124
        ff_dct_init(s, nbits, inverse);
125

  
126
    return s;
127
}
128

  
129
void av_dct_calc(DCTContext *s, FFTSample *data)
130
{
131
    ff_dct_calc(s, data);
132
}
133

  
134
void av_dct_end(DCTContext *s)
135
{
136
    if (s) {
137
        ff_dct_end(s);
138
        av_free(s);
139
    }
140
}
141

  
142
#endif /* CONFIG_DCT */
libavcodec/avfft.h
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
#ifndef AVCODEC_AVFFT_H
20
#define AVCODEC_AVFFT_H
21

  
22
typedef float FFTSample;
23

  
24
typedef struct FFTComplex {
25
    FFTSample re, im;
26
} FFTComplex;
27

  
28
typedef struct FFTContext FFTContext;
29

  
30
/**
31
 * Set up a complex FFT.
32
 * @param nbits           log2 of the length of the input array
33
 * @param inverse         if 0 perform the forward transform, if 1 perform the inverse
34
 */
35
FFTContext *av_fft_init(int nbits, int inverse);
36

  
37
/**
38
 * Do the permutation needed BEFORE calling ff_fft_calc().
39
 */
40
void av_fft_permute(FFTContext *s, FFTComplex *z);
41

  
42
/**
43
 * Do a complex FFT with the parameters defined in av_fft_init(). The
44
 * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
45
 */
46
void av_fft_calc(FFTContext *s, FFTComplex *z);
47

  
48
void av_fft_end(FFTContext *s);
49

  
50
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
51
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
52
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
53
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
54
void av_mdct_end(FFTContext *s);
55

  
56
/* Real Discrete Fourier Transform */
57

  
58
enum RDFTransformType {
59
    DFT_R2C,
60
    IDFT_C2R,
61
    IDFT_R2C,
62
    DFT_C2R,
63
};
64

  
65
typedef struct RDFTContext RDFTContext;
66

  
67
/**
68
 * Set up a real FFT.
69
 * @param nbits           log2 of the length of the input array
70
 * @param trans           the type of transform
71
 */
72
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
73
void av_rdft_calc(RDFTContext *s, FFTSample *data);
74
void av_rdft_end(RDFTContext *s);
75

  
76
/* Discrete Cosine Transform */
77

  
78
typedef struct DCTContext DCTContext;
79

  
80
/**
81
 * Set up (Inverse)DCT.
82
 * @param nbits           log2 of the length of the input array
83
 * @param inverse         >0 forward transform, <0 inverse transform
84
 */
85
DCTContext *av_dct_init(int nbits, int inverse);
86
void av_dct_calc(DCTContext *s, FFTSample *data);
87
void av_dct_end (DCTContext *s);
88

  
89
#endif /* AVCODEC_AVFFT_H */
libavcodec/fft.h
25 25
#include <stdint.h>
26 26
#include "config.h"
27 27
#include "libavutil/mem.h"
28
#include "avfft.h"
28 29

  
29 30
/* FFT computation */
30 31

  
31
/* NOTE: soon integer code will be added, so you must use the
32
   FFTSample type */
33
typedef float FFTSample;
34

  
35
typedef struct FFTComplex {
36
    FFTSample re, im;
37
} FFTComplex;
38

  
39
typedef struct FFTContext {
32
struct FFTContext {
40 33
    int nbits;
41 34
    int inverse;
42 35
    uint16_t *revtab;
......
57 50
    int permutation;
58 51
#define FF_MDCT_PERM_NONE       0
59 52
#define FF_MDCT_PERM_INTERLEAVE 1
60
} FFTContext;
53
};
61 54

  
62 55
#if CONFIG_HARDCODED_TABLES
63 56
#define COSTABLE_CONST const
......
194 187

  
195 188
/* Real Discrete Fourier Transform */
196 189

  
197
enum RDFTransformType {
198
    DFT_R2C,
199
    IDFT_C2R,
200
    IDFT_R2C,
201
    DFT_C2R,
202
};
203

  
204
typedef struct {
190
struct RDFTContext {
205 191
    int nbits;
206 192
    int inverse;
207 193
    int sign_convention;
......
210 196
    const FFTSample *tcos;
211 197
    SINTABLE_CONST FFTSample *tsin;
212 198
    FFTContext fft;
213
} RDFTContext;
199
};
214 200

  
215 201
/**
216 202
 * Sets up a real FFT.
......
223 209

  
224 210
/* Discrete Cosine Transform */
225 211

  
226
typedef struct {
212
struct DCTContext {
227 213
    int nbits;
228 214
    int inverse;
229 215
    FFTSample *data;
230 216
    RDFTContext rdft;
231 217
    const float *costab;
232 218
    FFTSample *csc2;
233
} DCTContext;
219
};
234 220

  
235 221
/**
236 222
 * Sets up (Inverse)DCT.

Also available in: Unified diff