Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-09-26 16:35:46 +08:00
commit 1205f246e9
112 changed files with 123 additions and 21765 deletions

View file

@ -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)

View file

@ -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);

View 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

View file

@ -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

View file

@ -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,