Dactyloidae/dom/media/platforms/wmf/DXVAVP9Manager.h
EAZYBLACK 1414824320 Add VP9 Hardware Decoding with DXVA (Non-MFT), Vista+
Thanks to Maggie (imjustsomeoneiguess) on discord for helping with a lot of this VP9 media code.
This is the first browser so far to support VP9 Non MFT
2026-09-15 18:36:03 +03:00

82 lines
2.2 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/. */
#ifndef DXVAVP9Manager_h_
#define DXVAVP9Manager_h_
#include "WMF.h"
#include "VP9DXVA.h"
#include "VP9HeaderParser.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Mutex.h"
#include "MediaInfo.h"
#include "ImageContainer.h"
#include "nsTArray.h"
#include "nsPrintfCString.h"
namespace mozilla {
namespace layers {
class KnowsCompositor;
class Image;
class D3D9RecycleAllocator;
}
class DXVAVP9Manager {
public:
DXVAVP9Manager();
~DXVAVP9Manager();
bool Init(IUnknown* aDeviceManager, uint32_t aWidth, uint32_t aHeight,
nsACString& aFailureReason);
HRESULT DecodeFrame(const uint8_t* aData, uint32_t aSize,
IDirect3DSurface9** aOutSurface,
bool* aOutShouldDisplay,
VP9FrameHeader* aOutHeader);
HRESULT ConfigureForSize(uint32_t aWidth, uint32_t aHeight);
void Flush();
void Shutdown();
bool IsValid() const { return mDecoder != nullptr; }
static const GUID& GetVP9DecoderGUID();
static bool SupportsVP9(IDirect3DDeviceManager9* aDeviceManager);
private:
HRESULT InitDecoder(uint32_t aWidth, uint32_t aHeight);
HRESULT AllocateSurfaces(uint32_t aWidth, uint32_t aHeight, uint32_t aCount);
void FreeSurfaces();
uint32_t PickNextSurface() const;
void FillPicParams(const VP9FrameHeader& aHeader,
UXP_DXVA_PicParams_VP9& aPicParams);
RefPtr<IDirect3DDeviceManager9> mDeviceManager;
RefPtr<IDirectXVideoDecoderService> mDecoderService;
RefPtr<IDirectXVideoDecoder> mDecoder;
static const uint32_t kMinSurfaces = 9;
static const uint32_t kDefaultSurfaces = 10;
static const uint32_t kMaxSurfaces = 24;
RefPtr<IDirect3DSurface9> mSurfaces[kMaxSurfaces];
uint32_t mNumSurfaces;
uint32_t mCurrentSurface;
uint32_t mWidth;
uint32_t mHeight;
uint8_t mRefFrameSurface[8];
uint32_t mRefFrameWidth[8];
uint32_t mRefFrameHeight[8];
uint32_t mFrameCount;
VP9HeaderParser mParser;
Mutex mLock;
};
} // namespace mozilla
#endif