summaryrefslogtreecommitdiff
path: root/plugins/supereq/ff_rdft.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-02-10 20:50:40 +0100
committerGravatar waker <wakeroid@gmail.com>2011-02-10 20:50:40 +0100
commita70bbf6c7a6896e3bc97177cab68b5cb96091868 (patch)
tree87f34e09920f80ce54afbcc65c4eb0b3f5288f9c /plugins/supereq/ff_rdft.c
parent6b43f7a6a6966d23eb8199407548770a8670485f (diff)
added ffmpeg fft support to supereq plugin
Diffstat (limited to 'plugins/supereq/ff_rdft.c')
-rw-r--r--plugins/supereq/ff_rdft.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/supereq/ff_rdft.c b/plugins/supereq/ff_rdft.c
new file mode 100644
index 00000000..70a09350
--- /dev/null
+++ b/plugins/supereq/ff_rdft.c
@@ -0,0 +1,63 @@
+#include <stdint.h>
+#include <complex.h>
+#include "libavcodec/avfft.h"
+#include "libavutil/avutil.h"
+
+void rfft(int n,int isign,float *x)
+{
+ static int wsize=0;
+ static float *w = NULL;
+ static RDFTContext *s = NULL;
+ static RDFTContext *si = NULL;
+ int newwsize;
+
+ if (n == 0) {
+ if (w) {
+ av_free(w);
+ w = NULL;
+ wsize = 0;
+ }
+ if (s) {
+ av_rdft_end (s);
+ s = NULL;
+ }
+ if (si) {
+ av_rdft_end (si);
+ si = NULL;
+ }
+ return;
+ }
+
+ newwsize = n/2;
+ if (newwsize > wsize) {
+ wsize = newwsize;
+ if (s) {
+ av_rdft_end (s);
+ s = NULL;
+ }
+ if (si) {
+ av_rdft_end (si);
+ si = NULL;
+ }
+ if (w) {
+ av_free (w);
+ w = NULL;
+ }
+ w = (float *)av_malloc(sizeof(float)*wsize);
+ }
+
+ if (!s) {
+ s = av_rdft_init(n,DFT_R2C);
+ }
+ if (!si) {
+ si = av_rdft_init(n,IDFT_C2R);
+ }
+
+ if (isign == 1) {
+ av_rdft_calc (s, x);
+ }
+ else {
+ av_rdft_calc (si, x);
+ }
+}
+