2018-07-21 00:16:03 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
2018-08-11 20:19:20 -07:00
|
|
|
// 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;
|
2020-02-08 17:47:26 -08:00
|
|
|
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;
|
2019-12-14 16:58:04 -08:00
|
|
|
virtual int getDecoderColorspace() override;
|
2018-07-21 00:16:03 -07:00
|
|
|
|
|
|
|
private:
|
2020-04-26 15:38:05 -07:00
|
|
|
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;
|
2020-04-26 20:13:00 -07:00
|
|
|
bool m_BlacklistedForDirectRendering;
|
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;
|
|
|
|
};
|