Go to the documentation of this file.
7 #define LOC QString("VDPAUInterop: ")
19 if (std::any_of(vdpau->second.cbegin(), vdpau->second.cend(), [](
auto Type) { return Type == GL_VDPAU; }))
29 if (Render->hasExtension(
"GL_NV_vdpau_interop"))
34 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"GL_NV_vdpau_interop is not available");
87 av_buffer_unref(&ref);
98 (
static_cast<VdpVideoSurface
>(
reinterpret_cast<uintptr_t
>(
m_referenceFrames[0]->data)) ==
99 static_cast<VdpVideoSurface
>(
reinterpret_cast<uintptr_t
>(
Buffer->data))))
110 av_buffer_unref(&ref);
140 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Ready");
147 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to retrieve procs");
157 VdpChromaType chroma = VDP_CHROMA_TYPE_420;
170 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Setup deinterlacer '%1'")
179 std::vector<QSize> sizes;
180 sizes.push_back(size);
181 std::vector<MythVideoTextureOpenGL*> textures =
183 if (textures.empty())
196 m_initNV(
reinterpret_cast<void*
>(
static_cast<uintptr_t
>(DeviceContext->device)),
197 reinterpret_cast<const void*
>(DeviceContext->get_proc_address));
200 QOpenGLTexture::Target2D, 1, &texid);
204 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to register VdpOutputSurface. Will retry.");
224 std::vector<MythVideoTextureOpenGL*>
230 std::vector<MythVideoTextureOpenGL*> result;
238 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Display preempted. Decoder needs to be reset");
244 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Mismatched OpenGL contexts");
247 QSize surfacesize(
Frame->m_width,
Frame->m_height);
251 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Video texture size changed!");
263 auto* buffer =
reinterpret_cast<AVBufferRef*
>(
Frame->m_priv[1]);
264 if (!buffer || !buffer->data)
266 auto* frames =
reinterpret_cast<AVHWFramesContext*
>(buffer->data);
267 if (!frames || !frames->device_ctx)
269 auto *devicecontext =
reinterpret_cast<AVVDPAUDeviceContext*
>(frames->device_ctx->hwctx);
274 if (!
InitNV(devicecontext))
278 auto surface =
static_cast<VdpVideoSurface
>(
reinterpret_cast<uintptr_t
>(
Frame->m_buffer));
290 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Ignoring scan for non-interlaced HEVC frame");
298 bool doublerate =
true;
313 Frame->m_deinterlaceInuse2x = doublerate;
314 deinterlacer = driverdeint;
331 if (!
InitVDPAU(devicecontext, surface, deinterlacer, doublerate))
348 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No VDPAU CSC matrix support");
361 static_cast<int>(
Frame->m_interlacedReverse ? !
Frame->m_topFieldFirst :
383 LOG(VB_GENERAL, LOG_INFO,
LOC +
"VDPAU display preempted");
static constexpr uint64_t DUMMY_INTEROP_ID
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
void RotateReferenceFrames(AVBufferRef *Buffer)
void SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace)
MYTH_VDPAUINITNV m_initNV
MythVDPAUSurfaceNV(APIENTRY *)(const void *, GLenum, GLsizei, const GLuint *) MYTH_VDPAUREGOUTSURFNV
void(APIENTRY *)(GLsizei, MythVDPAUSurfaceNV *) MYTH_VDPAUMAPSURFNV
MythVideoColourSpace * m_colourSpace
static MythVDPAUInterop * CreateVDPAU(MythPlayerUI *Player, MythRenderOpenGL *Context, MythCodecID CodecId)
QFunctionPointer GetProcAddress(const QString &Proc) const
bool UpdateColourSpace(const MythVideoFrame *Frame)
Set the current colourspace to use.
~MythVDPAUInterop() override
static bool HaveVDPAU(bool Reinit=false)
static const struct wl_interface * types[]
bool InitNV(AVVDPAUDeviceContext *DeviceContext)
void SetSupportedAttributes(PictureAttributeSupported Supported)
Enable the given set of picture attributes.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythVDPAUHelper * m_helper
bool IsAttributeAvailable(uint Attribute)
VdpOutputSurface CreateOutputSurface(QSize Size)
void(APIENTRY *)(void) MYTH_VDPAUFININV
std::map< VideoFrameType, InteropTypes > InteropMap
void DeleteOutputSurface(VdpOutputSurface Surface)
MythDeintType m_deinterlacer
std::vector< MythVideoTextureOpenGL * > Acquire(MythRenderOpenGL *Context, MythVideoColourSpace *ColourSpace, MythVideoFrame *Frame, FrameScanType Scan) override
Map VDPAU video surfaces to an OpenGL texture.
VdpOutputSurface m_outputSurface
MythRenderOpenGL * m_openglContext
void DisplayPreempted(void)
A simple wrapper around VDPAU functionality.
void DeleteMixer(VdpVideoMixer Mixer)
QSize GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma)
MYTH_VDPAUSURFACCESSNV m_accessNV
VdpVideoMixer CreateMixer(QSize Size, VdpChromaType ChromaType=VDP_CHROMA_TYPE_420, MythDeintType Deinterlacer=DEINT_BASIC)
void(APIENTRY *)(const void *, const void *) MYTH_VDPAUINITNV
#define ALL_PICTURE_ATTRIBUTES
void CleanupDeinterlacer(void)
QHash< unsigned long long, std::vector< MythVideoTextureOpenGL * > > m_openglTextures
QVector< AVBufferRef * > m_referenceFrames
@ kPictureAttributeSupported_None
void Updated(bool PrimariesChanged)
VdpChromaType m_mixerChroma
virtual void DeleteTextures()
static QString DeinterlacerName(MythDeintType Deint, bool DoubleRate, VideoFrameType Format=FMT_NONE)
MythVDPAUInterop(MythPlayerUI *Player, MythRenderOpenGL *Context, MythCodecID CodecID)
void(APIENTRY *)(MythVDPAUSurfaceNV, GLenum) MYTH_VDPAUSURFACCESSNV
uint64_t m_discontinuityCounter
bool IsPreempted(void) const
void MixerRender(VdpVideoMixer Mixer, VdpVideoSurface Source, VdpOutputSurface Dest, FrameScanType Scan, int TopFieldFirst, QVector< AVBufferRef * > &Frames)
void UpdateColourSpace(bool PrimariesChanged)
MYTH_VDPAUFININV m_finiNV
MYTH_VDPAUMAPSURFNV m_unmapNV
MythVDPAUSurfaceNV m_outputSurfaceReg
virtual int IncrRef(void)
Increments reference count.
MYTH_VDPAUREGOUTSURFNV m_registerNV
bool is_interlaced(FrameScanType Scan)
void DisplayPreempted(void)
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
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.
MYTH_VDPAUMAPSURFNV m_mapNV
static void GetVDPAUTypes(MythRenderOpenGL *Render, MythInteropGPU::InteropMap &Types)
bool InitVDPAU(AVVDPAUDeviceContext *DeviceContext, VdpVideoSurface Surface, MythDeintType Deint, bool DoubleRate)