Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/opengl/mythvaapidrminterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/opengl/mythvaapiglxinterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions mythtv/libs/libmythtv/opengl/mythvaapiinterop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -207,10 +215,7 @@ VASurfaceID MythVAAPIInterop::VerifySurface(MythRenderOpenGL *Context, MythVideo
}

// Retrieve surface
auto id = static_cast<VASurfaceID>(reinterpret_cast<uintptr_t>(Frame->m_buffer));
if (id)
result = id;
return result;
return static_cast<VASurfaceID>(reinterpret_cast<uintptr_t>(Frame->m_buffer));
}

bool MythVAAPIInterop::SetupDeinterlacer(MythDeintType Deinterlacer, bool DoubleRate,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/opengl/mythvaapiinterop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

Expand Down
Loading