Bug 1145029 - Disable DXVA for 4k videos on AMD hardware since it performs poorly. r=jya

This commit is contained in:
Matt Woodrow 2015-03-19 22:01:47 +13:00
parent 3e9a193e28
commit 067612065f
4 changed files with 40 additions and 2 deletions

View File

@ -486,7 +486,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
mInfo.mVideo.mDisplay =
nsIntSize(video.display_width, video.display_height);
mVideo.mCallback = new DecoderCallback(this, kVideo);
if (mSharedDecoderManager) {
if (mSharedDecoderManager && mPlatform->SupportsSharedDecoders(video)) {
mVideo.mDecoder =
mSharedDecoderManager->CreateVideoDecoder(mPlatform,
video,

View File

@ -137,6 +137,10 @@ public:
virtual void DisableHardwareAcceleration() {}
virtual bool SupportsSharedDecoders(const mp4_demuxer::VideoDecoderConfig& aConfig) const {
return true;
}
protected:
PlatformDecoderModule() {}
virtual ~PlatformDecoderModule() {}

View File

@ -14,6 +14,8 @@
#include "WMFMediaDataDecoder.h"
#include "nsIWindowsRegKey.h"
#include "nsComponentManagerUtils.h"
#include "nsIGfxInfo.h"
#include "GfxDriverInfo.h"
namespace mozilla {
@ -75,7 +77,7 @@ WMFDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aCon
new WMFMediaDataDecoder(new WMFVideoMFTManager(aConfig,
aLayersBackend,
aImageContainer,
sDXVAEnabled),
sDXVAEnabled && ShouldUseDXVA(aConfig)),
aVideoTaskQueue,
aCallback);
return decoder.forget();
@ -93,6 +95,34 @@ WMFDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aCon
return decoder.forget();
}
bool
WMFDecoderModule::ShouldUseDXVA(const mp4_demuxer::VideoDecoderConfig& aConfig) const
{
static bool isAMD = false;
static bool initialized = false;
if (!initialized) {
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
nsAutoString vendor;
gfxInfo->GetAdapterVendorID(vendor);
isAMD = vendor.Equals(widget::GfxDriverInfo::GetDeviceVendor(widget::VendorAMD), nsCaseInsensitiveStringComparator()) ||
vendor.Equals(widget::GfxDriverInfo::GetDeviceVendor(widget::VendorATI), nsCaseInsensitiveStringComparator());
initialized = true;
}
if (!isAMD) {
return true;
}
// Don't use DXVA for 4k videos or above, since it seems to perform poorly.
return aConfig.display_height <= 1920 && aConfig.display_height <= 1200;
}
bool
WMFDecoderModule::SupportsSharedDecoders(const mp4_demuxer::VideoDecoderConfig& aConfig) const
{
// If DXVA is enabled, but we're not going to use it for this specific config, then
// we can't use the shared decoder.
return !sDXVAEnabled || ShouldUseDXVA(aConfig);
}
bool
WMFDecoderModule::SupportsVideoMimeType(const char* aMimeType)
{

View File

@ -42,6 +42,8 @@ public:
sDXVAEnabled = false;
}
virtual bool SupportsSharedDecoders(const mp4_demuxer::VideoDecoderConfig& aConfig) const MOZ_OVERRIDE;
// Accessors that report whether we have the required MFTs available
// on the system to play various codecs. Windows Vista doesn't have the
// H.264/AAC decoders if the "Platform Update Supplement for Windows Vista"
@ -52,6 +54,8 @@ public:
// Called on main thread.
static void Init();
private:
bool ShouldUseDXVA(const mp4_demuxer::VideoDecoderConfig& aConfig) const;
static bool sIsWMFEnabled;
static bool sDXVAEnabled;
};