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

60 lines
1.4 KiB
C
Raw Normal View History

2018-07-21 00:16:03 -07:00
#pragma once
#include "renderer.h"
// Avoid X11 if SDL was built without it
#ifndef SDL_VIDEO_DRIVER_X11
#warning Unable to use libva-x11 without SDL support
#undef HAVE_LIBVA_X11
#endif
// Avoid Wayland if SDL was built without it
#ifndef SDL_VIDEO_DRIVER_WAYLAND
#warning Unable to use libva-wayland without SDL support
#undef HAVE_LIBVA_WAYLAND
#endif
2018-07-21 00:16:03 -07:00
extern "C" {
#include <va/va.h>
2018-08-11 19:43:36 -07:00
#ifdef HAVE_LIBVA_X11
2018-07-21 00:16:03 -07:00
#include <va/va_x11.h>
2018-08-11 19:43:36 -07:00
#endif
#ifdef HAVE_LIBVA_WAYLAND
#include <va/va_wayland.h>
#endif
2019-07-07 15:31:15 -07:00
#ifdef HAVE_LIBVA_DRM
#include <va/va_drm.h>
#endif
2018-07-21 00:16:03 -07:00
#include <libavutil/hwcontext_vaapi.h>
}
class VAAPIRenderer : public IFFmpegRenderer
{
public:
VAAPIRenderer();
2019-04-12 22:12:53 -07:00
virtual ~VAAPIRenderer() override;
virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
2019-04-12 22:12:53 -07:00
virtual void renderFrame(AVFrame* frame) override;
virtual bool needsTestFrame() override;
2019-04-12 22:54:21 -07:00
virtual bool isDirectRenderingSupported() override;
virtual int getDecoderColorspace() override;
2018-07-21 00:16:03 -07:00
private:
bool validateDriver(VADisplay display);
VADisplay openDisplay(SDL_Window* window);
2018-08-11 19:43:36 -07:00
int m_WindowSystem;
2018-07-21 00:16:03 -07:00
AVBufferRef* m_HwContext;
2019-07-07 15:31:15 -07:00
int m_DrmFd;
2018-08-11 19:43:36 -07:00
#ifdef HAVE_LIBVA_X11
Window m_XWindow;
#endif
2018-07-21 00:16:03 -07:00
int m_VideoWidth;
int m_VideoHeight;
int m_DisplayWidth;
int m_DisplayHeight;
};