summaryrefslogtreecommitdiff
path: root/gst-libs/gst/fft/kiss_fftr_f64.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/fft/kiss_fftr_f64.c')
-rw-r--r--gst-libs/gst/fft/kiss_fftr_f64.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/gst-libs/gst/fft/kiss_fftr_f64.c b/gst-libs/gst/fft/kiss_fftr_f64.c
index 0a6c282b5..7ab406e4f 100644
--- a/gst-libs/gst/fft/kiss_fftr_f64.c
+++ b/gst-libs/gst/fft/kiss_fftr_f64.c
@@ -1,19 +1,10 @@
/*
-Copyright (c) 2003-2004, Mark Borgerding
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+ * Copyright (c) 2003-2004, Mark Borgerding. All rights reserved.
+ * This file is part of KISS FFT - https://github.com/mborgerding/kissfft
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ * See COPYING file for more information.
+ */
#include "kiss_fftr_f64.h"
#include "_kiss_fft_guts_f64.h"
@@ -24,7 +15,7 @@ struct kiss_fftr_f64_state
kiss_fft_f64_cpx *tmpbuf;
kiss_fft_f64_cpx *super_twiddles;
#ifdef USE_SIMD
- long pad;
+ void *pad;
#endif
};
@@ -33,18 +24,15 @@ kiss_fftr_f64_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
{
int i;
kiss_fftr_f64_cfg st = NULL;
- size_t subsize, memneeded;
+ size_t subsize = 0, memneeded;
- if (nfft & 1) {
- fprintf (stderr, "Real FFT optimization must be even.\n");
- return NULL;
- }
+ g_return_val_if_fail ((nfft & 1) == 0, NULL);
nfft >>= 1;
kiss_fft_f64_alloc (nfft, inverse_fft, NULL, &subsize);
- memneeded = ALIGN_STRUCT (sizeof (struct kiss_fftr_f64_state))
- + ALIGN_STRUCT (subsize)
- + sizeof (kiss_fft_f64_cpx) * (nfft * 3 / 2);
+ memneeded =
+ ALIGN_STRUCT (sizeof (struct kiss_fftr_f64_state)) +
+ ALIGN_STRUCT (subsize) + sizeof (kiss_fft_f64_cpx) * (nfft * 3 / 2);
if (lenmem == NULL) {
st = (kiss_fftr_f64_cfg) KISS_FFT_F64_MALLOC (memneeded);
@@ -65,7 +53,6 @@ kiss_fftr_f64_alloc (int nfft, int inverse_fft, void *mem, size_t * lenmem)
for (i = 0; i < nfft / 2; ++i) {
double phase =
-3.14159265358979323846264338327 * ((double) (i + 1) / nfft + .5);
-
if (inverse_fft)
phase *= -1;
kf_cexp (st->super_twiddles + i, phase);
@@ -81,8 +68,7 @@ kiss_fftr_f64 (kiss_fftr_f64_cfg st, const kiss_fft_f64_scalar * timedata,
int k, ncfft;
kiss_fft_f64_cpx fpnk, fpk, f1k, f2k, tw, tdc;
- /* kiss fft usage error: improper alloc */
- g_return_if_fail (st->substate->inverse == 0);
+ g_return_if_fail (!st->substate->inverse);
ncfft = st->substate->nfft;
@@ -136,8 +122,7 @@ kiss_fftri_f64 (kiss_fftr_f64_cfg st, const kiss_fft_f64_cpx * freqdata,
/* input buffer timedata is stored row-wise */
int k, ncfft;
- /* kiss fft usage error: improper alloc */
- g_return_if_fail (st->substate->inverse != 0);
+ g_return_if_fail (st->substate->inverse);
ncfft = st->substate->nfft;
@@ -147,7 +132,6 @@ kiss_fftri_f64 (kiss_fftr_f64_cfg st, const kiss_fft_f64_cpx * freqdata,
for (k = 1; k <= ncfft / 2; ++k) {
kiss_fft_f64_cpx fk, fnkc, fek, fok, tmp;
-
fk = freqdata[k];
fnkc.r = freqdata[ncfft - k].r;
fnkc.i = -freqdata[ncfft - k].i;