CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/ext/at3_standalone/fft.h
Views: 1401
/*1* Copyright (c) 2000, 2001, 2002 Fabrice Bellard2* Copyright (c) 2002-2004 Michael Niedermayer <[email protected]>3*4* This file is part of FFmpeg.5*6* FFmpeg is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public8* License as published by the Free Software Foundation; either9* version 2.1 of the License, or (at your option) any later version.10*11* FFmpeg is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU14* Lesser General Public License for more details.15*16* You should have received a copy of the GNU Lesser General Public17* License along with FFmpeg; if not, write to the Free Software18* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA19*/2021#pragma once2223#define CMUL(dre, dim, are, aim, bre, bim) do { \24(dre) = (are) * (bre) - (aim) * (bim); \25(dim) = (are) * (bim) + (aim) * (bre); \26} while (0)2728#include <stdint.h>2930#include "compat.h"3132typedef float FFTSample;3334typedef struct FFTComplex {35FFTSample re, im;36} FFTComplex;3738typedef struct FFTContext FFTContext;3940typedef float FFTDouble;4142/* FFT computation */4344enum mdct_permutation_type {45FF_MDCT_PERM_NONE,46FF_MDCT_PERM_INTERLEAVE,47};4849struct FFTContext {50int nbits;51int inverse;52uint16_t *revtab;53FFTComplex *tmp_buf;54int mdct_size; /* size of MDCT (i.e. number of input data * 2) */55int mdct_bits; /* n = 2^nbits */56/* pre/post rotation tables */57FFTSample *tcos;58FFTSample *tsin;5960enum mdct_permutation_type mdct_permutation;61};6263/**64* Do a complex FFT with the parameters defined in ff_fft_init(). The65* input data must be permuted before. No 1.0/sqrt(n) normalization is done.66*/67void fft_calc(struct FFTContext *s, FFTComplex *z);68void imdct_calc(struct FFTContext *s, FFTSample *output, const FFTSample *input);69void imdct_half(struct FFTContext *s, FFTSample *output, const FFTSample *input);7071#define COSTABLE(size) \72DECLARE_ALIGNED(32, FFTSample, av_cos_##size)[size/2]7374extern COSTABLE(16);75extern COSTABLE(32);76extern COSTABLE(64);77extern COSTABLE(128);78extern COSTABLE(256);79extern COSTABLE(512);80extern COSTABLE(1024);81extern COSTABLE(2048);82extern COSTABLE(4096);83extern COSTABLE(8192);84extern COSTABLE(16384);85extern COSTABLE(32768);86extern COSTABLE(65536);8788/**89* Initialize the cosine table in ff_cos_tabs[index]90* @param index index in ff_cos_tabs array of the table to initialize91*/92void ff_init_ff_cos_tabs(int index);9394/**95* Set up a complex FFT.96* @param nbits log2 of the length of the input array97* @param inverse if 0 perform the forward transform, if 1 perform the inverse98*/99int ff_fft_init(FFTContext *s, int nbits, int inverse);100101void ff_fft_end(FFTContext *s);102103int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);104void ff_mdct_end(FFTContext *s);105106107