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

76 lines
2 KiB
C
Raw Normal View History

2018-07-13 02:28:10 -07:00
#pragma once
#include "renderer.h"
#include "pacer/pacer.h"
2018-07-13 02:28:10 -07:00
#include <d3d9.h>
#include <d3dx9.h>
2018-07-13 02:28:10 -07:00
#include <dxva2api.h>
extern "C" {
#include <libavcodec/dxva2.h>
}
2018-08-15 23:57:03 -07:00
class DXVA2Renderer : public IFFmpegRenderer
2018-07-13 02:28:10 -07:00
{
public:
DXVA2Renderer();
virtual ~DXVA2Renderer();
virtual bool initialize(SDL_Window* window,
int videoFormat,
int width,
int height,
int maxFps,
bool enableVsync);
2018-07-13 02:28:10 -07:00
virtual bool prepareDecoderContext(AVCodecContext* context);
virtual void renderFrameAtVsync(AVFrame* frame);
virtual bool needsTestFrame();
virtual int getDecoderCapabilities();
2018-12-25 12:57:00 -08:00
virtual FramePacingConstraint getFramePacingConstraint();
2018-07-13 02:28:10 -07:00
private:
bool initializeDecoder();
bool initializeRenderer();
bool initializeDevice(SDL_Window* window, bool enableVsync);
bool initializeOverlay();
bool isDecoderBlacklisted();
bool isDXVideoProcessorAPIBlacklisted();
2018-07-13 02:28:10 -07:00
static
AVBufferRef* ffPoolAlloc(void* opaque, int size);
static
void ffPoolDummyDelete(void*, uint8_t*);
static
int ffGetBuffer2(AVCodecContext* context, AVFrame* frame, int flags);
int m_VideoFormat;
2018-07-18 19:10:14 -07:00
int m_VideoWidth;
int m_VideoHeight;
int m_DisplayWidth;
int m_DisplayHeight;
2018-07-13 02:28:10 -07:00
struct dxva_context m_DXVAContext;
IDirect3DSurface9* m_DecSurfaces[19];
DXVA2_ConfigPictureDecode m_Config;
IDirectXVideoDecoderService* m_DecService;
IDirectXVideoDecoder* m_Decoder;
int m_SurfacesUsed;
AVBufferPool* m_Pool;
IDirect3DDevice9Ex* m_Device;
2018-07-13 02:28:10 -07: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;
LPD3DXFONT m_OverlayFont;
bool m_BlockingPresent;
2018-07-13 02:28:10 -07:00
};