Bug 1194753 - Wait longer when decoding the first frame of D3D9 DXVA video before deciding it is invalid. r=cpearce

This commit is contained in:
Matt Woodrow 2015-08-18 14:19:45 -04:00
parent ab4f3dab1d
commit 050cac5369
3 changed files with 12 additions and 3 deletions

View File

@ -71,6 +71,7 @@ private:
RefPtr<D3D9RecycleAllocator> mTextureClientAllocator;
nsRefPtr<IDirectXVideoDecoderService> mDecoderService;
UINT32 mResetToken;
bool mFirstFrame;
};
void GetDXVA2ExtendedFormatFromMFMediaType(IMFMediaType *pType,
@ -178,6 +179,7 @@ D3D9DXVA2Manager::SupportsConfig(IMFMediaType* aType)
D3D9DXVA2Manager::D3D9DXVA2Manager()
: mResetToken(0)
, mFirstFrame(true)
{
MOZ_COUNT_CTOR(D3D9DXVA2Manager);
MOZ_ASSERT(NS_IsMainThread());
@ -350,7 +352,8 @@ D3D9DXVA2Manager::CopyToImage(IMFSample* aSample,
"Wrong format?");
D3D9SurfaceImage* videoImage = static_cast<D3D9SurfaceImage*>(image.get());
hr = videoImage->SetData(D3D9SurfaceImage::Data(surface, aRegion, mTextureClientAllocator));
hr = videoImage->SetData(D3D9SurfaceImage::Data(surface, aRegion, mTextureClientAllocator, mFirstFrame));
mFirstFrame = false;
image.forget(aOutImage);

View File

@ -19,6 +19,7 @@ D3D9SurfaceImage::D3D9SurfaceImage()
: Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
, mSize(0, 0)
, mValid(false)
, mIsFirstFrame(false)
{}
D3D9SurfaceImage::~D3D9SurfaceImage()
@ -83,6 +84,7 @@ D3D9SurfaceImage::SetData(const Data& aData)
mTextureClient = textureClient;
mSize = region.Size();
mQuery = query;
mIsFirstFrame = aData.mIsFirstFrame;
return S_OK;
}
@ -103,7 +105,7 @@ D3D9SurfaceImage::EnsureSynchronized()
return;
}
int iterations = 0;
while (iterations < 10) {
while (iterations < (mIsFirstFrame ? 100 : 10)) {
HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
if (hr == S_FALSE) {
Sleep(1);

View File

@ -51,15 +51,18 @@ public:
struct Data {
Data(IDirect3DSurface9* aSurface,
const gfx::IntRect& aRegion,
D3D9RecycleAllocator* aAllocator)
D3D9RecycleAllocator* aAllocator,
bool aIsFirstFrame)
: mSurface(aSurface)
, mRegion(aRegion)
, mAllocator(aAllocator)
, mIsFirstFrame(aIsFirstFrame)
{}
RefPtr<IDirect3DSurface9> mSurface;
gfx::IntRect mRegion;
RefPtr<D3D9RecycleAllocator> mAllocator;
bool mIsFirstFrame;
};
D3D9SurfaceImage();
@ -90,6 +93,7 @@ private:
RefPtr<IDirect3DQuery9> mQuery;
RefPtr<SharedTextureClientD3D9> mTextureClient;
bool mValid;
bool mIsFirstFrame;
};
} // namepace layers