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