5 #define LOC QString("VAAPIGLX: ")
19 uint flags = VA_FRAME_PICTURE;
26 flags = VA_FRAME_PICTURE;
31 bool doublerate =
true;
44 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Enabled deinterlacer '%1'")
48 bool top =
Frame->m_interlacedReverse ? !
Frame->m_topFieldFirst :
Frame->m_topFieldFirst;
52 Frame->m_deinterlaceInuse2x = doublerate;
53 flags = top ? VA_TOP_FIELD : VA_BOTTOM_FIELD;
58 Frame->m_deinterlaceInuse2x = doublerate;
59 flags = top ? VA_BOTTOM_FIELD : VA_TOP_FIELD;
65 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Disabled basic VAAPI deinterlacer");
73 switch (
Frame->m_colorspace)
76 case AVCOL_SPC_SMPTE170M:
82 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Using '%1' VAAPI colourspace")
100 QVector<VADisplayAttribute> supported;
102 auto* attribs =
new VADisplayAttribute[
static_cast<unsigned int>(num)];
106 va_status = vaQueryDisplayAttributes(
m_vaDisplay, attribs, &actual);
109 for (
int i = 0; i < actual; i++)
111 int type = attribs[i].type;
112 if ((attribs[i].flags & VA_DISPLAY_ATTRIB_SETTABLE) &&
113 (
type == VADisplayAttribBrightness ||
114 type == VADisplayAttribContrast ||
115 type == VADisplayAttribHue ||
116 type == VADisplayAttribSaturation ||
117 type == VADisplayAttribCSCMatrix))
119 supported.push_back(attribs[i]);
120 if (
type == VADisplayAttribBrightness)
122 if (
type == VADisplayAttribHue)
124 if (
type == VADisplayAttribContrast)
126 if (
type == VADisplayAttribSaturation)
139 if (supported.isEmpty())
163 VADisplayAttribType attrib = VADisplayAttribBrightness;
167 attrib = VADisplayAttribBrightness;
170 attrib = VADisplayAttribContrast;
173 attrib = VADisplayAttribHue;
177 attrib = VADisplayAttribSaturation;
189 int newval = Value + adjustment;
190 if (newval > 100) newval -= 100;
217 Display *display = glXGetCurrentDisplay();
220 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to open GLX display");
227 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLX VADisplay");
237 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Deleting GLX surface");
245 std::vector<MythVideoTextureOpenGL*>
251 std::vector<MythVideoTextureOpenGL*> result;
289 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLX surface.");
294 result.push_back(texture);
315 m_vaDisplay = vaGetDisplay(glXGetCurrentDisplay());
317 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create X11 VADisplay");
326 Display* display = glXGetCurrentDisplay();
330 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Deleting GLX Pixmaps");
334 XSync(display, False);
342 std::vector<MythVideoTextureOpenGL*>
348 std::vector<MythVideoTextureOpenGL*> result;
370 Display* display = glXGetCurrentDisplay();
375 const std::array<const int,23> fbattribs {
376 GLX_RENDER_TYPE, GLX_RGBA_BIT,
377 GLX_X_RENDERABLE, True,
378 GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
379 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
380 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_BIT_EXT,
381 GLX_Y_INVERTED_EXT, True,
382 GLX_DOUBLEBUFFER, False,
389 GLXFBConfig *fbs = glXChooseFBConfig(display, DefaultScreen(display), fbattribs.data(), &fbcount);
392 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to retrieve GLX framebuffer config");
396 GLXFBConfig fbconfig = fbs[0];
397 XFree(
reinterpret_cast<void*
>(fbs));
402 XWindowAttributes xwattribs;
403 XGetWindowAttributes(display, DefaultRootWindow(display), &xwattribs);
404 m_pixmap = XCreatePixmap(display, DefaultRootWindow(display),
405 width, height,
static_cast<uint>(xwattribs.depth));
408 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create Pixmap");
412 const std::array<const int,7> attribs {
413 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
414 GLX_TEXTURE_FORMAT_EXT, xwattribs.depth == 32 ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
415 GLX_MIPMAP_TEXTURE_EXT, False, 0};
420 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to create GLXPixmap");
427 std::vector<QSize> size;
430 if (textures.empty())
432 result.push_back(textures[0]);
447 auto width =
static_cast<unsigned short>(
m_textureSize.width());
448 auto height =
static_cast<unsigned short>(
m_textureSize.height());
450 0, 0, width, height, 0, 0, width, height,
454 Display* glxdisplay = glXGetCurrentDisplay();
457 XSync(glxdisplay, False);
458 m_openglContext->glBindTexture(QOpenGLTexture::Target2D, result[0]->m_textureId);
475 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to resolve 'texture_from_pixmap' functions");
487 Display* display = glXGetCurrentDisplay();
490 int screen = DefaultScreen(display);
491 QByteArray extensions(glXQueryExtensionsString(display, screen));
492 return extensions.contains(
"GLX_EXT_texture_from_pixmap");