2018-07-21 07:16:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "renderer.h"
|
|
|
|
|
2018-08-12 03:19:20 +00: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 07:16:03 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <va/va.h>
|
2018-08-12 02:43:36 +00:00
|
|
|
#ifdef HAVE_LIBVA_X11
|
2018-07-21 07:16:03 +00:00
|
|
|
#include <va/va_x11.h>
|
2018-08-12 02:43:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LIBVA_WAYLAND
|
|
|
|
#include <va/va_wayland.h>
|
|
|
|
#endif
|
2019-07-07 22:31:15 +00:00
|
|
|
#ifdef HAVE_LIBVA_DRM
|
|
|
|
#include <va/va_drm.h>
|
|
|
|
#endif
|
2018-07-21 07:16:03 +00:00
|
|
|
#include <libavutil/hwcontext_vaapi.h>
|
2020-04-13 08:40:28 +00:00
|
|
|
#ifdef HAVE_EGL
|
|
|
|
#include <va/va_drmcommon.h>
|
|
|
|
#endif
|
2018-07-21 07:16:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VAAPIRenderer : public IFFmpegRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VAAPIRenderer();
|
2019-04-13 05:12:53 +00:00
|
|
|
virtual ~VAAPIRenderer() override;
|
|
|
|
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
2020-02-09 01:47:26 +00:00
|
|
|
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
|
2019-04-13 05:12:53 +00:00
|
|
|
virtual void renderFrame(AVFrame* frame) override;
|
|
|
|
virtual bool needsTestFrame() override;
|
2019-04-13 05:54:21 +00:00
|
|
|
virtual bool isDirectRenderingSupported() override;
|
2019-12-15 00:58:04 +00:00
|
|
|
virtual int getDecoderColorspace() override;
|
2020-04-13 08:40:28 +00:00
|
|
|
#ifdef HAVE_EGL
|
|
|
|
virtual bool canExportEGL() override;
|
2020-05-14 02:31:25 +00:00
|
|
|
virtual bool initializeEGL(EGLDisplay dpy, const EGLExtensions &ext) override;
|
2020-04-13 08:40:28 +00:00
|
|
|
virtual ssize_t exportEGLImages(AVFrame *frame, EGLDisplay dpy, EGLImage images[EGL_MAX_PLANES]) override;
|
|
|
|
virtual void freeEGLImages(EGLDisplay dpy, EGLImage[EGL_MAX_PLANES]) override;
|
|
|
|
#endif
|
2018-07-21 07:16:03 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-26 22:38:05 +00:00
|
|
|
VADisplay openDisplay(SDL_Window* window);
|
|
|
|
|
2018-08-12 02:43:36 +00:00
|
|
|
int m_WindowSystem;
|
2018-07-21 07:16:03 +00:00
|
|
|
AVBufferRef* m_HwContext;
|
2019-07-07 22:31:15 +00:00
|
|
|
int m_DrmFd;
|
2020-04-27 03:13:00 +00:00
|
|
|
bool m_BlacklistedForDirectRendering;
|
2018-08-12 02:43:36 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBVA_X11
|
|
|
|
Window m_XWindow;
|
|
|
|
#endif
|
|
|
|
|
2018-07-21 07:16:03 +00:00
|
|
|
int m_VideoWidth;
|
|
|
|
int m_VideoHeight;
|
|
|
|
int m_DisplayWidth;
|
|
|
|
int m_DisplayHeight;
|
2020-04-13 08:40:28 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_EGL
|
|
|
|
VADRMPRIMESurfaceDescriptor m_PrimeDescriptor;
|
|
|
|
bool m_EGLExtDmaBuf;
|
|
|
|
#endif
|
2018-07-21 07:16:03 +00:00
|
|
|
};
|