Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b66b9686 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Automerger Merge Worker
Browse files

Merge changes I51a37d7d,I02d767e7 am: 647de5a3

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1845914

Change-Id: I8da444c60bf59691414e390f35068fdd0d53eaca
parents 4f1c4046 647de5a3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ cc_library_static {
    defaults: ["fluoride_defaults"],
    srcs: [
        "Common/*.cpp",
        "Common/fft/*.c",
        "Common/Tables/*.cpp",
        "Encoder/*.cpp",
        "Decoder/*.cpp",
@@ -46,6 +47,7 @@ cc_library_static {
    export_include_dirs: [
        "Api",
        "Common",
        "Common/fft",
        "Common/Tables",
        "TestSupport",
    ],
+32 −2
Original line number Diff line number Diff line
@@ -64,8 +64,7 @@
 * really wanted to make sure, that no other code or build impact is generated
 * by the options in this file.
 */
//TODO: pick a FFT implementation library
//#define USE_KISSFFT
#define USE_OWN_FFT

#if defined USE_FFTW || defined USE_FFTW_FOR_FFT
#include <fftw3.h>
@@ -116,6 +115,8 @@ class KissfftConfig {
  kissfft<double>* fft;
};

#elif defined USE_OWN_FFT
#include "fft.h"
#endif

DctIVDbl::DctIVDbl(uint16_t NF_)
@@ -134,6 +135,8 @@ DctIVDbl::DctIVDbl(uint16_t NF_)
#elif defined USE_KISSFFT
  dctIVconfig = new KissfftConfig(NF / 2);

#elif defined USE_OWN_FFT
// setup is not needed
#endif

  for (uint16_t n = 0; n < NF; n++) {
@@ -155,6 +158,8 @@ DctIVDbl::~DctIVDbl() {
    delete kissfftConfig;
  }

#elif defined USE_OWN_FFT
// cleanup is not needed
#endif
  if (nullptr != in) {
    delete[] in;
@@ -232,6 +237,31 @@ void DctIVDbl::run() {
    out[NF - 2 * n - 1] = -complexOut.imag() * 2;
  }

#elif defined USE_OWN_FFT

  fft_complex inbuf[NF / 2];
  fft_complex outbuf[NF / 2];

  // assume NF being 4 times an integer
  for (uint16_t n = 1; n < NF / 2; n += 2) {
    double buffer;
    buffer = in[n];
    in[n] = in[NF - n];
    in[NF - n] = buffer;
  }

  for (uint16_t n = 0; n < NF / 2; n++) {
    inbuf[n].re = in[2 * n];
    inbuf[n].im = in[2 * n + 1];
  }

  fft_complex* actal_output = fft(false, inbuf, NF / 2, inbuf, outbuf);

  for (uint16_t n = 0; n < NF / 2; n++) {
    out[2 * n] = actal_output[n].re;
    out[NF - 2 * n - 1] = actal_output[n].im;
  }

#else
  DctIVDirectDbl(NF, in, out);
#endif
+677 −0

File added.

Preview size limit exceeded, changes collapsed.

+52 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright 2021 The Android Open Source Project
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#ifndef __LC3_OWN_FFT_H
#define __LC3_OWN_FFT_H

#include <stdbool.h>

/**
 * Complex floating point number
 */

struct fft_complex {
  float re, im;
};

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Perform FFT
 * inverse         True on inverse transform else forward
 * x, y0, y1       Input, and 2 scratch buffers of size `n`
 * n               Number of points 30, 40, 60, 80, 90, 120, 160, 180, 240
 * return          The buffer `y0` or `y1` that hold the result
 *
 * Input `x` can be the same as the `y0` second scratch buffer
 */
struct fft_complex* fft(bool inverse, const struct fft_complex* x, int n,
                        struct fft_complex* y0, struct fft_complex* y1);

#ifdef __cplusplus
}
#endif

#endif /* __LC3_OWN_FFT_H */
 No newline at end of file