diff --git a/mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp b/mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp index bed8ee9bb3a..d63ff47c1c1 100644 --- a/mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp +++ b/mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp @@ -180,7 +180,7 @@ MythVAAPIInteropDRM::Acquire(MythRenderOpenGL* Context, return result; VASurfaceID id = VerifySurface(Context, Frame); - if (!id || !m_vaDisplay) + if ((id == VA_INVALID_SURFACE) || !m_vaDisplay) return result; // Update frame colourspace and initialise on first frame diff --git a/mythtv/libs/libmythtv/opengl/mythvaapiglxinterop.cpp b/mythtv/libs/libmythtv/opengl/mythvaapiglxinterop.cpp index b426dc608fa..72fb676bdb8 100644 --- a/mythtv/libs/libmythtv/opengl/mythvaapiglxinterop.cpp +++ b/mythtv/libs/libmythtv/opengl/mythvaapiglxinterop.cpp @@ -272,7 +272,7 @@ MythVAAPIInteropGLXCopy::Acquire(MythRenderOpenGL* Context, // Retrieve the VASurface VASurfaceID id = VerifySurface(Context, Frame); - if (!id || !m_vaDisplay) + if ((id == VA_INVALID_SURFACE) || !m_vaDisplay) return result; // Initialise colourspace on first frame @@ -370,7 +370,7 @@ MythVAAPIInteropGLXPixmap::Acquire(MythRenderOpenGL* Context, // Retrieve the VASurface VASurfaceID id = VerifySurface(Context, Frame); - if (!id || !m_vaDisplay) + if ((id == VA_INVALID_SURFACE) || !m_vaDisplay) return result; // Initialise colourspace on first frame diff --git a/mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp b/mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp index 4fd626b3e63..714fcee74c3 100644 --- a/mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp +++ b/mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp @@ -175,19 +175,27 @@ void MythVAAPIInterop::DestroyDeinterlacer(void) m_deinterlacer = DEINT_NONE; m_deinterlacer2x = false; m_firstField = true; - m_lastFilteredFrame = 0; + m_lastFilteredFrame = VA_INVALID_SURFACE; m_lastFilteredFrameCount = 0; av_buffer_unref(&m_vppFramesContext); } +/*! \brief Check that Frame holds a VAAPI surface we can use. + * + * \returns The frame's VASurfaceID, or VA_INVALID_SURFACE on failure. + * + * \note m_buffer holds the VASurfaceID cast to a pointer, and 0 is a valid + * surface ID (the Intel iHD driver issues it), so a null m_buffer must not be + * treated as an error. + */ VASurfaceID MythVAAPIInterop::VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame) { - VASurfaceID result = 0; + VASurfaceID result = VA_INVALID_SURFACE; if (!Frame) return result; if ((Frame->m_pixFmt != AV_PIX_FMT_VAAPI) || (Frame->m_type != FMT_VAAPI) || - !Frame->m_buffer || !Frame->m_priv[1]) + !Frame->m_priv[1]) return result; // Sanity check the context @@ -207,10 +215,7 @@ VASurfaceID MythVAAPIInterop::VerifySurface(MythRenderOpenGL *Context, MythVideo } // Retrieve surface - auto id = static_cast(reinterpret_cast(Frame->m_buffer)); - if (id) - result = id; - return result; + return static_cast(reinterpret_cast(Frame->m_buffer)); } bool MythVAAPIInterop::SetupDeinterlacer(MythDeintType Deinterlacer, bool DoubleRate, @@ -474,7 +479,7 @@ VASurfaceID MythVAAPIInterop::Deinterlace(MythVideoFrame *Frame, VASurfaceID Cur // buffering in the VAAPI frames context, causes the image to 'jiggle' when using // double rate deinterlacing. If we are confident this is a pause frame we have seen, // return the last deinterlaced frame. - if (Frame->m_pauseFrame && m_lastFilteredFrame && (m_lastFilteredFrameCount == Frame->m_frameCounter)) + if (Frame->m_pauseFrame && (m_lastFilteredFrame != VA_INVALID_SURFACE) && (m_lastFilteredFrameCount == Frame->m_frameCounter)) return m_lastFilteredFrame; Frame->m_deinterlaceInuse = m_deinterlacer | DEINT_DRIVER; diff --git a/mythtv/libs/libmythtv/opengl/mythvaapiinterop.h b/mythtv/libs/libmythtv/opengl/mythvaapiinterop.h index e102bb33767..6422b2637f6 100644 --- a/mythtv/libs/libmythtv/opengl/mythvaapiinterop.h +++ b/mythtv/libs/libmythtv/opengl/mythvaapiinterop.h @@ -66,7 +66,7 @@ class MythVAAPIInterop : public MythOpenGLInterop bool m_filterError { false }; int m_filterWidth { 0 }; int m_filterHeight { 0 }; - VASurfaceID m_lastFilteredFrame { 0 }; + VASurfaceID m_lastFilteredFrame { VA_INVALID_SURFACE }; uint64_t m_lastFilteredFrameCount { 0 }; };