mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-26 10:27:32 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
1205f246e9
112 changed files with 123 additions and 21765 deletions
|
|
@ -147,6 +147,9 @@ FFmpegLibWrapper::Link()
|
|||
AV_FUNC(avcodec_free_frame, AV_FUNC_54)
|
||||
AV_FUNC(avcodec_send_packet, AV_FUNC_58)
|
||||
AV_FUNC(avcodec_receive_frame, AV_FUNC_58)
|
||||
AV_FUNC_OPTION(av_rdft_init, AV_FUNC_AVCODEC_ALL)
|
||||
AV_FUNC_OPTION(av_rdft_calc, AV_FUNC_AVCODEC_ALL)
|
||||
AV_FUNC_OPTION(av_rdft_end, AV_FUNC_AVCODEC_ALL)
|
||||
AV_FUNC(av_log_set_level, AV_FUNC_AVUTIL_ALL)
|
||||
AV_FUNC(av_malloc, AV_FUNC_AVUTIL_ALL)
|
||||
AV_FUNC(av_freep, AV_FUNC_AVUTIL_ALL)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef __FFmpegLibWrapper_h__
|
||||
#define __FFmpegLibWrapper_h__
|
||||
|
||||
#include "FFmpegRDFTTypes.h" // for AvRdftInitFn, etc.
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
|
|
@ -75,6 +76,11 @@ struct FFmpegLibWrapper
|
|||
int (*avcodec_send_packet)(AVCodecContext* avctx, const AVPacket* avpkt);
|
||||
int (*avcodec_receive_frame)(AVCodecContext* avctx, AVFrame* frame);
|
||||
|
||||
// libavcodec optional
|
||||
AvRdftInitFn av_rdft_init;
|
||||
AvRdftCalcFn av_rdft_calc;
|
||||
AvRdftEndFn av_rdft_end;
|
||||
|
||||
// libavutil
|
||||
void (*av_log_set_level)(int level);
|
||||
void* (*av_malloc)(size_t size);
|
||||
|
|
|
|||
34
dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
Normal file
34
dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef FFmpegRDFTTypes_h
|
||||
#define FFmpegRDFTTypes_h
|
||||
|
||||
struct RDFTContext;
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef RDFTContext* (*AvRdftInitFn)(int nbits, enum RDFTransformType trans);
|
||||
typedef void (*AvRdftCalcFn)(RDFTContext *s, FFTSample *data);
|
||||
typedef void (*AvRdftEndFn)(RDFTContext *s);
|
||||
|
||||
}
|
||||
|
||||
struct FFmpegRDFTFuncs
|
||||
{
|
||||
AvRdftInitFn init;
|
||||
AvRdftCalcFn calc;
|
||||
AvRdftEndFn end;
|
||||
};
|
||||
|
||||
#endif // FFmpegRDFTTypes_h
|
||||
|
|
@ -48,6 +48,7 @@ FFVPXRuntimeLinker::Init()
|
|||
return sLinkStatus == LinkStatus_SUCCEEDED;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
sLinkStatus = LinkStatus_FAILED;
|
||||
|
||||
// We retrieve the path of the lgpllibs library as this is where mozavcodec
|
||||
|
|
@ -109,4 +110,20 @@ FFVPXRuntimeLinker::CreateDecoderModule()
|
|||
return FFmpegDecoderModule<FFVPX_VERSION>::Create(&sFFVPXLib);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
FFVPXRuntimeLinker::GetRDFTFuncs(FFmpegRDFTFuncs* aOutFuncs)
|
||||
{
|
||||
MOZ_ASSERT(sLinkStatus != LinkStatus_INIT);
|
||||
if (sFFVPXLib.av_rdft_init &&
|
||||
sFFVPXLib.av_rdft_calc &&
|
||||
sFFVPXLib.av_rdft_end) {
|
||||
aOutFuncs->init = sFFVPXLib.av_rdft_init;
|
||||
aOutFuncs->calc = sFFVPXLib.av_rdft_calc;
|
||||
aOutFuncs->end = sFFVPXLib.av_rdft_end;
|
||||
} else {
|
||||
NS_WARNING("RDFT functions expected but not found");
|
||||
*aOutFuncs = FFmpegRDFTFuncs(); // zero
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -8,16 +8,24 @@
|
|||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
struct FFmpegRDFTFuncs;
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
class FFVPXRuntimeLinker
|
||||
{
|
||||
public:
|
||||
// Main thread only.
|
||||
static bool Init();
|
||||
// Main thread or after Init().
|
||||
static already_AddRefed<PlatformDecoderModule> CreateDecoderModule();
|
||||
|
||||
// Call (on any thread) after Init().
|
||||
static void GetRDFTFuncs(FFmpegRDFTFuncs* aOutFuncs);
|
||||
|
||||
private:
|
||||
// Set once on the main thread and then read from other threads.
|
||||
static enum LinkStatus {
|
||||
LinkStatus_INIT = 0,
|
||||
LinkStatus_FAILED,
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ if CONFIG['MOZ_WMF']:
|
|||
|
||||
if CONFIG['MOZ_FFVPX'] or CONFIG['MOZ_FFMPEG']:
|
||||
# common code to either FFmpeg or FFVPX
|
||||
EXPORTS += [
|
||||
'ffmpeg/FFmpegRDFTTypes.h',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'ffmpeg/FFmpegLibWrapper.cpp',
|
||||
]
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ AudioContext::AudioContext(nsPIDOMWindowInner* aWindow,
|
|||
if (mute) {
|
||||
Mute();
|
||||
}
|
||||
|
||||
FFTBlock::MainThreadInit();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ namespace mozilla {
|
|||
|
||||
typedef std::complex<double> Complex;
|
||||
|
||||
#ifdef MOZ_LIBAV_FFT
|
||||
FFmpegRDFTFuncs FFTBlock::sRDFTFuncs;
|
||||
#endif
|
||||
|
||||
FFTBlock* FFTBlock::CreateInterpolatedBlock(const FFTBlock& block0, const FFTBlock& block1, double interp)
|
||||
{
|
||||
FFTBlock* newBlock = new FFTBlock(block0.FFTSize());
|
||||
|
|
|
|||
|
|
@ -15,13 +15,8 @@
|
|||
#include "AlignedTArray.h"
|
||||
#include "AudioNodeEngine.h"
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "libavcodec/avfft.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "FFmpegRDFTTypes.h"
|
||||
#include "FFVPXRuntimeLinker.h"
|
||||
#else
|
||||
#include "kiss_fft/kiss_fftr.h"
|
||||
#endif
|
||||
|
|
@ -45,6 +40,16 @@ 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)
|
||||
|
|
@ -76,10 +81,12 @@ public:
|
|||
// Transform FFTSize() points of aData and store the result internally.
|
||||
void PerformFFT(const float* aData)
|
||||
{
|
||||
EnsureFFT();
|
||||
if (!EnsureFFT()) {
|
||||
return;
|
||||
}
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
PodCopy(mOutputBuffer.Elements()->f, aData, mFFTSize);
|
||||
av_rdft_calc(mAvRDFT, mOutputBuffer.Elements()->f);
|
||||
sRDFTFuncs.calc(mAvRDFT, mOutputBuffer.Elements()->f);
|
||||
// Recover packed Nyquist.
|
||||
mOutputBuffer[mFFTSize / 2].r = mOutputBuffer[0].i;
|
||||
mOutputBuffer[0].i = 0.0f;
|
||||
|
|
@ -106,7 +113,11 @@ public:
|
|||
// scaled, then the output will need scaling by 1/FFTSize().
|
||||
void GetInverseWithoutScaling(float* aDataOut)
|
||||
{
|
||||
EnsureIFFT();
|
||||
if (!EnsureIFFT()) {
|
||||
std::fill_n(aDataOut, mFFTSize, 0.0f);
|
||||
return;
|
||||
};
|
||||
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
{
|
||||
// Even though this function doesn't scale, the libav forward transform
|
||||
|
|
@ -115,7 +126,7 @@ public:
|
|||
AudioBufferCopyWithScale(mOutputBuffer.Elements()->f, 2.0f,
|
||||
aDataOut, mFFTSize);
|
||||
aDataOut[1] = 2.0f * mOutputBuffer[mFFTSize/2].r; // Packed Nyquist
|
||||
av_rdft_calc(mAvIRDFT, aDataOut);
|
||||
sRDFTFuncs.calc(mAvIRDFT, aDataOut);
|
||||
}
|
||||
#else
|
||||
#ifdef BUILD_ARM_NEON
|
||||
|
|
@ -215,11 +226,14 @@ private:
|
|||
FFTBlock(const FFTBlock& other) = delete;
|
||||
void operator=(const FFTBlock& other) = delete;
|
||||
|
||||
void EnsureFFT()
|
||||
bool EnsureFFT()
|
||||
{
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
if (!mAvRDFT) {
|
||||
mAvRDFT = av_rdft_init(log((double)mFFTSize)/M_LN2, DFT_R2C);
|
||||
if (!sRDFTFuncs.init) {
|
||||
return false;
|
||||
}
|
||||
mAvRDFT = sRDFTFuncs.init(log((double)mFFTSize)/M_LN2, DFT_R2C);
|
||||
}
|
||||
#else
|
||||
#ifdef BUILD_ARM_NEON
|
||||
|
|
@ -235,12 +249,17 @@ private:
|
|||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
void EnsureIFFT()
|
||||
|
||||
bool EnsureIFFT()
|
||||
{
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
if (!mAvIRDFT) {
|
||||
mAvIRDFT = av_rdft_init(log((double)mFFTSize)/M_LN2, IDFT_C2R);
|
||||
if (!sRDFTFuncs.init) {
|
||||
return false;
|
||||
}
|
||||
mAvIRDFT = sRDFTFuncs.init(log((double)mFFTSize)/M_LN2, IDFT_C2R);
|
||||
}
|
||||
#else
|
||||
#ifdef BUILD_ARM_NEON
|
||||
|
|
@ -256,6 +275,7 @@ private:
|
|||
}
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef BUILD_ARM_NEON
|
||||
|
|
@ -280,9 +300,14 @@ private:
|
|||
void Clear()
|
||||
{
|
||||
#if defined(MOZ_LIBAV_FFT)
|
||||
av_rdft_end(mAvRDFT);
|
||||
av_rdft_end(mAvIRDFT);
|
||||
mAvRDFT = mAvIRDFT = nullptr;
|
||||
if (mAvRDFT) {
|
||||
sRDFTFuncs.end(mAvRDFT);
|
||||
mAvRDFT = nullptr;
|
||||
}
|
||||
if (mAvIRDFT) {
|
||||
sRDFTFuncs.end(mAvIRDFT);
|
||||
mAvIRDFT = nullptr;
|
||||
}
|
||||
#else
|
||||
#ifdef BUILD_ARM_NEON
|
||||
free(mOmxFFT);
|
||||
|
|
@ -300,6 +325,7 @@ private:
|
|||
#if defined(MOZ_LIBAV_FFT)
|
||||
RDFTContext *mAvRDFT;
|
||||
RDFTContext *mAvIRDFT;
|
||||
static FFmpegRDFTFuncs sRDFTFuncs;
|
||||
#else
|
||||
kiss_fftr_cfg mKissFFT;
|
||||
kiss_fftr_cfg mKissIFFT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue