CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/ext/at3_standalone/fft.h
Views: 1401
1
/*
2
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3
* Copyright (c) 2002-2004 Michael Niedermayer <[email protected]>
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#pragma once
23
24
#define CMUL(dre, dim, are, aim, bre, bim) do { \
25
(dre) = (are) * (bre) - (aim) * (bim); \
26
(dim) = (are) * (bim) + (aim) * (bre); \
27
} while (0)
28
29
#include <stdint.h>
30
31
#include "compat.h"
32
33
typedef float FFTSample;
34
35
typedef struct FFTComplex {
36
FFTSample re, im;
37
} FFTComplex;
38
39
typedef struct FFTContext FFTContext;
40
41
typedef float FFTDouble;
42
43
/* FFT computation */
44
45
enum mdct_permutation_type {
46
FF_MDCT_PERM_NONE,
47
FF_MDCT_PERM_INTERLEAVE,
48
};
49
50
struct FFTContext {
51
int nbits;
52
int inverse;
53
uint16_t *revtab;
54
FFTComplex *tmp_buf;
55
int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
56
int mdct_bits; /* n = 2^nbits */
57
/* pre/post rotation tables */
58
FFTSample *tcos;
59
FFTSample *tsin;
60
61
enum mdct_permutation_type mdct_permutation;
62
};
63
64
/**
65
* Do a complex FFT with the parameters defined in ff_fft_init(). The
66
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
67
*/
68
void fft_calc(struct FFTContext *s, FFTComplex *z);
69
void imdct_calc(struct FFTContext *s, FFTSample *output, const FFTSample *input);
70
void imdct_half(struct FFTContext *s, FFTSample *output, const FFTSample *input);
71
72
#define COSTABLE(size) \
73
DECLARE_ALIGNED(32, FFTSample, av_cos_##size)[size/2]
74
75
extern COSTABLE(16);
76
extern COSTABLE(32);
77
extern COSTABLE(64);
78
extern COSTABLE(128);
79
extern COSTABLE(256);
80
extern COSTABLE(512);
81
extern COSTABLE(1024);
82
extern COSTABLE(2048);
83
extern COSTABLE(4096);
84
extern COSTABLE(8192);
85
extern COSTABLE(16384);
86
extern COSTABLE(32768);
87
extern COSTABLE(65536);
88
89
/**
90
* Initialize the cosine table in ff_cos_tabs[index]
91
* @param index index in ff_cos_tabs array of the table to initialize
92
*/
93
void ff_init_ff_cos_tabs(int index);
94
95
/**
96
* Set up a complex FFT.
97
* @param nbits log2 of the length of the input array
98
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
99
*/
100
int ff_fft_init(FFTContext *s, int nbits, int inverse);
101
102
void ff_fft_end(FFTContext *s);
103
104
int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
105
void ff_mdct_end(FFTContext *s);
106
107