aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Frühberger <Peter.Fruehberger@gmail.com>2019-04-05 08:45:59 +0200
committerGitHub <noreply@github.com>2019-04-05 08:45:59 +0200
commit6d967eba1492d1e98b42955ad2542e5c9eee56da (patch)
tree0e499b89173d5ef16ec2757eca935e59637ba04a
parent587561f18cae15afc0509ec0c628fb6b1b071ef5 (diff)
parent3e38d747173d76e828ce0808b9b0b037a45201b4 (diff)
Merge pull request #15830 from pkerling/vaapi-pp-fixes
Fix VAAPI post-processing of PAFF video
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp217
-rw-r--r--xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h12
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.cpp1
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.cpp53
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h5
5 files changed, 94 insertions, 194 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
index c2a1444f52..4d874fdf72 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
@@ -204,7 +204,7 @@ bool CVAAPIContext::CreateContext()
#endif
int major_version, minor_version;
- if (!CheckSuccess(vaInitialize(m_display, &major_version, &minor_version)))
+ if (!CheckSuccess(vaInitialize(m_display, &major_version, &minor_version), "vaInitialize"))
{
vaTerminate(m_display);
m_display = NULL;
@@ -225,7 +225,7 @@ void CVAAPIContext::DestroyContext()
{
delete[] m_profiles;
if (m_display)
- CheckSuccess(vaTerminate(m_display));
+ CheckSuccess(vaTerminate(m_display), "vaTerminate");
#if VA_CHECK_VERSION(1, 0, 0)
vaSetErrorCallback(m_display, nullptr, nullptr);
@@ -240,7 +240,7 @@ void CVAAPIContext::QueryCaps()
int max_profiles = vaMaxNumProfiles(m_display);
m_profiles = new VAProfile[max_profiles];
- if (!CheckSuccess(vaQueryConfigProfiles(m_display, m_profiles, &m_profileCount)))
+ if (!CheckSuccess(vaQueryConfigProfiles(m_display, m_profiles, &m_profileCount), "vaQueryConfigProfiles"))
return;
for(int i = 0; i < m_profileCount; i++)
@@ -259,7 +259,7 @@ VAConfigAttrib CVAAPIContext::GetAttrib(VAProfile profile)
VAConfigAttrib attrib;
attrib.type = VAConfigAttribRTFormat;
- CheckSuccess(vaGetConfigAttributes(m_display, profile, VAEntrypointVLD, &attrib, 1));
+ CheckSuccess(vaGetConfigAttributes(m_display, profile, VAEntrypointVLD, &attrib, 1), "vaGetConfigAttributes");
return attrib;
}
@@ -281,16 +281,16 @@ VAConfigID CVAAPIContext::CreateConfig(VAProfile profile, VAConfigAttrib attrib)
CSingleLock lock(m_section);
VAConfigID config = VA_INVALID_ID;
- CheckSuccess(vaCreateConfig(m_display, profile, VAEntrypointVLD, &attrib, 1, &config));
+ CheckSuccess(vaCreateConfig(m_display, profile, VAEntrypointVLD, &attrib, 1, &config), "vaCreateConfig");
return config;
}
-bool CVAAPIContext::CheckSuccess(VAStatus status)
+bool CVAAPIContext::CheckSuccess(VAStatus status, const std::string& function)
{
if (status != VA_STATUS_SUCCESS)
{
- CLog::Log(LOGERROR, "VAAPI::%s error: %s", __FUNCTION__, vaErrorStr(status));
+ CLog::Log(LOGERROR, "VAAPI/context {} error: {} ({})", function, vaErrorStr(status), status);
return false;
}
return true;
@@ -765,7 +765,7 @@ long CDecoder::Release()
VASurfaceID surf;
while((surf = m_videoSurfaces.RemoveNext(true)) != VA_INVALID_SURFACE)
{
- CheckSuccess(vaDestroySurfaces(m_vaapiConfig.dpy, &surf, 1));
+ CheckSuccess(vaDestroySurfaces(m_vaapiConfig.dpy, &surf, 1), "vaDestroySurfaces");
}
}
return IHardwareDecoder::Release();
@@ -1069,11 +1069,11 @@ bool CDecoder::CanSkipDeint()
return m_bufferStats.CanSkipDeint();
}
-bool CDecoder::CheckSuccess(VAStatus status)
+bool CDecoder::CheckSuccess(VAStatus status, const std::string& function)
{
if (status != VA_STATUS_SUCCESS)
{
- CLog::Log(LOGERROR, "VAAPI::%s - error: %s", __FUNCTION__, vaErrorStr(status));
+ CLog::Log(LOGERROR, "VAAPI/decoder {} error: {} ({})", function, vaErrorStr(status), status);
m_ErrorCount++;
if(m_DisplayState == VAAPI_OPEN)
@@ -1121,13 +1121,10 @@ bool CDecoder::ConfigVAAPI()
VASurfaceID surfaces[32];
int nb_surfaces = m_vaapiConfig.maxReferences;
- if (!CheckSuccess(vaCreateSurfaces(m_vaapiConfig.dpy,
- format,
- m_vaapiConfig.surfaceWidth,
- m_vaapiConfig.surfaceHeight,
- surfaces,
- nb_surfaces,
- attribs, 1)))
+ if (!CheckSuccess(
+ vaCreateSurfaces(m_vaapiConfig.dpy, format, m_vaapiConfig.surfaceWidth,
+ m_vaapiConfig.surfaceHeight, surfaces,
+ nb_surfaces, attribs, 1), "vaCreateSurfaces"))
{
return false;
}
@@ -1186,13 +1183,13 @@ void CDecoder::FiniVAAPIOutput()
VASurfaceID surf;
while((surf = m_videoSurfaces.RemoveNext()) != VA_INVALID_SURFACE)
{
- CheckSuccess(vaDestroySurfaces(m_vaapiConfig.dpy, &surf, 1));
+ CheckSuccess(vaDestroySurfaces(m_vaapiConfig.dpy, &surf, 1), "vaDestroySurfaces");
}
m_videoSurfaces.Reset();
// destroy vaapi config
if (m_vaapiConfig.configId != VA_INVALID_ID)
- CheckSuccess(vaDestroyConfig(m_vaapiConfig.dpy, m_vaapiConfig.configId));
+ CheckSuccess(vaDestroyConfig(m_vaapiConfig.dpy, m_vaapiConfig.configId), "vaDestroyConfig");
m_vaapiConfig.configId = VA_INVALID_ID;
}
@@ -1550,16 +1547,8 @@ void COutput::StateMachine(int signal, Protocol *port, Message *msg)
// set initial number of
EnsureBufferPool();
- if (!m_vaError)
- {
- m_state = O_TOP_CONFIGURED_IDLE;
- msg->Reply(COutputControlProtocol::ACC);
- }
- else
- {
- m_state = O_TOP_ERROR;
- msg->Reply(COutputControlProtocol::ERROR);
- }
+ m_state = O_TOP_CONFIGURED_IDLE;
+ msg->Reply(COutputControlProtocol::ACC);
return;
default:
break;
@@ -1750,11 +1739,6 @@ void COutput::StateMachine(int signal, Protocol *port, Message *msg)
m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &outPic, sizeof(outPic));
}
m_config.stats->DecProcessed();
- if (m_vaError)
- {
- m_state = O_TOP_ERROR;
- return;
- }
}
m_state = O_TOP_CONFIGURED_IDLE;
m_extTimeout = 0;
@@ -1864,7 +1848,7 @@ bool COutput::Init()
m_config.processInfo->UpdateDeinterlacingMethods(deintMethods);
m_config.processInfo->SetDeinterlacingMethodDefault(EINTERLACEMETHOD::VS_INTERLACEMETHOD_VAAPI_BOB);
- m_vaError = false;
+ m_seenInterlaced = false;
return true;
}
@@ -1985,9 +1969,13 @@ void COutput::InitCycle()
EINTERLACEMETHOD method = m_config.processInfo->GetVideoSettings().m_InterlaceMethod;
bool interlaced = m_currentPicture.DVDPic.iFlags & DVP_FLAG_INTERLACED;
+ // Remember whether any interlaced frames were encountered already.
+ // If this is the case, the deinterlace method will never automatically be switched to NONE again in
+ // order to not change deint methods every few frames in PAFF streams.
+ m_seenInterlaced = m_seenInterlaced || interlaced;
if (!(flags & DVD_CODEC_CTRL_NO_POSTPROC) &&
- interlaced &&
+ m_seenInterlaced &&
method != VS_INTERLACEMETHOD_NONE)
{
if (!m_config.processInfo->Supports(method))
@@ -2217,17 +2205,6 @@ void COutput::ReadyForDisposal(CPostproc *pp)
}
}
-bool COutput::CheckSuccess(VAStatus status)
-{
- if (status != VA_STATUS_SUCCESS)
- {
- CLog::Log(LOGERROR, "VAAPI::%s - Error: %s(%d)", __FUNCTION__, vaErrorStr(status), status);
- m_vaError = true;
- return false;
- }
- return true;
-}
-
//-----------------------------------------------------------------------------
// Postprocessing
//-----------------------------------------------------------------------------
@@ -2327,7 +2304,9 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods)
m_config = config;
// create config
- if (!CheckSuccess(vaCreateConfig(m_config.dpy, VAProfileNone, VAEntrypointVideoProc, NULL, 0, &m_configId)))
+ if (!CheckSuccess(
+ vaCreateConfig(m_config.dpy, VAProfileNone, VAEntrypointVideoProc, NULL, 0, &m_configId),
+ "vaCreateConfig"))
{
CLog::Log(LOGDEBUG, LOGVIDEO, "CVppPostproc::PreInit - VPP init failed in vaCreateConfig");
@@ -2350,13 +2329,10 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods)
attrib->value.value.i = VA_FOURCC_P010;
}
int nb_surfaces = NUM_RENDER_PICS;
- if (!CheckSuccess(vaCreateSurfaces(m_config.dpy,
- format,
- m_config.surfaceWidth,
- m_config.surfaceHeight,
- surfaces,
- nb_surfaces,
- attribs, 1)))
+ if (!CheckSuccess(
+ vaCreateSurfaces(m_config.dpy, format, m_config.surfaceWidth, m_config.surfaceHeight,
+ surfaces, nb_surfaces,
+ attribs, 1), "vaCreateSurfaces"))
{
CLog::Log(LOGDEBUG, LOGVIDEO, "CVppPostproc::PreInit - VPP init failed in vaCreateSurfaces");
@@ -2368,14 +2344,10 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods)
}
// create vaapi decoder context
- if (!CheckSuccess(vaCreateContext(m_config.dpy,
- m_configId,
- m_config.surfaceWidth,
- m_config.surfaceHeight,
- 0,
- surfaces,
- nb_surfaces,
- &m_contextId)))
+ if (!CheckSuccess(
+ vaCreateContext(m_config.dpy, m_configId, m_config.surfaceWidth, m_config.surfaceHeight, 0,
+ surfaces,
+ nb_surfaces, &m_contextId), "vaCreateContext"))
{
m_contextId = VA_INVALID_ID;
CLog::Log(LOGDEBUG, LOGVIDEO, "CVppPostproc::PreInit - VPP init failed in vaCreateContext");
@@ -2388,18 +2360,17 @@ bool CVppPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods)
VAProcFilterCapDeinterlacing deinterlacingCaps[VAProcDeinterlacingCount];
unsigned int numDeinterlacingCaps = VAProcDeinterlacingCount;
- if (!CheckSuccess(vaQueryVideoProcFilters(m_config.dpy, m_contextId, filters, &numFilters)))
+ if (!CheckSuccess(vaQueryVideoProcFilters(m_config.dpy, m_contextId, filters, &numFilters),
+ "vaQueryVideoProcFilters"))
{
CLog::Log(LOGDEBUG, LOGVIDEO, "CVppPostproc::PreInit - VPP init failed in vaQueryVideoProcFilters");
return false;
}
- if (!CheckSuccess(vaQueryVideoProcFilterCaps(m_config.dpy,
- m_contextId,
- VAProcFilterDeinterlacing,
- deinterlacingCaps,
- &numDeinterlacingCaps)))
+ if (!CheckSuccess(vaQueryVideoProcFilterCaps(m_config.dpy, m_contextId, VAProcFilterDeinterlacing,
+ deinterlacingCaps,
+ &numDeinterlacingCaps), "vaQueryVideoProcFilterCaps"))
{
CLog::Log(LOGDEBUG, LOGVIDEO, "CVppPostproc::PreInit - VPP init failed in vaQueryVideoProcFilterCaps");
@@ -2458,7 +2429,7 @@ bool CVppPostproc::UpdateDeintMethod(EINTERLACEMETHOD method)
if (m_filter != VA_INVALID_ID)
{
- CheckSuccess(vaDestroyBuffer(m_config.dpy, m_filter));
+ CheckSuccess(vaDestroyBuffer(m_config.dpy, m_filter), "vaDestroyBuffer");
m_filter = VA_INVALID_ID;
}
@@ -2491,17 +2462,17 @@ bool CVppPostproc::UpdateDeintMethod(EINTERLACEMETHOD method)
filterparams.algorithm = vppMethod;
filterparams.flags = 0;
- if (!CheckSuccess(vaCreateBuffer(m_config.dpy, m_contextId,
- VAProcFilterParameterBufferType,
- sizeof(filterparams), 1, &filterparams, &m_filter)))
+ if (!CheckSuccess(vaCreateBuffer(m_config.dpy, m_contextId, VAProcFilterParameterBufferType,
+ sizeof(filterparams), 1,
+ &filterparams, &m_filter), "vaCreateBuffer"))
{
m_filter = VA_INVALID_ID;
return false;
}
VAProcPipelineCaps pplCaps;
- if (!CheckSuccess(vaQueryVideoProcPipelineCaps(m_config.dpy, m_contextId,
- &m_filter, 1, &pplCaps)))
+ if (!CheckSuccess(vaQueryVideoProcPipelineCaps(m_config.dpy, m_contextId, &m_filter, 1, &pplCaps),
+ "vaQueryVideoProcPipelineCaps"))
{
return false;
}
@@ -2517,29 +2488,29 @@ void CVppPostproc::Dispose()
// make sure surfaces are idle
for (int i=0; i<m_videoSurfaces.Size(); i++)
{
- CheckSuccess(vaSyncSurface(m_config.dpy, m_videoSurfaces.GetAtIndex(i)));
+ CheckSuccess(vaSyncSurface(m_config.dpy, m_videoSurfaces.GetAtIndex(i)), "vaSyncSurface");
}
if (m_filter != VA_INVALID_ID)
{
- CheckSuccess(vaDestroyBuffer(m_config.dpy, m_filter));
+ CheckSuccess(vaDestroyBuffer(m_config.dpy, m_filter), "vaDestroyBuffer");
m_filter = VA_INVALID_ID;
}
if (m_contextId != VA_INVALID_ID)
{
- CheckSuccess(vaDestroyContext(m_config.dpy, m_contextId));
+ CheckSuccess(vaDestroyContext(m_config.dpy, m_contextId), "vaDestroyContext");
m_contextId = VA_INVALID_ID;
}
VASurfaceID surf;
while((surf = m_videoSurfaces.RemoveNext()) != VA_INVALID_SURFACE)
{
- CheckSuccess(vaDestroySurfaces(m_config.dpy, &surf, 1));
+ CheckSuccess(vaDestroySurfaces(m_config.dpy, &surf, 1), "vaDestroySurface");
}
m_videoSurfaces.Reset();
if (m_configId != VA_INVALID_ID)
{
- CheckSuccess(vaDestroyConfig(m_config.dpy, m_configId));
+ CheckSuccess(vaDestroyConfig(m_config.dpy, m_configId), "vaDestroyConfig");
m_configId = VA_INVALID_ID;
}
@@ -2597,7 +2568,7 @@ bool CVppPostproc::Filter(CVaapiProcessedPicture &outPic)
// skip deinterlacing cycle if requested
if ((m_step == 1) &&
- ((outPic.DVDPic.iFlags & DVD_CODEC_CTRL_SKIPDEINT) || (m_vppMethod == VS_INTERLACEMETHOD_NONE)))
+ ((outPic.DVDPic.iFlags & DVD_CODEC_CTRL_SKIPDEINT) || !(outPic.DVDPic.iFlags & DVP_FLAG_INTERLACED) || (m_vppMethod == VS_INTERLACEMETHOD_NONE)))
{
Advance();
return false;
@@ -2610,18 +2581,18 @@ bool CVppPostproc::Filter(CVaapiProcessedPicture &outPic)
VARectangle inputRegion;
VARectangle outputRegion;
- if (!CheckSuccess(vaBeginPicture(m_config.dpy, m_contextId, surf)))
+ if (!CheckSuccess(vaBeginPicture(m_config.dpy, m_contextId, surf), "vaBeginPicture"))
{
return false;
}
- if (!CheckSuccess(vaCreateBuffer(m_config.dpy, m_contextId,
- VAProcPipelineParameterBufferType,
- sizeof(VAProcPipelineParameterBuffer), 1, NULL, &pipelineBuf)))
+ if (!CheckSuccess(vaCreateBuffer(m_config.dpy, m_contextId, VAProcPipelineParameterBufferType,
+ sizeof(VAProcPipelineParameterBuffer), 1, NULL, &pipelineBuf), "vaCreateBuffer"))
{
return false;
}
- if (!CheckSuccess(vaMapBuffer(m_config.dpy, pipelineBuf, (void**)&pipelineParams)))
+ if (!CheckSuccess(vaMapBuffer(m_config.dpy, pipelineBuf, (void**) &pipelineParams),
+ "vaMapBuffer"))
{
return false;
}
@@ -2635,6 +2606,7 @@ bool CVppPostproc::Filter(CVaapiProcessedPicture &outPic)
pipelineParams->output_region = &outputRegion;
pipelineParams->surface_region = &inputRegion;
pipelineParams->output_background_color = 0xff000000;
+ pipelineParams->filter_flags = 0;
VASurfaceID forwardRefs[32];
VASurfaceID backwardRefs[32];
@@ -2651,33 +2623,32 @@ bool CVppPostproc::Filter(CVaapiProcessedPicture &outPic)
if (m_vppMethod != VS_INTERLACEMETHOD_NONE)
{
unsigned int flags = 0;
- if (it->DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
- flags = 0;
- else
- flags = VA_DEINTERLACING_BOTTOM_FIELD_FIRST | VA_DEINTERLACING_BOTTOM_FIELD;
- if (m_step)
+ if (it->DVDPic.iFlags & DVP_FLAG_INTERLACED)
{
- if (flags & VA_DEINTERLACING_BOTTOM_FIELD)
- flags &= ~VA_DEINTERLACING_BOTTOM_FIELD;
+ if (it->DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
+ flags = 0;
else
- flags |= VA_DEINTERLACING_BOTTOM_FIELD;
+ flags = VA_DEINTERLACING_BOTTOM_FIELD_FIRST | VA_DEINTERLACING_BOTTOM_FIELD;
+
+ if (m_step)
+ {
+ if (flags & VA_DEINTERLACING_BOTTOM_FIELD)
+ flags &= ~VA_DEINTERLACING_BOTTOM_FIELD;
+ else
+ flags |= VA_DEINTERLACING_BOTTOM_FIELD;
+ }
}
- if (!CheckSuccess(vaMapBuffer(m_config.dpy, m_filter, (void**)&filterParams)))
+ if (!CheckSuccess(vaMapBuffer(m_config.dpy, m_filter, (void**) &filterParams), "vaMapBuffer"))
{
return false;
}
filterParams->flags = flags;
- if (!CheckSuccess(vaUnmapBuffer(m_config.dpy, m_filter)))
+ if (!CheckSuccess(vaUnmapBuffer(m_config.dpy, m_filter), "vaUnmapBuffer"))
{
return false;
}
- if (m_vppMethod == VS_INTERLACEMETHOD_VAAPI_BOB)
- pipelineParams->filter_flags = (flags & VA_DEINTERLACING_BOTTOM_FIELD) ? VA_BOTTOM_FIELD : VA_TOP_FIELD;
- else
- pipelineParams->filter_flags = 0;
-
pipelineParams->filters = &m_filter;
pipelineParams->num_filters = 1;
}
@@ -2722,23 +2693,22 @@ bool CVppPostproc::Filter(CVaapiProcessedPicture &outPic)
if (pipelineParams->surface == VA_INVALID_SURFACE)
return false;
- if (!CheckSuccess(vaUnmapBuffer(m_config.dpy, pipelineBuf)))
+ if (!CheckSuccess(vaUnmapBuffer(m_config.dpy, pipelineBuf), "vaUnmmapBuffer"))
{
return false;
}
- if (!CheckSuccess(vaRenderPicture(m_config.dpy, m_contextId,
- &pipelineBuf, 1)))
+ if (!CheckSuccess(vaRenderPicture(m_config.dpy, m_contextId, &pipelineBuf, 1), "vaRenderPicture"))
{
return false;
}
- if (!CheckSuccess(vaEndPicture(m_config.dpy, m_contextId)))
+ if (!CheckSuccess(vaEndPicture(m_config.dpy, m_contextId), "vaEndPicture"))
{
return false;
}
- if (!CheckSuccess(vaDestroyBuffer(m_config.dpy, pipelineBuf)))
+ if (!CheckSuccess(vaDestroyBuffer(m_config.dpy, pipelineBuf), "vaDestroyBuffer"))
{
return false;
}
@@ -2817,11 +2787,11 @@ void CVppPostproc::Discard(COutput *output, ReadyToDispose cb)
(m_pOut->*m_cbDispose)(this);
}
-bool CVppPostproc::CheckSuccess(VAStatus status)
+bool CVppPostproc::CheckSuccess(VAStatus status, const std::string& function)
{
if (status != VA_STATUS_SUCCESS)
{
- CLog::Log(LOGERROR, "VAAPI::%s - Error: %s(%d)", __FUNCTION__, vaErrorStr(status), status);
+ CLog::Log(LOGERROR, "VAAPI/vpp {} error: {} ({})", function, vaErrorStr(status), status);
return false;
}
return true;
@@ -2884,7 +2854,7 @@ bool CFFmpegPostproc::PreInit(CVaapiConfig &config, SDiMethods *methods)
use_filter = false;
}
if (image.image_id != VA_INVALID_ID)
- CheckSuccess(vaDestroyImage(config.dpy,image.image_id));
+ CheckSuccess(vaDestroyImage(config.dpy, image.image_id), "vaDestroyImage");
if (use_filter && !m_dllSSE4.Load())
{
@@ -3015,13 +2985,13 @@ bool CFFmpegPostproc::AddPicture(CVaapiDecodedPicture &inPic)
m_DVDPic.SetParams(inPic.DVDPic);
bool result = false;
- if (!CheckSuccess(vaSyncSurface(m_config.dpy, surf)))
+ if (!CheckSuccess(vaSyncSurface(m_config.dpy, surf), "vaSyncSurface"))
goto error;
- if (!CheckSuccess(vaDeriveImage(m_config.dpy, surf, &image)))
+ if (!CheckSuccess(vaDeriveImage(m_config.dpy, surf, &image), "vaDeriveImage"))
goto error;
- if (!CheckSuccess(vaMapBuffer(m_config.dpy, image.buf, (void**)&buf)))
+ if (!CheckSuccess(vaMapBuffer(m_config.dpy, image.buf, (void**) &buf), "vaMapBuffer"))
goto error;
m_pFilterFrameIn->format = AV_PIX_FMT_NV12;
@@ -3057,8 +3027,8 @@ bool CFFmpegPostproc::AddPicture(CVaapiDecodedPicture &inPic)
m_pFilterFrameIn->data[3] = NULL;
m_pFilterFrameIn->pkt_size = image.data_size;
- CheckSuccess(vaUnmapBuffer(m_config.dpy, image.buf));
- CheckSuccess(vaDestroyImage(m_config.dpy,image.image_id));
+ CheckSuccess(vaUnmapBuffer(m_config.dpy, image.buf), "vaUnmapBuffer");
+ CheckSuccess(vaDestroyImage(m_config.dpy, image.image_id), "vaDestroyImage");
if (m_diMethod == VS_INTERLACEMETHOD_DEINTERLACE)
{
@@ -3162,19 +3132,8 @@ void CFFmpegPostproc::Flush()
bool CFFmpegPostproc::UpdateDeintMethod(EINTERLACEMETHOD method)
{
- // switching between certain methods should be done without deinit/init
- if (method != m_diMethod)
- return false;
-
- if (method == VS_INTERLACEMETHOD_DEINTERLACE)
- return true;
- else if (method == VS_INTERLACEMETHOD_RENDER_BOB)
- return true;
- else if (method == VS_INTERLACEMETHOD_NONE &&
- !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_PREFERVAAPIRENDER))
- return true;
-
- return false;
+ /// \todo switching between certain methods could be done without deinit/init
+ return (m_diMethod == method);
}
bool CFFmpegPostproc::DoesSync()
@@ -3195,11 +3154,11 @@ void CFFmpegPostproc::Discard(COutput *output, ReadyToDispose cb)
(m_pOut->*m_cbDispose)(this);
}
-bool CFFmpegPostproc::CheckSuccess(VAStatus status)
+bool CFFmpegPostproc::CheckSuccess(VAStatus status, const std::string& function)
{
if (status != VA_STATUS_SUCCESS)
{
- CLog::Log(LOGERROR, "VAAPI - Error: %s(%d)", vaErrorStr(status), status);
+ CLog::Log(LOGERROR, "VAAPI/ffpp error: {} ({})", function, vaErrorStr(status), status);
return false;
}
return true;
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h
index d21fd98765..4ad6efda0d 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.h
@@ -264,7 +264,6 @@ protected:
void Flush();
void EnsureBufferPool();
void ReleaseBufferPool(bool precleanup = false);
- bool CheckSuccess(VAStatus status);
void ReadyForDisposal(CPostproc *pp);
CEvent m_outMsgEvent;
CEvent *m_inMsgEvent;
@@ -274,7 +273,8 @@ protected:
// extended state variables for state machine
int m_extTimeout;
- bool m_vaError;
+ /// \brief Whether at least one interlaced frame was encountered in the video stream (indicating that more interlaced frames could potentially follow)
+ bool m_seenInterlaced;
CVaapiConfig m_config;
std::shared_ptr<CVaapiBufferPool> m_bufferPool;
CVaapiDecodedPicture m_currentPicture;
@@ -330,7 +330,7 @@ private:
bool CreateContext();
void DestroyContext();
void QueryCaps();
- bool CheckSuccess(VAStatus status);
+ bool CheckSuccess(VAStatus status, const std::string& function);
bool IsValidDecoder(CDecoder *decoder);
void SetValidDRMVaDisplayFromRenderNode();
static CVAAPIContext *m_context;
@@ -396,7 +396,7 @@ protected:
void FiniVAAPIOutput();
void ReturnRenderPicture(CVaapiRenderPicture *renderPic);
long ReleasePicReference();
- bool CheckSuccess(VAStatus status);
+ bool CheckSuccess(VAStatus status, const std::string& function);
enum EDisplayState
{ VAAPI_OPEN
@@ -498,7 +498,7 @@ public:
bool UseVideoSurface() override;
void Discard(COutput *output, ReadyToDispose cb) override;
protected:
- bool CheckSuccess(VAStatus status);
+ bool CheckSuccess(VAStatus status, const std::string& function);
void Dispose();
void Advance();
VAConfigID m_configId;
@@ -533,7 +533,7 @@ public:
bool UseVideoSurface() override;
void Discard(COutput *output, ReadyToDispose cb) override;
protected:
- bool CheckSuccess(VAStatus status);
+ bool CheckSuccess(VAStatus status, const std::string& function);
void Close();
DllLibSSE4 m_dllSSE4;
uint8_t *m_cache;
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.cpp
index 47b488c1fb..f35fc73d08 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVAAPIGL.cpp
@@ -211,7 +211,6 @@ bool CRendererVAAPI::UploadTexture(int index)
}
m_vaapiTextures[index]->Map(pic);
- m_buffers[index].m_srcTextureBits = m_vaapiTextures[index]->GetBits();
YuvImage &im = buf.image;
CYuvPlane (&planes)[3] = buf.fields[0];
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.cpp
index 35113d6421..e50963891e 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.cpp
@@ -60,7 +60,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
{
case VA_FOURCC('N','V','1','2'):
{
- m_bits = 8;
attrib = attribs;
*attrib++ = EGL_LINUX_DRM_FOURCC_EXT;
*attrib++ = fourcc_code('R', '8', ' ', ' ');
@@ -109,8 +108,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
return false;
}
- GLint format, type;
-
glGenTextures(1, &m_textureY);
glBindTexture(m_interop.textureTarget, m_textureY);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -118,7 +115,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_interop.glEGLImageTargetTexture2DOES(m_interop.textureTarget, m_glSurface.eglImageY);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
glGenTextures(1, &m_textureVU);
glBindTexture(m_interop.textureTarget, m_textureVU);
@@ -127,17 +123,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_interop.glEGLImageTargetTexture2DOES(m_interop.textureTarget, m_glSurface.eglImageVU);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
- if (type == GL_UNSIGNED_BYTE)
- m_bits = 8;
- else if (type == GL_UNSIGNED_SHORT)
- m_bits = 16;
- else
- {
- CLog::Log(LOGWARNING, "Did not expect texture type: %d", (int) type);
- m_bits = 8;
- }
glBindTexture(m_interop.textureTarget, 0);
@@ -145,7 +130,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
}
case VA_FOURCC('P','0','1','0'):
{
- m_bits = 10;
attrib = attribs;
*attrib++ = EGL_LINUX_DRM_FOURCC_EXT;
*attrib++ = fourcc_code('R', '1', '6', ' ');
@@ -194,8 +178,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
return false;
}
- GLint format, type;
-
glGenTextures(1, &m_textureY);
glBindTexture(m_interop.textureTarget, m_textureY);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -203,7 +185,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_interop.glEGLImageTargetTexture2DOES(m_interop.textureTarget, m_glSurface.eglImageY);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
glGenTextures(1, &m_textureVU);
glBindTexture(m_interop.textureTarget, m_textureVU);
@@ -212,17 +193,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(m_interop.textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_interop.glEGLImageTargetTexture2DOES(m_interop.textureTarget, m_glSurface.eglImageVU);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
- if (type == GL_UNSIGNED_BYTE)
- m_bits = 8;
- else if (type == GL_UNSIGNED_SHORT)
- m_bits = 16;
- else
- {
- CLog::Log(LOGWARNING, "Did not expect texture type: %d", (int) type);
- m_bits = 8;
- }
glBindTexture(m_interop.textureTarget, 0);
@@ -230,7 +200,6 @@ bool CVaapi1Texture::Map(CVaapiRenderPicture *pic)
}
case VA_FOURCC('B','G','R','A'):
{
- m_bits = 8;
attrib = attribs;
*attrib++ = EGL_DRM_BUFFER_FORMAT_MESA;
*attrib++ = EGL_DRM_BUFFER_FORMAT_ARGB32_MESA;
@@ -307,11 +276,6 @@ void CVaapi1Texture::Unmap()
m_vaapiPic = nullptr;
}
-int CVaapi1Texture::GetBits()
-{
- return m_bits;
-}
-
GLuint CVaapi1Texture::GetTextureY()
{
return m_textureY;
@@ -514,18 +478,6 @@ bool CVaapi2Texture::Map(CVaapiRenderPicture* pic)
m_textureSize.Set(pic->DVDPic.iWidth, pic->DVDPic.iHeight);
- GLint type;
- glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
- if (type == GL_UNSIGNED_BYTE)
- m_bits = 8;
- else if (type == GL_UNSIGNED_SHORT)
- m_bits = 16;
- else
- {
- CLog::Log(LOGWARNING, "Did not expect texture type: %d", static_cast<int> (type));
- m_bits = 8;
- }
-
for (uint32_t layerNo = 0; layerNo < surface.num_layers; layerNo++)
{
int plane = 0;
@@ -626,11 +578,6 @@ void CVaapi2Texture::Unmap()
m_vaapiPic = nullptr;
}
-int CVaapi2Texture::GetBits()
-{
- return m_bits;
-}
-
GLuint CVaapi2Texture::GetTextureY()
{
return m_y.glTexture;
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h
index 6bac5a8804..b24f1ca77d 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VaapiEGL.h
@@ -49,7 +49,6 @@ public:
virtual bool Map(CVaapiRenderPicture *pic) = 0;
virtual void Unmap() = 0;
- virtual int GetBits() = 0;
virtual GLuint GetTextureY() = 0;
virtual GLuint GetTextureVU() = 0;
virtual CSizeInt GetTextureSize() = 0;
@@ -64,7 +63,6 @@ public:
void Unmap() override;
void Init(InteropInfo &interop) override;
- int GetBits() override;
GLuint GetTextureY() override;
GLuint GetTextureVU() override;
CSizeInt GetTextureSize() override;
@@ -76,7 +74,6 @@ public:
GLuint m_textureVU = 0;
int m_texWidth = 0;
int m_texHeight = 0;
- int m_bits = 0;
protected:
static bool TestInteropDeepColor(VADisplay vaDpy, EGLDisplay eglDisplay);
@@ -99,7 +96,6 @@ public:
void Unmap() override;
void Init(InteropInfo &interop) override;
- int GetBits() override;
GLuint GetTextureY() override;
GLuint GetTextureVU() override;
CSizeInt GetTextureSize() override;
@@ -120,7 +116,6 @@ private:
CVaapiRenderPicture* m_vaapiPic{};
bool m_hasPlaneModifiers{false};
std::array<KODI::UTILS::POSIX::CFileHandle, 4> m_drmFDs;
- int m_bits{0};
MappedTexture m_y, m_vu;
CSizeInt m_textureSize;
};