m_config.useInteropYuv = false;
m_bufferPool.numOutputSurfaces = NUM_RENDER_PICS;
EnsureBufferPool();
- GLMapSurfaces();
+ GLMapSurface(false, procPic.outputSurface);
retPic->sourceIdx = procPic.outputSurface;
retPic->texture[0] = m_bufferPool.glOutputSurfaceMap[procPic.outputSurface].texture[0];
retPic->texWidth = m_config.outWidth;
else
{
m_config.useInteropYuv = true;
- GLMapSurfaces();
+ GLMapSurface(true, procPic.videoSurface);
retPic->sourceIdx = procPic.videoSurface;
for (unsigned int i=0; i<4; ++i)
retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.videoSurface].texture[i];
CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
return;
}
+#ifdef GL_NV_vdpau_interop
+ glVDPAUUnmapSurfacesNV(1, &(it->second.glVdpauSurface));
+#endif
VdpVideoSurface surf = it->second.sourceVuv;
m_config.videoSurfaces->ClearRender(surf);
}
CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
return;
}
+#ifdef GL_NV_vdpau_interop
+ glVDPAUUnmapSurfacesNV(1, &(it->second.glVdpauSurface));
+#endif
VdpOutputSurface outSurf = it->second.sourceRgb;
m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &outSurf, sizeof(outSurf));
}
return true;
}
-void COutput::GLMapSurfaces()
+void COutput::GLMapSurface(bool yuv, uint32_t source)
{
#ifdef GL_NV_vdpau_interop
- if (m_config.useInteropYuv)
+ if (yuv)
{
- VdpauBufferPool::GLVideoSurface glSurface;
- VdpVideoSurface surf;
- if (m_config.videoSurfaces->Size() != m_bufferPool.glVideoSurfaceMap.size())
+ std::map<VdpVideoSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
+ it = m_bufferPool.glVideoSurfaceMap.find(source);
+ if (it == m_bufferPool.glVideoSurfaceMap.end())
{
- for (unsigned int i = 0; i < m_config.videoSurfaces->Size(); i++)
- {
- surf = m_config.videoSurfaces->GetAtIndex(i);
+ VdpauBufferPool::GLVideoSurface glSurface;
+ VdpVideoSurface surf = source;
- if (surf == VDP_INVALID_HANDLE)
- continue;
+ if (surf == VDP_INVALID_HANDLE)
+ return;
- if (m_bufferPool.glVideoSurfaceMap.find(surf) == m_bufferPool.glVideoSurfaceMap.end())
- {
- glSurface.sourceVuv = surf;
- while (glGetError() != GL_NO_ERROR) ;
- glGenTextures(4, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
- m_vdpError = true;
- }
- glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast<void*>(surf),
+ glSurface.sourceVuv = surf;
+ while (glGetError() != GL_NO_ERROR) ;
+ glGenTextures(4, glSurface.texture);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
+ m_vdpError = true;
+ }
+ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast<void*>(surf),
GL_TEXTURE_2D, 4, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
- m_vdpError = true;
- }
- glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
- m_vdpError = true;
- }
- glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
- m_vdpError = true;
- }
- m_bufferPool.glVideoSurfaceMap[surf] = glSurface;
- if (m_vdpError)
- return;
- CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
- }
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
+ m_vdpError = true;
}
+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
+ m_vdpError = true;
+ }
+ m_bufferPool.glVideoSurfaceMap[surf] = glSurface;
+
+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
}
+
+ while (glGetError() != GL_NO_ERROR) ;
+ glVDPAUMapSurfacesNV(1, &m_bufferPool.glVideoSurfaceMap[source].glVdpauSurface);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
+ m_vdpError = true;
+ }
+
+ if (m_vdpError)
+ return;
}
else
{
- if (m_bufferPool.glOutputSurfaceMap.size() != m_bufferPool.numOutputSurfaces)
+ std::map<VdpOutputSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
+ it = m_bufferPool.glOutputSurfaceMap.find(source);
+ if (it == m_bufferPool.glOutputSurfaceMap.end())
{
- VdpauBufferPool::GLVideoSurface glSurface;
- for (unsigned int i = m_bufferPool.glOutputSurfaceMap.size(); i<m_bufferPool.outputSurfaces.size(); i++)
+ unsigned int idx = 0;
+ for (idx = 0; idx<m_bufferPool.outputSurfaces.size(); idx++)
{
- glSurface.sourceRgb = m_bufferPool.outputSurfaces[i];
- glGenTextures(1, glSurface.texture);
- glSurface.glVdpauSurface = glVDPAURegisterOutputSurfaceNV(reinterpret_cast<void*>(m_bufferPool.outputSurfaces[i]),
+ if (m_bufferPool.outputSurfaces[idx] == source)
+ break;
+ }
+
+ VdpauBufferPool::GLVideoSurface glSurface;
+ glSurface.sourceRgb = m_bufferPool.outputSurfaces[idx];
+ glGenTextures(1, glSurface.texture);
+ glSurface.glVdpauSurface = glVDPAURegisterOutputSurfaceNV(reinterpret_cast<void*>(m_bufferPool.outputSurfaces[idx]),
GL_TEXTURE_2D, 1, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
- m_vdpError = true;
- }
- glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
- m_vdpError = true;
- }
- glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
- m_vdpError = true;
- }
- m_bufferPool.glOutputSurfaceMap[m_bufferPool.outputSurfaces[i]] = glSurface;
- if (m_vdpError)
- return;
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
+ m_vdpError = true;
}
+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
+ m_vdpError = true;
+ }
+ m_bufferPool.glOutputSurfaceMap[source] = glSurface;
CLog::Log(LOGNOTICE, "VDPAU::COutput registered output surfaces");
}
+
+ while (glGetError() != GL_NO_ERROR) ;
+ glVDPAUMapSurfacesNV(1, &m_bufferPool.glOutputSurfaceMap[source].glVdpauSurface);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
+ m_vdpError = true;
+ }
+
+ if (m_vdpError)
+ return;
}
#endif
}