annotate ffmpeg/libavcodec/fft.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
yading@10 3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
yading@10 4 *
yading@10 5 * This file is part of FFmpeg.
yading@10 6 *
yading@10 7 * FFmpeg is free software; you can redistribute it and/or
yading@10 8 * modify it under the terms of the GNU Lesser General Public
yading@10 9 * License as published by the Free Software Foundation; either
yading@10 10 * version 2.1 of the License, or (at your option) any later version.
yading@10 11 *
yading@10 12 * FFmpeg is distributed in the hope that it will be useful,
yading@10 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 15 * Lesser General Public License for more details.
yading@10 16 *
yading@10 17 * You should have received a copy of the GNU Lesser General Public
yading@10 18 * License along with FFmpeg; if not, write to the Free Software
yading@10 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 20 */
yading@10 21
yading@10 22 #ifndef AVCODEC_FFT_H
yading@10 23 #define AVCODEC_FFT_H
yading@10 24
yading@10 25 #ifndef CONFIG_FFT_FLOAT
yading@10 26 #define CONFIG_FFT_FLOAT 1
yading@10 27 #endif
yading@10 28
yading@10 29 #include <stdint.h>
yading@10 30 #include "config.h"
yading@10 31 #include "libavutil/mem.h"
yading@10 32
yading@10 33 #if CONFIG_FFT_FLOAT
yading@10 34
yading@10 35 #include "avfft.h"
yading@10 36
yading@10 37 #define FFT_NAME(x) x
yading@10 38
yading@10 39 typedef float FFTDouble;
yading@10 40
yading@10 41 #else
yading@10 42
yading@10 43 #define FFT_NAME(x) x ## _fixed
yading@10 44
yading@10 45 typedef int16_t FFTSample;
yading@10 46 typedef int FFTDouble;
yading@10 47
yading@10 48 typedef struct FFTComplex {
yading@10 49 int16_t re, im;
yading@10 50 } FFTComplex;
yading@10 51
yading@10 52 typedef struct FFTContext FFTContext;
yading@10 53
yading@10 54 #endif /* CONFIG_FFT_FLOAT */
yading@10 55
yading@10 56 typedef struct FFTDComplex {
yading@10 57 FFTDouble re, im;
yading@10 58 } FFTDComplex;
yading@10 59
yading@10 60 /* FFT computation */
yading@10 61
yading@10 62 struct FFTContext {
yading@10 63 int nbits;
yading@10 64 int inverse;
yading@10 65 uint16_t *revtab;
yading@10 66 FFTComplex *tmp_buf;
yading@10 67 int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
yading@10 68 int mdct_bits; /* n = 2^nbits */
yading@10 69 /* pre/post rotation tables */
yading@10 70 FFTSample *tcos;
yading@10 71 FFTSample *tsin;
yading@10 72 /**
yading@10 73 * Do the permutation needed BEFORE calling fft_calc().
yading@10 74 */
yading@10 75 void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
yading@10 76 /**
yading@10 77 * Do a complex FFT with the parameters defined in ff_fft_init(). The
yading@10 78 * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
yading@10 79 */
yading@10 80 void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
yading@10 81 void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
yading@10 82 void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
yading@10 83 void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
yading@10 84 void (*mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input);
yading@10 85 int fft_permutation;
yading@10 86 #define FF_FFT_PERM_DEFAULT 0
yading@10 87 #define FF_FFT_PERM_SWAP_LSBS 1
yading@10 88 #define FF_FFT_PERM_AVX 2
yading@10 89 int mdct_permutation;
yading@10 90 #define FF_MDCT_PERM_NONE 0
yading@10 91 #define FF_MDCT_PERM_INTERLEAVE 1
yading@10 92 };
yading@10 93
yading@10 94 #if CONFIG_HARDCODED_TABLES
yading@10 95 #define COSTABLE_CONST const
yading@10 96 #else
yading@10 97 #define COSTABLE_CONST
yading@10 98 #endif
yading@10 99
yading@10 100 #define COSTABLE(size) \
yading@10 101 COSTABLE_CONST DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2]
yading@10 102
yading@10 103 extern COSTABLE(16);
yading@10 104 extern COSTABLE(32);
yading@10 105 extern COSTABLE(64);
yading@10 106 extern COSTABLE(128);
yading@10 107 extern COSTABLE(256);
yading@10 108 extern COSTABLE(512);
yading@10 109 extern COSTABLE(1024);
yading@10 110 extern COSTABLE(2048);
yading@10 111 extern COSTABLE(4096);
yading@10 112 extern COSTABLE(8192);
yading@10 113 extern COSTABLE(16384);
yading@10 114 extern COSTABLE(32768);
yading@10 115 extern COSTABLE(65536);
yading@10 116 extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[17];
yading@10 117
yading@10 118 #define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs)
yading@10 119
yading@10 120 /**
yading@10 121 * Initialize the cosine table in ff_cos_tabs[index]
yading@10 122 * @param index index in ff_cos_tabs array of the table to initialize
yading@10 123 */
yading@10 124 void ff_init_ff_cos_tabs(int index);
yading@10 125
yading@10 126 #define ff_fft_init FFT_NAME(ff_fft_init)
yading@10 127 #define ff_fft_end FFT_NAME(ff_fft_end)
yading@10 128
yading@10 129 /**
yading@10 130 * Set up a complex FFT.
yading@10 131 * @param nbits log2 of the length of the input array
yading@10 132 * @param inverse if 0 perform the forward transform, if 1 perform the inverse
yading@10 133 */
yading@10 134 int ff_fft_init(FFTContext *s, int nbits, int inverse);
yading@10 135
yading@10 136 #if CONFIG_FFT_FLOAT
yading@10 137 void ff_fft_init_altivec(FFTContext *s);
yading@10 138 void ff_fft_init_x86(FFTContext *s);
yading@10 139 void ff_fft_init_arm(FFTContext *s);
yading@10 140 void ff_fft_init_mips(FFTContext *s);
yading@10 141 #else
yading@10 142 void ff_fft_fixed_init_arm(FFTContext *s);
yading@10 143 #endif
yading@10 144
yading@10 145 void ff_fft_end(FFTContext *s);
yading@10 146
yading@10 147 #define ff_mdct_init FFT_NAME(ff_mdct_init)
yading@10 148 #define ff_mdct_end FFT_NAME(ff_mdct_end)
yading@10 149
yading@10 150 int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
yading@10 151 void ff_mdct_end(FFTContext *s);
yading@10 152
yading@10 153 #endif /* AVCODEC_FFT_H */