diff --git a/dom/media/Benchmark.cpp b/dom/media/Benchmark.cpp index 0dace35e798a..5d87c5940719 100644 --- a/dom/media/Benchmark.cpp +++ b/dom/media/Benchmark.cpp @@ -22,6 +22,7 @@ #include "mozilla/Telemetry.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/gfx/gfxVars.h" +#include "nsIGfxInfo.h" #ifndef MOZ_WIDGET_ANDROID #include "WebMSample.h" @@ -33,7 +34,7 @@ namespace mozilla { // Update this version number to force re-running the benchmark. Such as when // an improvement to FFVP9 or LIBVPX is deemed worthwhile. -const uint32_t VP9Benchmark::sBenchmarkVersionID = 4; +const uint32_t VP9Benchmark::sBenchmarkVersionID = 5; const char* VP9Benchmark::sBenchmarkFpsPref = "media.benchmark.vp9.fps"; const char* VP9Benchmark::sBenchmarkFpsVersionCheck = "media.benchmark.vp9.versioncheck"; @@ -41,12 +42,47 @@ bool VP9Benchmark::sHasRunTest = false; // static bool -VP9Benchmark::IsVP9DecodeFast(bool aDefault) +VP9Benchmark::ShouldRun() { - // Disable VP9 estimizer on Mac, see bug 1400787. -#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_APPLEMEDIA) +#if defined(MOZ_WIDGET_ANDROID) + // Assume that the VP9 software decoder will always be too slow. return false; #else +#if defined(MOZ_APPLEMEDIA) + const nsCOMPtr gfxInfo = services::GetGfxInfo(); + nsString vendorID, deviceID; + gfxInfo->GetAdapterVendorID(vendorID); + // We won't run the VP9 benchmark on mac using an Intel GPU as performance are + // poor, see bug 1404042. + if (vendorID.EqualsLiteral("0x8086")) { + return false; + } + // Fall Through +#endif + return true; +#endif +} + +// static +uint32_t +VP9Benchmark::MediaBenchmarkVp9Fps() +{ + if (!ShouldRun()) { + return 0; + } + return StaticPrefs::MediaBenchmarkVp9Threshold(); +} + +// static +bool +VP9Benchmark::IsVP9DecodeFast(bool aDefault) +{ +#if defined(MOZ_WIDGET_ANDROID) + return false; +#else + if (!ShouldRun()) { + return false; + } static StaticMutex sMutex; uint32_t decodeFps = StaticPrefs::MediaBenchmarkVp9Fps(); uint32_t hadRecentUpdate = StaticPrefs::MediaBenchmarkVp9Versioncheck(); diff --git a/dom/media/Benchmark.h b/dom/media/Benchmark.h index f17e906b1f97..f6a5ff53b6a5 100644 --- a/dom/media/Benchmark.h +++ b/dom/media/Benchmark.h @@ -114,6 +114,11 @@ public: static const char* sBenchmarkFpsVersionCheck; static const uint32_t sBenchmarkVersionID; static bool sHasRunTest; + // Return the value of media.benchmark.vp9.fps preference (which will be 0 if + // not known) + static uint32_t MediaBenchmarkVp9Fps(); +private: + static bool ShouldRun(); }; } diff --git a/dom/media/mediacapabilities/MediaCapabilities.cpp b/dom/media/mediacapabilities/MediaCapabilities.cpp index 311f151d1386..e062b697e385 100644 --- a/dom/media/mediacapabilities/MediaCapabilities.cpp +++ b/dom/media/mediacapabilities/MediaCapabilities.cpp @@ -361,7 +361,7 @@ MediaCapabilities::DecodingInfo( powerEfficient = decoder->IsHardwareAccelerated(reason); if (!powerEfficient && VPXDecoder::IsVP9(config->mMimeType)) { smooth = VP9Benchmark::IsVP9DecodeFast(true /* default */); - uint32_t fps = StaticPrefs::MediaBenchmarkVp9Fps(); + uint32_t fps = VP9Benchmark::MediaBenchmarkVp9Fps(); if (!smooth && fps > 0) { // The VP9 estimizer decode a 1280x720 video. Let's adjust // the result for the resolution and frame rate of what we