mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1879873
- Remove MOZ_LIBAV_FFT. r=karlt
We have some time to use av_fft.h, after which we'll have to use tx.h directly. It's not hard to update. Differential Revision: https://phabricator.services.mozilla.com/D201601
This commit is contained in:
parent
a71183d09c
commit
555a8424d6
@ -1267,11 +1267,6 @@ if CONFIG["MOZ_SYSTEM_JPEG"]:
|
||||
"jpeglib.h",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_LIBAV_FFT"]:
|
||||
system_headers += [
|
||||
"libavcodec/avfft.h",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_SYSTEM_PNG"]:
|
||||
system_headers += [
|
||||
"png.h",
|
||||
|
@ -36,9 +36,7 @@ namespace mozilla {
|
||||
|
||||
typedef std::complex<double> Complex;
|
||||
|
||||
#ifdef MOZ_LIBAV_FFT
|
||||
FFmpegRDFTFuncs FFTBlock::sRDFTFuncs;
|
||||
#endif
|
||||
|
||||
static double fdlibm_cabs(const Complex& z) {
|
||||
return fdlibm_hypot(real(z), imag(z));
|
||||
|
@ -7,31 +7,17 @@
|
||||
#ifndef FFTBlock_h_
|
||||
#define FFTBlock_h_
|
||||
|
||||
#ifdef BUILD_ARM_NEON
|
||||
# include <cmath>
|
||||
# include "mozilla/arm.h"
|
||||
# include "dl/sp/api/omxSP.h"
|
||||
#endif
|
||||
|
||||
#include "AlignedTArray.h"
|
||||
#include "AudioNodeEngine.h"
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
# include "FFmpegRDFTTypes.h"
|
||||
# include "FFVPXRuntimeLinker.h"
|
||||
#else
|
||||
# include "kiss_fft/kiss_fftr.h"
|
||||
#endif
|
||||
#include "FFmpegRDFTTypes.h"
|
||||
#include "FFVPXRuntimeLinker.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// This class defines an FFT block, loosely modeled after Blink's FFTFrame
|
||||
// class to make sharing code with Blink easy.
|
||||
// Currently it's implemented on top of KissFFT on all platforms.
|
||||
class FFTBlock final {
|
||||
union ComplexU {
|
||||
#if !defined(MOZ_LIBAV_FFT)
|
||||
kiss_fft_cpx c;
|
||||
#endif
|
||||
float f[2];
|
||||
struct {
|
||||
float r;
|
||||
@ -41,28 +27,13 @@ class FFTBlock final {
|
||||
|
||||
public:
|
||||
static void MainThreadInit() {
|
||||
#ifdef MOZ_LIBAV_FFT
|
||||
FFVPXRuntimeLinker::Init();
|
||||
if (!sRDFTFuncs.init) {
|
||||
FFVPXRuntimeLinker::GetRDFTFuncs(&sRDFTFuncs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
explicit FFTBlock(uint32_t aFFTSize)
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
: mAvRDFT(nullptr),
|
||||
mAvIRDFT(nullptr)
|
||||
#else
|
||||
: mKissFFT(nullptr),
|
||||
mKissIFFT(nullptr)
|
||||
# ifdef BUILD_ARM_NEON
|
||||
,
|
||||
mOmxFFT(nullptr),
|
||||
mOmxIFFT(nullptr)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
explicit FFTBlock(uint32_t aFFTSize) : mAvRDFT(nullptr), mAvIRDFT(nullptr) {
|
||||
MOZ_COUNT_CTOR(FFTBlock);
|
||||
SetFFTSize(aFFTSize);
|
||||
}
|
||||
@ -83,22 +54,11 @@ class FFTBlock final {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
PodCopy(mOutputBuffer.Elements()->f, aData, mFFTSize);
|
||||
sRDFTFuncs.calc(mAvRDFT, mOutputBuffer.Elements()->f);
|
||||
// Recover packed Nyquist.
|
||||
mOutputBuffer[mFFTSize / 2].r = mOutputBuffer[0].i;
|
||||
mOutputBuffer[0].i = 0.0f;
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
if (mozilla::supports_neon()) {
|
||||
omxSP_FFTFwd_RToCCS_F32_Sfs(aData, mOutputBuffer.Elements()->f, mOmxFFT);
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
kiss_fftr(mKissFFT, aData, &(mOutputBuffer.Elements()->c));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// Inverse-transform internal data and store the resulting FFTSize()
|
||||
// points in aDataOut.
|
||||
@ -116,27 +76,13 @@ class FFTBlock final {
|
||||
return;
|
||||
};
|
||||
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
{
|
||||
// Even though this function doesn't scale, the libav forward transform
|
||||
// gives a value that needs scaling by 2 in order for things to turn out
|
||||
// similar to how we expect from kissfft/openmax.
|
||||
AudioBufferCopyWithScale(mOutputBuffer.Elements()->f, 2.0f, aDataOut,
|
||||
mFFTSize);
|
||||
aDataOut[1] = 2.0f * mOutputBuffer[mFFTSize / 2].r; // Packed Nyquist
|
||||
sRDFTFuncs.calc(mAvIRDFT, aDataOut);
|
||||
}
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
if (mozilla::supports_neon()) {
|
||||
omxSP_FFTInv_CCSToR_F32_Sfs_unscaled(mOutputBuffer.Elements()->f,
|
||||
aDataOut, mOmxIFFT);
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
kiss_fftri(mKissIFFT, &(mOutputBuffer.Elements()->c), aDataOut);
|
||||
}
|
||||
#endif
|
||||
// Even though this function doesn't scale, the libav forward transform
|
||||
// gives a value that needs scaling by 2 in order for things to turn out
|
||||
// similar to how we expect from kissfft/openmax.
|
||||
AudioBufferCopyWithScale(mOutputBuffer.Elements()->f, 2.0f, aDataOut,
|
||||
mFFTSize);
|
||||
aDataOut[1] = 2.0f * mOutputBuffer[mFFTSize / 2].r; // Packed Nyquist
|
||||
sRDFTFuncs.calc(mAvIRDFT, aDataOut);
|
||||
}
|
||||
|
||||
void Multiply(const FFTBlock& aFrame) {
|
||||
@ -188,7 +134,6 @@ class FFTBlock final {
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||
size_t amount = 0;
|
||||
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
auto ComputedSizeOfContextIfSet = [this](void* aContext) -> size_t {
|
||||
if (!aContext) {
|
||||
return 0;
|
||||
@ -209,17 +154,6 @@ class FFTBlock final {
|
||||
|
||||
amount += ComputedSizeOfContextIfSet(mAvRDFT);
|
||||
amount += ComputedSizeOfContextIfSet(mAvIRDFT);
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
amount += aMallocSizeOf(mOmxFFT);
|
||||
amount += aMallocSizeOf(mOmxIFFT);
|
||||
# endif
|
||||
# ifdef USE_SIMD
|
||||
# error kiss fft uses malloc only when USE_SIMD is not defined
|
||||
# endif
|
||||
amount += aMallocSizeOf(mKissFFT);
|
||||
amount += aMallocSizeOf(mKissIFFT);
|
||||
#endif
|
||||
amount += mOutputBuffer.ShallowSizeOfExcludingThis(aMallocSizeOf);
|
||||
return amount;
|
||||
}
|
||||
@ -233,7 +167,6 @@ class FFTBlock final {
|
||||
void operator=(const FFTBlock& other) = delete;
|
||||
|
||||
bool EnsureFFT() {
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
if (!mAvRDFT) {
|
||||
if (!sRDFTFuncs.init) {
|
||||
return false;
|
||||
@ -241,25 +174,10 @@ class FFTBlock final {
|
||||
|
||||
mAvRDFT = sRDFTFuncs.init(FloorLog2(mFFTSize), DFT_R2C);
|
||||
}
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
if (mozilla::supports_neon()) {
|
||||
if (!mOmxFFT) {
|
||||
mOmxFFT = createOmxFFT(mFFTSize);
|
||||
}
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
if (!mKissFFT) {
|
||||
mKissFFT = kiss_fftr_alloc(mFFTSize, 0, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EnsureIFFT() {
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
if (!mAvIRDFT) {
|
||||
if (!sRDFTFuncs.init) {
|
||||
return false;
|
||||
@ -267,44 +185,10 @@ class FFTBlock final {
|
||||
|
||||
mAvIRDFT = sRDFTFuncs.init(FloorLog2(mFFTSize), IDFT_C2R);
|
||||
}
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
if (mozilla::supports_neon()) {
|
||||
if (!mOmxIFFT) {
|
||||
mOmxIFFT = createOmxFFT(mFFTSize);
|
||||
}
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
if (!mKissIFFT) {
|
||||
mKissIFFT = kiss_fftr_alloc(mFFTSize, 1, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef BUILD_ARM_NEON
|
||||
static OMXFFTSpec_R_F32* createOmxFFT(uint32_t aFFTSize) {
|
||||
MOZ_ASSERT((aFFTSize & (aFFTSize - 1)) == 0);
|
||||
OMX_INT bufSize;
|
||||
OMX_INT order = FloorLog2(aFFTSize);
|
||||
MOZ_ASSERT(aFFTSize >> order == 1);
|
||||
OMXResult status = omxSP_FFTGetBufSize_R_F32(order, &bufSize);
|
||||
if (status == OMX_Sts_NoErr) {
|
||||
OMXFFTSpec_R_F32* context =
|
||||
static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize));
|
||||
if (omxSP_FFTInit_R_F32(context, order) != OMX_Sts_NoErr) {
|
||||
return nullptr;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Clear() {
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
if (mAvRDFT) {
|
||||
sRDFTFuncs.end(mAvRDFT);
|
||||
mAvRDFT = nullptr;
|
||||
@ -313,34 +197,15 @@ class FFTBlock final {
|
||||
sRDFTFuncs.end(mAvIRDFT);
|
||||
mAvIRDFT = nullptr;
|
||||
}
|
||||
#else
|
||||
# ifdef BUILD_ARM_NEON
|
||||
free(mOmxFFT);
|
||||
free(mOmxIFFT);
|
||||
mOmxFFT = mOmxIFFT = nullptr;
|
||||
# endif
|
||||
free(mKissFFT);
|
||||
free(mKissIFFT);
|
||||
mKissFFT = mKissIFFT = nullptr;
|
||||
#endif
|
||||
}
|
||||
void AddConstantGroupDelay(double sampleFrameDelay);
|
||||
void InterpolateFrequencyComponents(const FFTBlock& block0,
|
||||
const FFTBlock& block1, double interp);
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
static FFmpegRDFTFuncs sRDFTFuncs;
|
||||
RDFTContext* mAvRDFT;
|
||||
RDFTContext* mAvIRDFT;
|
||||
#else
|
||||
kiss_fftr_cfg mKissFFT;
|
||||
kiss_fftr_cfg mKissIFFT;
|
||||
# ifdef BUILD_ARM_NEON
|
||||
OMXFFTSpec_R_F32* mOmxFFT;
|
||||
OMXFFTSpec_R_F32* mOmxIFFT;
|
||||
# endif
|
||||
#endif
|
||||
AlignedTArray<ComplexU> mOutputBuffer;
|
||||
uint32_t mFFTSize;
|
||||
uint32_t mFFTSize{};
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -1,11 +1,9 @@
|
||||
// This file contains overrides for config.h, that can be platform-specific.
|
||||
|
||||
#ifdef MOZ_LIBAV_FFT
|
||||
#undef CONFIG_FFT
|
||||
#undef CONFIG_RDFT
|
||||
#define CONFIG_FFT 1
|
||||
#define CONFIG_RDFT 1
|
||||
#endif
|
||||
|
||||
// override '#define EXTERN_ASM _' in config_generic.h to allow building with
|
||||
// gcc on arm
|
||||
|
@ -30,11 +30,9 @@ av_packet_free
|
||||
av_parser_close
|
||||
av_parser_init
|
||||
av_parser_parse2
|
||||
#ifdef MOZ_LIBAV_FFT
|
||||
av_rdft_calc
|
||||
av_rdft_end
|
||||
av_rdft_init
|
||||
#endif
|
||||
av_shrink_packet
|
||||
av_vorbis_parse_frame
|
||||
av_vorbis_parse_frame_flags
|
||||
|
@ -22,6 +22,7 @@ SOURCES += [
|
||||
'allcodecs.c',
|
||||
'avcodec.c',
|
||||
'avdct.c',
|
||||
'avfft.c',
|
||||
'avpacket.c',
|
||||
'bitstream.c',
|
||||
'bitstream_filters.c',
|
||||
@ -145,11 +146,6 @@ else:
|
||||
CXXFLAGS += CONFIG["MOZ_LIBVPX_CFLAGS"]
|
||||
OS_LIBS += CONFIG["MOZ_LIBVPX_LIBS"]
|
||||
|
||||
if CONFIG['MOZ_LIBAV_FFT']:
|
||||
SOURCES += [
|
||||
'avfft.c',
|
||||
]
|
||||
|
||||
SYMBOLS_FILE = 'avcodec.symbols'
|
||||
NoVisibilityFlags()
|
||||
|
||||
|
@ -2377,17 +2377,6 @@ with only_when(compile_environment):
|
||||
|
||||
# FFmpeg's ffvpx configuration
|
||||
# ==============================================================
|
||||
with only_when(compile_environment):
|
||||
|
||||
@depends(target)
|
||||
def libav_fft(target):
|
||||
if target.os == "Android" and target.cpu != "arm":
|
||||
return True
|
||||
return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
|
||||
|
||||
set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
|
||||
set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
|
||||
|
||||
|
||||
# Artifact builds need MOZ_FFVPX defined as if compilation happened.
|
||||
with only_when(compile_environment | artifact_builds):
|
||||
|
Loading…
Reference in New Issue
Block a user