7#define LOC QString("VAAPIGLX: ")
21 uint flags = VA_FRAME_PICTURE;
28 flags = VA_FRAME_PICTURE;
33 bool doublerate =
true;
46 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Enabled deinterlacer '%1'")
50 bool top =
Frame->m_interlacedReverse ? !
Frame->m_topFieldFirst :
Frame->m_topFieldFirst;
54 Frame->m_deinterlaceInuse2x = doublerate;
55 flags = top ? VA_TOP_FIELD : VA_BOTTOM_FIELD;
60 Frame->m_deinterlaceInuse2x = doublerate;
61 flags = top ? VA_BOTTOM_FIELD : VA_TOP_FIELD;
67 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Disabled basic VAAPI deinterlacer");
75 switch (
Frame->m_colorspace)
78 case AVCOL_SPC_SMPTE170M:
84 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Using '%1' VAAPI colourspace")
102 QVector<VADisplayAttribute> supported;
104 auto* attribs =
new VADisplayAttribute[
static_cast<unsigned int>(num)];
108 va_status = vaQueryDisplayAttributes(
m_vaDisplay, attribs, &actual);
111 for (
int i = 0; i < actual; i++)
113 int type = attribs[i].type;
114 if ((attribs[i].flags & VA_DISPLAY_ATTRIB_SETTABLE) &&
115 (
type == VADisplayAttribBrightness ||
116 type == VADisplayAttribContrast ||
117 type == VADisplayAttribHue ||
118 type == VADisplayAttribSaturation ||
119 type == VADisplayAttribCSCMatrix))
121 supported.push_back(attribs[i]);
122 if (
type == VADisplayAttribBrightness)
124 if (
type == VADisplayAttribHue)
126 if (
type == VADisplayAttribContrast)
128 if (
type == VADisplayAttribSaturation)
141 if (supported.isEmpty())
165 VADisplayAttribType attrib = VADisplayAttribBrightness;
169 attrib = VADisplayAttribBrightness;
172 attrib = VADisplayAttribContrast;
175 attrib = VADisplayAttribHue;
179 attrib = VADisplayAttribSaturation;
191 int newval = Value + adjustment;
192 if (newval > 100) newval -= 100;
219 Display *display = glXGetCurrentDisplay();
222 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to open GLX display");
229 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLX VADisplay");
239 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Deleting GLX surface");
247std::vector<MythVideoTextureOpenGL*>
253 std::vector<MythVideoTextureOpenGL*> result;
291 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLX surface.");
296 result.push_back(texture);
317 m_vaDisplay = vaGetDisplay(glXGetCurrentDisplay());
319 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create X11 VADisplay");
328 Display* display = glXGetCurrentDisplay();
332 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Deleting GLX Pixmaps");
336 XSync(display, False);
344std::vector<MythVideoTextureOpenGL*>
350 std::vector<MythVideoTextureOpenGL*> result;
372 Display* display = glXGetCurrentDisplay();
377 const std::array<const int,23> fbattribs {
378 GLX_RENDER_TYPE, GLX_RGBA_BIT,
379 GLX_X_RENDERABLE, True,
380 GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
381 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
382 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
383 GLX_Y_INVERTED_EXT, True,
384 GLX_DOUBLEBUFFER, False,
391 GLXFBConfig *fbs = glXChooseFBConfig(display, DefaultScreen(display), fbattribs.data(), &fbcount);
394 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to retrieve GLX framebuffer config");
398 GLXFBConfig fbconfig = fbs[0];
399 XFree(
reinterpret_cast<void*
>(fbs));
404 XWindowAttributes xwattribs;
405 XGetWindowAttributes(display, DefaultRootWindow(display), &xwattribs);
406 m_pixmap = XCreatePixmap(display, DefaultRootWindow(display),
407 width, height,
static_cast<uint>(xwattribs.depth));
410 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create Pixmap");
414 const std::array<const int,7> attribs {
415 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
416 GLX_TEXTURE_FORMAT_EXT, xwattribs.depth == 32 ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
417 GLX_MIPMAP_TEXTURE_EXT, False, 0};
422 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLXPixmap");
429 std::vector<QSize> size;
432 if (textures.empty())
434 result.push_back(textures[0]);
449 auto width =
static_cast<unsigned short>(
m_textureSize.width());
450 auto height =
static_cast<unsigned short>(
m_textureSize.height());
452 0, 0, width, height, 0, 0, width, height,
456 Display* glxdisplay = glXGetCurrentDisplay();
459 XSync(glxdisplay, False);
460 m_openglContext->glBindTexture(QOpenGLTexture::Target2D, result[0]->m_textureId);
477 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to resolve 'texture_from_pixmap' functions");
489 Display* display = glXGetCurrentDisplay();
492 int screen = DefaultScreen(display);
493 QByteArray extensions(glXQueryExtensionsString(display, screen));
494 return extensions.contains(
"GLX_EXT_texture_from_pixmap");
QOpenGLTexture * m_texture
MythRenderOpenGL * m_openglContext
QHash< unsigned long long, std::vector< MythVideoTextureOpenGL * > > m_openglTextures
std::vector< MythVideoTextureOpenGL * > Acquire(MythRenderOpenGL *Context, MythVideoColourSpace *ColourSpace, MythVideoFrame *Frame, FrameScanType Scan) override
MythVAAPIInteropGLXCopy(MythPlayerUI *Player, MythRenderOpenGL *Context)
~MythVAAPIInteropGLXCopy() override
MYTH_GLXRELEASETEXIMAGEEXT m_glxReleaseTexImageEXT
MythVAAPIInteropGLXPixmap(MythPlayerUI *Player, MythRenderOpenGL *Context)
std::vector< MythVideoTextureOpenGL * > Acquire(MythRenderOpenGL *Context, MythVideoColourSpace *ColourSpace, MythVideoFrame *Frame, FrameScanType Scan) override
static bool IsSupported(MythRenderOpenGL *Context)
~MythVAAPIInteropGLXPixmap() override
MYTH_GLXBINDTEXIMAGEEXT m_glxBindTexImageEXT
~MythVAAPIInteropGLX() override
MythVAAPIInteropGLX(MythPlayerUI *Player, MythRenderOpenGL *Context, InteropType Type)
void InitPictureAttributes(MythVideoColourSpace *ColourSpace)
VADisplayAttribute * m_vaapiPictureAttributes
int m_vaapiPictureAttributeCount
MythDeintType m_basicDeinterlacer
uint GetFlagsForFrame(MythVideoFrame *Frame, FrameScanType Scan)
int SetPictureAttribute(PictureAttribute Attribute, int Value)
void InitaliseDisplay(void)
MythDeintType m_deinterlacer
VASurfaceID VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame)
VASurfaceID Deinterlace(MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan)
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
void PictureAttributeChanged(PictureAttribute Attribute, int Value)
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
int GetPictureAttribute(PictureAttribute Attribute)
static QString DeinterlacerName(MythDeintType Deint, bool DoubleRate, VideoFrameType Format=FMT_NONE)
VideoFrameType m_frameFormat
static std::vector< MythVideoTextureOpenGL * > CreateTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target=QOpenGLTexture::Target2D)
Create a set of textures suitable for the given Type and Format.
static MythVideoTextureOpenGL * CreateTexture(MythRenderOpenGL *Context, QSize Size, GLenum Target=QOpenGLTexture::Target2D, QOpenGLTexture::PixelType PixelType=QOpenGLTexture::UInt8, QOpenGLTexture::PixelFormat PixelFormat=QOpenGLTexture::RGBA, QOpenGLTexture::TextureFormat Format=QOpenGLTexture::NoFormat, QOpenGLTexture::Filter Filter=QOpenGLTexture::Linear, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Create and initialise a MythVideoTexture that is backed by a QOpenGLTexture.
VideoFrameType m_frameType
static void DeleteTexture(MythRenderOpenGL *Context, MythVideoTextureOpenGL *Texture)
static constexpr uint64_t DUMMY_INTEROP_ID
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void(*)(Display *, GLXDrawable, int) MYTH_GLXRELEASETEXIMAGEEXT
void(*)(Display *, GLXDrawable, int, int *) MYTH_GLXBINDTEXIMAGEEXT
static eu8 clamp(eu8 value, eu8 low, eu8 high)
PictureAttributeSupported
@ kPictureAttributeSupported_Colour
@ kPictureAttributeSupported_Brightness
@ kPictureAttributeSupported_Hue
@ kPictureAttributeSupported_Contrast
@ kPictureAttributeSupported_None
@ kPictureAttribute_Contrast
@ kPictureAttribute_Brightness
@ kPictureAttribute_Colour
bool is_interlaced(FrameScanType Scan)