bug 1476231 add accessor for ffvpx real DFT functions r?jya
MozReview-Commit-ID: AF2jl6ZnD4z
--- a/dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
+++ b/dom/media/platforms/ffmpeg/FFmpegRDFTTypes.h
@@ -21,9 +21,16 @@ enum RDFTransformType {
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
--- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
@@ -57,16 +57,17 @@ MozAVLink(nsIFile* aFile)
/* static */ bool
FFVPXRuntimeLinker::Init()
{
if (sLinkStatus) {
return sLinkStatus == LinkStatus_SUCCEEDED;
}
+ MOZ_ASSERT(NS_IsMainThread());
sLinkStatus = LinkStatus_FAILED;
// We retrieve the path of the lgpllibs library as this is where mozavcodec
// and mozavutil libs are located.
PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs");
if (lgpllibsname.IsEmpty()) {
return false;
}
@@ -115,9 +116,25 @@ FFVPXRuntimeLinker::Init()
FFVPXRuntimeLinker::CreateDecoderModule()
{
if (!Init()) {
return nullptr;
}
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
--- a/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.h
+++ b/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.h
@@ -4,26 +4,34 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __FFVPXRuntimeLinker_h__
#define __FFVPXRuntimeLinker_h__
#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,
LinkStatus_SUCCEEDED
} sLinkStatus;
};
}
--- a/dom/media/platforms/moz.build
+++ b/dom/media/platforms/moz.build
@@ -43,16 +43,19 @@ DIRS += [
'omx'
]
if CONFIG['MOZ_WMF']:
DIRS += [ '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',
]
if CONFIG['MOZ_FFVPX']:
DIRS += [
'ffmpeg/ffvpx',
]