moonlight-qt/app/streaming/video/ffmpeg-renderers/dxva2.h

86 lines
2.4 KiB
C
Raw Normal View History

2018-07-13 09:28:10 +00:00
#pragma once
#include "renderer.h"
#include "pacer/pacer.h"
2018-07-13 09:28:10 +00:00
#include <d3d9.h>
#include <dxva2api.h>
extern "C" {
#include <libavcodec/dxva2.h>
}
2018-08-16 06:57:03 +00:00
class DXVA2Renderer : public IFFmpegRenderer
2018-07-13 09:28:10 +00:00
{
public:
DXVA2Renderer(int decoderSelectionPass);
2019-04-13 05:12:53 +00:00
virtual ~DXVA2Renderer() override;
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override;
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override;
virtual int getDecoderColorspace() override;
2022-10-05 03:56:21 +00:00
virtual int getDecoderCapabilities() override;
2018-07-13 09:28:10 +00:00
private:
bool initializeDecoder();
bool initializeRenderer();
bool initializeDevice(SDL_Window* window, bool enableVsync);
bool isDecoderBlacklisted();
bool initializeDeviceQuirks();
void renderOverlay(Overlay::OverlayType type);
2018-07-13 09:28:10 +00:00
2022-01-22 05:09:43 +00:00
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 68, 0)
#define FF_POOL_SIZE_TYPE size_t
#else
#define FF_POOL_SIZE_TYPE int
#endif
2018-07-13 09:28:10 +00:00
static
2022-01-22 05:09:43 +00:00
AVBufferRef* ffPoolAlloc(void* opaque, FF_POOL_SIZE_TYPE size);
2018-07-13 09:28:10 +00:00
static
void ffPoolDummyDelete(void*, uint8_t*);
static
int ffGetBuffer2(AVCodecContext* context, AVFrame* frame, int flags);
int m_DecoderSelectionPass;
2018-07-13 09:28:10 +00:00
int m_VideoFormat;
2018-07-19 02:10:14 +00:00
int m_VideoWidth;
int m_VideoHeight;
int m_DisplayWidth;
int m_DisplayHeight;
2018-07-13 09:28:10 +00:00
struct dxva_context m_DXVAContext;
IDirect3DSurface9* m_DecSurfaces[19];
2018-07-13 09:28:10 +00:00
DXVA2_ConfigPictureDecode m_Config;
IDirectXVideoDecoderService* m_DecService;
IDirectXVideoDecoder* m_Decoder;
int m_SurfacesUsed;
AVBufferPool* m_Pool;
SDL_SpinLock m_OverlayLock;
IDirect3DVertexBuffer9* m_OverlayVertexBuffers[Overlay::OverlayMax];
IDirect3DTexture9* m_OverlayTextures[Overlay::OverlayMax];
IDirect3DDevice9Ex* m_Device;
2018-07-13 09:28:10 +00:00
IDirect3DSurface9* m_RenderTarget;
IDirectXVideoProcessorService* m_ProcService;
IDirectXVideoProcessor* m_Processor;
DXVA2_ValueRange m_BrightnessRange;
DXVA2_ValueRange m_ContrastRange;
DXVA2_ValueRange m_HueRange;
DXVA2_ValueRange m_SaturationRange;
DXVA2_VideoDesc m_Desc;
REFERENCE_TIME m_FrameIndex;
bool m_BlockingPresent;
#define DXVA2_QUIRK_NO_VP 0x01
#define DXVA2_QUIRK_SET_DEST_FORMAT 0x02
#define DXVA2_QUIRK_WDDM_20_PLUS 0x04
int m_DeviceQuirks;
2018-07-13 09:28:10 +00:00
};