diff --git a/packages/mediacenter/xbmc-theme-Confluence/meta b/packages/mediacenter/xbmc-theme-Confluence/meta index 0dc6553a99..ab1c3a6051 100644 --- a/packages/mediacenter/xbmc-theme-Confluence/meta +++ b/packages/mediacenter/xbmc-theme-Confluence/meta @@ -21,7 +21,7 @@ PKG_NAME="xbmc-theme-Confluence" PKG_VERSION="12.2-49f61b4" if [ "$XBMC" = "master" ]; then - PKG_VERSION="13.alpha-710b1ee" + PKG_VERSION="13.alpha-9df3bc9" elif [ "$XBMC" = "xbmc-aml" ]; then PKG_VERSION="aml-frodo-d9119f2" fi diff --git a/packages/mediacenter/xbmc/package.mk b/packages/mediacenter/xbmc/package.mk index b7002c0151..c840e33ca3 100644 --- a/packages/mediacenter/xbmc/package.mk +++ b/packages/mediacenter/xbmc/package.mk @@ -21,7 +21,7 @@ PKG_NAME="xbmc" PKG_VERSION="12.2-49f61b4" if [ "$XBMC" = "master" ]; then - PKG_VERSION="13.alpha-710b1ee" + PKG_VERSION="13.alpha-9df3bc9" elif [ "$XBMC" = "xbmc-aml" ]; then PKG_VERSION="aml-frodo-d9119f2" fi diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-453-add_openelec.tv_RSS_news-0.1.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-453-add_openelec.tv_RSS_news-0.1.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-453-add_openelec.tv_RSS_news-0.1.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-453-add_openelec.tv_RSS_news-0.1.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-602-add_as.xml_busy_dialog_delay_control.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-602-add_as.xml_busy_dialog_delay_control.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-602-add_as.xml_busy_dialog_delay_control.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-602-add_as.xml_busy_dialog_delay_control.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-990.15-depends-mark_our_wrapped_functions_as_used.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-990.15-depends-mark_our_wrapped_functions_as_used.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-990.15-depends-mark_our_wrapped_functions_as_used.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-990.15-depends-mark_our_wrapped_functions_as_used.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-995.01-xvba_support-d646570.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-995.01-vdpau-fixes-e7eb33d.patch similarity index 69% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-995.01-xvba_support-d646570.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-995.01-vdpau-fixes-e7eb33d.patch index 1b1e0c9720..bde9cf90a9 100644 --- a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-995.01-xvba_support-d646570.patch +++ b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-995.01-vdpau-fixes-e7eb33d.patch @@ -1,7 +1,3162 @@ -From 36d5fb1c32e5bb7b6b62c06985b9a22faf74a9fd Mon Sep 17 00:00:00 2001 +From 8411afb1d9a113c28cba0007ceff7cd6883884f1 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Thu, 12 Sep 2013 22:28:50 +0200 +Subject: [PATCH 01/87] vdpau: exit gfx lock in OnLostDevice and OnResetDevice + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index adf7413..76f2d8d 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -289,6 +289,8 @@ void CDecoder::OnLostDevice() + { + CLog::Log(LOGNOTICE,"CVDPAU::OnLostDevice event"); + ++ int count = g_graphicsContext.exit(); ++ + CSingleLock lock(m_DecoderSection); + FiniVDPAUOutput(); + FiniVDPAUProcs(); +@@ -296,12 +298,16 @@ void CDecoder::OnLostDevice() + m_DisplayState = VDPAU_LOST; + lock.Leave(); + m_DisplayEvent.Reset(); ++ ++ g_graphicsContext.restore(count); + } + + void CDecoder::OnResetDevice() + { + CLog::Log(LOGNOTICE,"CVDPAU::OnResetDevice event"); + ++ int count = g_graphicsContext.exit(); ++ + CSingleLock lock(m_DecoderSection); + if (m_DisplayState == VDPAU_LOST) + { +@@ -309,6 +315,8 @@ void CDecoder::OnResetDevice() + lock.Leave(); + m_DisplayEvent.Set(); + } ++ ++ g_graphicsContext.restore(count); + } + + int CDecoder::Check(AVCodecContext* avctx) +-- +1.8.4 + + +From ab2bd23efe3b74e96a43c570fea1cfc4a0e92bfb Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Tue, 17 Sep 2013 18:21:43 +0200 +Subject: [PATCH 02/87] vdpau: increase timeout for display event, some systems + are too slow switching refresh rate + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 76f2d8d..f27fb60 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -330,7 +330,7 @@ int CDecoder::Check(AVCodecContext* avctx) + if (state == VDPAU_LOST) + { + CLog::Log(LOGNOTICE,"CVDPAU::Check waiting for display reset event"); +- if (!m_DisplayEvent.WaitMSec(2000)) ++ if (!m_DisplayEvent.WaitMSec(4000)) + { + CLog::Log(LOGERROR, "CVDPAU::Check - device didn't reset in reasonable time"); + state = VDPAU_RESET; +-- +1.8.4 + + +From c6cae1c4f88d28c101d5ba50298e1b4982b24225 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Sat, 21 Sep 2013 14:17:09 +0200 +Subject: [PATCH 03/87] vdpau: drop old ffmpeg vdpau_render_state + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 391 ++++++++++++++----------- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 39 ++- + 2 files changed, 243 insertions(+), 187 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index f27fb60..2b8a5ad 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -80,6 +80,151 @@ + void* CDecoder::dl_handle; + + //----------------------------------------------------------------------------- ++// VDPAU Video Surface states ++//----------------------------------------------------------------------------- ++ ++#define SURFACE_USED_FOR_REFERENCE 0x01 ++#define SURFACE_USED_FOR_RENDER 0x02 ++ ++void CVideoSurfaces::AddSurface(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ m_state[surf] = SURFACE_USED_FOR_REFERENCE; ++} ++ ++void CVideoSurfaces::ClearReference(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ if (m_state.find(surf) == m_state.end()) ++ { ++ CLog::Log(LOGWARNING, "CVideoSurfaces::ClearReference - surface invalid"); ++ return; ++ } ++ m_state[surf] &= ~SURFACE_USED_FOR_REFERENCE; ++ if (m_state[surf] == 0) ++ { ++ m_freeSurfaces.push_back(surf); ++ } ++} ++ ++bool CVideoSurfaces::MarkRender(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ if (m_state.find(surf) == m_state.end()) ++ { ++ CLog::Log(LOGWARNING, "CVideoSurfaces::MarkRender - surface invalid"); ++ return false; ++ } ++ std::list::iterator it; ++ it = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); ++ if (it != m_freeSurfaces.end()) ++ { ++ m_freeSurfaces.erase(it); ++ } ++ m_state[surf] |= SURFACE_USED_FOR_RENDER; ++ return true; ++} ++ ++void CVideoSurfaces::ClearRender(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ if (m_state.find(surf) == m_state.end()) ++ { ++ CLog::Log(LOGWARNING, "CVideoSurfaces::ClearRender - surface invalid"); ++ return; ++ } ++ m_state[surf] &= ~SURFACE_USED_FOR_RENDER; ++ if (m_state[surf] == 0) ++ { ++ m_freeSurfaces.push_back(surf); ++ } ++} ++ ++bool CVideoSurfaces::IsValid(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ if (m_state.find(surf) != m_state.end()) ++ return true; ++ else ++ return false; ++} ++ ++VdpVideoSurface CVideoSurfaces::GetFree(VdpVideoSurface surf) ++{ ++ CSingleLock lock(m_section); ++ if (m_state.find(surf) != m_state.end()) ++ { ++ std::list::iterator it; ++ it = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); ++ if (it == m_freeSurfaces.end()) ++ { ++ CLog::Log(LOGWARNING, "CVideoSurfaces::GetFree - surface not free"); ++ } ++ else ++ { ++ m_freeSurfaces.erase(it); ++ m_state[surf] = SURFACE_USED_FOR_REFERENCE; ++ return surf; ++ } ++ } ++ ++ if (!m_freeSurfaces.empty()) ++ { ++ VdpVideoSurface freeSurf = m_freeSurfaces.front(); ++ m_freeSurfaces.pop_front(); ++ m_state[freeSurf] = SURFACE_USED_FOR_REFERENCE; ++ return freeSurf; ++ } ++ ++ return VDP_INVALID_HANDLE; ++} ++ ++VdpVideoSurface CVideoSurfaces::GetAtIndex(int idx) ++{ ++ if (idx >= m_state.size()) ++ return VDP_INVALID_HANDLE; ++ ++ std::map::iterator it = m_state.begin(); ++ for(int i = 0; i < idx; i++) ++ ++it; ++ return it->first; ++} ++ ++VdpVideoSurface CVideoSurfaces::RemoveNext(bool skiprender) ++{ ++ CSingleLock lock(m_section); ++ VdpVideoSurface surf; ++ std::map::iterator it; ++ for(it = m_state.begin(); it != m_state.end(); ++it) ++ { ++ if (skiprender && it->second & SURFACE_USED_FOR_RENDER) ++ continue; ++ surf = it->first; ++ m_state.erase(surf); ++ ++ std::list::iterator it2; ++ it2 = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); ++ if (it2 != m_freeSurfaces.end()) ++ m_freeSurfaces.erase(it2); ++ return surf; ++ } ++ return VDP_INVALID_HANDLE; ++} ++ ++void CVideoSurfaces::Reset() ++{ ++ CSingleLock lock(m_section); ++ m_freeSurfaces.clear(); ++ m_state.clear(); ++} ++ ++int CVideoSurfaces::Size() ++{ ++ CSingleLock lock(m_section); ++ return m_state.size(); ++} ++ ++//----------------------------------------------------------------------------- + // CVDPAU + //----------------------------------------------------------------------------- + +@@ -87,7 +232,6 @@ + { + m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; + m_vdpauConfig.videoSurfaces = &m_videoSurfaces; +- m_vdpauConfig.videoSurfaceSec = &m_videoSurfaceSec; + + m_vdpauConfigured = false; + m_hwContext.bitstream_buffers_allocated = 0; +@@ -164,6 +308,7 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int + m_hwContext.render = CDecoder::Render; + m_hwContext.bitstream_buffers_allocated = 0; + avctx->get_buffer = CDecoder::FFGetBuffer; ++ avctx->reget_buffer = CDecoder::FFGetBuffer; + avctx->release_buffer = CDecoder::FFReleaseBuffer; + avctx->draw_horiz_band = CDecoder::FFDrawSlice; + avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; +@@ -193,16 +338,6 @@ void CDecoder::Close() + FiniVDPAUProcs(); + m_vdpauOutput.Dispose(); + +- while (!m_videoSurfaces.empty()) +- { +- vdpau_render_state *render = m_videoSurfaces.back(); +- m_videoSurfaces.pop_back(); +- if (render->bitstream_buffers_allocated) +- m_dllAvUtil.av_freep(&render->bitstream_buffers); +- render->bitstream_buffers_allocated = 0; +- free(render); +- } +- + if (m_hwContext.bitstream_buffers_allocated) + { + m_dllAvUtil.av_freep(&m_hwContext.bitstream_buffers); +@@ -239,14 +374,10 @@ long CDecoder::Release() + m_DisplayState = VDPAU_ERROR; + } + +- for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i) ++ VdpVideoSurface surf; ++ while((surf = m_videoSurfaces.RemoveNext(true)) != VDP_INVALID_HANDLE) + { +- vdpau_render_state *render = m_videoSurfaces[i]; +- if (render->surface != VDP_INVALID_HANDLE && !(render->state & FF_VDPAU_STATE_USED_FOR_RENDER)) +- { +- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface); +- render->surface = VDP_INVALID_HANDLE; +- } ++ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); + } + } + return IHardwareDecoder::Release(); +@@ -514,20 +645,16 @@ void CDecoder::FiniVDPAUOutput() + return; + m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE; + +- CSingleLock lock(m_videoSurfaceSec); +- CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", (int)m_videoSurfaces.size()); ++ CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", m_videoSurfaces.Size()); + +- for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i) ++ VdpVideoSurface surf; ++ while((surf = m_videoSurfaces.RemoveNext()) != VDP_INVALID_HANDLE) + { +- vdpau_render_state *render = m_videoSurfaces[i]; +- if (render->surface != VDP_INVALID_HANDLE) +- { +- vdp_st = m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface); +- render->surface = VDP_INVALID_HANDLE; +- } ++ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); + if (CheckStatus(vdp_st, __LINE__)) + return; + } ++ m_videoSurfaces.Reset(); + } + + void CDecoder::ReadFormatOf( AVCodecID codec +@@ -696,33 +823,6 @@ void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. va + + } + +-bool CDecoder::IsSurfaceValid(vdpau_render_state *render) +-{ +- // find render state in queue +- bool found(false); +- unsigned int i; +- for(i = 0; i < m_videoSurfaces.size(); ++i) +- { +- if(m_videoSurfaces[i] == render) +- { +- found = true; +- break; +- } +- } +- if (!found) +- { +- CLog::Log(LOGERROR,"%s - video surface not found", __FUNCTION__); +- return false; +- } +- if (m_videoSurfaces[i]->surface == VDP_INVALID_HANDLE) +- { +- m_videoSurfaces[i]->state = 0; +- return false; +- } +- +- return true; +-} +- + int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) + { + //CLog::Log(LOGNOTICE,"%s",__FUNCTION__); +@@ -738,63 +838,38 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) + return -1; + } + +- vdpau_render_state * render = NULL; +- +- // find unused surface +- { CSingleLock lock(vdp->m_videoSurfaceSec); +- for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++) +- { +- if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER))) +- { +- render = vdp->m_videoSurfaces[i]; +- render->state = 0; +- break; +- } +- } +- } ++ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)pic->data[3]; ++ surf = vdp->m_videoSurfaces.GetFree(surf != 0 ? surf : VDP_INVALID_HANDLE); + + VdpStatus vdp_st = VDP_STATUS_ERROR; +- if (render == NULL) ++ if (surf == VDP_INVALID_HANDLE) + { + // create a new surface + VdpDecoderProfile profile; + ReadFormatOf(avctx->codec_id, profile, vdp->m_vdpauConfig.vdpChromaType); +- render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1); +- if (render == NULL) +- { +- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - calloc failed"); +- return -1; +- } +- CSingleLock lock(vdp->m_videoSurfaceSec); +- render->surface = VDP_INVALID_HANDLE; +- vdp->m_videoSurfaces.push_back(render); +- } + +- if (render->surface == VDP_INVALID_HANDLE) +- { + vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice, + vdp->m_vdpauConfig.vdpChromaType, + avctx->coded_width, + avctx->coded_height, +- &render->surface); ++ &surf); + vdp->CheckStatus(vdp_st, __LINE__); + if (vdp_st != VDP_STATUS_OK) + { +- free(render); + CLog::Log(LOGERROR, "CVDPAU::FFGetBuffer - No Video surface available could be created"); + return -1; + } ++ vdp->m_videoSurfaces.AddSurface(surf); + } + + pic->data[1] = pic->data[2] = NULL; +- pic->data[0] = (uint8_t*)render; +- pic->data[3] = (uint8_t*)(uintptr_t)render->surface; ++ pic->data[0] = (uint8_t*)(uintptr_t)surf; ++ pic->data[3] = (uint8_t*)(uintptr_t)surf; + + pic->linesize[0] = pic->linesize[1] = pic->linesize[2] = 0; + + pic->type= FF_BUFFER_TYPE_USER; + +- render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE; + pic->reordered_opaque= avctx->reordered_opaque; + return 0; + } +@@ -805,31 +880,17 @@ void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic) + CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; + CDecoder* vdp = (CDecoder*)ctx->GetHardware(); + +- vdpau_render_state * render; ++ VdpVideoSurface surf; + unsigned int i; + + CSingleLock lock(vdp->m_DecoderSection); + +- render=(vdpau_render_state*)pic->data[0]; +- if(!render) +- { +- CLog::Log(LOGERROR, "CVDPAU::FFReleaseBuffer - invalid context handle provided"); +- return; +- } ++ surf = (VdpVideoSurface)(uintptr_t)pic->data[3]; ++ ++ vdp->m_videoSurfaces.ClearReference(surf); + +- CSingleLock vLock(vdp->m_videoSurfaceSec); +- render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE; + for(i=0; i<4; i++) + pic->data[i]= NULL; +- +- // find render state in queue +- if (!vdp->IsSurfaceValid(render)) +- { +- CLog::Log(LOGDEBUG, "CVDPAU::FFReleaseBuffer - ignoring invalid buffer"); +- return; +- } +- +- render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE; + } + + VdpStatus CDecoder::Render( VdpDecoder decoder, VdpVideoSurface target, +@@ -861,17 +922,10 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, + } + + VdpStatus vdp_st; +- vdpau_render_state * render; +- +- render = (vdpau_render_state*)src->data[0]; +- if(!render) +- { +- CLog::Log(LOGERROR, "CVDPAU::FFDrawSlice - invalid context handle provided"); +- return; +- } ++ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)src->data[3]; + + // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid +- if (!vdp->IsSurfaceValid(render)) ++ if (!vdp->m_videoSurfaces.IsValid(surf)) + { + CLog::Log(LOGWARNING, "CVDPAU::FFDrawSlice - ignoring invalid buffer"); + return; +@@ -893,7 +947,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, + uint16_t decoded, processed, rend; + vdp->m_bufferStats.Get(decoded, processed, rend); + vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, +- render->surface, ++ surf, + (VdpPictureInfo const *)&(vdp->m_hwContext.info), + vdp->m_hwContext.bitstream_buffers_used, + vdp->m_hwContext.bitstream_buffers); +@@ -919,29 +973,20 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) + if(pFrame) + { // we have a new frame from decoder + +- vdpau_render_state * render = (vdpau_render_state*)pFrame->data[0]; +- if(!render) +- { +- CLog::Log(LOGERROR, "CVDPAU::Decode: no valid frame"); +- return VC_ERROR; +- } +- ++ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)pFrame->data[3]; + // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid +- if (!IsSurfaceValid(render)) ++ if (!m_videoSurfaces.IsValid(surf)) + { + CLog::Log(LOGWARNING, "CVDPAU::Decode - ignoring invalid buffer"); + return VC_BUFFER; + } +- +- CSingleLock lock(m_videoSurfaceSec); +- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER; +- lock.Leave(); ++ m_videoSurfaces.MarkRender(surf); + + // send frame to output for processing + CVdpauDecodedPicture pic; + memset(&pic.DVDPic, 0, sizeof(pic.DVDPic)); + ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic); +- pic.render = render; ++ pic.videoSurface = surf; + pic.DVDPic.color_matrix = avctx->colorspace; + m_bufferStats.IncDecoded(); + m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic)); +@@ -2128,17 +2173,13 @@ void CMixer::Flush() + { + CVdpauDecodedPicture pic = m_mixerInput.back(); + m_mixerInput.pop_back(); +- CSingleLock lock(*m_config.videoSurfaceSec); +- if (pic.render) +- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(pic.videoSurface); + } + while (!m_decodedPics.empty()) + { + CVdpauDecodedPicture pic = m_decodedPics.front(); + m_decodedPics.pop(); +- CSingleLock lock(*m_config.videoSurfaceSec); +- if (pic.render) +- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(pic.videoSurface); + } + Message *msg; + while (m_dataPort.ReceiveOutMessage(&msg)) +@@ -2146,9 +2187,7 @@ void CMixer::Flush() + if (msg->signal == CMixerDataProtocol::FRAME) + { + CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data; +- CSingleLock lock(*m_config.videoSurfaceSec); +- if (pic.render) +- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(pic.videoSurface); + } + else if (msg->signal == CMixerDataProtocol::BUFFER) + { +@@ -2269,7 +2308,7 @@ void CMixer::InitCycle() + } + + m_processPicture.DVDPic = m_mixerInput[1].DVDPic; +- m_processPicture.render = m_mixerInput[1].render; ++ m_processPicture.videoSurface = m_mixerInput[1].videoSurface; + } + + void CMixer::FiniCycle() +@@ -2277,10 +2316,9 @@ void CMixer::FiniCycle() + while (m_mixerInput.size() > 3) + { + CVdpauDecodedPicture &tmp = m_mixerInput.back(); +- if (tmp.render && m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) ++ if (m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) + { +- CSingleLock lock(*m_config.videoSurfaceSec); +- tmp.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(tmp.videoSurface); + } + m_mixerInput.pop_back(); + // m_config.stats->DecDecoded(); +@@ -2312,10 +2350,10 @@ void CMixer::ProcessPicture() + // use only 2 past 1 future for progressive/weave + // (only used for postproc anyway eg noise reduction) + if (m_mixerInput.size() > 3) +- past_surfaces[1] = m_mixerInput[3].render->surface; ++ past_surfaces[1] = m_mixerInput[3].videoSurface; + if (m_mixerInput.size() > 2) +- past_surfaces[0] = m_mixerInput[2].render->surface; +- futu_surfaces[0] = m_mixerInput[0].render->surface; ++ past_surfaces[0] = m_mixerInput[2].videoSurface; ++ futu_surfaces[0] = m_mixerInput[0].videoSurface; + pastCount = 2; + futuCount = 1; + } +@@ -2325,31 +2363,31 @@ void CMixer::ProcessPicture() + { // first field + if (m_mixerInput.size() > 3) + { +- past_surfaces[3] = m_mixerInput[3].render->surface; +- past_surfaces[2] = m_mixerInput[3].render->surface; ++ past_surfaces[3] = m_mixerInput[3].videoSurface; ++ past_surfaces[2] = m_mixerInput[3].videoSurface; + } + if (m_mixerInput.size() > 2) + { +- past_surfaces[1] = m_mixerInput[2].render->surface; +- past_surfaces[0] = m_mixerInput[2].render->surface; ++ past_surfaces[1] = m_mixerInput[2].videoSurface; ++ past_surfaces[0] = m_mixerInput[2].videoSurface; + } +- futu_surfaces[0] = m_mixerInput[1].render->surface; +- futu_surfaces[1] = m_mixerInput[0].render->surface;; ++ futu_surfaces[0] = m_mixerInput[1].videoSurface; ++ futu_surfaces[1] = m_mixerInput[0].videoSurface; + } + else + { // second field + if (m_mixerInput.size() > 3) + { +- past_surfaces[3] = m_mixerInput[3].render->surface; ++ past_surfaces[3] = m_mixerInput[3].videoSurface; + } + if (m_mixerInput.size() > 2) + { +- past_surfaces[2] = m_mixerInput[2].render->surface; +- past_surfaces[1] = m_mixerInput[2].render->surface; ++ past_surfaces[2] = m_mixerInput[2].videoSurface; ++ past_surfaces[1] = m_mixerInput[2].videoSurface; + } +- past_surfaces[0] = m_mixerInput[1].render->surface; +- futu_surfaces[0] = m_mixerInput[1].render->surface; +- futu_surfaces[1] = m_mixerInput[1].render->surface; ++ past_surfaces[0] = m_mixerInput[1].videoSurface; ++ futu_surfaces[0] = m_mixerInput[1].videoSurface; ++ futu_surfaces[1] = m_mixerInput[1].videoSurface; + + if (m_mixerInput[0].DVDPic.pts != DVD_NOPTS_VALUE && + m_mixerInput[1].DVDPic.pts != DVD_NOPTS_VALUE) +@@ -2384,7 +2422,7 @@ void CMixer::ProcessPicture() + m_mixerfield, + pastCount, + past_surfaces, +- m_mixerInput[1].render->surface, ++ m_mixerInput[1].videoSurface, + futuCount, + futu_surfaces, + &sourceRect, +@@ -2858,9 +2896,7 @@ void COutput::Flush() + CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data; + if (pic.DVDPic.format == RENDER_FMT_VDPAU_420) + { +- CSingleLock lock(*m_config.videoSurfaceSec); +- if (pic.render) +- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(pic.videoSurface); + } + } + msg->Release(); +@@ -2871,9 +2907,7 @@ void COutput::Flush() + if (msg->signal == COutputDataProtocol::NEWFRAME) + { + CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data; +- CSingleLock lock(*m_config.videoSurfaceSec); +- if (pic.render) +- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->ClearRender(pic.videoSurface); + } + else if (msg->signal == COutputDataProtocol::RETURNPIC) + { +@@ -2908,9 +2942,7 @@ void COutput::Flush() + CLog::Log(LOGDEBUG, "COutput::Flush - gl surface not found"); + continue; + } +- vdpau_render_state *render = it2->second.sourceVuv; +- if (render) +- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER; ++ m_config.videoSurfaces->MarkRender(it2->second.sourceVuv); + } + } + } +@@ -3004,9 +3036,9 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() + { + m_config.useInteropYuv = true; + GLMapSurfaces(); +- retPic->sourceIdx = procPic.render->surface; ++ retPic->sourceIdx = procPic.videoSurface; + for (unsigned int i=0; i<4; ++i) +- retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.render->surface].texture[i]; ++ retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.videoSurface].texture[i]; + retPic->texWidth = m_config.surfaceWidth; + retPic->texHeight = m_config.surfaceHeight; + retPic->crop.x1 = 0; +@@ -3123,9 +3155,8 @@ void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) + CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found"); + return; + } +- vdpau_render_state *render = it->second.sourceVuv; +- CSingleLock lock(*m_config.videoSurfaceSec); +- render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; ++ VdpVideoSurface surf = it->second.sourceVuv; ++ m_config.videoSurfaces->ClearRender(surf); + } + else if (pic->DVDPic.format == RENDER_FMT_VDPAU) + { +@@ -3531,17 +3562,19 @@ void COutput::GLMapSurfaces() + if (m_config.useInteropYuv) + { + VdpauBufferPool::GLVideoSurface glSurface; +- if (m_config.videoSurfaces->size() != m_bufferPool.glVideoSurfaceMap.size()) ++ VdpVideoSurface surf; ++ if (m_config.videoSurfaces->Size() != m_bufferPool.glVideoSurfaceMap.size()) + { +- CSingleLock lock(*m_config.videoSurfaceSec); +- for (unsigned int i = 0; i < m_config.videoSurfaces->size(); i++) ++ for (unsigned int i = 0; i < m_config.videoSurfaces->Size(); i++) + { +- if ((*m_config.videoSurfaces)[i]->surface == VDP_INVALID_HANDLE) ++ surf = m_config.videoSurfaces->GetAtIndex(i); ++ ++ if (surf == VDP_INVALID_HANDLE) + continue; + +- if (m_bufferPool.glVideoSurfaceMap.find((*m_config.videoSurfaces)[i]->surface) == m_bufferPool.glVideoSurfaceMap.end()) ++ if (m_bufferPool.glVideoSurfaceMap.find(surf) == m_bufferPool.glVideoSurfaceMap.end()) + { +- glSurface.sourceVuv = (*m_config.videoSurfaces)[i]; ++ glSurface.sourceVuv = surf; + while (glGetError() != GL_NO_ERROR) ; + glGenTextures(4, glSurface.texture); + if (glGetError() != GL_NO_ERROR) +@@ -3549,7 +3582,7 @@ void COutput::GLMapSurfaces() + CLog::Log(LOGERROR, "VDPAU::COutput error creating texture"); + m_vdpError = true; + } +- glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast((*m_config.videoSurfaces)[i]->surface), ++ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast(surf), + GL_TEXTURE_2D, 4, glSurface.texture); + + if (glGetError() != GL_NO_ERROR) +@@ -3569,7 +3602,7 @@ void COutput::GLMapSurfaces() + CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface"); + m_vdpError = true; + } +- m_bufferPool.glVideoSurfaceMap[(*m_config.videoSurfaces)[i]->surface] = glSurface; ++ m_bufferPool.glVideoSurfaceMap[surf] = glSurface; + if (m_vdpError) + return; + CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface"); +@@ -3621,7 +3654,7 @@ void COutput::GLUnmapSurfaces() + if (m_config.usePixmaps) + return; + +- { CSingleLock lock(*m_config.videoSurfaceSec); ++ { + std::map::iterator it; + for (it = m_bufferPool.glVideoSurfaceMap.begin(); it != m_bufferPool.glVideoSurfaceMap.end(); ++it) + { +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +index db2671f..0b5239c 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +@@ -60,6 +60,7 @@ + #include "threads/Event.h" + #include "threads/Thread.h" + #include "utils/ActorProtocol.h" ++#include + + using namespace Actor; + +@@ -167,6 +168,8 @@ class CVdpauBufferStats + * for init. + */ + ++class CVideoSurfaces; ++ + struct CVdpauConfig + { + int surfaceWidth; +@@ -184,8 +187,7 @@ struct CVdpauConfig + int featureCount; + int upscale; + VdpVideoMixerFeature vdpFeatures[14]; +- std::vector *videoSurfaces; +- CCriticalSection *videoSurfaceSec; ++ CVideoSurfaces *videoSurfaces; + bool usePixmaps; + int numRenderBuffers; + uint32_t maxReferences; +@@ -199,7 +201,7 @@ struct CVdpauConfig + struct CVdpauDecodedPicture + { + DVDVideoPicture DVDPic; +- vdpau_render_state *render; ++ VdpVideoSurface videoSurface; + }; + + /** +@@ -208,7 +210,7 @@ struct CVdpauDecodedPicture + struct CVdpauProcessedPicture + { + DVDVideoPicture DVDPic; +- vdpau_render_state *render; ++ VdpVideoSurface videoSurface; + VdpOutputSurface outputSurface; + }; + +@@ -381,7 +383,7 @@ struct VdpauBufferPool + #ifdef GL_NV_vdpau_interop + GLvdpauSurfaceNV glVdpauSurface; + #endif +- vdpau_render_state *sourceVuv; ++ VdpVideoSurface sourceVuv; + VdpOutputSurface sourceRgb; + }; + std::vector allRenderPics; +@@ -511,6 +513,29 @@ class COutput : private CThread + }; + + //----------------------------------------------------------------------------- ++// VDPAU Video Surface states ++//----------------------------------------------------------------------------- ++ ++class CVideoSurfaces ++{ ++public: ++ void AddSurface(VdpVideoSurface surf); ++ void ClearReference(VdpVideoSurface surf); ++ bool MarkRender(VdpVideoSurface surf); ++ void ClearRender(VdpVideoSurface surf); ++ bool IsValid(VdpVideoSurface surf); ++ VdpVideoSurface GetFree(VdpVideoSurface surf); ++ VdpVideoSurface GetAtIndex(int idx); ++ VdpVideoSurface RemoveNext(bool skiprender = false); ++ void Reset(); ++ int Size(); ++protected: ++ std::map m_state; ++ std::list m_freeSurfaces; ++ CCriticalSection m_section; ++}; ++ ++//----------------------------------------------------------------------------- + // VDPAU decoder + //----------------------------------------------------------------------------- + +@@ -570,7 +595,6 @@ class CDecoder + bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); + void SpewHardwareAvailable(); + bool CheckStatus(VdpStatus vdp_st, int line); +- bool IsSurfaceValid(vdpau_render_state *render); + void InitVDPAUProcs(); + void FiniVDPAUProcs(); + void FiniVDPAUOutput(); +@@ -603,9 +627,8 @@ class CDecoder + ThreadIdentifier m_decoderThread; + bool m_vdpauConfigured; + CVdpauConfig m_vdpauConfig; +- std::vector m_videoSurfaces; ++ CVideoSurfaces m_videoSurfaces; + AVVDPAUContext m_hwContext; +- CCriticalSection m_videoSurfaceSec; + + COutput m_vdpauOutput; + CVdpauBufferStats m_bufferStats; +-- +1.8.4 + + +From 05f3a2368ae19a04d31e138d53215facde989b34 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Fri, 27 Sep 2013 16:04:45 +0200 +Subject: [PATCH 04/87] vdpau: clear processed pics on flush + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 2b8a5ad..b275c3e 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -2894,10 +2894,7 @@ void COutput::Flush() + if (msg->signal == CMixerDataProtocol::PICTURE) + { + CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data; +- if (pic.DVDPic.format == RENDER_FMT_VDPAU_420) +- { +- m_config.videoSurfaces->ClearRender(pic.videoSurface); +- } ++ m_bufferPool.processedPics.push(pic); + } + msg->Release(); + } +@@ -2945,6 +2942,21 @@ void COutput::Flush() + m_config.videoSurfaces->MarkRender(it2->second.sourceVuv); + } + } ++ ++ // clear processed pics ++ while(!m_bufferPool.processedPics.empty()) ++ { ++ CVdpauProcessedPicture procPic = m_bufferPool.processedPics.front(); ++ if (procPic.DVDPic.format == RENDER_FMT_VDPAU) ++ { ++ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &procPic.outputSurface, sizeof(procPic.outputSurface)); ++ } ++ else if (procPic.DVDPic.format == RENDER_FMT_VDPAU_420) ++ { ++ m_config.videoSurfaces->ClearRender(procPic.videoSurface); ++ } ++ m_bufferPool.processedPics.pop(); ++ } + } + + bool COutput::HasWork() +-- +1.8.4 + + +From 895dc073da6b3e46087ff3f1e4e9150884073feb Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Sat, 28 Sep 2013 19:56:19 +0200 +Subject: [PATCH 05/87] vdpau: reactivate long decoding time debug message + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index b275c3e..eb75adc 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -943,7 +943,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, + return; + } + +-// uint64_t startTime = CurrentHostCounter(); ++ uint64_t startTime = CurrentHostCounter(); + uint16_t decoded, processed, rend; + vdp->m_bufferStats.Get(decoded, processed, rend); + vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, +@@ -952,10 +952,9 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, + vdp->m_hwContext.bitstream_buffers_used, + vdp->m_hwContext.bitstream_buffers); + vdp->CheckStatus(vdp_st, __LINE__); +-// uint64_t diff = CurrentHostCounter() - startTime; +-// if (diff*1000/CurrentHostFrequency() > 30) +-// CLog::Log(LOGWARNING,"CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend); +- ++ uint64_t diff = CurrentHostCounter() - startTime; ++ if (diff*1000/CurrentHostFrequency() > 30) ++ CLog::Log(LOGDEBUG, "CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend); + } + + +-- +1.8.4 + + +From 515d99358788ea5c08e00b39a5be47d75783cd1e Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Sun, 29 Sep 2013 07:30:41 +0200 +Subject: [PATCH 06/87] vdpau: keep video surfaces for another cycle + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index eb75adc..271e72c 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -2312,7 +2312,10 @@ void CMixer::InitCycle() + + void CMixer::FiniCycle() + { +- while (m_mixerInput.size() > 3) ++ // Keep video surfaces for one 2 cycles longer than used ++ // by mixer. This avoids blocking in decoder. ++ // NVidia recommends num_ref + 5 ++ while (m_mixerInput.size() > 5) + { + CVdpauDecodedPicture &tmp = m_mixerInput.back(); + if (m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) +-- +1.8.4 + + +From 8de31feb9cf8d85c42fee720b7d45941bc113558 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Mon, 30 Sep 2013 10:49:58 +0200 +Subject: [PATCH 07/87] vdpau: create only a single vdpau device + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 326 ++++++++++++++++--------- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 34 ++- + 2 files changed, 236 insertions(+), 124 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 271e72c..150c1c7 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -74,10 +74,192 @@ + static float studioCSCKCoeffs601[3] = {0.299, 0.587, 0.114}; //BT601 {Kr, Kg, Kb} + static float studioCSCKCoeffs709[3] = {0.2126, 0.7152, 0.0722}; //BT709 {Kr, Kg, Kb} + +-//since libvdpau 0.4, vdp_device_create_x11() installs a callback on the Display*, +-//if we unload libvdpau with dlclose(), we segfault on XCloseDisplay, +-//so we just keep a static handle to libvdpau around +-void* CDecoder::dl_handle; ++//----------------------------------------------------------------------------- ++//----------------------------------------------------------------------------- ++ ++CVDPAUContext *CVDPAUContext::m_context = 0; ++CCriticalSection CVDPAUContext::m_section; ++Display *CVDPAUContext::m_display = 0; ++void *CVDPAUContext::m_dlHandle = 0; ++ ++CVDPAUContext::CVDPAUContext() ++{ ++ m_context = 0; ++ m_refCount = 0; ++} ++ ++void CVDPAUContext::Release() ++{ ++ CSingleLock lock(m_section); ++ ++ m_refCount--; ++ if (m_refCount <= 0) ++ { ++ Close(); ++ delete this; ++ m_context = 0; ++ } ++} ++ ++void CVDPAUContext::Close() ++{ ++ CLog::Log(LOGNOTICE, "VDPAU::Close - closing decoder context"); ++ DestroyContext(); ++} ++ ++bool CVDPAUContext::EnsureContext(CVDPAUContext **ctx) ++{ ++ CSingleLock lock(m_section); ++ ++ if (m_context) ++ { ++ m_context->m_refCount++; ++ *ctx = m_context; ++ return true; ++ } ++ ++ m_context = new CVDPAUContext(); ++ *ctx = m_context; ++ { ++ CSingleLock gLock(g_graphicsContext); ++ if (!m_context->LoadSymbols() || !m_context->CreateContext()) ++ { ++ delete m_context; ++ m_context = 0; ++ return false; ++ } ++ } ++ ++ m_context->m_refCount++; ++ ++ *ctx = m_context; ++ return true; ++} ++ ++bool CVDPAUContext::LoadSymbols() ++{ ++ if (!m_dlHandle) ++ { ++ m_dlHandle = dlopen("libvdpau.so.1", RTLD_LAZY); ++ if (!m_dlHandle) ++ { ++ const char* error = dlerror(); ++ if (!error) ++ error = "dlerror() returned NULL"; ++ ++ CLog::Log(LOGERROR,"VDPAU::LoadSymbols: Unable to get handle to lib: %s", error); ++ return false; ++ } ++ } ++ ++ char* error; ++ (void)dlerror(); ++ dl_vdp_device_create_x11 = (VdpStatus (*)(Display*, int, VdpDevice*, VdpStatus (**)(VdpDevice, VdpFuncId, void**)))dlsym(m_dlHandle, (const char*)"vdp_device_create_x11"); ++ error = dlerror(); ++ if (error) ++ { ++ CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__); ++ m_vdpDevice = VDP_INVALID_HANDLE; ++ return false; ++ } ++ return true; ++} ++ ++bool CVDPAUContext::CreateContext() ++{ ++ CLog::Log(LOGNOTICE,"VDPAU::CreateContext - creating decoder context"); ++ ++ int mScreen; ++ { CSingleLock lock(g_graphicsContext); ++ if (!m_display) ++ m_display = XOpenDisplay(NULL); ++ mScreen = g_Windowing.GetCurrentScreen(); ++ } ++ ++ VdpStatus vdp_st; ++ // Create Device ++ vdp_st = dl_vdp_device_create_x11(m_display, ++ mScreen, ++ &m_vdpDevice, ++ &m_vdp_get_proc_address); ++ ++ CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpDevice,vdp_st); ++ if (vdp_st != VDP_STATUS_OK) ++ { ++ CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st); ++ m_vdpDevice = VDP_INVALID_HANDLE; ++ return false; ++ } ++ vdp_st = m_vdp_get_proc_address(m_vdpDevice, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&m_vdp_device_destroy); ++ ++ return true; ++} ++ ++void CVDPAUContext::GetProcs(VDPAU_procs &procs) ++{ ++ VdpStatus vdp_st; ++ ++ procs.vdp_get_proc_address = m_vdp_get_proc_address; ++ ++#define VDP_PROC(id, proc) \ ++ do { \ ++ vdp_st = m_vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ ++ if (vdp_st != VDP_STATUS_OK) \ ++ { \ ++ CLog::Log(LOGERROR, "CVDPAUContext::GetProcs - failed to get proc id"); \ ++ } \ ++ } while(0); ++ ++ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , procs.vdp_get_error_string); ++ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , procs.vdp_device_destroy); ++ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , procs.vdp_generate_csc_matrix); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , procs.vdp_video_surface_create); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , procs.vdp_video_surface_destroy); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_video_surface_put_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , procs.vdp_video_surface_get_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_output_surface_put_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , procs.vdp_output_surface_put_bits_native); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , procs.vdp_output_surface_create); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , procs.vdp_output_surface_destroy); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , procs.vdp_output_surface_get_bits_native); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, procs.vdp_output_surface_render_output_surface); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , procs.vdp_output_surface_put_bits_indexed); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , procs.vdp_video_mixer_create); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , procs.vdp_video_mixer_set_feature_enables); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , procs.vdp_video_mixer_destroy); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , procs.vdp_video_mixer_render); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , procs.vdp_video_mixer_set_attribute_values); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , procs.vdp_video_mixer_query_parameter_support); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , procs.vdp_video_mixer_query_feature_support); ++ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , procs.vdp_decoder_create); ++ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , procs.vdp_decoder_destroy); ++ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , procs.vdp_decoder_render); ++ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , procs.vdp_decoder_query_caps); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , procs.vdp_presentation_queue_target_destroy); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , procs.vdp_presentation_queue_create); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , procs.vdp_presentation_queue_destroy); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , procs.vdp_presentation_queue_display); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, procs.vdp_presentation_queue_block_until_surface_idle); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , procs.vdp_presentation_queue_target_create_x11); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , procs.vdp_presentation_queue_query_surface_status); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , procs.vdp_presentation_queue_get_time); ++ ++#undef VDP_PROC ++} ++ ++VdpDevice CVDPAUContext::GetDevice() ++{ ++ return m_vdpDevice; ++} ++ ++void CVDPAUContext::DestroyContext() ++{ ++ if (!m_vdp_device_destroy) ++ return; ++ ++ m_vdp_device_destroy(m_vdpDevice); ++ m_vdpDevice = VDP_INVALID_HANDLE; ++} + + //----------------------------------------------------------------------------- + // VDPAU Video Surface states +@@ -236,6 +418,7 @@ int CVideoSurfaces::Size() + m_vdpauConfigured = false; + m_hwContext.bitstream_buffers_allocated = 0; + m_DisplayState = VDPAU_OPEN; ++ m_vdpauConfig.context = 0; + } + + bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces) +@@ -252,27 +435,19 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int + if ((avctx->codec_id == AV_CODEC_ID_MPEG4) && !g_advancedSettings.m_videoAllowMpeg4VDPAU) + return false; + +- if (!dl_handle) +- { +- dl_handle = dlopen("libvdpau.so.1", RTLD_LAZY); +- if (!dl_handle) +- { +- const char* error = dlerror(); +- if (!error) +- error = "dlerror() returned NULL"; ++ if (!CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) ++ return false; + +- CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error); +- return false; +- } +- } ++ m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); ++ m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); ++ m_DisplayState = VDPAU_OPEN; ++ m_vdpauConfigured = false; + + if (!m_dllAvUtil.Load()) + return false; + +- InitVDPAUProcs(); + m_presentPicture = 0; + +- if (m_vdpauConfig.vdpDevice != VDP_INVALID_HANDLE) + { + SpewHardwareAvailable(); + +@@ -295,7 +470,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int + if(vdp_st != VDP_STATUS_OK) + { + CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st); +- FiniVDPAUProcs(); + return false; + } + +@@ -335,7 +509,6 @@ void CDecoder::Close() + CSingleLock lock(m_DecoderSection); + + FiniVDPAUOutput(); +- FiniVDPAUProcs(); + m_vdpauOutput.Dispose(); + + if (m_hwContext.bitstream_buffers_allocated) +@@ -344,6 +517,10 @@ void CDecoder::Close() + } + + m_dllAvUtil.Unload(); ++ ++ if (m_vdpauConfig.context) ++ m_vdpauConfig.context->Release(); ++ m_vdpauConfig.context = 0; + } + + long CDecoder::Release() +@@ -424,7 +601,9 @@ void CDecoder::OnLostDevice() + + CSingleLock lock(m_DecoderSection); + FiniVDPAUOutput(); +- FiniVDPAUProcs(); ++ if (m_vdpauConfig.context) ++ m_vdpauConfig.context->Release(); ++ m_vdpauConfig.context = 0; + + m_DisplayState = VDPAU_LOST; + lock.Leave(); +@@ -477,9 +656,17 @@ int CDecoder::Check(AVCodecContext* avctx) + CSingleLock lock(m_DecoderSection); + + FiniVDPAUOutput(); +- FiniVDPAUProcs(); ++ if (m_vdpauConfig.context) ++ m_vdpauConfig.context->Release(); ++ m_vdpauConfig.context = 0; + +- InitVDPAUProcs(); ++ if (CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) ++ { ++ m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); ++ m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); ++ m_DisplayState = VDPAU_OPEN; ++ m_vdpauConfigured = false; ++ } + + if (state == VDPAU_RESET) + return VC_FLUSHED; +@@ -535,99 +722,6 @@ EINTERLACEMETHOD CDecoder::AutoInterlaceMethod() + return VS_INTERLACEMETHOD_RENDER_BOB; + } + +-void CDecoder::InitVDPAUProcs() +-{ +- char* error; +- +- (void)dlerror(); +- dl_vdp_device_create_x11 = (VdpStatus (*)(Display*, int, VdpDevice*, VdpStatus (**)(VdpDevice, VdpFuncId, void**)))dlsym(dl_handle, (const char*)"vdp_device_create_x11"); +- error = dlerror(); +- if (error) +- { +- CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__); +- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; +- return; +- } +- +- if (dl_vdp_device_create_x11) +- { +- m_Display = XOpenDisplay(NULL); +- } +- +- int mScreen = g_Windowing.GetCurrentScreen(); +- VdpStatus vdp_st; +- +- // Create Device +- vdp_st = dl_vdp_device_create_x11(m_Display, //x_display, +- mScreen, //x_screen, +- &m_vdpauConfig.vdpDevice, +- &m_vdpauConfig.vdpProcs.vdp_get_proc_address); +- +- CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpauConfig.vdpDevice,vdp_st); +- if (vdp_st != VDP_STATUS_OK) +- { +- CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st); +- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; +- return; +- } +- +-#define VDP_PROC(id, proc) \ +- do { \ +- vdp_st = m_vdpauConfig.vdpProcs.vdp_get_proc_address(m_vdpauConfig.vdpDevice, id, (void**)&proc); \ +- CheckStatus(vdp_st, __LINE__); \ +- } while(0); +- +- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpauConfig.vdpProcs.vdp_get_error_string); +- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpauConfig.vdpProcs.vdp_device_destroy); +- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpauConfig.vdpProcs.vdp_generate_csc_matrix); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_video_surface_create); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_surface_destroy); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_put_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_get_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_native); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_output_surface_create); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_output_surface_destroy); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_get_bits_native); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpauConfig.vdpProcs.vdp_output_surface_render_output_surface); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_indexed); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpauConfig.vdpProcs.vdp_video_mixer_create); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_feature_enables); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_mixer_destroy); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpauConfig.vdpProcs.vdp_video_mixer_render); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_attribute_values); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_parameter_support); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support); +- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpauConfig.vdpProcs.vdp_decoder_create); +- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpauConfig.vdpProcs.vdp_decoder_destroy); +- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpauConfig.vdpProcs.vdp_decoder_render); +- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpauConfig.vdpProcs.vdp_decoder_query_caps); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpauConfig.vdpProcs.vdp_presentation_queue_create); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_display); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpauConfig.vdpProcs.vdp_presentation_queue_block_until_surface_idle); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_create_x11); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpauConfig.vdpProcs.vdp_presentation_queue_query_surface_status); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpauConfig.vdpProcs.vdp_presentation_queue_get_time); +- +-#undef VDP_PROC +- +- // set all vdpau resources to invalid +- m_DisplayState = VDPAU_OPEN; +- m_vdpauConfigured = false; +-} +- +-void CDecoder::FiniVDPAUProcs() +-{ +- if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE) return; +- +- VdpStatus vdp_st; +- vdp_st = m_vdpauConfig.vdpProcs.vdp_device_destroy(m_vdpauConfig.vdpDevice); +- CheckStatus(vdp_st, __LINE__); +- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; +-} +- + void CDecoder::FiniVDPAUOutput() + { + if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return; +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +index 0b5239c..c8e89dc 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +@@ -169,6 +169,7 @@ class CVdpauBufferStats + */ + + class CVideoSurfaces; ++class CVDPAUContext; + + struct CVdpauConfig + { +@@ -192,6 +193,7 @@ struct CVdpauConfig + int numRenderBuffers; + uint32_t maxReferences; + bool useInteropYuv; ++ CVDPAUContext *context; + }; + + /** +@@ -539,6 +541,30 @@ class CVideoSurfaces + // VDPAU decoder + //----------------------------------------------------------------------------- + ++class CVDPAUContext ++{ ++public: ++ static bool EnsureContext(CVDPAUContext **ctx); ++ void Release(); ++ void GetProcs(VDPAU_procs &procs); ++ VdpDevice GetDevice(); ++private: ++ CVDPAUContext(); ++ void Close(); ++ bool LoadSymbols(); ++ bool CreateContext(); ++ void DestroyContext(); ++ static CVDPAUContext *m_context; ++ static CCriticalSection m_section; ++ static Display *m_display; ++ int m_refCount; ++ static void *m_dlHandle; ++ VdpDevice m_vdpDevice; ++ VdpGetProcAddress *m_vdp_get_proc_address; ++ VdpDeviceDestroy *m_vdp_device_destroy; ++ VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); ++}; ++ + /** + * VDPAU main class + */ +@@ -595,8 +621,6 @@ class CDecoder + bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); + void SpewHardwareAvailable(); + bool CheckStatus(VdpStatus vdp_st, int line); +- void InitVDPAUProcs(); +- void FiniVDPAUProcs(); + void FiniVDPAUOutput(); + void ReturnRenderPicture(CVdpauRenderPicture *renderPic); + long ReleasePicReference(); +@@ -605,10 +629,6 @@ class CDecoder + , VdpDecoderProfile &decoder_profile + , VdpChromaType &chroma_type); + +- VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); +- VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer); +- VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context); +- + // OnLostDevice triggers transition from all states to LOST + // internal errors trigger transition from OPEN to RESET + // OnResetDevice triggers transition from LOST to RESET +@@ -621,9 +641,7 @@ class CDecoder + CCriticalSection m_DecoderSection; + CEvent m_DisplayEvent; + +- static void* dl_handle; + DllAvUtil m_dllAvUtil; +- Display* m_Display; + ThreadIdentifier m_decoderThread; + bool m_vdpauConfigured; + CVdpauConfig m_vdpauConfig; +-- +1.8.4 + + +From 34e2e9a97eec23137717c7dbeff4a3066b71408c Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Mon, 30 Sep 2013 18:52:31 +0200 +Subject: [PATCH 08/87] vdpau: make sure buffers a full before returning a + picture + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 24 ++++++++++-------------- + 1 file changed, 10 insertions(+), 14 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 150c1c7..28f069d 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -1106,7 +1106,14 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) + uint64_t startTime = CurrentHostCounter(); + while (!retval) + { +- if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg)) ++ // first fill the buffers to keep vdpau busy ++ // mixer will run with decoded >= 2. output is limited by number of output surfaces ++ // In case mixer is bypassed we limit by looking at processed ++ if (decoded < 3 && processed < 3) ++ { ++ retval |= VC_BUFFER; ++ } ++ else if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg)) + { + if (msg->signal == COutputDataProtocol::PICTURE) + { +@@ -1140,20 +1147,9 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) + msg->Release(); + } + +- // TODO +- if (1) //(m_codecControl & DVP_FLAG_DRAIN)) ++ if (decoded < 3 && processed < 3) + { +- if (decoded + processed + render < 4) +- { +- retval |= VC_BUFFER; +- } +- } +- else +- { +- if (decoded < 4 && (processed + render) < 3) +- { +- retval |= VC_BUFFER; +- } ++ retval |= VC_BUFFER; + } + + if (!retval && !m_inMsgEvent.WaitMSec(2000)) +-- +1.8.4 + + +From 8b8f8ef84525e6328107d647bddcb821b0ce4ca9 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Mon, 30 Sep 2013 21:05:03 +0200 +Subject: [PATCH 09/87] vdpau: move common attributes into vdpau context + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 350 +++++++++++++------------ + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 17 +- + 2 files changed, 190 insertions(+), 177 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 28f069d..8f7e0dd 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -136,6 +136,21 @@ bool CVDPAUContext::EnsureContext(CVDPAUContext **ctx) + return true; + } + ++VDPAU_procs& CVDPAUContext::GetProcs() ++{ ++ return m_vdpProcs; ++} ++ ++VdpVideoMixerFeature* CVDPAUContext::GetFeatures() ++{ ++ return m_vdpFeatures; ++} ++ ++int CVDPAUContext::GetFeatureCount() ++{ ++ return m_featureCount; ++} ++ + bool CVDPAUContext::LoadSymbols() + { + if (!m_dlHandle) +@@ -181,7 +196,7 @@ bool CVDPAUContext::CreateContext() + vdp_st = dl_vdp_device_create_x11(m_display, + mScreen, + &m_vdpDevice, +- &m_vdp_get_proc_address); ++ &m_vdpProcs.vdp_get_proc_address); + + CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpDevice,vdp_st); + if (vdp_st != VDP_STATUS_OK) +@@ -190,59 +205,58 @@ bool CVDPAUContext::CreateContext() + m_vdpDevice = VDP_INVALID_HANDLE; + return false; + } +- vdp_st = m_vdp_get_proc_address(m_vdpDevice, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&m_vdp_device_destroy); + ++ QueryProcs(); ++ SpewHardwareAvailable(); + return true; + } + +-void CVDPAUContext::GetProcs(VDPAU_procs &procs) ++void CVDPAUContext::QueryProcs() + { + VdpStatus vdp_st; + +- procs.vdp_get_proc_address = m_vdp_get_proc_address; +- + #define VDP_PROC(id, proc) \ + do { \ +- vdp_st = m_vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ ++ vdp_st = m_vdpProcs.vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ + if (vdp_st != VDP_STATUS_OK) \ + { \ + CLog::Log(LOGERROR, "CVDPAUContext::GetProcs - failed to get proc id"); \ + } \ + } while(0); + +- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , procs.vdp_get_error_string); +- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , procs.vdp_device_destroy); +- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , procs.vdp_generate_csc_matrix); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , procs.vdp_video_surface_create); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , procs.vdp_video_surface_destroy); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_video_surface_put_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , procs.vdp_video_surface_get_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_output_surface_put_bits_y_cb_cr); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , procs.vdp_output_surface_put_bits_native); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , procs.vdp_output_surface_create); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , procs.vdp_output_surface_destroy); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , procs.vdp_output_surface_get_bits_native); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, procs.vdp_output_surface_render_output_surface); +- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , procs.vdp_output_surface_put_bits_indexed); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , procs.vdp_video_mixer_create); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , procs.vdp_video_mixer_set_feature_enables); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , procs.vdp_video_mixer_destroy); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , procs.vdp_video_mixer_render); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , procs.vdp_video_mixer_set_attribute_values); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , procs.vdp_video_mixer_query_parameter_support); +- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , procs.vdp_video_mixer_query_feature_support); +- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , procs.vdp_decoder_create); +- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , procs.vdp_decoder_destroy); +- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , procs.vdp_decoder_render); +- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , procs.vdp_decoder_query_caps); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , procs.vdp_presentation_queue_target_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , procs.vdp_presentation_queue_create); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , procs.vdp_presentation_queue_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , procs.vdp_presentation_queue_display); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, procs.vdp_presentation_queue_block_until_surface_idle); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , procs.vdp_presentation_queue_target_create_x11); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , procs.vdp_presentation_queue_query_surface_status); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , procs.vdp_presentation_queue_get_time); ++ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpProcs.vdp_get_error_string); ++ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpProcs.vdp_device_destroy); ++ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpProcs.vdp_generate_csc_matrix); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpProcs.vdp_video_surface_create); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpProcs.vdp_video_surface_destroy); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_put_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_get_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_output_surface_put_bits_y_cb_cr); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpProcs.vdp_output_surface_put_bits_native); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpProcs.vdp_output_surface_create); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpProcs.vdp_output_surface_destroy); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpProcs.vdp_output_surface_get_bits_native); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpProcs.vdp_output_surface_render_output_surface); ++ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpProcs.vdp_output_surface_put_bits_indexed); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpProcs.vdp_video_mixer_create); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpProcs.vdp_video_mixer_set_feature_enables); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpProcs.vdp_video_mixer_destroy); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpProcs.vdp_video_mixer_render); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpProcs.vdp_video_mixer_set_attribute_values); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpProcs.vdp_video_mixer_query_parameter_support); ++ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpProcs.vdp_video_mixer_query_feature_support); ++ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpProcs.vdp_decoder_create); ++ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpProcs.vdp_decoder_destroy); ++ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpProcs.vdp_decoder_render); ++ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpProcs.vdp_decoder_query_caps); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpProcs.vdp_presentation_queue_target_destroy); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpProcs.vdp_presentation_queue_create); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpProcs.vdp_presentation_queue_destroy); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpProcs.vdp_presentation_queue_display); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpProcs.vdp_presentation_queue_block_until_surface_idle); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpProcs.vdp_presentation_queue_target_create_x11); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpProcs.vdp_presentation_queue_query_surface_status); ++ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpProcs.vdp_presentation_queue_get_time); + + #undef VDP_PROC + } +@@ -254,13 +268,71 @@ VdpDevice CVDPAUContext::GetDevice() + + void CVDPAUContext::DestroyContext() + { +- if (!m_vdp_device_destroy) ++ if (!m_vdpProcs.vdp_device_destroy) + return; + +- m_vdp_device_destroy(m_vdpDevice); ++ m_vdpProcs.vdp_device_destroy(m_vdpDevice); + m_vdpDevice = VDP_INVALID_HANDLE; + } + ++void CVDPAUContext::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo ++{ ++ VdpStatus rv; ++ CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:"); ++ CLog::Log(LOGNOTICE,"name level macbs width height"); ++ CLog::Log(LOGNOTICE,"------------------------------------"); ++ for(unsigned int x=0; xGetProcs(m_vdpauConfig.vdpProcs); +- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); + m_DisplayState = VDPAU_OPEN; + m_vdpauConfigured = false; + +@@ -449,8 +518,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int + m_presentPicture = 0; + + { +- SpewHardwareAvailable(); +- + VdpDecoderProfile profile = 0; + if(avctx->codec_id == AV_CODEC_ID_H264) + profile = VDP_DECODER_PROFILE_H264_HIGH; +@@ -465,15 +532,15 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int + + /* attempt to create a decoder with this width/height, some sizes are not supported by hw */ + VdpStatus vdp_st; +- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder); ++ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(), profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder); + + if(vdp_st != VDP_STATUS_OK) + { +- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st); ++ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st); + return false; + } + +- m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); ++ m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); + CheckStatus(vdp_st, __LINE__); + } + +@@ -554,7 +621,7 @@ long CDecoder::Release() + VdpVideoSurface surf; + while((surf = m_videoSurfaces.RemoveNext(true)) != VDP_INVALID_HANDLE) + { +- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); ++ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf); + } + } + return IHardwareDecoder::Release(); +@@ -662,8 +729,6 @@ int CDecoder::Check(AVCodecContext* avctx) + + if (CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) + { +- m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); +- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); + m_DisplayState = VDPAU_OPEN; + m_vdpauConfigured = false; + } +@@ -686,12 +751,7 @@ bool CDecoder::IsVDPAUFormat(PixelFormat format) + + bool CDecoder::Supports(VdpVideoMixerFeature feature) + { +- for(int i = 0; i < m_vdpauConfig.featureCount; i++) +- { +- if(m_vdpauConfig.vdpFeatures[i] == feature) +- return true; +- } +- return false; ++ return m_vdpauConfig.context->Supports(feature); + } + + bool CDecoder::Supports(EINTERLACEMETHOD method) +@@ -724,7 +784,8 @@ EINTERLACEMETHOD CDecoder::AutoInterlaceMethod() + + void CDecoder::FiniVDPAUOutput() + { +- if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return; ++ if (!m_vdpauConfigured) ++ return; + + CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__); + +@@ -734,7 +795,7 @@ void CDecoder::FiniVDPAUOutput() + + VdpStatus vdp_st; + +- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); ++ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); + if (CheckStatus(vdp_st, __LINE__)) + return; + m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE; +@@ -744,7 +805,7 @@ void CDecoder::FiniVDPAUOutput() + VdpVideoSurface surf; + while((surf = m_videoSurfaces.RemoveNext()) != VDP_INVALID_HANDLE) + { +- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); ++ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf); + if (CheckStatus(vdp_st, __LINE__)) + return; + } +@@ -816,7 +877,7 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) + else + m_vdpauConfig.maxReferences = 2; + +- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, ++ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(), + vdp_decoder_profile, + m_vdpauConfig.surfaceWidth, + m_vdpauConfig.surfaceHeight, +@@ -868,55 +929,6 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) + return true; + } + +-void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo +-{ +- VdpStatus rv; +- CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:"); +- CLog::Log(LOGNOTICE,"name level macbs width height"); +- CLog::Log(LOGNOTICE,"------------------------------------"); +- for(unsigned int x=0; xcodec_id, profile, vdp->m_vdpauConfig.vdpChromaType); + +- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice, ++ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_video_surface_create(vdp->m_vdpauConfig.context->GetDevice(), + vdp->m_vdpauConfig.vdpChromaType, + avctx->coded_width, + avctx->coded_height, +@@ -1040,7 +1052,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, + uint64_t startTime = CurrentHostCounter(); + uint16_t decoded, processed, rend; + vdp->m_bufferStats.Get(decoded, processed, rend); +- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, ++ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, + surf, + (VdpPictureInfo const *)&(vdp->m_hwContext.info), + vdp->m_hwContext.bitstream_buffers_used, +@@ -1229,7 +1241,7 @@ bool CDecoder::CheckStatus(VdpStatus vdp_st, int line) + { + if (vdp_st != VDP_STATUS_OK) + { +- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); ++ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); + + if(m_DisplayState == VDPAU_OPEN) + { +@@ -1683,9 +1695,9 @@ void CMixer::CreateVdpauMixer() + &m_config.vdpChromaType}; + + VdpStatus vdp_st = VDP_STATUS_ERROR; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_create(m_config.vdpDevice, +- m_config.featureCount, +- m_config.vdpFeatures, ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_create(m_config.context->GetDevice(), ++ m_config.context->GetFeatureCount(), ++ m_config.context->GetFeatures(), + ARSIZE(parameters), + parameters, + parameter_values, +@@ -1772,7 +1784,7 @@ void CMixer::PostProcOff() + VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}; + + VdpBool enabled[]={0,0,0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + + if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION)) +@@ -1780,7 +1792,7 @@ void CMixer::PostProcOff() + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION}; + + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -1789,7 +1801,7 @@ void CMixer::PostProcOff() + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS}; + + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -1901,13 +1913,13 @@ void CMixer::SetColor() + float studioCSC[3][4]; + GenerateStudioCSCMatrix(colorStandard, studioCSC); + void const * pm_CSCMatix[] = { &studioCSC }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); + } + else + { +- vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix); ++ vdp_st = m_config.context->GetProcs().vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix); + void const * pm_CSCMatix[] = { &m_CSCMatrix }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); + } + + CheckStatus(vdp_st, __LINE__); +@@ -1925,16 +1937,16 @@ void CMixer::SetNoiseReduction() + if (!CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction) + { + VdpBool enabled[]= {0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + return; + } + VdpBool enabled[]={1}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + void* nr[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction }; + CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction); +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr); + CheckStatus(vdp_st, __LINE__); + } + +@@ -1950,16 +1962,16 @@ void CMixer::SetSharpness() + if (!CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness) + { + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + return; + } + VdpBool enabled[]={1}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + void* sh[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness }; + CLog::Log(LOGNOTICE,"Setting Sharpness to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness); +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2009,7 +2021,7 @@ void CMixer::SetDeinterlacing() + if (mode == VS_DEINTERLACEMODE_OFF) + { + VdpBool enabled[] = {0,0,0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + } + else + { +@@ -2018,7 +2030,7 @@ void CMixer::SetDeinterlacing() + VdpBool enabled[] = {1,0,0}; + if (g_advancedSettings.m_videoVDPAUtelecine) + enabled[2] = 1; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + } + else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL + || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF) +@@ -2026,7 +2038,7 @@ void CMixer::SetDeinterlacing() + VdpBool enabled[] = {1,0,0}; + if (g_advancedSettings.m_videoVDPAUtelecine) + enabled[2] = 1; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + } + else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL + || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF) +@@ -2034,12 +2046,12 @@ void CMixer::SetDeinterlacing() + VdpBool enabled[] = {1,1,0}; + if (g_advancedSettings.m_videoVDPAUtelecine) + enabled[2] = 1; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + } + else + { + VdpBool enabled[]={0,0,0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + } + } + CheckStatus(vdp_st, __LINE__); +@@ -2061,7 +2073,7 @@ void CMixer::SetDeintSkipChroma() + val = 0; + + void const *values[]={&val}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values); + + CheckStatus(vdp_st, __LINE__); + } +@@ -2078,63 +2090,63 @@ void CMixer::SetHWUpscaling() + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 8: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 7: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 6: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 5: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 4: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 3: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 2: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + case 1: + if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1)) + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 }; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + break; + } + default: +@@ -2156,7 +2168,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2164,7 +2176,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2172,7 +2184,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2180,7 +2192,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2188,7 +2200,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2196,7 +2208,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2204,7 +2216,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2212,7 +2224,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + +@@ -2220,7 +2232,7 @@ void CMixer::DisableHQScaling() + { + VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 }; + VdpBool enabled[]={0}; +- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); + CheckStatus(vdp_st, __LINE__); + } + } +@@ -2251,7 +2263,7 @@ void CMixer::Uninit() + { + m_outputSurfaces.pop(); + } +- m_config.vdpProcs.vdp_video_mixer_destroy(m_videoMixer); ++ m_config.context->GetProcs().vdp_video_mixer_destroy(m_videoMixer); + + delete [] m_BlackBar; + } +@@ -2508,7 +2520,7 @@ void CMixer::ProcessPicture() + destRect.y1 = m_config.outHeight; + + // start vdpau video mixer +- vdp_st = m_config.vdpProcs.vdp_video_mixer_render(m_videoMixer, ++ vdp_st = m_config.context->GetProcs().vdp_video_mixer_render(m_videoMixer, + VDP_INVALID_HANDLE, + 0, + m_mixerfield, +@@ -2536,7 +2548,7 @@ void CMixer::ProcessPicture() + clipRect.y1 = clipRect.y0 + 2; + uint32_t *data[] = {m_BlackBar}; + uint32_t pitches[] = {destRect.x1}; +- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface, ++ vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface, + (void**)data, + pitches, + &clipRect); +@@ -2544,7 +2556,7 @@ void CMixer::ProcessPicture() + + clipRect = destRect; + clipRect.y0 = clipRect.y1 - 2; +- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface, ++ vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface, + (void**)data, + pitches, + &clipRect); +@@ -2557,7 +2569,7 @@ bool CMixer::CheckStatus(VdpStatus vdp_st, int line) + { + if (vdp_st != VDP_STATUS_OK) + { +- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); ++ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); + m_vdpError = true; + return true; + } +@@ -3086,7 +3098,7 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() + pixmap->DVDPic = pic.DVDPic; + pixmap->id = i; + m_bufferPool.notVisiblePixmaps.push_back(i); +- m_config.vdpProcs.vdp_presentation_queue_display(pixmap->vdp_flip_queue, ++ m_config.context->GetProcs().vdp_presentation_queue_display(pixmap->vdp_flip_queue, + pixmap->surface,0,0,0); + } + if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) +@@ -3096,7 +3108,7 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() + VdpPresentationQueueStatus status; + int idx = m_bufferPool.notVisiblePixmaps.front(); + VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[idx]; +- vdp_st = m_config.vdpProcs.vdp_presentation_queue_query_surface_status( ++ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_query_surface_status( + pixmap->vdp_flip_queue, pixmap->surface, &status, &time); + + if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE) +@@ -3299,7 +3311,7 @@ bool COutput::EnsureBufferPool() + VdpOutputSurface outputSurface; + for (int i = m_bufferPool.outputSurfaces.size(); i < m_bufferPool.numOutputSurfaces; i++) + { +- vdp_st = m_config.vdpProcs.vdp_output_surface_create(m_config.vdpDevice, ++ vdp_st = m_config.context->GetProcs().vdp_output_surface_create(m_config.context->GetDevice(), + VDP_RGBA_FORMAT_B8G8R8A8, + m_config.outWidth, + m_config.outHeight, +@@ -3328,13 +3340,13 @@ bool COutput::EnsureBufferPool() + pixmap.vdp_flip_target = VDP_INVALID_HANDLE; + MakePixmap(pixmap); + glXMakeCurrent(m_Display, None, NULL); +- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_create_x11(m_config.vdpDevice, ++ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_create_x11(m_config.context->GetDevice(), + pixmap.pixmap, //x_window, + &pixmap.vdp_flip_target); + + CheckStatus(vdp_st, __LINE__); + +- vdp_st = m_config.vdpProcs.vdp_presentation_queue_create(m_config.vdpDevice, ++ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_create(m_config.context->GetDevice(), + pixmap.vdp_flip_target, + &pixmap.vdp_flip_queue); + CheckStatus(vdp_st, __LINE__); +@@ -3362,12 +3374,12 @@ void COutput::ReleaseBufferPool() + { + if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE) + { +- vdp_st = m_config.vdpProcs.vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); ++ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); + CheckStatus(vdp_st, __LINE__); + } + if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE) + { +- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); ++ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); + CheckStatus(vdp_st, __LINE__); + } + if (m_bufferPool.pixmaps[i].glPixmap) +@@ -3387,7 +3399,7 @@ void COutput::ReleaseBufferPool() + { + if (m_bufferPool.outputSurfaces[i] == VDP_INVALID_HANDLE) + continue; +- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); ++ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); + CheckStatus(vdp_st, __LINE__); + } + m_bufferPool.outputSurfaces.clear(); +@@ -3476,7 +3488,7 @@ void COutput::PreCleanup() + m_bufferPool.glOutputSurfaceMap.erase(it_map); + #endif + +- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); ++ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); + CheckStatus(vdp_st, __LINE__); + + m_bufferPool.outputSurfaces[i] = VDP_INVALID_HANDLE; +@@ -3635,7 +3647,7 @@ bool COutput::GLInit() + if (!m_config.usePixmaps) + { + while (glGetError() != GL_NO_ERROR); +- glVDPAUInitNV(reinterpret_cast(m_config.vdpDevice), reinterpret_cast(m_config.vdpProcs.vdp_get_proc_address)); ++ glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); + if (glGetError() != GL_NO_ERROR) + { + CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); +@@ -3833,7 +3845,7 @@ bool COutput::CheckStatus(VdpStatus vdp_st, int line) + { + if (vdp_st != VDP_STATUS_OK) + { +- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); ++ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); + m_vdpError = true; + return true; + } +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +index c8e89dc..07a98a2 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +@@ -179,15 +179,11 @@ struct CVdpauConfig + int vidHeight; + int outWidth; + int outHeight; +- VDPAU_procs vdpProcs; +- VdpDevice vdpDevice; + VdpDecoder vdpDecoder; + VdpChromaType vdpChromaType; + CVdpauBufferStats *stats; + CDecoder *vdpau; +- int featureCount; + int upscale; +- VdpVideoMixerFeature vdpFeatures[14]; + CVideoSurfaces *videoSurfaces; + bool usePixmaps; + int numRenderBuffers; +@@ -546,22 +542,28 @@ class CVDPAUContext + public: + static bool EnsureContext(CVDPAUContext **ctx); + void Release(); +- void GetProcs(VDPAU_procs &procs); ++ VDPAU_procs& GetProcs(); + VdpDevice GetDevice(); ++ bool Supports(VdpVideoMixerFeature feature); ++ VdpVideoMixerFeature* GetFeatures(); ++ int GetFeatureCount(); + private: + CVDPAUContext(); + void Close(); + bool LoadSymbols(); + bool CreateContext(); + void DestroyContext(); ++ void QueryProcs(); ++ void SpewHardwareAvailable(); + static CVDPAUContext *m_context; + static CCriticalSection m_section; + static Display *m_display; + int m_refCount; ++ VdpVideoMixerFeature m_vdpFeatures[14]; ++ int m_featureCount; + static void *m_dlHandle; + VdpDevice m_vdpDevice; +- VdpGetProcAddress *m_vdp_get_proc_address; +- VdpDeviceDestroy *m_vdp_device_destroy; ++ VDPAU_procs m_vdpProcs; + VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); + }; + +@@ -619,7 +621,6 @@ class CDecoder + protected: + void SetWidthHeight(int width, int height); + bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); +- void SpewHardwareAvailable(); + bool CheckStatus(VdpStatus vdp_st, int line); + void FiniVDPAUOutput(); + void ReturnRenderPicture(CVdpauRenderPicture *renderPic); +-- +1.8.4 + + +From 1e7eb3091940464992275fe543878e74a761b65c Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Mon, 30 Sep 2013 21:30:28 +0200 +Subject: [PATCH 10/87] vdpau: drop pixmap magic, it violates the spec + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 328 ++----------------------- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 31 --- + 2 files changed, 17 insertions(+), 342 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index 8f7e0dd..c5beec1 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -249,15 +249,6 @@ void CVDPAUContext::QueryProcs() + VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpProcs.vdp_decoder_destroy); + VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpProcs.vdp_decoder_render); + VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpProcs.vdp_decoder_query_caps); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpProcs.vdp_presentation_queue_target_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpProcs.vdp_presentation_queue_create); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpProcs.vdp_presentation_queue_destroy); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpProcs.vdp_presentation_queue_display); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpProcs.vdp_presentation_queue_block_until_surface_idle); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpProcs.vdp_presentation_queue_target_create_x11); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpProcs.vdp_presentation_queue_query_surface_status); +- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpProcs.vdp_presentation_queue_get_time); +- + #undef VDP_PROC + } + +@@ -760,11 +751,8 @@ bool CDecoder::Supports(EINTERLACEMETHOD method) + || method == VS_INTERLACEMETHOD_AUTO) + return true; + +- if (!m_vdpauConfig.usePixmaps) +- { +- if (method == VS_INTERLACEMETHOD_RENDER_BOB) +- return true; +- } ++ if (method == VS_INTERLACEMETHOD_RENDER_BOB) ++ return true; + + if (method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE) + return false; +@@ -900,15 +888,6 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) + sizeof(m_vdpauConfig))) + { + bool success = reply->signal == COutputControlProtocol::ACC ? true : false; +- if (success) +- { +- CVdpauConfig *data; +- data = (CVdpauConfig*)reply->data; +- if (data) +- { +- m_vdpauConfig.usePixmaps = data->usePixmaps; +- } +- } + reply->Release(); + if (!success) + { +@@ -2971,7 +2950,6 @@ bool COutput::Uninit() + { + m_mixer.Dispose(); + GLUnmapSurfaces(); +- GLUnbindPixmaps(); + ReleaseBufferPool(); + DestroyGlxContext(); + return true; +@@ -3065,69 +3043,16 @@ void COutput::Flush() + + bool COutput::HasWork() + { +- if (m_config.usePixmaps) +- { +- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0) +- return true; +- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) +- return true; +- return false; +- } +- else +- { +- if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) +- return true; +- return false; +- } ++ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) ++ return true; ++ return false; + } + + CVdpauRenderPicture* COutput::ProcessMixerPicture() + { + CVdpauRenderPicture *retPic = NULL; + +- if (m_config.usePixmaps) +- { +- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0) +- { +- unsigned int i = FindFreePixmap(); +- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[i]; +- pixmap->used = true; +- CVdpauProcessedPicture pic = m_bufferPool.processedPics.front(); +- m_bufferPool.processedPics.pop(); +- pixmap->surface = pic.outputSurface; +- pixmap->DVDPic = pic.DVDPic; +- pixmap->id = i; +- m_bufferPool.notVisiblePixmaps.push_back(i); +- m_config.context->GetProcs().vdp_presentation_queue_display(pixmap->vdp_flip_queue, +- pixmap->surface,0,0,0); +- } +- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) +- { +- VdpStatus vdp_st; +- VdpTime time; +- VdpPresentationQueueStatus status; +- int idx = m_bufferPool.notVisiblePixmaps.front(); +- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[idx]; +- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_query_surface_status( +- pixmap->vdp_flip_queue, pixmap->surface, &status, &time); +- +- if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE) +- { +- int idx = m_bufferPool.freeRenderPics.front(); +- retPic = m_bufferPool.allRenderPics[idx]; +- m_bufferPool.freeRenderPics.pop_front(); +- m_bufferPool.usedRenderPics.push_back(idx); +- retPic->sourceIdx = pixmap->id; +- retPic->DVDPic = pixmap->DVDPic; +- retPic->valid = true; +- retPic->texture[0] = pixmap->texture; +- retPic->crop = CRect(0,0,0,0); +- m_bufferPool.notVisiblePixmaps.pop_front(); +- m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &pixmap->surface, sizeof(pixmap->surface)); +- } +- } +- } // pixmap +- else if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) ++ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) + { + int idx = m_bufferPool.freeRenderPics.front(); + retPic = m_bufferPool.allRenderPics[idx]; +@@ -3257,12 +3182,7 @@ bool COutput::ProcessSyncPicture() + + void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) + { +- if (m_config.usePixmaps) +- { +- m_bufferPool.pixmaps[pic->sourceIdx].used = false; +- return; +- } +- else if (pic->DVDPic.format == RENDER_FMT_VDPAU_420) ++ if (pic->DVDPic.format == RENDER_FMT_VDPAU_420) + { + std::map::iterator it; + it = m_bufferPool.glVideoSurfaceMap.find(pic->sourceIdx); +@@ -3288,21 +3208,6 @@ void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) + } + } + +-int COutput::FindFreePixmap() +-{ +- // find free pixmap +- unsigned int i; +- for (i = 0; i < m_bufferPool.pixmaps.size(); ++i) +- { +- if (!m_bufferPool.pixmaps[i].used) +- break; +- } +- if (i == m_bufferPool.pixmaps.size()) +- return -1; +- else +- return i; +-} +- + bool COutput::EnsureBufferPool() + { + VdpStatus vdp_st; +@@ -3325,40 +3230,6 @@ bool COutput::EnsureBufferPool() + sizeof(VdpOutputSurface)); + CLog::Log(LOGNOTICE, "VDPAU::COutput::InitBufferPool - Output Surface created"); + } +- +- +- if (m_config.usePixmaps && m_bufferPool.pixmaps.empty()) +- { +- // create pixmpas +- VdpauBufferPool::Pixmaps pixmap; +- unsigned int numPixmaps = NUM_RENDER_PICS; +- for (unsigned int i = 0; i < numPixmaps; i++) +- { +- pixmap.pixmap = None; +- pixmap.glPixmap = None; +- pixmap.vdp_flip_queue = VDP_INVALID_HANDLE; +- pixmap.vdp_flip_target = VDP_INVALID_HANDLE; +- MakePixmap(pixmap); +- glXMakeCurrent(m_Display, None, NULL); +- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_create_x11(m_config.context->GetDevice(), +- pixmap.pixmap, //x_window, +- &pixmap.vdp_flip_target); +- +- CheckStatus(vdp_st, __LINE__); +- +- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_create(m_config.context->GetDevice(), +- pixmap.vdp_flip_target, +- &pixmap.vdp_flip_queue); +- CheckStatus(vdp_st, __LINE__); +- glXMakeCurrent(m_Display, m_glPixmap, m_glContext); +- +- pixmap.id = i; +- pixmap.used = false; +- m_bufferPool.pixmaps.push_back(pixmap); +- } +- GLBindPixmaps(); +- } +- + return true; + } + +@@ -3368,32 +3239,6 @@ void COutput::ReleaseBufferPool() + + CSingleLock lock(m_bufferPool.renderPicSec); + +- if (m_config.usePixmaps) +- { +- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); ++i) +- { +- if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE) +- { +- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); +- CheckStatus(vdp_st, __LINE__); +- } +- if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE) +- { +- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); +- CheckStatus(vdp_st, __LINE__); +- } +- if (m_bufferPool.pixmaps[i].glPixmap) +- { +- glXDestroyPixmap(m_Display, m_bufferPool.pixmaps[i].glPixmap); +- } +- if (m_bufferPool.pixmaps[i].pixmap) +- { +- XFreePixmap(m_Display, m_bufferPool.pixmaps[i].pixmap); +- } +- } +- m_bufferPool.pixmaps.clear(); +- } +- + // release all output surfaces + for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i) + { +@@ -3508,89 +3353,8 @@ void COutput::InitMixer() + } + } + +-bool COutput::MakePixmap(VdpauBufferPool::Pixmaps &pixmap) +-{ +- CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", m_config.outWidth, m_config.outHeight); +- +- // Get our window attribs. +- XWindowAttributes wndattribs; +- XGetWindowAttributes(m_Display, g_Windowing.GetWindow(), &wndattribs); +- +- pixmap.pixmap = XCreatePixmap(m_Display, +- g_Windowing.GetWindow(), +- m_config.outWidth, +- m_config.outHeight, +- wndattribs.depth); +- if (!pixmap.pixmap) +- { +- CLog::Log(LOGERROR, "VDPAU::COUtput::MakePixmap - GLX Error: MakePixmap: Unable to create XPixmap"); +- return false; +- } +- +-// XGCValues values = {}; +-// GC xgc; +-// values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display)); +-// xgc = XCreateGC(m_Display, pixmap.pixmap, GCForeground, &values); +-// XFillRectangle(m_Display, pixmap.pixmap, xgc, 0, 0, m_config.outWidth, m_config.outHeight); +-// XFreeGC(m_Display, xgc); +- +- if(!MakePixmapGL(pixmap)) +- return false; +- +- return true; +-} +- +-bool COutput::MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap) +-{ +- int num=0; +- int fbConfigIndex = 0; +- +- int doubleVisAttributes[] = { +- GLX_RENDER_TYPE, GLX_RGBA_BIT, +- GLX_RED_SIZE, 8, +- GLX_GREEN_SIZE, 8, +- GLX_BLUE_SIZE, 8, +- GLX_ALPHA_SIZE, 8, +- GLX_DEPTH_SIZE, 8, +- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, +- GLX_BIND_TO_TEXTURE_RGBA_EXT, True, +- GLX_DOUBLEBUFFER, False, +- GLX_Y_INVERTED_EXT, True, +- GLX_X_RENDERABLE, True, +- None +- }; +- +- int pixmapAttribs[] = { +- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, +- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, +- None +- }; +- +- GLXFBConfig *fbConfigs; +- fbConfigs = glXChooseFBConfig(m_Display, g_Windowing.GetCurrentScreen(), doubleVisAttributes, &num); +- if (fbConfigs==NULL) +- { +- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - No compatible framebuffers found"); +- return false; +- } +- fbConfigIndex = 0; +- +- pixmap.glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], pixmap.pixmap, pixmapAttribs); +- +- if (!pixmap.glPixmap) +- { +- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - Could not create Pixmap"); +- XFree(fbConfigs); +- return false; +- } +- XFree(fbConfigs); +- return true; +-} +- + bool COutput::GLInit() + { +- glXBindTexImageEXT = NULL; +- glXReleaseTexImageEXT = NULL; + #ifdef GL_NV_vdpau_interop + glVDPAUInitNV = NULL; + glVDPAUFiniNV = NULL; +@@ -3604,8 +3368,6 @@ bool COutput::GLInit() + glVDPAUGetSurfaceivNV = NULL; + #endif + +- m_config.usePixmaps = false; +- + #ifdef GL_NV_vdpau_interop + if (glewIsSupported("GL_NV_vdpau_interop")) + { +@@ -3635,27 +3397,21 @@ bool COutput::GLInit() + else + #endif + { +- m_config.usePixmaps = true; +- CSettings::Get().SetBool("videoplayer.usevdpaumixer",true); ++ // TODO should be detected before vdpau is opened, though very unlikely ++ // that this code is hit ++ CLog::Log(LOGERROR, "VDPAU::COutput driver does not support GL_NV_vdpau_interop"); + } +- if (!glXBindTexImageEXT) +- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT"); +- if (!glXReleaseTexImageEXT) +- glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT"); + + #ifdef GL_NV_vdpau_interop +- if (!m_config.usePixmaps) ++ while (glGetError() != GL_NO_ERROR); ++ glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); ++ if (glGetError() != GL_NO_ERROR) + { +- while (glGetError() != GL_NO_ERROR); +- glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); +- if (glGetError() != GL_NO_ERROR) +- { +- CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); +- m_vdpError = true; +- return false; +- } +- CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized"); ++ CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); ++ m_vdpError = true; ++ return false; + } ++ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized"); + #endif + + #ifdef GL_ARB_sync +@@ -3672,8 +3428,6 @@ bool COutput::GLInit() + void COutput::GLMapSurfaces() + { + #ifdef GL_NV_vdpau_interop +- if (m_config.usePixmaps) +- return; + + if (m_config.useInteropYuv) + { +@@ -3767,8 +3521,6 @@ void COutput::GLMapSurfaces() + void COutput::GLUnmapSurfaces() + { + #ifdef GL_NV_vdpau_interop +- if (m_config.usePixmaps) +- return; + + { + std::map::iterator it; +@@ -3795,52 +3547,6 @@ void COutput::GLUnmapSurfaces() + #endif + } + +-void COutput::GLBindPixmaps() +-{ +- if (!m_config.usePixmaps) +- return; +- +- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++) +- { +- // create texture +- glGenTextures(1, &m_bufferPool.pixmaps[i].texture); +- +- //bind texture +- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture); +- +- // bind pixmap +- glXBindTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT, NULL); +- +- glBindTexture(GL_TEXTURE_2D, 0); +- } +- +- CLog::Log(LOGNOTICE, "VDPAU::COutput: bound pixmaps"); +-} +- +-void COutput::GLUnbindPixmaps() +-{ +- if (!m_config.usePixmaps) +- return; +- +- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++) +- { +- // create texture +- if (!glIsTexture(m_bufferPool.pixmaps[i].texture)) +- continue; +- +- //bind texture +- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture); +- +- // release pixmap +- glXReleaseTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT); +- +- glBindTexture(GL_TEXTURE_2D, 0); +- +- glDeleteTextures(1, &m_bufferPool.pixmaps[i].texture); +- } +- CLog::Log(LOGNOTICE, "VDPAU::COutput: unbound pixmaps"); +-} +- + bool COutput::CheckStatus(VdpStatus vdp_st, int line) + { + if (vdp_st != VDP_STATUS_OK) +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +index 07a98a2..abe8da2 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h +@@ -103,15 +103,6 @@ struct VDPAU_procs + + VdpGenerateCSCMatrix * vdp_generate_csc_matrix; + +- VdpPresentationQueueTargetDestroy * vdp_presentation_queue_target_destroy; +- VdpPresentationQueueCreate * vdp_presentation_queue_create; +- VdpPresentationQueueDestroy * vdp_presentation_queue_destroy; +- VdpPresentationQueueDisplay * vdp_presentation_queue_display; +- VdpPresentationQueueBlockUntilSurfaceIdle * vdp_presentation_queue_block_until_surface_idle; +- VdpPresentationQueueTargetCreateX11 * vdp_presentation_queue_target_create_x11; +- VdpPresentationQueueQuerySurfaceStatus * vdp_presentation_queue_query_surface_status; +- VdpPresentationQueueGetTime * vdp_presentation_queue_get_time; +- + VdpGetErrorString * vdp_get_error_string; + + VdpDecoderCreate * vdp_decoder_create; +@@ -185,7 +176,6 @@ struct CVdpauConfig + CDecoder *vdpau; + int upscale; + CVideoSurfaces *videoSurfaces; +- bool usePixmaps; + int numRenderBuffers; + uint32_t maxReferences; + bool useInteropYuv; +@@ -363,18 +353,6 @@ struct VdpauBufferPool + { + VdpauBufferPool(); + virtual ~VdpauBufferPool(); +- struct Pixmaps +- { +- unsigned short id; +- bool used; +- DVDVideoPicture DVDPic; +- GLuint texture; +- Pixmap pixmap; +- GLXPixmap glPixmap; +- VdpPresentationQueueTarget vdp_flip_target; +- VdpPresentationQueue vdp_flip_queue; +- VdpOutputSurface surface; +- }; + struct GLVideoSurface + { + GLuint texture[4]; +@@ -386,9 +364,7 @@ struct VdpauBufferPool + }; + std::vector allRenderPics; + unsigned short numOutputSurfaces; +- std::vector pixmaps; + std::vector outputSurfaces; +- std::deque notVisiblePixmaps; + std::map glVideoSurfaceMap; + std::map glOutputSurfaceMap; + std::queue processedPics; +@@ -457,7 +433,6 @@ class COutput : private CThread + void QueueReturnPicture(CVdpauRenderPicture *pic); + void ProcessReturnPicture(CVdpauRenderPicture *pic); + bool ProcessSyncPicture(); +- int FindFreePixmap(); + bool Init(); + bool Uninit(); + void Flush(); +@@ -470,10 +445,6 @@ class COutput : private CThread + bool GLInit(); + void GLMapSurfaces(); + void GLUnmapSurfaces(); +- void GLBindPixmaps(); +- void GLUnbindPixmaps(); +- bool MakePixmap(VdpauBufferPool::Pixmaps &pixmap); +- bool MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap); + bool CheckStatus(VdpStatus vdp_st, int line); + CEvent m_outMsgEvent; + CEvent *m_inMsgEvent; +@@ -494,8 +465,6 @@ class COutput : private CThread + GLXPixmap m_glPixmap; + + // gl functions +- PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT; +- PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT; + #ifdef GL_NV_vdpau_interop + PFNGLVDPAUINITNVPROC glVDPAUInitNV; + PFNGLVDPAUFININVPROC glVDPAUFiniNV; +-- +1.8.4 + + +From bd45e5319f740e24981e831a8851145be55933b1 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Tue, 1 Oct 2013 17:42:01 +0200 +Subject: [PATCH 11/87] vdpau: reduce number of render pics + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index c5beec1..d4dff12 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -38,7 +38,7 @@ + #include "cores/VideoRenderers/RenderFlags.h" + + using namespace VDPAU; +-#define NUM_RENDER_PICS 9 ++#define NUM_RENDER_PICS 7 + + #define ARSIZE(x) (sizeof(x) / sizeof((x)[0])) + +-- +1.8.4 + + +From 551e5a217bade9d23d245cd1eefaf181636665c3 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Tue, 1 Oct 2013 17:51:02 +0200 +Subject: [PATCH 12/87] vdpau: cosmetics + +--- + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 20 +++----------------- + 1 file changed, 3 insertions(+), 17 deletions(-) + +diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +index d4dff12..f57935e 100644 +--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp ++++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +@@ -961,7 +961,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) + + void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic) + { +- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__); + CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; + CDecoder* vdp = (CDecoder*)ctx->GetHardware(); + +@@ -1298,7 +1297,7 @@ void CVdpauRenderPicture::Sync() + // Mixer + //----------------------------------------------------------------------------- + CMixer::CMixer(CEvent *inMsgEvent) : +- CThread("Vdpau Mixer Thread"), ++ CThread("Vdpau Mixer"), + m_controlPort("ControlPort", inMsgEvent, &m_outMsgEvent), + m_dataPort("DataPort", inMsgEvent, &m_outMsgEvent) + { +@@ -1462,11 +1461,6 @@ void CMixer::StateMachine(int signal, Protocol *port, Message *msg) + } + else + { +-// if (m_extTimeout != 0) +-// { +-// SetPostProcFeatures(false); +-// CLog::Log(LOGWARNING,"CVDPAU::Mixer timeout - decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size()); +-// } + m_extTimeout = 100; + } + return; +@@ -1534,11 +1528,6 @@ void CMixer::StateMachine(int signal, Protocol *port, Message *msg) + } + else + { +-// if (m_extTimeout != 0) +-// { +-// SetPostProcFeatures(false); +-// CLog::Log(LOGNOTICE,"---mixer wait2 decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size()); +-// } + m_extTimeout = 100; + } + return; +@@ -2216,7 +2205,6 @@ void CMixer::DisableHQScaling() + } + } + +- + void CMixer::Init() + { + m_Brightness = 0.0; +@@ -2282,10 +2270,9 @@ void CMixer::Flush() + void CMixer::InitCycle() + { + CheckFeatures(); +- uint64_t latency; + int flags; ++ uint64_t latency; + m_config.stats->GetParams(latency, flags); +- latency = (latency*1000)/CurrentHostFrequency(); + // TODO + if (0) //flags & DVP_FLAG_NO_POSTPROC) + SetPostProcFeatures(false); +@@ -2404,7 +2391,6 @@ void CMixer::FiniCycle() + m_config.videoSurfaces->ClearRender(tmp.videoSurface); + } + m_mixerInput.pop_back(); +-// m_config.stats->DecDecoded(); + } + } + +@@ -2584,7 +2570,7 @@ bool CMixer::CheckStatus(VdpStatus vdp_st, int line) + // Output + //----------------------------------------------------------------------------- + COutput::COutput(CEvent *inMsgEvent) : +- CThread("Vdpau Output Thread"), ++ CThread("Vdpau Output"), + m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent), + m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent), + m_mixer(&m_outMsgEvent) +-- +1.8.4 + + +From 124e8cfaf4001809adf5e358775843b5b3664c35 Mon Sep 17 00:00:00 2001 +From: Rainer Hochecker +Date: Sat, 5 Oct 2013 14:31:19 +0200 +Subject: [PATCH 13/87] vdpau: fix incorrect spcifier in settings for vdpau + mixer + +--- + system/settings/settings.xml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/system/settings/settings.xml b/system/settings/settings.xml +index a22138c..64d6e63 100644 +--- a/system/settings/settings.xml ++++ b/system/settings/settings.xml +@@ -376,7 +376,7 @@ + true + + +- HAVE_LIBVDPAU ++ HAVE_LIBVDPAU + 2 + true + +-- +1.8.4 + + +From 98d69153c2fc3140dea7e2d12399bcde79fc787d Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 28 May 2012 10:34:39 +0200 -Subject: [PATCH 01/89] videoplayer: adapt lateness detection and dropping to +Subject: [PATCH 14/87] videoplayer: adapt lateness detection and dropping to buffering --- @@ -15,10 +3170,10 @@ Subject: [PATCH 01/89] videoplayer: adapt lateness detection and dropping to 7 files changed, 260 insertions(+), 38 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp -index fbc2aae..ae610ca 100644 +index 249222a..c0a6409 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp -@@ -299,6 +299,8 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi +@@ -300,6 +300,8 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi m_bIsStarted = true; m_bReconfigured = true; m_presentstep = PRESENT_IDLE; @@ -27,7 +3182,7 @@ index fbc2aae..ae610ca 100644 m_presentevent.notifyAll(); m_firstFlipPage = false; // tempfix -@@ -640,7 +642,7 @@ void CXBMCRenderManager::SetViewMode(int iViewMode) +@@ -641,7 +643,7 @@ void CXBMCRenderManager::SetViewMode(int iViewMode) m_pRenderer->SetViewMode(iViewMode); } @@ -36,7 +3191,7 @@ index fbc2aae..ae610ca 100644 { { CSharedLock lock(m_sharedSection); -@@ -708,6 +710,7 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L +@@ -709,6 +711,7 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L m.timestamp = timestamp; m.presentfield = sync; m.presentmethod = presentmethod; @@ -44,7 +3199,7 @@ index fbc2aae..ae610ca 100644 requeue(m_queued, m_free); /* signal to any waiters to check state */ -@@ -1072,6 +1075,8 @@ void CXBMCRenderManager::PrepareNextRender() +@@ -1077,6 +1080,8 @@ void CXBMCRenderManager::PrepareNextRender() m_discard.push_back(m_presentsource); m_presentsource = idx; m_queued.pop_front(); @@ -53,7 +3208,7 @@ index fbc2aae..ae610ca 100644 m_presentevent.notifyAll(); } } -@@ -1088,3 +1093,12 @@ void CXBMCRenderManager::DiscardBuffer() +@@ -1093,3 +1098,12 @@ void CXBMCRenderManager::DiscardBuffer() m_presentstep = PRESENT_IDLE; m_presentevent.notifyAll(); } @@ -114,10 +3269,10 @@ index 28596cf..befd851 100644 double m_presenterr; double m_errorbuff[ERRORBUFFSIZE]; diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -index 87edaa5..eaac7fd 100644 +index baee6e0..8a88c0d 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -@@ -117,6 +117,10 @@ struct DVDVideoUserData +@@ -123,6 +123,10 @@ struct DVDVideoUserData #define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped #define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data @@ -128,7 +3283,7 @@ index 87edaa5..eaac7fd 100644 // DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2! #define DVP_QSCALE_UNKNOWN 0 -@@ -134,6 +138,9 @@ struct DVDVideoUserData +@@ -140,6 +144,9 @@ struct DVDVideoUserData #define VC_PICTURE 0x00000004 // the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data #define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again @@ -138,7 +3293,7 @@ index 87edaa5..eaac7fd 100644 class CDVDVideoCodec { public: -@@ -251,10 +258,16 @@ class CDVDVideoCodec +@@ -257,10 +264,16 @@ class CDVDVideoCodec return 0; } @@ -254,7 +3409,7 @@ index 2287031..8376f72 100644 + int m_codecControlFlags; }; diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index d35751c..487ca01 100644 +index 2321d2c..d8a61f8 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -39,6 +39,7 @@ @@ -349,7 +3504,7 @@ index d35751c..487ca01 100644 // reset the request, the following while loop may break before // setting the flag to a new value bRequestDrop = false; -@@ -1182,33 +1203,12 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) +@@ -1183,33 +1204,12 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) m_FlipTimeStamp += max(0.0, iSleepTime); m_FlipTimeStamp += iFrameDuration; @@ -387,7 +3542,7 @@ index d35751c..487ca01 100644 // set fieldsync if picture is interlaced EFIELDSYNC mDisplayField = FS_NONE; -@@ -1241,7 +1241,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) +@@ -1242,7 +1242,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) if (index < 0) return EOS_DROPPED; @@ -396,7 +3551,7 @@ index d35751c..487ca01 100644 return result; #else -@@ -1541,3 +1541,127 @@ void CDVDPlayerVideo::CalcFrameRate() +@@ -1542,3 +1542,127 @@ void CDVDPlayerVideo::CalcFrameRate() m_iFrameRateCount = 0; } } @@ -582,10 +3737,10 @@ index f8ad541..186e271 100644 1.8.4 -From ebf5388ef964f0ce79dc141923277c84489255e1 Mon Sep 17 00:00:00 2001 +From 1b8ca711710cdc9ed60d0c2189aca59897d1f731 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 2 Sep 2012 16:05:21 +0200 -Subject: [PATCH 02/89] video player: present correct pts to user for a/v sync +Subject: [PATCH 15/87] video player: present correct pts to user for a/v sync (after buffering in renderer) --- @@ -594,10 +3749,10 @@ Subject: [PATCH 02/89] video player: present correct pts to user for a/v sync 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index 487ca01..99c8b3c 100644 +index d8a61f8..752a291 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -@@ -1461,6 +1461,22 @@ void CDVDPlayerVideo::ResetFrameRateCalc() +@@ -1462,6 +1462,22 @@ void CDVDPlayerVideo::ResetFrameRateCalc() g_advancedSettings.m_videoFpsDetect == 0; } @@ -620,7 +3775,7 @@ index 487ca01..99c8b3c 100644 #define MAXFRAMERATEDIFF 0.01 #define MAXFRAMESERR 1000 -@@ -1579,6 +1595,15 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts) +@@ -1580,6 +1596,15 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts) else iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE; @@ -653,10 +3808,10 @@ index 186e271..59c7f09 100644 1.8.4 -From 3d21b5239ce8a310ed9a8a588e08cc971e14e22b Mon Sep 17 00:00:00 2001 +From 7e98d7e146f1ac7c3ee8c672d5ac06a8f317d840 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sat, 16 Feb 2013 18:25:53 +0100 -Subject: [PATCH 03/89] videoplayer: some rework and documentation +Subject: [PATCH 16/87] videoplayer: some rework and documentation --- .../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h | 29 ++++++++++++++++++++-- @@ -666,10 +3821,10 @@ Subject: [PATCH 03/89] videoplayer: some rework and documentation 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -index eaac7fd..d358777 100644 +index 8a88c0d..b898491 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -@@ -139,7 +139,6 @@ struct DVDVideoUserData +@@ -145,7 +145,6 @@ struct DVDVideoUserData #define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again #define VC_DROPPED 0x00000020 // needed to identify if a picture was dropped @@ -677,7 +3832,7 @@ index eaac7fd..d358777 100644 class CDVDVideoCodec { -@@ -264,10 +263,36 @@ class CDVDVideoCodec +@@ -270,10 +269,36 @@ class CDVDVideoCodec */ virtual unsigned GetAllowedReferences() { return 0; } @@ -751,10 +3906,10 @@ index 8376f72..c0ce198 100644 bool IsHardwareAllowed() { return !m_bSoftware; } diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index 99c8b3c..be3d511 100644 +index 752a291..0aef5ee 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -@@ -1572,7 +1572,7 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts) +@@ -1573,7 +1573,7 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts) int iBufferLevel; // get decoder stats @@ -767,10 +3922,10 @@ index 99c8b3c..be3d511 100644 1.8.4 -From 66d7a704de4d48b9e5489383c155f28aa39d97eb Mon Sep 17 00:00:00 2001 +From a73fe3a694826bbe9cdde127bee68aa5e4e5cc73 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 1 Jun 2013 11:21:19 +0200 -Subject: [PATCH 04/89] renderer: bump buffers to 5 +Subject: [PATCH 17/87] renderer: bump buffers to 5 --- xbmc/cores/VideoRenderers/BaseRenderer.h | 2 +- @@ -793,10 +3948,10 @@ index a61d3cf..df5fe0e 100644 1.8.4 -From a18f1c9b926063f2ecf7e36bd0ac8e693f91552e Mon Sep 17 00:00:00 2001 +From bb145eeba6de5eb473aac7a1dae65e8a20b747d9 Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 28 May 2012 10:41:31 +0200 -Subject: [PATCH 05/89] videoplayer: update frametime, it might change due to +Subject: [PATCH 18/87] videoplayer: update frametime, it might change due to fps detection --- @@ -804,7 +3959,7 @@ Subject: [PATCH 05/89] videoplayer: update frametime, it might change due to 1 file changed, 2 insertions(+) diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index be3d511..dbbd11b 100644 +index 0aef5ee..e7e5097 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -711,6 +711,8 @@ void CDVDPlayerVideo::Process() @@ -820,10 +3975,10 @@ index be3d511..dbbd11b 100644 1.8.4 -From f9d60190eeb63493bee3ad3530ea2a288491115c Mon Sep 17 00:00:00 2001 +From d4ff6ac75519782389371a0042c5f29acee80d3d Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 28 May 2012 10:43:06 +0200 -Subject: [PATCH 06/89] videoplayer: give streams with invalid fps a chance for +Subject: [PATCH 19/87] videoplayer: give streams with invalid fps a chance for fps detection --- @@ -831,10 +3986,10 @@ Subject: [PATCH 06/89] videoplayer: give streams with invalid fps a chance for 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index dbbd11b..eb443af 100644 +index e7e5097..c40d193 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -@@ -1503,7 +1503,7 @@ void CDVDPlayerVideo::CalcFrameRate() +@@ -1504,7 +1504,7 @@ void CDVDPlayerVideo::CalcFrameRate() double frameduration = m_pullupCorrection.GetFrameDuration(); if (frameduration == DVD_NOPTS_VALUE || @@ -847,10 +4002,10 @@ index dbbd11b..eb443af 100644 1.8.4 -From f2b3710bb6199a0ff84eb93d462b23a9d37e2ad2 Mon Sep 17 00:00:00 2001 +From 40875a03e9bcab1582b655c0625ad1f7d3a3493f Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 28 May 2012 10:49:05 +0200 -Subject: [PATCH 07/89] dvdplayer: allow rewinding at end of stream, do a seek +Subject: [PATCH 20/87] dvdplayer: allow rewinding at end of stream, do a seek after rewind --- @@ -858,7 +4013,7 @@ Subject: [PATCH 07/89] dvdplayer: allow rewinding at end of stream, do a seek 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp -index 0cd222a..53f82a0 100644 +index 94adb6e..964ea2e 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -1552,7 +1552,7 @@ void CDVDPlayer::HandlePlaySpeed() @@ -887,26 +4042,27 @@ index 0cd222a..53f82a0 100644 1.8.4 -From 6386b7275fb75e9e6253df4bb40e174521c22f3f Mon Sep 17 00:00:00 2001 +From 4b3f7b67ca569c24fd3822b3b759fcffc3ee0ba9 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 15:22:05 +0200 -Subject: [PATCH 08/89] X11: ditch SDL for video and window events +Subject: [PATCH 21/87] X11: ditch SDL for video and window events --- xbmc/Application.cpp | 2 +- xbmc/system.h | 5 + - xbmc/windowing/Makefile | 1 + - xbmc/windowing/WinEvents.h | 4 + - xbmc/windowing/WinEventsX11.cpp | 765 ++++++++++++++++++++++++++++++++++++ - xbmc/windowing/WinEventsX11.h | 57 +++ + xbmc/windowing/Makefile | 3 +- + xbmc/windowing/WinEvents.cpp | 4 + + xbmc/windowing/WinEvents.h | 1 - + xbmc/windowing/WinEventsX11.cpp | 784 ++++++++++++++++++++++++++++++++++++ + xbmc/windowing/WinEventsX11.h | 65 +++ xbmc/windowing/X11/WinSystemX11.cpp | 370 ++++++++++++----- xbmc/windowing/X11/WinSystemX11.h | 9 +- - 8 files changed, 1112 insertions(+), 101 deletions(-) + 9 files changed, 1140 insertions(+), 103 deletions(-) create mode 100644 xbmc/windowing/WinEventsX11.cpp create mode 100644 xbmc/windowing/WinEventsX11.h diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp -index 54fe68b..1062469 100644 +index e033d1b..3dbc541 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -853,7 +853,7 @@ bool CApplication::CreateGUI() @@ -945,38 +4101,50 @@ index 1f4e15f..075e44a 100644 #define HAS_LIRC #ifdef HAVE_LIBPULSE diff --git a/xbmc/windowing/Makefile b/xbmc/windowing/Makefile -index f109bec..f981642 100644 +index b52d16c..07100d8 100644 --- a/xbmc/windowing/Makefile +++ b/xbmc/windowing/Makefile -@@ -1,6 +1,7 @@ +@@ -1,7 +1,8 @@ SRCS=WinEventsSDL.cpp \ WinEventsLinux.cpp \ WinSystem.cpp \ -+ WinEventsX11.cpp \ +- WinEvents.cpp ++ WinEvents.cpp \ ++ WinEventsX11.cpp LIB=windowing.a -diff --git a/xbmc/windowing/WinEvents.h b/xbmc/windowing/WinEvents.h -index 9e09b54..87bf855 100644 ---- a/xbmc/windowing/WinEvents.h -+++ b/xbmc/windowing/WinEvents.h -@@ -56,6 +56,10 @@ class CWinEventsBase +diff --git a/xbmc/windowing/WinEvents.cpp b/xbmc/windowing/WinEvents.cpp +index d47784c..bf554ec 100644 +--- a/xbmc/windowing/WinEvents.cpp ++++ b/xbmc/windowing/WinEvents.cpp +@@ -42,6 +42,10 @@ #include "WinEventsSDL.h" - #define CWinEvents CWinEventsSDL + #define WinEventsType CWinEventsSDL -+#elif defined(TARGET_LINUX) && defined(HAS_X11_WIN_EVENTS) ++#elif (defined(TARGET_FREEBSD) || defined(TARGET_LINUX)) && defined(HAS_X11_WIN_EVENTS) +#include "WinEventsX11.h" -+#define CWinEvents CWinEventsX11 ++#define WinEventsType CWinEventsX11 + #elif defined(TARGET_LINUX) && defined(HAS_LINUX_EVENTS) #include "WinEventsLinux.h" - #define CWinEvents CWinEventsLinux + #define WinEventsType CWinEventsLinux +diff --git a/xbmc/windowing/WinEvents.h b/xbmc/windowing/WinEvents.h +index 8ae126a..e04631f 100644 +--- a/xbmc/windowing/WinEvents.h ++++ b/xbmc/windowing/WinEvents.h +@@ -45,5 +45,4 @@ class CWinEvents + static size_t GetQueueSize(); + }; + +- + #endif // WINDOW_EVENTS_H diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp new file mode 100644 -index 0000000..5a8bbb8 +index 0000000..ad58aad --- /dev/null +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -0,0 +1,765 @@ +@@ -0,0 +1,784 @@ +/* +* Copyright (C) 2005-2012 Team XBMC +* http://www.xbmc.org @@ -1014,7 +4182,7 @@ index 0000000..5a8bbb8 +#include "guilib/GUIWindowManager.h" +#include "input/MouseStat.h" + -+CWinEventsX11* CWinEventsX11::WinEvents = 0; ++CWinEventsX11Imp* CWinEventsX11Imp::WinEvents = 0; + +static uint32_t SymMappingsX11[][2] = +{ @@ -1126,8 +4294,17 @@ index 0000000..5a8bbb8 +, {XF86XK_AudioForward, XBMCK_FASTFORWARD} +}; + ++bool CWinEventsX11::MessagePump() ++{ ++ return CWinEventsX11Imp::MessagePump(); ++} + -+CWinEventsX11::CWinEventsX11() ++size_t CWinEventsX11::GetQueueSize() ++{ ++ return CWinEventsX11Imp::GetQueueSize(); ++} ++ ++CWinEventsX11Imp::CWinEventsX11Imp() +{ + m_display = 0; + m_window = 0; @@ -1135,7 +4312,7 @@ index 0000000..5a8bbb8 + m_utf16buf = 0; +} + -+CWinEventsX11::~CWinEventsX11() ++CWinEventsX11Imp::~CWinEventsX11Imp() +{ + if (m_keybuf); + { @@ -1165,12 +4342,12 @@ index 0000000..5a8bbb8 + m_symLookupTable.clear(); +} + -+bool CWinEventsX11::Init(Display *dpy, Window win) ++bool CWinEventsX11Imp::Init(Display *dpy, Window win) +{ + if (WinEvents) + return true; + -+ WinEvents = new CWinEventsX11(); ++ WinEvents = new CWinEventsX11Imp(); + WinEvents->m_display = dpy; + WinEvents->m_window = win; + WinEvents->m_keybuf = (char*)malloc(32*sizeof(char)); @@ -1244,7 +4421,7 @@ index 0000000..5a8bbb8 + return true; +} + -+void CWinEventsX11::Quit() ++void CWinEventsX11Imp::Quit() +{ + if (!WinEvents) + return; @@ -1253,7 +4430,7 @@ index 0000000..5a8bbb8 + WinEvents = 0; +} + -+bool CWinEventsX11::HasStructureChanged() ++bool CWinEventsX11Imp::HasStructureChanged() +{ + if (!WinEvents) + return false; @@ -1263,7 +4440,7 @@ index 0000000..5a8bbb8 + return ret; +} + -+bool CWinEventsX11::MessagePump() ++bool CWinEventsX11Imp::MessagePump() +{ + if (!WinEvents) + return false; @@ -1529,7 +4706,17 @@ index 0000000..5a8bbb8 + return ret; +} + -+bool CWinEventsX11::ProcessKey(XBMC_Event &event, int repeatDelay) ++size_t CWinEventsX11Imp::GetQueueSize() ++{ ++ int ret = 0; ++ ++ if (WinEvents) ++ ret = XPending(WinEvents->m_display); ++ ++ return ret; ++} ++ ++bool CWinEventsX11Imp::ProcessKey(XBMC_Event &event, int repeatDelay) +{ + if (event.type == XBMC_KEYDOWN) + { @@ -1615,7 +4802,7 @@ index 0000000..5a8bbb8 + return g_application.OnEvent(event); +} + -+bool CWinEventsX11::ProcessShortcuts(XBMC_Event& event) ++bool CWinEventsX11Imp::ProcessShortcuts(XBMC_Event& event) +{ + if (event.key.keysym.mod & XBMCKMOD_ALT) + { @@ -1632,7 +4819,7 @@ index 0000000..5a8bbb8 + return false; +} + -+bool CWinEventsX11::ProcessKeyRepeat() ++bool CWinEventsX11Imp::ProcessKeyRepeat() +{ + if (WinEvents && (WinEvents->m_lastKey.type == XBMC_KEYDOWN)) + { @@ -1644,7 +4831,7 @@ index 0000000..5a8bbb8 + return false; +} + -+int CWinEventsX11::Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength) ++int CWinEventsX11Imp::Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength) +{ + // p moves over the output buffer. max_ptr points to the next to the last slot of the buffer. + uint16_t *p = utf16; @@ -1725,7 +4912,7 @@ index 0000000..5a8bbb8 + return p - utf16; +} + -+XBMCKey CWinEventsX11::LookupXbmcKeySym(KeySym keysym) ++XBMCKey CWinEventsX11Imp::LookupXbmcKeySym(KeySym keysym) +{ + // try direct mapping first + std::map::iterator it; @@ -1744,10 +4931,10 @@ index 0000000..5a8bbb8 +#endif diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h new file mode 100644 -index 0000000..e9b7553 +index 0000000..ce57c23 --- /dev/null +++ b/xbmc/windowing/WinEventsX11.h -@@ -0,0 +1,57 @@ +@@ -0,0 +1,65 @@ +/* +* Copyright (C) 2005-2012 Team XBMC +* http://www.xbmc.org @@ -1775,15 +4962,23 @@ index 0000000..e9b7553 +#include "threads/SystemClock.h" +#include + -+class CWinEventsX11 : public CWinEventsBase ++class CWinEventsX11 : public IWinEvents +{ +public: -+ CWinEventsX11(); -+ virtual ~CWinEventsX11(); ++ virtual bool MessagePump(); ++ virtual size_t GetQueueSize(); ++}; ++ ++class CWinEventsX11Imp ++{ ++public: ++ CWinEventsX11Imp(); ++ virtual ~CWinEventsX11Imp(); + static bool Init(Display *dpy, Window win); + static void Quit(); + static bool HasStructureChanged(); + static bool MessagePump(); ++ static size_t GetQueueSize(); + +protected: + static int Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength); @@ -1791,7 +4986,7 @@ index 0000000..e9b7553 + static bool ProcessKey(XBMC_Event &event, int repeatDelay); + static bool ProcessKeyRepeat(); + static bool ProcessShortcuts(XBMC_Event& event); -+ static CWinEventsX11 *WinEvents; ++ static CWinEventsX11Imp *WinEvents; + Display *m_display; + Window m_window; + Atom m_wmDeleteMessage; @@ -1806,7 +5001,7 @@ index 0000000..e9b7553 + bool m_structureChanged; +}; diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 31f5304..265e05e 100644 +index 31f5304..7011980 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -22,7 +22,6 @@ @@ -1824,13 +5019,13 @@ index 31f5304..265e05e 100644 -#include #include "cores/VideoRenderers/RenderManager.h" #include "utils/TimeUtils.h" -+#include "settings/GUISettings.h" ++//#include "settings/GUISettings.h" #if defined(HAS_XRANDR) #include #endif -+#include "../WinEvents.h" ++#include "../WinEventsX11.h" +#include "input/MouseStat.h" + using namespace std; @@ -1926,7 +5121,7 @@ index 31f5304..265e05e 100644 + m_invisibleCursor = 0; + } + -+ CWinEvents::Quit(); ++ CWinEventsX11Imp::Quit(); + + XUnmapWindow(m_dpy, m_glWindow); + XSync(m_dpy,TRUE); @@ -2268,13 +5463,13 @@ index 31f5304..265e05e 100644 + XDefineCursor(m_dpy,m_glWindow, m_invisibleCursor); + + //init X11 events -+ CWinEvents::Init(m_dpy, m_glWindow); ++ CWinEventsX11Imp::Init(m_dpy, m_glWindow); + + changeWindow = true; + changeSize = true; + } + -+ if (!CWinEvents::HasStructureChanged() && ((width != m_nWidth) || (height != m_nHeight))) ++ if (!CWinEventsX11Imp::HasStructureChanged() && ((width != m_nWidth) || (height != m_nHeight))) + { + changeSize = true; + } @@ -2334,10 +5529,10 @@ index 31f5304..265e05e 100644 + #endif diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index b6b6ec4..448a1bb 100644 +index 3d438c8..3f204d7 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -52,6 +52,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -53,6 +53,7 @@ class CWinSystemX11 : public CWinSystemBase virtual bool EnableFrameLimiter(); virtual void NotifyAppActiveChange(bool bActivated); @@ -2345,7 +5540,7 @@ index b6b6ec4..448a1bb 100644 virtual bool Minimize(); virtual bool Restore() ; -@@ -64,19 +65,21 @@ class CWinSystemX11 : public CWinSystemBase +@@ -65,19 +66,21 @@ class CWinSystemX11 : public CWinSystemBase Display* GetDisplay() { return m_dpy; } GLXWindow GetWindow() { return m_glWindow; } GLXContext GetGlxContext() { return m_glContext; } @@ -2374,10 +5569,10 @@ index b6b6ec4..448a1bb 100644 1.8.4 -From dcca86983d2aeae7540bdd029aa64c92f6113165 Mon Sep 17 00:00:00 2001 +From e401ad8d3a70729076ef476a8eee4080ba8bbbf2 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 15:24:22 +0200 -Subject: [PATCH 09/89] X11: Add xbmc icon +Subject: [PATCH 22/87] X11: Add xbmc icon --- xbmc/windowing/X11/WinSystemX11.cpp | 126 +++++++++++++++++++++++++++++++++++- @@ -2385,7 +5580,7 @@ Subject: [PATCH 09/89] X11: Add xbmc icon 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 265e05e..f3ff34d 100644 +index 7011980..058a189 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -136,6 +136,9 @@ bool CWinSystemX11::DestroyWindow() @@ -2543,10 +5738,10 @@ index 265e05e..f3ff34d 100644 + #endif diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 448a1bb..e618268 100644 +index 3f204d7..3e99c3c 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -77,6 +77,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -78,6 +78,7 @@ class CWinSystemX11 : public CWinSystemBase GLXContext m_glContext; Display* m_dpy; Cursor m_invisibleCursor; @@ -2554,7 +5749,7 @@ index 448a1bb..e618268 100644 bool m_bWasFullScreenBeforeMinimize; bool m_minimized; bool m_bIgnoreNextFocusMessage; -@@ -88,6 +89,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -89,6 +90,7 @@ class CWinSystemX11 : public CWinSystemBase private: bool IsSuitableVisual(XVisualInfo *vInfo); static int XErrorHandler(Display* dpy, XErrorEvent* error); @@ -2566,17 +5761,17 @@ index 448a1bb..e618268 100644 1.8.4 -From 4cddafc5d371d7233b8d75f4bae6497a5a1bacf0 Mon Sep 17 00:00:00 2001 +From c9a3d6217740110079d881001521b81facb1885a Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 20 May 2012 14:11:26 +0200 -Subject: [PATCH 10/89] X11: add SDL joystick until we have a better solution +Subject: [PATCH 23/87] X11: add SDL joystick until we have a better solution --- xbmc/windowing/WinEventsX11.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 5a8bbb8..5bc1de0 100644 +index ad58aad..6f57a87 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -35,6 +35,10 @@ @@ -2587,10 +5782,10 @@ index 5a8bbb8..5bc1de0 100644 +#include "input/SDLJoystick.h" +#endif + - CWinEventsX11* CWinEventsX11::WinEvents = 0; + CWinEventsX11Imp* CWinEventsX11Imp::WinEvents = 0; static uint32_t SymMappingsX11[][2] = -@@ -547,6 +551,28 @@ bool CWinEventsX11::MessagePump() +@@ -556,6 +560,28 @@ bool CWinEventsX11Imp::MessagePump() ret |= ProcessKeyRepeat(); @@ -2623,10 +5818,10 @@ index 5a8bbb8..5bc1de0 100644 1.8.4 -From bc331fe276d47a54772ecb33fb12106f1b8eb9cf Mon Sep 17 00:00:00 2001 +From c7ac504a35600131a1a960d7bdb372234788082d Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 5 Jul 2012 12:35:55 +0200 -Subject: [PATCH 11/89] X11: factor out code handling device reset notification +Subject: [PATCH 24/87] X11: factor out code handling device reset notification --- xbmc/windowing/X11/WinSystemX11.cpp | 22 ++++++++++++++-------- @@ -2634,7 +5829,7 @@ Subject: [PATCH 11/89] X11: factor out code handling device reset notification 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index f3ff34d..c5938af 100644 +index 058a189..df0dc67 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -532,14 +532,7 @@ void CWinSystemX11::CheckDisplayEvents() @@ -2674,10 +5869,10 @@ index f3ff34d..c5938af 100644 { CLog::Log(LOGDEBUG, "%s - notify display change event", __FUNCTION__); diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index e618268..c4d4b76 100644 +index 3e99c3c..a07ab97 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -66,6 +66,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -67,6 +67,7 @@ class CWinSystemX11 : public CWinSystemBase GLXWindow GetWindow() { return m_glWindow; } GLXContext GetGlxContext() { return m_glContext; } void RefreshWindow(); @@ -2689,10 +5884,10 @@ index e618268..c4d4b76 100644 1.8.4 -From fb3ff63b1a0d7edf046ebd59ff691cbcb1c4516b Mon Sep 17 00:00:00 2001 +From 4a9fffdddb42877549500d8b0691ed55c8218b41 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 15:02:00 +0200 -Subject: [PATCH 12/89] X11: move xrandr events to WinEventsX11 +Subject: [PATCH 25/87] X11: move xrandr events to WinEventsX11 --- xbmc/windowing/WinEventsX11.cpp | 42 +++++++++++++++++++++++++++++++++++++ @@ -2701,7 +5896,7 @@ Subject: [PATCH 12/89] X11: move xrandr events to WinEventsX11 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 5bc1de0..d9dc911 100644 +index 6f57a87..d77cb2a 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -35,6 +35,10 @@ @@ -2715,7 +5910,7 @@ index 5bc1de0..d9dc911 100644 #ifdef HAS_SDL_JOYSTICK #include "input/SDLJoystick.h" #endif -@@ -203,6 +207,7 @@ bool CWinEventsX11::Init(Display *dpy, Window win) +@@ -212,6 +216,7 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) WinEvents->m_keymodState = 0; WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False); WinEvents->m_structureChanged = false; @@ -2723,7 +5918,7 @@ index 5bc1de0..d9dc911 100644 memset(&(WinEvents->m_lastKey), 0, sizeof(XBMC_Event)); // open input method -@@ -266,6 +271,13 @@ bool CWinEventsX11::Init(Display *dpy, Window win) +@@ -275,6 +280,13 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) WinEvents->m_symLookupTable[SymMappingsX11[i][0]] = SymMappingsX11[i][1]; } @@ -2737,11 +5932,11 @@ index 5bc1de0..d9dc911 100644 return true; } -@@ -288,6 +300,15 @@ bool CWinEventsX11::HasStructureChanged() +@@ -297,6 +309,15 @@ bool CWinEventsX11Imp::HasStructureChanged() return ret; } -+void CWinEventsX11::SetXRRFailSafeTimer(int millis) ++void CWinEventsX11Imp::SetXRRFailSafeTimer(int millis) +{ + if (!WinEvents) + return; @@ -2750,10 +5945,10 @@ index 5bc1de0..d9dc911 100644 + WinEvents->m_xrrEventPending = true; +} + - bool CWinEventsX11::MessagePump() + bool CWinEventsX11Imp::MessagePump() { if (!WinEvents) -@@ -547,10 +568,31 @@ bool CWinEventsX11::MessagePump() +@@ -556,10 +577,31 @@ bool CWinEventsX11Imp::MessagePump() break; } }// switch event.type @@ -2786,19 +5981,19 @@ index 5bc1de0..d9dc911 100644 SDL_Event event; while (SDL_PollEvent(&event)) diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h -index e9b7553..6100933 100644 +index ce57c23..a412f32 100644 --- a/xbmc/windowing/WinEventsX11.h +++ b/xbmc/windowing/WinEventsX11.h -@@ -33,6 +33,8 @@ class CWinEventsX11 : public CWinEventsBase +@@ -40,6 +40,8 @@ class CWinEventsX11Imp static bool Init(Display *dpy, Window win); static void Quit(); static bool HasStructureChanged(); + static void PendingResize(int width, int height); + static void SetXRRFailSafeTimer(int millis); static bool MessagePump(); + static size_t GetQueueSize(); - protected: -@@ -54,4 +56,7 @@ class CWinEventsX11 : public CWinEventsBase +@@ -62,4 +64,7 @@ class CWinEventsX11Imp std::map m_symLookupTable; int m_keymodState; bool m_structureChanged; @@ -2807,7 +6002,7 @@ index e9b7553..6100933 100644 + bool m_xrrEventPending; }; diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index c5938af..9f74dd5 100644 +index df0dc67..5d88b9a 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -509,7 +509,7 @@ bool CWinSystemX11::Show(bool raise) @@ -2827,7 +6022,7 @@ index c5938af..9f74dd5 100644 // fail safe timer m_dpyLostTime = CurrentHostCounter(); +#else -+ CWinEvents::SetXRRFailSafeTimer(3000); ++ CWinEventsX11Imp::SetXRRFailSafeTimer(3000); +#endif } @@ -2836,10 +6031,10 @@ index c5938af..9f74dd5 100644 1.8.4 -From 4163dafc3065d1bafb0ad39d89577e6b1feef044 Mon Sep 17 00:00:00 2001 +From c2281e1a68abcaf9c59839421449a0649aa2bc24 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 12 Apr 2012 15:43:56 +0200 -Subject: [PATCH 13/89] xrandr: remove method RestoreState +Subject: [PATCH 26/87] xrandr: remove method RestoreState --- xbmc/windowing/X11/WinSystemX11.cpp | 13 +++++++++++-- @@ -2848,7 +6043,7 @@ Subject: [PATCH 13/89] xrandr: remove method RestoreState 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 9f74dd5..05a1d60 100644 +index 5d88b9a..0f37763 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -79,9 +79,18 @@ bool CWinSystemX11::InitWindowSystem() @@ -2918,10 +6113,10 @@ index 0aec487..00b49dc 100644 1.8.4 -From 8be862507bba37afe6f65564afb01e270da51c37 Mon Sep 17 00:00:00 2001 +From 00f02a5318e55c7b156c5329fab70b63757a8c15 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 20 May 2012 13:17:10 +0200 -Subject: [PATCH 14/89] xrandr: observe orientation +Subject: [PATCH 27/87] xrandr: observe orientation --- xbmc/windowing/X11/WinSystemX11.cpp | 89 ++++++++++++++++++++++++++++++------- @@ -2931,7 +6126,7 @@ Subject: [PATCH 14/89] xrandr: observe orientation 4 files changed, 82 insertions(+), 17 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 05a1d60..c5ccbc4 100644 +index 0f37763..4bec03d 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -84,11 +84,11 @@ bool CWinSystemX11::DestroyWindowSystem() @@ -3084,10 +6279,10 @@ index 05a1d60..c5ccbc4 100644 { int value; diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index c4d4b76..0727bb9 100644 +index a07ab97..d5ce9a2e 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -73,12 +73,14 @@ class CWinSystemX11 : public CWinSystemBase +@@ -74,12 +74,14 @@ class CWinSystemX11 : public CWinSystemBase void CheckDisplayEvents(); void OnLostDevice(); bool SetWindow(int width, int height, bool fullscreen); @@ -3136,10 +6331,10 @@ index 00b49dc..508604d 100644 1.8.4 -From a42ed82f08ef5f0242b72752d213cd7c0e540d3f Mon Sep 17 00:00:00 2001 +From 2f1c5cff27869d47db33f6d5be4e07a64ccd928f Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 11:54:15 +0200 -Subject: [PATCH 15/89] xrandr: allow getting info for multiple screen's +Subject: [PATCH 28/87] xrandr: allow getting info for multiple screen's Refactored by: Joakim Plate --- @@ -3314,10 +6509,10 @@ index 508604d..d37838a 100644 1.8.4 -From 42a408e9056343cfb1f5ae6192068e126c239706 Mon Sep 17 00:00:00 2001 +From 920a5ddeaf2b7720028f7d7027e7ab70880bfc26 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 11:44:00 +0200 -Subject: [PATCH 16/89] X11: fix multi-head setups +Subject: [PATCH 29/87] X11: fix multi-head setups --- language/English/strings.po | 4 +- @@ -3332,7 +6527,7 @@ Subject: [PATCH 16/89] X11: fix multi-head setups 9 files changed, 229 insertions(+), 116 deletions(-) diff --git a/language/English/strings.po b/language/English/strings.po -index b59f647..2f223fc 100755 +index 24c4085..c8734c1 100755 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -1003,7 +1003,9 @@ msgctxt "#245" @@ -3347,7 +6542,7 @@ index b59f647..2f223fc 100755 msgctxt "#247" msgid "Scripts" diff --git a/system/settings/settings.xml b/system/settings/settings.xml -index a22138c..47e8145 100644 +index 64d6e63..9312642 100644 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -1844,6 +1844,15 @@ @@ -3501,10 +6696,10 @@ index cc4002b..d80f1dc 100644 protected: CDisplaySettings(); diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp -index be6990d..7bd8607 100644 +index da10a5d..98c0acc 100644 --- a/xbmc/settings/Settings.cpp +++ b/xbmc/settings/Settings.cpp -@@ -384,6 +384,7 @@ void CSettings::Uninitialize() +@@ -387,6 +387,7 @@ void CSettings::Uninitialize() m_settingsManager->UnregisterSettingOptionsFiller("screens"); m_settingsManager->UnregisterSettingOptionsFiller("stereoscopicmodes"); m_settingsManager->UnregisterSettingOptionsFiller("preferedstereoscopicviewmodes"); @@ -3512,7 +6707,7 @@ index be6990d..7bd8607 100644 m_settingsManager->UnregisterSettingOptionsFiller("shutdownstates"); m_settingsManager->UnregisterSettingOptionsFiller("startupwindows"); m_settingsManager->UnregisterSettingOptionsFiller("streamlanguages"); -@@ -694,6 +695,7 @@ void CSettings::InitializeOptionFillers() +@@ -697,6 +698,7 @@ void CSettings::InitializeOptionFillers() m_settingsManager->RegisterSettingOptionsFiller("screens", CDisplaySettings::SettingOptionsScreensFiller); m_settingsManager->RegisterSettingOptionsFiller("stereoscopicmodes", CDisplaySettings::SettingOptionsStereoscopicModesFiller); m_settingsManager->RegisterSettingOptionsFiller("preferedstereoscopicviewmodes", CDisplaySettings::SettingOptionsPreferredStereoscopicViewModesFiller); @@ -3520,7 +6715,7 @@ index be6990d..7bd8607 100644 m_settingsManager->RegisterSettingOptionsFiller("shutdownstates", CPowerManager::SettingOptionsShutdownStatesFiller); m_settingsManager->RegisterSettingOptionsFiller("startupwindows", ADDON::CSkinInfo::SettingOptionsStartupWindowsFiller); m_settingsManager->RegisterSettingOptionsFiller("streamlanguages", CLangInfo::SettingOptionsStreamLanguagesFiller); -@@ -721,6 +723,9 @@ void CSettings::InitializeConditions() +@@ -724,6 +726,9 @@ void CSettings::InitializeConditions() #ifdef HAS_GL m_settingsManager->AddCondition("has_gl"); #endif @@ -3530,7 +6725,7 @@ index be6990d..7bd8607 100644 #ifdef HAS_GLES m_settingsManager->AddCondition("has_gles"); #endif -@@ -866,6 +871,7 @@ void CSettings::InitializeISettingCallbacks() +@@ -873,6 +878,7 @@ void CSettings::InitializeISettingCallbacks() settingSet.insert("videoscreen.screen"); settingSet.insert("videoscreen.resolution"); settingSet.insert("videoscreen.screenmode"); @@ -3539,10 +6734,10 @@ index be6990d..7bd8607 100644 settingSet.clear(); diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index d9dc911..c58067b 100644 +index d77cb2a..d98f12f 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -517,9 +517,16 @@ bool CWinEventsX11::MessagePump() +@@ -526,9 +526,16 @@ bool CWinEventsX11Imp::MessagePump() break; } @@ -3560,14 +6755,14 @@ index d9dc911..c58067b 100644 break; } diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index c5ccbc4..d9654b9 100644 +index 4bec03d..1abbab0 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -34,7 +34,8 @@ #include "threads/SingleLock.h" #include "cores/VideoRenderers/RenderManager.h" #include "utils/TimeUtils.h" --#include "settings/GUISettings.h" +-//#include "settings/GUISettings.h" +#include "settings/Settings.h" +#include "windowing/WindowingFactory.h" @@ -4049,10 +7244,10 @@ index c5ccbc4..d9654b9 100644 return true; } diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 0727bb9..b1eb278 100644 +index d5ce9a2e..8310546 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -65,15 +65,16 @@ class CWinSystemX11 : public CWinSystemBase +@@ -66,15 +66,16 @@ class CWinSystemX11 : public CWinSystemBase Display* GetDisplay() { return m_dpy; } GLXWindow GetWindow() { return m_glWindow; } GLXContext GetGlxContext() { return m_glContext; } @@ -4072,7 +7267,7 @@ index 0727bb9..b1eb278 100644 Window m_glWindow; GLXContext m_glContext; -@@ -88,6 +89,9 @@ class CWinSystemX11 : public CWinSystemBase +@@ -89,6 +90,9 @@ class CWinSystemX11 : public CWinSystemBase CCriticalSection m_resourceSection; std::vector m_resources; uint64_t m_dpyLostTime; @@ -4086,10 +7281,10 @@ index 0727bb9..b1eb278 100644 1.8.4 -From 4f084ec3acbc23b81b78f68de1b986105b1260df Mon Sep 17 00:00:00 2001 +From 72e7e9b77fb3e3d8f0e5330d14e1fc8388f0e3b0 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 11:36:32 +0200 -Subject: [PATCH 17/89] X11: remove all DefaultScreen and RootWindow macros +Subject: [PATCH 30/87] X11: remove all DefaultScreen and RootWindow macros --- xbmc/windowing/X11/WinSystemX11.cpp | 6 +++--- @@ -4098,7 +7293,7 @@ Subject: [PATCH 17/89] X11: remove all DefaultScreen and RootWindow macros 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index d9654b9..e2580a4 100644 +index 1abbab0..00af550 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -269,7 +269,7 @@ void CWinSystemX11::UpdateResolutions() @@ -4129,10 +7324,10 @@ index d9654b9..e2580a4 100644 m_minimized = true; return true; diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index b1eb278..b9154ab 100644 +index 8310546..474466e 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -47,6 +47,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -48,6 +48,7 @@ class CWinSystemX11 : public CWinSystemBase virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays); virtual void UpdateResolutions(); virtual int GetNumScreens() { return 1; } @@ -4157,10 +7352,10 @@ index 81c6800..8a8ff83 100644 1.8.4 -From da5eae0383a9caf497d8f4290a7cd4ef006c468a Mon Sep 17 00:00:00 2001 +From 46beacaa20f769a6561f5e26cfd9c068d92f203a Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 11:45:22 +0200 -Subject: [PATCH 18/89] X11: remove all DefaultScreen and RootWindow macros +Subject: [PATCH 31/87] X11: remove all DefaultScreen and RootWindow macros (VideoRefClock) Note this is on a separate display connection. @@ -4232,10 +7427,10 @@ index 3ba991a..7eecd40 100644 1.8.4 -From a89921f7de0fc027d368d0d30f83da28aaa97895 Mon Sep 17 00:00:00 2001 +From a34171aa74eb6cf1e852eb7d2724a53e9e2c3339 Mon Sep 17 00:00:00 2001 From: xbmc Date: Wed, 20 Jun 2012 17:37:11 +0200 -Subject: [PATCH 19/89] X11: recreate gl context after output has changed +Subject: [PATCH 32/87] X11: recreate gl context after output has changed --- xbmc/windowing/X11/WinSystemX11.cpp | 24 ++++++++++++++---------- @@ -4244,7 +7439,7 @@ Subject: [PATCH 19/89] X11: recreate gl context after output has changed 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index e2580a4..dce0433 100644 +index 00af550..6b64c1c 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -170,7 +170,6 @@ bool CWinSystemX11::ResizeWindow(int newWidth, int newHeight, int newLeft, int n @@ -4333,10 +7528,10 @@ index e2580a4..dce0433 100644 } diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index b9154ab..05aa60e 100644 +index 474466e..1ff3724 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -93,6 +93,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -94,6 +94,7 @@ class CWinSystemX11 : public CWinSystemBase CStdString m_currentOutput; bool m_windowDirty; bool m_bIsInternalXrr; @@ -4386,10 +7581,10 @@ index 8a8ff83..8707467 100644 1.8.4 -From aebb65bf97c6ebffb0598c62208046cdc7b46bf1 Mon Sep 17 00:00:00 2001 +From bfa905cb6eec58a4736940ccb214282915ff936b Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 12:06:25 +0200 -Subject: [PATCH 20/89] X11: hook video reference clock in windowing +Subject: [PATCH 33/87] X11: hook video reference clock in windowing --- xbmc/video/VideoReferenceClock.cpp | 71 +++++++++++++++++++++++++++----------- @@ -4594,10 +7789,10 @@ index dd65a1b..afd71fc 100644 1.8.4 -From b962ef14c56706ba7260d99c272d68055108d6b6 Mon Sep 17 00:00:00 2001 +From 2a02d24a30c3f84280cdd170b36f361226627c42 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 21 Jun 2012 17:26:51 +0200 -Subject: [PATCH 21/89] X11: fix video calibrations +Subject: [PATCH 34/87] X11: fix video calibrations --- xbmc/windowing/WinSystem.h | 1 + @@ -4618,7 +7813,7 @@ index 00a2d24..c0db210 100644 // text input interface virtual void EnableTextInput(bool bEnable) {} diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index dce0433..e7f4f61 100644 +index 6b64c1c..255a5d4 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -318,7 +318,7 @@ void CWinSystemX11::UpdateResolutions() @@ -4674,10 +7869,10 @@ index dce0433..e7f4f61 100644 void CWinSystemX11::GetConnectedOutputs(std::vector *outputs) diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 05aa60e..95672d1 100644 +index 1ff3724..2fc3f57 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -61,6 +61,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -62,6 +62,7 @@ class CWinSystemX11 : public CWinSystemBase virtual bool Show(bool raise = true); virtual void Register(IDispResource *resource); virtual void Unregister(IDispResource *resource); @@ -4689,10 +7884,10 @@ index 05aa60e..95672d1 100644 1.8.4 -From a21b398748b4f7e5d021eac59258b66637dee9d6 Mon Sep 17 00:00:00 2001 +From cbada69a9fc7e0b61f8ee801eacbf55b4039d15b Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 12:00:26 +0200 -Subject: [PATCH 22/89] X11: deactivate screen saver on startup +Subject: [PATCH 35/87] X11: deactivate screen saver on startup --- xbmc/windowing/X11/WinSystemX11.cpp | 29 +++++++++++++++++++++++++++++ @@ -4700,7 +7895,7 @@ Subject: [PATCH 22/89] X11: deactivate screen saver on startup 2 files changed, 30 insertions(+) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index e7f4f61..14a4307 100644 +index 255a5d4..3084980 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -519,6 +519,33 @@ void CWinSystemX11::ResetOSScreensaver() @@ -4747,10 +7942,10 @@ index e7f4f61..14a4307 100644 { GLX_RGBA, diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 95672d1..51ac314 100644 +index 2fc3f57..e7e1781 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -51,6 +51,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -52,6 +52,7 @@ class CWinSystemX11 : public CWinSystemBase virtual void ShowOSMouse(bool show); virtual void ResetOSScreensaver(); virtual bool EnableFrameLimiter(); @@ -4762,17 +7957,17 @@ index 95672d1..51ac314 100644 1.8.4 -From 17c841eb920621a5580b2b4cde8ccef51eca8fdd Mon Sep 17 00:00:00 2001 +From bb83108383be0cfcf1e7872f22a247b8150945e1 Mon Sep 17 00:00:00 2001 From: FernetMenta Date: Thu, 5 Jul 2012 12:10:09 +0200 -Subject: [PATCH 23/89] X11: change method of going full-screen +Subject: [PATCH 36/87] X11: change method of going full-screen --- xbmc/windowing/X11/WinSystemX11.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 14a4307..66b91fd 100644 +index 3084980..daabde3 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -36,6 +36,7 @@ @@ -4809,10 +8004,10 @@ index 14a4307..66b91fd 100644 1.8.4 -From 938e122d50138ace8abb4234b7dc09b407190ab3 Mon Sep 17 00:00:00 2001 +From 0cc2b9edeb202eb4c8936fed6a24eb28098bfc61 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 28 Jun 2012 19:12:39 +0200 -Subject: [PATCH 24/89] X11: reset key repeat and key modifier on focus lost +Subject: [PATCH 37/87] X11: reset key repeat and key modifier on focus lost and gain --- @@ -4820,10 +8015,10 @@ Subject: [PATCH 24/89] X11: reset key repeat and key modifier on focus lost 1 file changed, 3 insertions(+) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index c58067b..c9f8a20 100644 +index d98f12f..743aca9 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -359,6 +359,8 @@ bool CWinEventsX11::MessagePump() +@@ -368,6 +368,8 @@ bool CWinEventsX11Imp::MessagePump() if (WinEvents->m_xic) XSetICFocus(WinEvents->m_xic); g_application.m_AppFocused = true; @@ -4832,7 +8027,7 @@ index c58067b..c9f8a20 100644 if (serial == xevent.xfocus.serial) break; g_Windowing.NotifyAppFocusChange(g_application.m_AppFocused); -@@ -370,6 +372,7 @@ bool CWinEventsX11::MessagePump() +@@ -379,6 +381,7 @@ bool CWinEventsX11Imp::MessagePump() if (WinEvents->m_xic) XUnsetICFocus(WinEvents->m_xic); g_application.m_AppFocused = false; @@ -4844,10 +8039,10 @@ index c58067b..c9f8a20 100644 1.8.4 -From fa7000dcdf9e80bf698f4724a2376bcb0194a2bc Mon Sep 17 00:00:00 2001 +From e8a9989e8d0453bd929dacb0d8f3b42474e54e31 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 5 Jul 2012 14:18:46 +0200 -Subject: [PATCH 25/89] X11: replace custom utf8 to unicode with charset +Subject: [PATCH 38/87] X11: replace custom utf8 to unicode with charset convertor (squash to x11 events) --- @@ -4856,7 +8051,7 @@ Subject: [PATCH 25/89] X11: replace custom utf8 to unicode with charset 2 files changed, 11 insertions(+), 110 deletions(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index c9f8a20..1a81d05 100644 +index 743aca9..6b98e67 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -32,6 +32,7 @@ @@ -4867,15 +8062,15 @@ index c9f8a20..1a81d05 100644 #include "guilib/GUIWindowManager.h" #include "input/MouseStat.h" -@@ -161,7 +162,6 @@ +@@ -170,7 +171,6 @@ size_t CWinEventsX11::GetQueueSize() m_display = 0; m_window = 0; m_keybuf = 0; - m_utf16buf = 0; } - CWinEventsX11::~CWinEventsX11() -@@ -172,12 +172,6 @@ + CWinEventsX11Imp::~CWinEventsX11Imp() +@@ -181,12 +181,6 @@ size_t CWinEventsX11::GetQueueSize() m_keybuf = 0; } @@ -4888,7 +8083,7 @@ index c9f8a20..1a81d05 100644 if (m_xic) { XUnsetICFocus(m_xic); -@@ -203,7 +197,6 @@ bool CWinEventsX11::Init(Display *dpy, Window win) +@@ -212,7 +206,6 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) WinEvents->m_display = dpy; WinEvents->m_window = win; WinEvents->m_keybuf = (char*)malloc(32*sizeof(char)); @@ -4896,7 +8091,7 @@ index c9f8a20..1a81d05 100644 WinEvents->m_keymodState = 0; WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False); WinEvents->m_structureChanged = false; -@@ -433,8 +426,6 @@ bool CWinEventsX11::MessagePump() +@@ -442,8 +435,6 @@ bool CWinEventsX11Imp::MessagePump() } Status status; @@ -4905,7 +8100,7 @@ index c9f8a20..1a81d05 100644 int len; len = Xutf8LookupString(WinEvents->m_xic, &xevent.xkey, WinEvents->m_keybuf, sizeof(WinEvents->m_keybuf), -@@ -453,36 +444,29 @@ bool CWinEventsX11::MessagePump() +@@ -462,36 +453,29 @@ bool CWinEventsX11Imp::MessagePump() case XLookupChars: case XLookupBoth: { @@ -4952,11 +8147,11 @@ index c9f8a20..1a81d05 100644 newEvent.key.state = xevent.xkey.state; newEvent.key.type = xevent.xkey.type; -@@ -743,87 +727,6 @@ bool CWinEventsX11::ProcessKeyRepeat() +@@ -762,87 +746,6 @@ bool CWinEventsX11Imp::ProcessKeyRepeat() return false; } --int CWinEventsX11::Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength) +-int CWinEventsX11Imp::Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength) -{ - // p moves over the output buffer. max_ptr points to the next to the last slot of the buffer. - uint16_t *p = utf16; @@ -5037,22 +8232,22 @@ index c9f8a20..1a81d05 100644 - return p - utf16; -} - - XBMCKey CWinEventsX11::LookupXbmcKeySym(KeySym keysym) + XBMCKey CWinEventsX11Imp::LookupXbmcKeySym(KeySym keysym) { // try direct mapping first diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h -index 6100933..72955ad 100644 +index a412f32..9a8a912 100644 --- a/xbmc/windowing/WinEventsX11.h +++ b/xbmc/windowing/WinEventsX11.h -@@ -38,7 +38,6 @@ class CWinEventsX11 : public CWinEventsBase - static bool MessagePump(); +@@ -46,7 +46,6 @@ class CWinEventsX11Imp + static size_t GetQueueSize(); protected: - static int Utf8ToUnicode(const char *utf8, const int utf8Length, uint16_t *utf16, const int utf16MaxLength); static XBMCKey LookupXbmcKeySym(KeySym keysym); static bool ProcessKey(XBMC_Event &event, int repeatDelay); static bool ProcessKeyRepeat(); -@@ -48,7 +47,6 @@ class CWinEventsX11 : public CWinEventsBase +@@ -56,7 +55,6 @@ class CWinEventsX11Imp Window m_window; Atom m_wmDeleteMessage; char *m_keybuf; @@ -5064,10 +8259,10 @@ index 6100933..72955ad 100644 1.8.4 -From e25f6b853d78375b88d6a111c78ce5ffab87b89b Mon Sep 17 00:00:00 2001 +From 7f49f62bddc9b29c35d06711d8976b0f92a98be2 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 5 Jul 2012 14:23:54 +0200 -Subject: [PATCH 26/89] X11: fixed invalid usage of sizeof() (squash into x11 +Subject: [PATCH 39/87] X11: fixed invalid usage of sizeof() (squash into x11 changes) --- @@ -5076,19 +8271,19 @@ Subject: [PATCH 26/89] X11: fixed invalid usage of sizeof() (squash into x11 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 1a81d05..4a5aab4 100644 +index 6b98e67..a62521f 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -162,6 +162,7 @@ +@@ -171,6 +171,7 @@ size_t CWinEventsX11::GetQueueSize() m_display = 0; m_window = 0; m_keybuf = 0; + m_keybuf_len = 0; } - CWinEventsX11::~CWinEventsX11() -@@ -196,7 +197,8 @@ bool CWinEventsX11::Init(Display *dpy, Window win) - WinEvents = new CWinEventsX11(); + CWinEventsX11Imp::~CWinEventsX11Imp() +@@ -205,7 +206,8 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) + WinEvents = new CWinEventsX11Imp(); WinEvents->m_display = dpy; WinEvents->m_window = win; - WinEvents->m_keybuf = (char*)malloc(32*sizeof(char)); @@ -5097,7 +8292,7 @@ index 1a81d05..4a5aab4 100644 WinEvents->m_keymodState = 0; WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False); WinEvents->m_structureChanged = false; -@@ -428,13 +430,14 @@ bool CWinEventsX11::MessagePump() +@@ -437,13 +439,14 @@ bool CWinEventsX11Imp::MessagePump() Status status; int len; len = Xutf8LookupString(WinEvents->m_xic, &xevent.xkey, @@ -5116,10 +8311,10 @@ index 1a81d05..4a5aab4 100644 } switch (status) diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h -index 72955ad..102a076 100644 +index 9a8a912..c69169c 100644 --- a/xbmc/windowing/WinEventsX11.h +++ b/xbmc/windowing/WinEventsX11.h -@@ -47,6 +47,7 @@ class CWinEventsX11 : public CWinEventsBase +@@ -55,6 +55,7 @@ class CWinEventsX11Imp Window m_window; Atom m_wmDeleteMessage; char *m_keybuf; @@ -5131,10 +8326,10 @@ index 72955ad..102a076 100644 1.8.4 -From 6bf1cf919924114f4041b59ec55c93588b1e703f Mon Sep 17 00:00:00 2001 +From 163e1aee533c3b55898318107c61492e7141c081 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sat, 9 Jun 2012 18:23:53 +0200 -Subject: [PATCH 27/89] add missing keys to xbmc keytable +Subject: [PATCH 40/87] add missing keys to xbmc keytable --- xbmc/input/XBMC_keytable.cpp | 2 ++ @@ -5157,10 +8352,10 @@ index b430f55..246164b 100644 1.8.4 -From 5f554cecdd4c8363d3ea6d2c3508b2bfbeed6a17 Mon Sep 17 00:00:00 2001 +From 717f97cfc316cd6d772992147c4f2aa4671e6b9d Mon Sep 17 00:00:00 2001 From: xbmc Date: Fri, 16 Mar 2012 15:57:51 +0100 -Subject: [PATCH 28/89] videorefclock: temp deactivate of nv settings +Subject: [PATCH 41/87] videorefclock: temp deactivate of nv settings --- xbmc/video/VideoReferenceClock.cpp | 2 +- @@ -5183,10 +8378,10 @@ index 4071ff0..b9afc09 100644 1.8.4 -From 8429ae732a504112380e2b14765efcdf4e915064 Mon Sep 17 00:00:00 2001 +From 7cf6a5ae57eb980ead6b9e20b14a9a222288f75d Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 20 Aug 2012 09:09:09 +0200 -Subject: [PATCH 29/89] videorefclock: ask graphics context for refresh rate +Subject: [PATCH 42/87] videorefclock: ask graphics context for refresh rate --- xbmc/video/VideoReferenceClock.cpp | 3 ++- @@ -5217,10 +8412,10 @@ index b9afc09..2f6c7de 100644 1.8.4 -From 760bb61f7607998ab4d65ed02da153186c82ab59 Mon Sep 17 00:00:00 2001 +From 1df73e08c3c803fdd46f89193f989f9f6eb9ff58 Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 9 Jul 2012 14:00:18 +0200 -Subject: [PATCH 30/89] X11: fix icon texture after +Subject: [PATCH 43/87] X11: fix icon texture after cc5ed3c2474084ebc0373a3046410e6f766e03f4 --- @@ -5228,7 +8423,7 @@ Subject: [PATCH 30/89] X11: fix icon texture after 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 66b91fd..b00eddc 100644 +index daabde3..516dc69 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -872,22 +872,24 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const CStd @@ -5328,10 +8523,10 @@ index 66b91fd..b00eddc 100644 1.8.4 -From 2a8e7de3c0df03c17077d2e3967ec34dfa3f18c0 Mon Sep 17 00:00:00 2001 +From 0bb219f2cb7bf99a68a272009b1d612281770f54 Mon Sep 17 00:00:00 2001 From: xbmc Date: Tue, 10 Jul 2012 11:14:12 +0200 -Subject: [PATCH 31/89] X11: check for window manager +Subject: [PATCH 44/87] X11: check for window manager --- xbmc/windowing/X11/WinSystemX11.cpp | 74 ++++++++++++++++++++++++++++++++++++- @@ -5339,7 +8534,7 @@ Subject: [PATCH 31/89] X11: check for window manager 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index b00eddc..05279ad 100644 +index 516dc69..e8b73b5 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -814,8 +814,10 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const CStd @@ -5437,10 +8632,10 @@ index b00eddc..05279ad 100644 + #endif diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 51ac314..ce3c289 100644 +index e7e1781..4175556 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -101,6 +101,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -102,6 +102,7 @@ class CWinSystemX11 : public CWinSystemBase bool IsSuitableVisual(XVisualInfo *vInfo); static int XErrorHandler(Display* dpy, XErrorEvent* error); bool CreateIconPixmap(); @@ -5452,17 +8647,17 @@ index 51ac314..ce3c289 100644 1.8.4 -From b4c3338d0c185e4a94661a0a397d562044f6b467 Mon Sep 17 00:00:00 2001 +From 4008a404a8e71d672be86282c0219c0f6e873402 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 12 Jul 2012 11:11:47 +0200 -Subject: [PATCH 32/89] X11: dont set window on xrandr if no mode available +Subject: [PATCH 45/87] X11: dont set window on xrandr if no mode available --- xbmc/windowing/X11/WinSystemX11.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 05279ad..9697cbb 100644 +index e8b73b5..dee08e0 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -663,16 +663,17 @@ void CWinSystemX11::NotifyXRREvent() @@ -5492,17 +8687,17 @@ index 05279ad..9697cbb 100644 1.8.4 -From a990744c3ec9b4273c3d7140b8f1c42e243dc5dc Mon Sep 17 00:00:00 2001 +From 9b797e3fc5cb302e0605bbb38e587ae6f89bda8f Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 26 Jul 2012 09:34:28 +0200 -Subject: [PATCH 33/89] X11: fix crash after a resolution change on startup +Subject: [PATCH 46/87] X11: fix crash after a resolution change on startup --- xbmc/windowing/X11/WinSystemX11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 9697cbb..868071c 100644 +index dee08e0..edfd370 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -221,7 +221,8 @@ bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bl @@ -5519,17 +8714,17 @@ index 9697cbb..868071c 100644 1.8.4 -From e366cc308192a9e229e5c6072d1cd1018f3ed176 Mon Sep 17 00:00:00 2001 +From 3266649022e6224fa956079374a8ce7c4ac7fe04 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sat, 15 Sep 2012 18:27:29 +0200 -Subject: [PATCH 34/89] X11: lock graphics context in NotifyXRREvent +Subject: [PATCH 47/87] X11: lock graphics context in NotifyXRREvent --- xbmc/windowing/X11/WinSystemX11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 868071c..9ff947c 100644 +index edfd370..974ce96 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -664,6 +664,8 @@ void CWinSystemX11::NotifyXRREvent() @@ -5545,4464 +8740,10 @@ index 868071c..9ff947c 100644 1.8.4 -From 84207ba51bafff6671d3d97e41407cb0fcbc7a54 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Sat, 8 Oct 2011 16:45:13 +0200 -Subject: [PATCH 35/89] ffmpeg: add xvba hwaccel, co-author fritsch - ---- - lib/ffmpeg/configure | 11 ++ - lib/ffmpeg/libavcodec/Makefile | 6 ++ - lib/ffmpeg/libavcodec/allcodecs.c | 4 + - lib/ffmpeg/libavcodec/h263dec.c | 3 + - lib/ffmpeg/libavcodec/h264.c | 6 ++ - lib/ffmpeg/libavcodec/vc1dec.c | 3 + - lib/ffmpeg/libavcodec/xvba.c | 77 ++++++++++++++ - lib/ffmpeg/libavcodec/xvba.h | 72 +++++++++++++ - lib/ffmpeg/libavcodec/xvba_h264.c | 194 ++++++++++++++++++++++++++++++++++ - lib/ffmpeg/libavcodec/xvba_internal.h | 25 +++++ - lib/ffmpeg/libavcodec/xvba_mpeg2.c | 52 +++++++++ - lib/ffmpeg/libavcodec/xvba_vc1.c | 193 +++++++++++++++++++++++++++++++++ - lib/ffmpeg/libavutil/pixdesc.c | 6 ++ - lib/ffmpeg/libavutil/pixfmt.h | 1 + - 14 files changed, 653 insertions(+) - create mode 100644 lib/ffmpeg/libavcodec/xvba.c - create mode 100644 lib/ffmpeg/libavcodec/xvba.h - create mode 100644 lib/ffmpeg/libavcodec/xvba_h264.c - create mode 100644 lib/ffmpeg/libavcodec/xvba_internal.h - create mode 100644 lib/ffmpeg/libavcodec/xvba_mpeg2.c - create mode 100644 lib/ffmpeg/libavcodec/xvba_vc1.c - -diff --git a/lib/ffmpeg/configure b/lib/ffmpeg/configure -index 351611d..876a6ea 100755 ---- a/lib/ffmpeg/configure -+++ b/lib/ffmpeg/configure -@@ -144,6 +144,7 @@ Hardware accelerators: - --enable-vaapi enable VAAPI code - --enable-vda enable VDA code - --enable-vdpau enable VDPAU code -+ --disable-xvba disable XVBA code - - Individual component options: - --disable-everything disable all components listed below -@@ -1197,6 +1198,7 @@ HWACCEL_LIST=" - vaapi - vda - vdpau -+ xvba - " - - LIBRARY_LIST=" -@@ -1827,6 +1829,7 @@ crystalhd_deps="libcrystalhd_libcrystalhd_if_h" - dxva2_deps="dxva2api_h" - vaapi_deps="va_va_h" - vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads" -+xvba_deps="amd_amdxvba_h" - vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore" - vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h" - -@@ -1847,6 +1850,8 @@ h264_vdpau_decoder_deps="vdpau" - h264_vdpau_decoder_select="h264_decoder" - h264_vdpau_hwaccel_deps="vdpau" - h264_vdpau_hwaccel_select="h264_decoder" -+h264_xvba_hwaccel_select="h264_decoder" -+h264_xvba_hwaccel_deps="xvba" - mpeg_vdpau_decoder_deps="vdpau" - mpeg_vdpau_decoder_select="mpegvideo_decoder" - mpeg1_vdpau_decoder_deps="vdpau" -@@ -1859,6 +1864,8 @@ mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" - mpeg2_vaapi_hwaccel_deps="vaapi" - mpeg2_vaapi_hwaccel_select="mpeg2video_decoder" - mpeg2_vdpau_hwaccel_deps="vdpau" -+mpeg2_xvba_hwaccel_select="mpeg2video_decoder" -+mpeg2_xvba_hwaccel_deps="xvba" - mpeg2_vdpau_hwaccel_select="mpeg2video_decoder" - mpeg4_crystalhd_decoder_select="crystalhd" - mpeg4_vaapi_hwaccel_deps="vaapi" -@@ -1877,11 +1884,14 @@ vc1_vdpau_decoder_deps="vdpau" - vc1_vdpau_decoder_select="vc1_decoder" - vc1_vdpau_hwaccel_deps="vdpau" - vc1_vdpau_hwaccel_select="vc1_decoder" -+vc1_xvba_hwaccel_select="vc1_decoder" -+vc1_xvba_hwaccel_deps="xvba" - wmv3_crystalhd_decoder_select="crystalhd" - wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" - wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" - wmv3_vdpau_decoder_select="vc1_vdpau_decoder" - wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" -+wmv3_xvba_hwaccel_select="vc1_xvba_hwaccel" - - # parsers - h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp" -@@ -3832,6 +3842,7 @@ check_header termios.h - check_header unistd.h - check_header vdpau/vdpau.h - check_header vdpau/vdpau_x11.h -+check_header amd/amdxvba.h - check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support - - check_header VideoDecodeAcceleration/VDADecoder.h -diff --git a/lib/ffmpeg/libavcodec/Makefile b/lib/ffmpeg/libavcodec/Makefile -index dc065a5..c386923 100644 ---- a/lib/ffmpeg/libavcodec/Makefile -+++ b/lib/ffmpeg/libavcodec/Makefile -@@ -12,6 +12,7 @@ HEADERS = avcodec.h \ - vdpau.h \ - version.h \ - xvmc.h \ -+ xvba.h \ - - OBJS = allcodecs.o \ - audioconvert.o \ -@@ -73,6 +74,7 @@ OBJS-$(CONFIG_SHARED) += log2_tab.o - OBJS-$(CONFIG_SINEWIN) += sinewin.o - OBJS-$(CONFIG_VAAPI) += vaapi.o - OBJS-$(CONFIG_VDPAU) += vdpau.o -+OBJS-$(CONFIG_XVBA) += xvba.o - OBJS-$(CONFIG_VIDEODSP) += videodsp.o - OBJS-$(CONFIG_VP3DSP) += vp3dsp.o - -@@ -232,6 +234,7 @@ OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o - OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o - OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o - OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o -+OBJS-$(CONFIG_H264_XVBA_HWACCEL) += xvba_h264.o - OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o - OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o - OBJS-$(CONFIG_IAC_DECODER) += imc.o -@@ -295,6 +298,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o \ - OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL) += dxva2_mpeg2.o - OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL) += vaapi_mpeg2.o - OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL) += vdpau_mpeg12.o -+OBJS-$(CONFIG_MPEG2_XVBA_HWACCEL) += xvba_mpeg2.o - OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12.o mpeg12data.o - OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o \ - timecode.o -@@ -459,6 +463,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1.o vc1data.o vc1dsp.o \ - OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o - OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o - OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o -+OBJS-$(CONFIG_VC1_XVBA_HWACCEL) += xvba_vc1.o - OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o - OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o - OBJS-$(CONFIG_VMDVIDEO_DECODER) += vmdav.o -@@ -788,6 +793,7 @@ SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h - SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h - SKIPHEADERS-$(CONFIG_MPEG_XVMC_DECODER) += xvmc.h - SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h -+SKIPHEADERS-$(CONFIG_XVBA) += xvba_internal.h - SKIPHEADERS-$(CONFIG_VDA) += vda.h - SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h - SKIPHEADERS-$(HAVE_OS2THREADS) += os2threads.h -diff --git a/lib/ffmpeg/libavcodec/allcodecs.c b/lib/ffmpeg/libavcodec/allcodecs.c -index 584446f..7a8f61c 100644 ---- a/lib/ffmpeg/libavcodec/allcodecs.c -+++ b/lib/ffmpeg/libavcodec/allcodecs.c -@@ -79,18 +79,22 @@ void avcodec_register_all(void) - REGISTER_HWACCEL(H264_VAAPI, h264_vaapi); - REGISTER_HWACCEL(H264_VDA, h264_vda); - REGISTER_HWACCEL(H264_VDPAU, h264_vdpau); -+ REGISTER_HWACCEL(H264_XVBA, h264_xvba); - REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau); - REGISTER_HWACCEL(MPEG2_DXVA2, mpeg2_dxva2); - REGISTER_HWACCEL(MPEG2_VAAPI, mpeg2_vaapi); - REGISTER_HWACCEL(MPEG2_VDPAU, mpeg2_vdpau); -+ REGISTER_HWACCEL(MPEG2_XVBA, mpeg2_xvba); - REGISTER_HWACCEL(MPEG4_VAAPI, mpeg4_vaapi); - REGISTER_HWACCEL(MPEG4_VDPAU, mpeg4_vdpau); - REGISTER_HWACCEL(VC1_DXVA2, vc1_dxva2); - REGISTER_HWACCEL(VC1_VAAPI, vc1_vaapi); - REGISTER_HWACCEL(VC1_VDPAU, vc1_vdpau); -+ REGISTER_HWACCEL(VC1_XVBA, vc1_xvba); - REGISTER_HWACCEL(WMV3_DXVA2, wmv3_dxva2); - REGISTER_HWACCEL(WMV3_VAAPI, wmv3_vaapi); - REGISTER_HWACCEL(WMV3_VDPAU, wmv3_vdpau); -+ REGISTER_HWACCEL(WMV3_XVBA, wmv3_xvba); - - /* video codecs */ - REGISTER_ENCODER(A64MULTI, a64multi); -diff --git a/lib/ffmpeg/libavcodec/h263dec.c b/lib/ffmpeg/libavcodec/h263dec.c -index e231b08..6fcd2a0 100644 ---- a/lib/ffmpeg/libavcodec/h263dec.c -+++ b/lib/ffmpeg/libavcodec/h263dec.c -@@ -769,6 +769,9 @@ int ff_h263_decode_frame(AVCodecContext *avctx, - #if CONFIG_VDPAU - AV_PIX_FMT_VDPAU, - #endif -+#if CONFIG_XVBA -+ AV_PIX_FMT_XVBA_VLD, -+#endif - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_NONE - }; -diff --git a/lib/ffmpeg/libavcodec/h264.c b/lib/ffmpeg/libavcodec/h264.c -index 1cab49f..62ac8fb 100644 ---- a/lib/ffmpeg/libavcodec/h264.c -+++ b/lib/ffmpeg/libavcodec/h264.c -@@ -81,6 +81,9 @@ - #if CONFIG_H264_VDPAU_HWACCEL - AV_PIX_FMT_VDPAU, - #endif -+#if CONFIG_H264_XVBA_HWACCEL -+ AV_PIX_FMT_XVBA_VLD, -+#endif - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_NONE - }; -@@ -98,6 +101,9 @@ - #if CONFIG_H264_VDPAU_HWACCEL - AV_PIX_FMT_VDPAU, - #endif -+#if CONFIG_H264_XVBA_HWACCEL -+ AV_PIX_FMT_XVBA_VLD, -+#endif - AV_PIX_FMT_YUVJ420P, - AV_PIX_FMT_NONE - }; -diff --git a/lib/ffmpeg/libavcodec/vc1dec.c b/lib/ffmpeg/libavcodec/vc1dec.c -index 2130c74..4d611f9 100644 ---- a/lib/ffmpeg/libavcodec/vc1dec.c -+++ b/lib/ffmpeg/libavcodec/vc1dec.c -@@ -5807,6 +5807,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, - #if CONFIG_VDPAU - AV_PIX_FMT_VDPAU, - #endif -+#if CONFIG_XVBA -+ AV_PIX_FMT_XVBA_VLD, -+#endif - AV_PIX_FMT_YUV420P, - AV_PIX_FMT_NONE - }; -diff --git a/lib/ffmpeg/libavcodec/xvba.c b/lib/ffmpeg/libavcodec/xvba.c -new file mode 100644 -index 0000000..c6ff2fe ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba.c -@@ -0,0 +1,77 @@ -+/* -+ * HW decode acceleration for MPEG-2, H.264 and VC-1 -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+ -+/** -+ * \addtogroup XVBA_Decoding -+ * -+ * @{ -+ */ -+ -+#include -+#include "xvba.h" -+#include "xvba_internal.h" -+#include "avcodec.h" -+#include "mpegvideo.h" -+ -+int ff_xvba_translate_profile(int profile) { -+ -+ if (profile == 66) -+ return 1; -+ else if (profile == 77) -+ return 2; -+ else if (profile == 100) -+ return 3; -+ else if (profile == 0) -+ return 4; -+ else if (profile == 1) -+ return 5; -+ else if (profile == 3) -+ return 6; -+ else -+ return -1; -+} -+ -+// See page 25 of the documentation -+int ff_xvba_translate_picture_structure(int picture_structure) { -+ if(picture_structure == PICT_BOTTOM_FIELD) -+ return 0; -+ else if (picture_structure == PICT_TOP_FIELD) -+ return 1; -+ else //PICT_FRAME by default -+ return 3; -+} -+ -+void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size) { -+ -+ render->buffers = av_fast_realloc( -+ render->buffers, -+ &render->buffers_alllocated, -+ sizeof(struct xvba_bitstream_buffers)*(render->num_slices + 1) -+ ); -+ -+ render->buffers[render->num_slices].buffer = buffer; -+ render->buffers[render->num_slices].size = size; -+ -+ render->num_slices++; -+} -+ -diff --git a/lib/ffmpeg/libavcodec/xvba.h b/lib/ffmpeg/libavcodec/xvba.h -new file mode 100644 -index 0000000..e590faf ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba.h -@@ -0,0 +1,72 @@ -+/* -+ * HW decode acceleration for MPEG-2, H.264 and VC-1 -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#ifndef AVCODEC_XVBA_H -+#define AVCODEC_XVBA_H -+ -+#include -+#include -+#include -+ -+ -+/** -+ * \defgroup XVBA_Decoding VA API Decoding -+ * \ingroup Decoder -+ * @{ -+ */ -+ -+/** \brief The videoSurface is used for rendering. */ -+#define FF_XVBA_STATE_USED_FOR_RENDER 1 -+ -+/** -+ * \brief The videoSurface is needed for reference/prediction. -+ * The codec manipulates this. -+ */ -+#define FF_XVBA_STATE_USED_FOR_REFERENCE 2 -+ -+/** -+ * \brief The videoSurface holds a decoded frame. -+ * The codec manipulates this. -+ */ -+#define FF_XVBA_STATE_DECODED 4 -+ -+/* @} */ -+ -+struct xvba_bitstream_buffers -+{ -+ const void *buffer; -+ unsigned int size; -+}; -+ -+struct xvba_render_state { -+ -+ int state; ///< Holds FF_XVBA_STATE_* values. -+ void *surface; -+ XVBAPictureDescriptor *picture_descriptor; -+ XVBAQuantMatrixAvc *iq_matrix; -+ unsigned int num_slices; -+ struct xvba_bitstream_buffers *buffers; -+ uint32_t buffers_alllocated; -+ int psf; -+}; -+ -+#endif /* AVCODEC_XVBA_H */ -diff --git a/lib/ffmpeg/libavcodec/xvba_h264.c b/lib/ffmpeg/libavcodec/xvba_h264.c -new file mode 100644 -index 0000000..20ba2f2 ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba_h264.c -@@ -0,0 +1,194 @@ -+/* -+ * H.264 HW decode acceleration through XVBA -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include "xvba.h" -+#include "xvba_internal.h" -+#include "h264.h" -+#include -+ -+/** @file -+ * This file implements the glue code between FFmpeg's and XvBA API's -+ * structures for H.264 decoding. -+ */ -+ -+ -+/** Initialize and start decoding a frame with XVBA. */ -+static int start_frame(AVCodecContext *avctx, -+ av_unused const uint8_t *buffer, -+ av_unused uint32_t size) -+{ -+ H264Context * const h = avctx->priv_data; -+ struct xvba_render_state *render; -+ XVBAPictureDescriptor *pic_descriptor; -+ int i; -+ -+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0]; -+ assert(render); -+ -+ if (render->picture_descriptor == 0) -+ return -1; -+ -+ pic_descriptor = render->picture_descriptor; -+ -+ for (i = 0; i < 2; ++i) { -+ int foc = h->cur_pic_ptr->field_poc[i]; -+ if (foc == INT_MAX) -+ foc = 0; -+ pic_descriptor->avc_curr_field_order_cnt_list[i] = foc; -+ } -+ -+ pic_descriptor->avc_frame_num = h->frame_num; -+ -+ render->num_slices = 0; -+ -+ return 0; -+} -+ -+/** End a hardware decoding based frame. */ -+static int end_frame(AVCodecContext *avctx) -+{ -+ H264Context * const h = avctx->priv_data; -+ struct xvba_render_state *render; -+ XVBAPictureDescriptor *pic_descriptor; -+ XVBAQuantMatrixAvc *iq_matrix; -+ -+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0]; -+ assert(render); -+ -+ if (render->picture_descriptor == 0 || render->iq_matrix == 0) -+ return -1; -+ -+ pic_descriptor = render->picture_descriptor; -+ iq_matrix = render->iq_matrix; -+ -+ av_dlog(avctx, "end_frame()\n"); -+ -+ /* Fill in Picture Parameters*/ -+ pic_descriptor->profile = ff_xvba_translate_profile(avctx->profile); -+ pic_descriptor->level = avctx->level; -+ pic_descriptor->width_in_mb = h->mb_width; -+ pic_descriptor->height_in_mb = h->mb_height; -+ -+ pic_descriptor->picture_structure = ff_xvba_translate_picture_structure(h->picture_structure); -+ -+ pic_descriptor->chroma_format = h->chroma_format_idc ? h->chroma_format_idc : 1; -+ pic_descriptor->avc_intra_flag = (h->slice_type == AV_PICTURE_TYPE_I) ? 1 : 0; -+ pic_descriptor->avc_reference = (h->cur_pic_ptr->f.reference & 3) ? 1 : 0; -+ -+ pic_descriptor->avc_bit_depth_luma_minus8 = h->sps.bit_depth_luma - 8; -+ pic_descriptor->avc_bit_depth_chroma_minus8 = h->sps.bit_depth_chroma - 8; -+ pic_descriptor->avc_log2_max_frame_num_minus4 = h->sps.log2_max_frame_num -4; -+ pic_descriptor->avc_pic_order_cnt_type = h->sps.poc_type; -+ pic_descriptor->avc_log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; -+ pic_descriptor->avc_num_ref_frames = h->sps.ref_frame_count; -+ pic_descriptor->avc_reserved_8bit = 0; -+ -+ /* Set a level that can decode stuff in every case without a lookup table -+ xvba seems to have problems only when the number of Reframes goes beyond -+ the max support number of Level4.1@High. So in praxis decoding a Level 3.0 -+ file that in deed has level4.1@High specs does not matter. We use this fact -+ and check if the ref_frames stay in the range Level4.1@high can decode if -+ not, we set Level5.1 */ -+ if (pic_descriptor->avc_num_ref_frames > 4) { -+ const unsigned int mbw = pic_descriptor->width_in_mb; -+ const unsigned int mbh = pic_descriptor->height_in_mb; -+ // this matches Level4.1@High stats to differ between <= 4.1 and 5.1 -+ const unsigned int max_ref_frames = 12288 * 1024 / (mbw * mbh * 384); -+ const unsigned int num_ref_frames = pic_descriptor->avc_num_ref_frames; -+ if (max_ref_frames < num_ref_frames) -+ pic_descriptor->level = 51; -+ } -+ -+ pic_descriptor->avc_num_slice_groups_minus1 = h->pps.slice_group_count - 1; -+ pic_descriptor->avc_num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1; -+ pic_descriptor->avc_num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1; -+ -+ pic_descriptor->avc_pic_init_qp_minus26 = h->pps.init_qp - 26; -+ pic_descriptor->avc_pic_init_qs_minus26 = h->pps.init_qs - 26; -+ pic_descriptor->avc_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; -+ pic_descriptor->avc_second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; -+ pic_descriptor->avc_slice_group_change_rate_minus1 = 0; // not implemented in ffmpeg -+ pic_descriptor->avc_reserved_16bit = 0; // must be 0 -+ memset(pic_descriptor->avc_field_order_cnt_list,0,sizeof(pic_descriptor->avc_field_order_cnt_list)); // must be 0 -+ memset(pic_descriptor->avc_slice_group_map,0,sizeof(pic_descriptor->avc_slice_group_map)); // must be 0 -+ -+ // sps -+ pic_descriptor->sps_info.avc.delta_pic_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; -+ pic_descriptor->sps_info.avc.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; -+ pic_descriptor->sps_info.avc.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; -+ pic_descriptor->sps_info.avc.gaps_in_frame_num_value_allowed_flag = h->sps.gaps_in_frame_num_allowed_flag; -+ pic_descriptor->sps_info.avc.mb_adaptive_frame_field_flag = h->sps.mb_aff; -+ pic_descriptor->sps_info.avc.residual_colour_transform_flag = h->sps.residual_color_transform_flag; -+ pic_descriptor->sps_info.avc.xvba_avc_sps_reserved = 0; -+ -+ // pps -+ pic_descriptor->pps_info.avc.entropy_coding_mode_flag = h->pps.cabac; -+ pic_descriptor->pps_info.avc.pic_order_present_flag = h->pps.pic_order_present; -+ pic_descriptor->pps_info.avc.weighted_pred_flag = h->pps.weighted_pred; -+ pic_descriptor->pps_info.avc.weighted_bipred_idc = h->pps.weighted_bipred_idc; -+ pic_descriptor->pps_info.avc.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; -+ pic_descriptor->pps_info.avc.constrained_intra_pred_flag = h->pps.constrained_intra_pred; -+ pic_descriptor->pps_info.avc.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; -+ pic_descriptor->pps_info.avc.transform_8x8_mode_flag = h->pps.transform_8x8_mode; -+ pic_descriptor->pps_info.avc.xvba_avc_pps_reserved = 0; // must be 0 -+ -+ memcpy(iq_matrix->bScalingLists4x4, h->pps.scaling_matrix4, sizeof(iq_matrix->bScalingLists4x4)); -+ memcpy(iq_matrix->bScalingLists8x8[0], h->pps.scaling_matrix8[0], sizeof(iq_matrix->bScalingLists8x8[0])); -+ memcpy(iq_matrix->bScalingLists8x8[1], h->pps.scaling_matrix8[3], sizeof(iq_matrix->bScalingLists8x8[0])); -+ -+ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs -+ if (!h->got_first_iframe) { -+ if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI) -+ return -1; -+ h->got_first_iframe = 1; -+ } -+ -+ ff_h264_draw_horiz_band(h, 0, h->avctx->height); -+ -+ return 0; -+} -+ -+/** Decode the given H.264 slice with XVBA. */ -+static int decode_slice(AVCodecContext *avctx, -+ const uint8_t *buffer, -+ uint32_t size) -+{ -+ H264Context * const h = avctx->priv_data; -+ struct xvba_render_state *render; -+ -+ render = (struct xvba_render_state *)h->cur_pic_ptr->f.data[0]; -+ assert(render); -+ -+ ff_xvba_add_slice_data(render, buffer, size); -+ -+ return 0; -+} -+ -+AVHWAccel ff_h264_xvba_hwaccel = { -+ .name = "h264_xvba", -+ .type = AVMEDIA_TYPE_VIDEO, -+ .id = CODEC_ID_H264, -+ .pix_fmt = AV_PIX_FMT_XVBA_VLD, -+ .start_frame = start_frame, -+ .end_frame = end_frame, -+ .decode_slice = decode_slice, -+}; -diff --git a/lib/ffmpeg/libavcodec/xvba_internal.h b/lib/ffmpeg/libavcodec/xvba_internal.h -new file mode 100644 -index 0000000..18faa3e ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba_internal.h -@@ -0,0 +1,25 @@ -+/* -+ * HW decode acceleration for MPEG-2, H.264 and VC-1 -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+int ff_xvba_translate_profile(int profile); -+int ff_xvba_translate_picture_structure(int picture_structure); -+void ff_xvba_add_slice_data(struct xvba_render_state *render, const uint8_t *buffer, uint32_t size); -diff --git a/lib/ffmpeg/libavcodec/xvba_mpeg2.c b/lib/ffmpeg/libavcodec/xvba_mpeg2.c -new file mode 100644 -index 0000000..0fc7d78 ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba_mpeg2.c -@@ -0,0 +1,52 @@ -+/* -+ * MPEG-2 HW decode acceleration through XVBA -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include "dsputil.h" -+ -+static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) -+{ -+ struct MpegEncContext * const s = avctx->priv_data; -+ return 0; -+} -+ -+static int end_frame(AVCodecContext *avctx) -+{ -+ return 0; -+} -+ -+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) -+{ -+ struct MpegEncContext * const s = avctx->priv_data; -+ return 0; -+} -+ -+AVHWAccel ff_mpeg2_xvba_hwaccel = { -+ .name = "mpeg2_xvba", -+ .type = AVMEDIA_TYPE_VIDEO, -+ .id = CODEC_ID_MPEG2VIDEO, -+ .pix_fmt = AV_PIX_FMT_XVBA_VLD, -+ .capabilities = 0, -+ .start_frame = start_frame, -+ .end_frame = end_frame, -+ .decode_slice = decode_slice, -+ .priv_data_size = 0, -+}; -diff --git a/lib/ffmpeg/libavcodec/xvba_vc1.c b/lib/ffmpeg/libavcodec/xvba_vc1.c -new file mode 100644 -index 0000000..e7a85a7 ---- /dev/null -+++ b/lib/ffmpeg/libavcodec/xvba_vc1.c -@@ -0,0 +1,193 @@ -+/* -+ * VC-1 HW decode acceleration through XVBA -+ * -+ * Copyright (C) 2005-2011 Team XBMC -+ * -+ * This file is part of FFmpeg. -+ * -+ * FFmpeg is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * FFmpeg is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with FFmpeg; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+ -+#include "xvba.h" -+#include "xvba_internal.h" -+#include "vc1.h" -+#include "vc1data.h" -+#include -+ -+ -+/** @file -+ * Implement structures of ffmpeg <-> XvBA -+ */ -+ -+/* Initialize and start decoding a frame with XvBA */ -+static int start_frame(AVCodecContext *avctx, -+ av_unused const uint8_t *buffer, -+ av_unused uint32_t size) -+{ -+ VC1Context * const v = avctx->priv_data; -+ MpegEncContext * const s = &v->s; -+ struct xvba_render_state *render; -+ -+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; -+ assert(render); -+ -+ render->num_slices = 0; -+ return 0; -+} -+ -+/* End a hardware decoding based frame */ -+static int end_frame(AVCodecContext *avctx) -+{ -+ VC1Context* const v = avctx->priv_data; -+ MpegEncContext* const s = &v->s; -+ struct xvba_render_state *render, *last, *next; -+ XVBAPictureDescriptor *pic_descriptor; -+ -+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; -+ assert(render); -+ -+ if (render->picture_descriptor == 0) -+ return -1; -+ -+ pic_descriptor = render->picture_descriptor; -+ -+ av_dlog(avctx, "xvba_vc1_end_frame()\n"); -+ -+ memset(pic_descriptor, 0, sizeof(*pic_descriptor)); -+ -+ /* Fill in Parameters - for reference see AMD sdk documentation */ -+ pic_descriptor->profile = ff_xvba_translate_profile(v->profile); -+ pic_descriptor->level = v->level; -+ //done like in va-driver and vaapi -+ if (v->profile == PROFILE_ADVANCED) { -+ pic_descriptor->width_in_mb = s->avctx->coded_width; -+ pic_descriptor->height_in_mb = s->avctx->coded_height; -+ } else { -+ pic_descriptor->width_in_mb = s->mb_width; -+ pic_descriptor->height_in_mb = s->mb_height; -+ } -+ -+ pic_descriptor->picture_structure = ff_xvba_translate_picture_structure(s->picture_structure); -+ -+ // xvba-video set this to 1 only 4:2:0 supported -+ // doc says: if not set, choose 1 - we try this -+ pic_descriptor->chroma_format = 1; -+ pic_descriptor->avc_intra_flag = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1; -+ pic_descriptor->avc_reference = (s->current_picture_ptr->f.reference & 3) ? 1 : 0; -+ -+ // VC-1 explicit parameters see page 30 of sdk -+ // sps_info -+ pic_descriptor->sps_info.vc1.postprocflag = v->postprocflag; -+ -+ // done as in vaapi -+ pic_descriptor->sps_info.vc1.pulldown = v->broadcast; -+ pic_descriptor->sps_info.vc1.interlace = v->interlace; -+ pic_descriptor->sps_info.vc1.tfcntrflag = v->tfcntrflag; -+ pic_descriptor->sps_info.vc1.finterpflag = v->finterpflag; -+ pic_descriptor->sps_info.vc1.reserved = 1; -+ // eventually check if this makes sense together with interlace -+ pic_descriptor->sps_info.vc1.psf = v->psf; -+ // what about if it is a frame (page 31) -+ // looked at xvba-driver -+ pic_descriptor->sps_info.vc1.second_field = v->interlace && v->second_field && (v->fcm == ILACE_FIELD); -+ pic_descriptor->sps_info.vc1.xvba_vc1_sps_reserved = 0; -+ -+ // VC-1 explicit parameters see page 30 of sdk -+ // pps_info -+ pic_descriptor->pps_info.vc1.panscan_flag = v->panscanflag; -+ pic_descriptor->pps_info.vc1.refdist_flag = v->refdist_flag; -+ pic_descriptor->pps_info.vc1.loopfilter = s->loop_filter; -+ pic_descriptor->pps_info.vc1.fastuvmc = v->fastuvmc; -+ pic_descriptor->pps_info.vc1.extended_mv = v->extended_mv; -+ pic_descriptor->pps_info.vc1.dquant = v->dquant; -+ pic_descriptor->pps_info.vc1.vstransform = v->vstransform; -+ pic_descriptor->pps_info.vc1.overlap = v->overlap; -+ pic_descriptor->pps_info.vc1.quantizer = v->quantizer_mode; -+ pic_descriptor->pps_info.vc1.extended_dmv = v->extended_dmv; -+ pic_descriptor->pps_info.vc1.maxbframes = s->avctx->max_b_frames; -+ pic_descriptor->pps_info.vc1.rangered = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : v->rangered; -+ pic_descriptor->pps_info.vc1.syncmarker = (pic_descriptor->profile == PROFILE_SIMPLE) ? 0 : s->resync_marker; -+ pic_descriptor->pps_info.vc1.multires = v->multires; -+ pic_descriptor->pps_info.vc1.reserved = 1; -+ pic_descriptor->pps_info.vc1.range_mapy_flag = v->range_mapy_flag; -+ pic_descriptor->pps_info.vc1.range_mapy = v->range_mapy; -+ pic_descriptor->pps_info.vc1.range_mapuv_flag = v->range_mapuv_flag; -+ pic_descriptor->pps_info.vc1.range_mapuv = v->range_mapuv; -+ pic_descriptor->pps_info.vc1.xvba_vc1_pps_reserved = 0; -+ -+ pic_descriptor->past_surface = 0; -+ pic_descriptor->future_surface = 0; -+ switch (s->pict_type) { -+ case AV_PICTURE_TYPE_B: -+ next = (struct xvba_render_state *)s->next_picture.f.data[0]; -+ assert(next); -+ if (next) -+ pic_descriptor->past_surface = next->surface; -+ // fall-through -+ case AV_PICTURE_TYPE_P: -+ last = (struct xvba_render_state *)s->last_picture.f.data[0]; -+ assert(last); -+ if (last) -+ pic_descriptor->future_surface = last->surface; -+ break; -+ } -+ render->psf = v->psf; -+ -+ ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); -+ -+ return 0; -+} -+ -+static int decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) -+{ -+ VC1Context* const v = avctx->priv_data; -+ MpegEncContext* const s = &v->s; -+ struct xvba_render_state *render; -+ -+ render = (struct xvba_render_state *)s->current_picture_ptr->f.data[0]; -+ assert(render); -+ -+ if (avctx->codec_id == CODEC_ID_VC1 && -+ size >= 4 && IS_MARKER(AV_RB32(buffer))) { -+ buffer += 4; -+ size -= 4; -+ } -+ -+ ff_xvba_add_slice_data(render, buffer, size); -+ -+ return 0; -+} -+ -+#if CONFIG_WMV3_XVBA_HWACCEL -+AVHWAccel ff_wmv3_xvba_hwaccel = { -+ .name = "wmv3_xvba", -+ .type = AVMEDIA_TYPE_VIDEO, -+ .id = CODEC_ID_WMV3, -+ .pix_fmt = AV_PIX_FMT_XVBA_VLD, -+ .start_frame = start_frame, -+ .end_frame = end_frame, -+ .decode_slice = decode_slice, -+}; -+#endif -+ -+AVHWAccel ff_vc1_xvba_hwaccel = { -+ .name = "vc1_xvba", -+ .type = AVMEDIA_TYPE_VIDEO, -+ .id = CODEC_ID_VC1, -+ .pix_fmt = AV_PIX_FMT_XVBA_VLD, -+ .start_frame = start_frame, -+ .end_frame = end_frame, -+ .decode_slice = decode_slice, -+}; -diff --git a/lib/ffmpeg/libavutil/pixdesc.c b/lib/ffmpeg/libavutil/pixdesc.c -index 1016dba..53dfec1 100644 ---- a/lib/ffmpeg/libavutil/pixdesc.c -+++ b/lib/ffmpeg/libavutil/pixdesc.c -@@ -1141,6 +1141,12 @@ void av_write_image_line(const uint16_t *src, - .log2_chroma_h = 1, - .flags = PIX_FMT_HWACCEL, - }, -+ [AV_PIX_FMT_XVBA_VLD] = { -+ .name = "xvba_vld", -+ .log2_chroma_w = 1, -+ .log2_chroma_h = 1, -+ .flags = PIX_FMT_HWACCEL, -+ }, - [AV_PIX_FMT_YUV420P9LE] = { - .name = "yuv420p9le", - .nb_components = 3, -diff --git a/lib/ffmpeg/libavutil/pixfmt.h b/lib/ffmpeg/libavutil/pixfmt.h -index 1c00ac4..6437e29 100644 ---- a/lib/ffmpeg/libavutil/pixfmt.h -+++ b/lib/ffmpeg/libavutil/pixfmt.h -@@ -124,6 +124,7 @@ enum AVPixelFormat { - AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers - AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers - AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers -+ AV_PIX_FMT_XVBA_VLD, ///< HW decoding through xvba, Picture.data[3] contains a xvba_rander_state struct which contains the bitstream of the slices - - AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian --- -1.8.4 - - -From 97e82ab1ca33d207a5df73f81faf0114d611874c Mon Sep 17 00:00:00 2001 -From: xbmc -Date: Thu, 12 Apr 2012 12:09:31 +0200 -Subject: [PATCH 36/89] xvba: add decoder, co-author fritsch - ---- - configure.in | 47 + - language/English/strings.po | 13 +- - system/settings/settings.xml | 5 + - xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 217 +- - xbmc/cores/VideoRenderers/LinuxRendererGL.h | 15 +- - xbmc/cores/VideoRenderers/RenderFormats.h | 1 + - xbmc/cores/VideoRenderers/RenderManager.cpp | 8 +- - xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp | 5 + - .../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h | 4 + - .../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 16 + - xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in | 4 + - xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp | 2375 ++++++++++++++++++++ - xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h | 383 ++++ - xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 1 + - xbmc/settings/Settings.cpp | 3 + - xbmc/settings/VideoSettings.h | 2 + - xbmc/video/dialogs/GUIDialogVideoSettings.cpp | 1 + - 17 files changed, 3091 insertions(+), 9 deletions(-) - create mode 100644 xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp - create mode 100644 xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h - -diff --git a/configure.in b/configure.in -index ec5ea78..428536f 100644 ---- a/configure.in -+++ b/configure.in -@@ -150,6 +150,8 @@ vaapi_not_found="== Could not find libva. VAAPI support disabled. ==" - vaapi_disabled="== VAAPI support manually disabled. ==" - crystalhd_not_found="== Could not find libcrystalhd. CrystalHD support disabled. ==" - crystalhd_disabled="== CrystalHD support manually disabled. ==" -+xvba_not_found="== Could not find amdxvba.h. XVBA support disabled. ==" -+xvba_disabled="== XVBA support manually disabled. ==" - vtbdecoder_enabled="== VTBDecoder support enabled. ==" - vtbdecoder_disabled="== VTBDecoder support manually disabled. ==" - openmax_disabled="== OpenMax support manually disabled. ==" -@@ -269,6 +271,12 @@ AC_ARG_ENABLE([crystalhd], - [enable CrystalHD decoding (default is auto)])], - [use_crystalhd=$enableval], - [use_crystalhd=auto]) -+ -+AC_ARG_ENABLE([xvba], -+ [AS_HELP_STRING([--enable-xvba], -+ [enable XVBA decoding (default is auto)])], -+ [use_xvba=$enableval], -+ [use_xvba=auto]) - - AC_ARG_ENABLE([vtbdecoder], - [AS_HELP_STRING([--enable-vtbdecoder], -@@ -1829,6 +1837,37 @@ else - USE_CRYSTALHD=0 - fi - -+# XVBA -+if test "x$use_xvba" != "xno"; then -+ if test "$host_vendor" = "apple" ; then -+ if test "x$use_xvba" = "xyes"; then -+ AC_MSG_ERROR([XVBA not supported on this platform]) -+ else -+ use_xvba="no" -+ AC_MSG_NOTICE($xvba_disabled) -+ fi -+ USE_XVBA=0 -+ else -+ initial_val=$use_xvba -+ AC_CHECK_HEADER([amd/amdxvba.h],, use_xvba=no, [#include ]) -+ -+ if test "x$use_xvba" = "xno"; then -+ if test "x$initial_val" = "xyes"; then -+ AC_MSG_ERROR($xvba_not_found) -+ else -+ AC_MSG_RESULT($xvba_not_found) -+ fi -+ USE_XVBA=0 -+ else -+ AC_DEFINE([HAVE_LIBXVBA], [1], [Define to 1 if you have the 'xvba' header (amdxvba.h)]) -+ USE_XVBA=1 -+ fi -+ fi -+else -+ AC_MSG_NOTICE($xvba_disabled) -+ USE_XVBA=0 -+fi -+ - # VTBDecoder - if test "x$use_vtbdecoder" != "xno"; then - if test "$host_vendor" = "apple" ; then -@@ -2040,6 +2079,12 @@ else - final_message="$final_message\n CrystalHD:\tNo" - fi - -+if test "x$use_xvba" != "xno"; then -+ final_message="$final_message\n XVBA:\t\tYes" -+else -+ final_message="$final_message\n XVBA:\t\tNo" -+fi -+ - if test "x$use_vtbdecoder" != "xno"; then - final_message="$final_message\n VTBDecoder:\tYes" - else -@@ -2530,6 +2575,7 @@ AC_SUBST(USE_OPENGLES) - AC_SUBST(USE_VDPAU) - AC_SUBST(USE_VAAPI) - AC_SUBST(USE_CRYSTALHD) -+AC_SUBST(USE_XVBA) - AC_SUBST(USE_LIBSMBCLIENT) - AC_SUBST(USE_LIBNFS) - AC_SUBST(USE_LIBAFPCLIENT) -@@ -2712,6 +2758,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [ - `if test "x$use_vdpau" != "xno"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \ - `if test "x$use_vaapi" != "xno"; then echo --enable-vaapi; else echo --disable-vaapi; fi` \ - `if test "$use_optimizations" != "no"; then echo --enable-optimizations; else echo --disable-optimizations; fi` \ -+ `if test "x$use_xvba" != "xno"; then echo --enable-xvba; else echo --disable-xvba; fi` \ - --enable-protocol=http \ - --enable-pthreads \ - --enable-runtime-cpudetect \ -diff --git a/language/English/strings.po b/language/English/strings.po -index 2f223fc..e22508c 100755 ---- a/language/English/strings.po -+++ b/language/English/strings.po -@@ -5803,7 +5803,12 @@ msgctxt "#13438" - msgid "Allow hardware acceleration (amcodec)" - msgstr "" - --#empty strings from id 13439 to 13499 -+#: system/settings/settings.xml -+msgctxt "#13439" -+msgid "Allow hardware acceleration (XVBA)" -+msgstr "" -+ -+#empty strings from id 13440 to 13499 - - #: system/settings/settings.xml - msgctxt "#13500" -@@ -6889,7 +6894,11 @@ msgctxt "#16325" - msgid "VDPAU - Bob" - msgstr "" - --#empty strings from id 16326 to 16399 -+msgctxt "#16326" -+msgid "XVBA" -+msgstr "" -+ -+#empty strings from id 16327 to 16399 - - msgctxt "#16400" - msgid "Post-processing" -diff --git a/system/settings/settings.xml b/system/settings/settings.xml -index 47e8145..e117a9d 100644 ---- a/system/settings/settings.xml -+++ b/system/settings/settings.xml -@@ -410,6 +410,11 @@ - 2 - true - -+ -+ HAVE_LIBXVBA -+ 2 -+ true -+ - - HAS_GL - 4 -diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp -index e562102..82e3545 100644 ---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp -+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp -@@ -65,6 +65,9 @@ - VA_MICRO_VERSION == 0 && VA_SDS_VERSION < 5))) - - #endif -+#ifdef HAVE_LIBXVBA -+#include "cores/dvdplayer/DVDCodecs/Video/XVBA.h" -+#endif - - #ifdef TARGET_DARWIN - #include "osx/CocoaInterface.h" -@@ -134,6 +137,9 @@ - #ifdef TARGET_DARWIN_OSX - cvBufferRef = NULL; - #endif -+#ifdef HAVE_LIBXVBA -+ xvba = NULL; -+#endif - } - - CLinuxRendererGL::YUVBUFFER::~YUVBUFFER() -@@ -624,12 +630,15 @@ void CLinuxRendererGL::Flush() - - void CLinuxRendererGL::ReleaseBuffer(int idx) - { --#if defined(HAVE_LIBVDPAU) || defined(HAVE_LIBVA) || defined(TARGET_DARWIN) -+#if defined(HAVE_LIBVDPAU) || defined(HAVE_LIBVA) || defined(TARGET_DARWIN) || defined(HAVE_LIBXVBA) - YUVBUFFER &buf = m_buffers[idx]; - #endif - #ifdef HAVE_LIBVDPAU - SAFE_RELEASE(buf.vdpau); - #endif -+#ifdef HAVE_LIBXVBA -+ SAFE_RELEASE(buf.xvba); -+#endif - #ifdef HAVE_LIBVA - buf.vaapi.surface.reset(); - #endif -@@ -895,7 +904,7 @@ void CLinuxRendererGL::UpdateVideoFilter() - case VS_SCALINGMETHOD_LINEAR: - SetTextureFilter(m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR); - m_renderQuality = RQ_SINGLEPASS; -- if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) && m_nonLinStretch) -+ if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA)) && m_nonLinStretch) - { - m_pVideoFilterShader = new StretchFilterShader(); - if (!m_pVideoFilterShader->CompileAndLink()) -@@ -981,6 +990,11 @@ void CLinuxRendererGL::LoadShaders(int field) - CLog::Log(LOGNOTICE, "GL: Using CVBREF render method"); - m_renderMethod = RENDER_CVREF; - } -+ else if (m_format == RENDER_FMT_XVBA) -+ { -+ CLog::Log(LOGNOTICE, "GL: Using XVBA render method"); -+ m_renderMethod = RENDER_XVBA; -+ } - else - { - int requestedMethod = CSettings::Get().GetInt("videoplayer.rendermethod"); -@@ -1129,6 +1143,12 @@ void CLinuxRendererGL::LoadShaders(int field) - m_textureCreate = &CLinuxRendererGL::CreateCVRefTexture; - m_textureDelete = &CLinuxRendererGL::DeleteCVRefTexture; - } -+ else if (m_format == RENDER_FMT_XVBA) -+ { -+ m_textureUpload = &CLinuxRendererGL::UploadXVBATexture; -+ m_textureCreate = &CLinuxRendererGL::CreateXVBATexture; -+ m_textureDelete = &CLinuxRendererGL::DeleteXVBATexture; -+ } - else - { - // setup default YV12 texture handlers -@@ -1239,6 +1259,13 @@ void CLinuxRendererGL::Render(DWORD flags, int renderBuffer) - RenderVAAPI(renderBuffer, m_currentField); - } - #endif -+#ifdef HAVE_LIBXVBA -+ else if (m_renderMethod & RENDER_XVBA) -+ { -+ UpdateVideoFilter(); -+ RenderXVBA(renderBuffer, m_currentField); -+ } -+#endif - else - { - // RENDER_CVREF uses the same render as the default case -@@ -1766,6 +1793,77 @@ void CLinuxRendererGL::RenderVAAPI(int index, int field) - #endif - } - -+void CLinuxRendererGL::RenderXVBA(int index, int field) -+{ -+#ifdef HAVE_LIBXVBA -+ YUVPLANE &plane = m_buffers[index].fields[0][1]; -+ -+ glEnable(m_textureTarget); -+ glActiveTextureARB(GL_TEXTURE0); -+ -+ glBindTexture(m_textureTarget, plane.id); -+ -+ // Try some clamping or wrapping -+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); -+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -+ -+ if (m_pVideoFilterShader) -+ { -+ GLint filter; -+ if (!m_pVideoFilterShader->GetTextureFilter(filter)) -+ filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR; -+ -+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter); -+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter); -+ m_pVideoFilterShader->SetSourceTexture(0); -+ m_pVideoFilterShader->SetWidth(m_sourceWidth); -+ m_pVideoFilterShader->SetHeight(m_sourceHeight); -+ -+ //disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer -+ //having non-linear stretch on breaks the alignment -+ if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu()) -+ m_pVideoFilterShader->SetNonLinStretch(1.0); -+ else -+ m_pVideoFilterShader->SetNonLinStretch(pow(CDisplaySettings::Get().GetPixelRatio(), g_advancedSettings.m_videoNonLinStretchRatio)); -+ -+ m_pVideoFilterShader->Enable(); -+ } -+ else -+ { -+ GLint filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR; -+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter); -+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter); -+ } -+ -+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); -+ VerifyGLState(); -+ -+ glBegin(GL_QUADS); -+ if (m_textureTarget==GL_TEXTURE_2D) -+ { -+ glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex2f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y); -+ glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex2f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y); -+ glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex2f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y); -+ glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex2f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y); -+ } -+ else -+ { -+ glTexCoord2f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y); glVertex4f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y, 0.0f, 0.0f); -+ glTexCoord2f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y); glVertex4f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y, 1.0f, 0.0f); -+ glTexCoord2f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y); glVertex4f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y, 1.0f, 1.0f); -+ glTexCoord2f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y); glVertex4f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y, 0.0f, 1.0f); -+ } -+ glEnd(); -+ VerifyGLState(); -+ -+ if (m_pVideoFilterShader) -+ m_pVideoFilterShader->Disable(); -+ -+ glBindTexture (m_textureTarget, 0); -+ glDisable(m_textureTarget); -+#endif -+} -+ - void CLinuxRendererGL::RenderSoftware(int index, int field) - { - // used for textues uploaded from rgba or CVPixelBuffers. -@@ -2812,6 +2910,87 @@ bool CLinuxRendererGL::CreateCVRefTexture(int index) - return true; - } - -+void CLinuxRendererGL::DeleteXVBATexture(int index) -+{ -+#ifdef HAVE_LIBXVBA -+ YUVPLANE &plane = m_buffers[index].fields[0][0]; -+ YUVFIELDS &fields = m_buffers[index].fields; -+ -+ SAFE_RELEASE(m_buffers[index].xvba); -+ -+ if(plane.id && glIsTexture(plane.id)) -+ glDeleteTextures(1, &plane.id); -+ plane.id = 0; -+ fields[0][1].id = 0; -+#endif -+} -+ -+bool CLinuxRendererGL::CreateXVBATexture(int index) -+{ -+#ifdef HAVE_LIBXVBA -+ YV12Image &im = m_buffers[index].image; -+ YUVFIELDS &fields = m_buffers[index].fields; -+ YUVPLANE &plane = fields[0][0]; -+ -+ DeleteXVBATexture(index); -+ -+ memset(&im , 0, sizeof(im)); -+ memset(&fields, 0, sizeof(fields)); -+ -+ glGenTextures(1, &plane.id); -+ -+#endif -+ return true; -+} -+ -+bool CLinuxRendererGL::UploadXVBATexture(int index) -+{ -+#ifdef HAVE_LIBXVBA -+ XVBA::CXvbaRenderPicture *xvba = m_buffers[index].xvba; -+ YV12Image &im = m_buffers[index].image; -+ -+ YUVFIELDS &fields = m_buffers[index].fields; -+ YUVPLANE &plane = fields[0][1]; -+ -+ if (!xvba || !xvba->valid) -+ { -+ return false; -+ } -+ -+ plane.id = xvba->texture; -+ -+ im.height = xvba->texHeight; -+ im.width = xvba->texWidth; -+ -+ plane.texwidth = xvba->texWidth; -+ plane.texheight = xvba->texHeight; -+ plane.pixpertex_x = 1; -+ plane.pixpertex_y = 1; -+ -+ plane.rect = m_sourceRect; -+ plane.width = im.width; -+ plane.height = im.height; -+ -+ plane.height /= plane.pixpertex_y; -+ plane.rect.y1 /= plane.pixpertex_y; -+ plane.rect.y2 /= plane.pixpertex_y; -+ plane.width /= plane.pixpertex_x; -+ plane.rect.x1 /= plane.pixpertex_x; -+ plane.rect.x2 /= plane.pixpertex_x; -+ -+ if (m_textureTarget == GL_TEXTURE_2D) -+ { -+ plane.height /= plane.texheight; -+ plane.rect.y1 /= plane.texheight; -+ plane.rect.y2 /= plane.texheight; -+ plane.width /= plane.texwidth; -+ plane.rect.x1 /= plane.texwidth; -+ plane.rect.x2 /= plane.texwidth; -+ } -+#endif -+ return true; -+} -+ - bool CLinuxRendererGL::UploadYUV422PackedTexture(int source) - { - YUVBUFFER& buf = m_buffers[source]; -@@ -3387,6 +3566,9 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) - if (m_renderMethod & RENDER_VAAPI) - return false; - -+ if (m_renderMethod & RENDER_XVBA) -+ return false; -+ - return (m_renderMethod & RENDER_GLSL) - || (m_renderMethod & RENDER_ARB) - || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE); -@@ -3400,6 +3582,9 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) - if (m_renderMethod & RENDER_VAAPI) - return false; - -+ if (m_renderMethod & RENDER_XVBA) -+ return false; -+ - return (m_renderMethod & RENDER_GLSL) - || (m_renderMethod & RENDER_ARB) - || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE); -@@ -3423,7 +3608,8 @@ bool CLinuxRendererGL::Supports(ERENDERFEATURE feature) - if (feature == RENDERFEATURE_NONLINSTRETCH) - { - if (((m_renderMethod & RENDER_GLSL) && !(m_renderMethod & RENDER_POT)) || -- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) -+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || -+ (m_renderMethod & RENDER_XVBA)) - return true; - } - -@@ -3495,6 +3681,16 @@ bool CLinuxRendererGL::Supports(EINTERLACEMETHOD method) - return false; - } - -+ if(m_renderMethod & RENDER_XVBA) -+ { -+#ifdef HAVE_LIBXVBA -+ XVBA::CXvbaRenderPicture *xvba = m_buffers[m_iYV12RenderBuffer].xvba; -+ if(xvba) -+ return xvba->xvba->Supports(method); -+#endif -+ return false; -+ } -+ - #ifdef TARGET_DARWIN - // YADIF too slow for HD but we have no methods to fall back - // to something that works so just turn it off. -@@ -3544,7 +3740,7 @@ bool CLinuxRendererGL::Supports(ESCALINGMETHOD method) - return false; - - if ((glewIsSupported("GL_EXT_framebuffer_object") && (m_renderMethod & RENDER_GLSL)) || -- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) -+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA)) - { - // spline36 and lanczos3 are only allowed through advancedsettings.xml - if(method != VS_SCALINGMETHOD_SPLINE36 -@@ -3611,7 +3807,8 @@ unsigned int CLinuxRendererGL::GetProcessorSize() - if(m_format == RENDER_FMT_VDPAU - || m_format == RENDER_FMT_VDPAU_420 - || m_format == RENDER_FMT_VAAPI -- || m_format == RENDER_FMT_CVBREF) -+ || m_format == RENDER_FMT_CVBREF -+ || m_format == RENDER_FMT_XVBA) - return 1; - else - return 0; -@@ -3647,4 +3844,14 @@ void CLinuxRendererGL::AddProcessor(struct __CVBuffer *cvBufferRef, int index) - } - #endif - -+#ifdef HAVE_LIBXVBA -+void CLinuxRendererGL::AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index) -+{ -+ YUVBUFFER &buf = m_buffers[index]; -+ XVBA::CXvbaRenderPicture *pic = xvba->Acquire(); -+ SAFE_RELEASE(buf.xvba); -+ buf.xvba = pic; -+} -+#endif -+ - #endif -diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoRenderers/LinuxRendererGL.h -index 3311ee6..bb6baad 100644 ---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.h -+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.h -@@ -43,6 +43,8 @@ - namespace Shaders { class BaseVideoFilterShader; } - namespace VAAPI { struct CHolder; } - namespace VDPAU { class CVdpauRenderPicture; } -+namespace XVBA { class CXvbaRenderPicture; } -+ - - #undef ALIGN - #define ALIGN(value, alignment) (((value)+((alignment)-1))&~((alignment)-1)) -@@ -88,6 +90,7 @@ enum RenderMethod - RENDER_POT=0x10, - RENDER_VAAPI=0x20, - RENDER_CVREF = 0x40, -+ RENDER_XVBA=0x80, - }; - - enum RenderQuality -@@ -149,7 +152,9 @@ class CLinuxRendererGL : public CBaseRenderer - #ifdef TARGET_DARWIN - virtual void AddProcessor(struct __CVBuffer *cvBufferRef, int index); - #endif -- -+#ifdef HAVE_LIBXVBA -+ virtual void AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index); -+#endif - virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255); - - // Feature support -@@ -204,6 +209,10 @@ class CLinuxRendererGL : public CBaseRenderer - void DeleteCVRefTexture(int index); - bool CreateCVRefTexture(int index); - -+ bool UploadXVBATexture(int index); -+ void DeleteXVBATexture(int index); -+ bool CreateXVBATexture(int index); -+ - bool UploadYUV422PackedTexture(int index); - void DeleteYUV422PackedTexture(int index); - bool CreateYUV422PackedTexture(int index); -@@ -223,6 +232,7 @@ class CLinuxRendererGL : public CBaseRenderer - void RenderVDPAU(int renderBuffer, int field); // render using vdpau hardware - void RenderProgressiveWeave(int renderBuffer, int field); // render using vdpau hardware - void RenderVAAPI(int renderBuffer, int field); // render using vdpau hardware -+ void RenderXVBA(int renderBuffer, int field); // render using xvba hardware - - struct - { -@@ -290,6 +300,9 @@ class CLinuxRendererGL : public CBaseRenderer - #ifdef TARGET_DARWIN_OSX - struct __CVBuffer *cvBufferRef; - #endif -+#ifdef HAVE_LIBXVBA -+ XVBA::CXvbaRenderPicture *xvba; -+#endif - }; - - typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS]; -diff --git a/xbmc/cores/VideoRenderers/RenderFormats.h b/xbmc/cores/VideoRenderers/RenderFormats.h -index 3b09194..b193c24 100644 ---- a/xbmc/cores/VideoRenderers/RenderFormats.h -+++ b/xbmc/cores/VideoRenderers/RenderFormats.h -@@ -36,6 +36,7 @@ enum ERenderFormat { - RENDER_FMT_CVBREF, - RENDER_FMT_BYPASS, - RENDER_FMT_EGLIMG, -+ RENDER_FMT_XVBA, - }; - - #endif -diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp -index ae610ca..08d6230 100644 ---- a/xbmc/cores/VideoRenderers/RenderManager.cpp -+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp -@@ -936,11 +936,17 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic) - else if(pic.format == RENDER_FMT_VAAPI) - m_pRenderer->AddProcessor(*pic.vaapi, index); - #endif --#ifdef HAS_LIBSTAGEFRIGHT -+ -+ #ifdef HAS_LIBSTAGEFRIGHT - else if(pic.format == RENDER_FMT_EGLIMG) - m_pRenderer->AddProcessor(pic.stf, pic.eglimg, index); - #endif - -+#ifdef HAVE_LIBXVBA -+ else if(pic.format == RENDER_FMT_XVBA) -+ m_pRenderer->AddProcessor(pic.xvba, index); -+#endif -+ - m_pRenderer->ReleaseImage(index, false); - - return index; -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp -index bc3072a..b6c5c66 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp -@@ -184,6 +184,11 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne - #elif defined(TARGET_POSIX) && !defined(TARGET_DARWIN) - hwSupport += "VAAPI:no "; - #endif -+#if defined(HAVE_LIBXVBA) && defined(TARGET_LINUX) -+ hwSupport += "XVBA:yes "; -+#elif defined(TARGET_LINUX) -+ hwSupport += "XVBA:no "; -+#endif - - CLog::Log(LOGDEBUG, "CDVDFactoryCodec: compiled in hardware support: %s", hwSupport.c_str()); - #if defined(HAS_LIBAMCODEC) -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -index d358777..35516d7 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h -@@ -35,6 +35,7 @@ - namespace DXVA { class CSurfaceContext; } - namespace VAAPI { struct CHolder; } - namespace VDPAU { class CVdpauRenderPicture; } -+namespace XVBA { class CXvbaRenderPicture; } - class COpenMax; - class COpenMaxVideo; - struct OpenMaxVideoBuffer; -@@ -62,6 +63,9 @@ struct DVDVideoPicture - struct { - VAAPI::CHolder* vaapi; - }; -+ struct { -+ XVBA::CXvbaRenderPicture* xvba; -+ }; - - struct { - COpenMax *openMax; -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -index 9f1fc03..7e01ef0 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -@@ -60,6 +60,9 @@ - #ifdef TARGET_DARWIN_OSX - #include "VDA.h" - #endif -+#ifdef HAVE_LIBXVBA -+#include "XVBA.h" -+#endif - - using namespace boost; - -@@ -101,6 +104,19 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx - dec->Release(); - } - #endif -+#ifdef HAVE_LIBXVBA -+ if(*cur == AV_PIX_FMT_XVBA_VLD && CSettings::Get().GetBool("videoplayer.usexvba")) -+ { -+ XVBA::CDecoder* dec = new XVBA::CDecoder(); -+ if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount)) -+ { -+ ctx->SetHardware(dec); -+ return *cur; -+ } -+ else -+ dec->Release(); -+ } -+#endif - #ifdef HAVE_LIBVA - // mpeg4 vaapi decoding is disabled - if(*cur == PIX_FMT_VAAPI_VLD && CSettings::Get().GetBool("videoplayer.usevaapi") -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in -index 043f570..8754625 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in -@@ -34,6 +34,10 @@ INCLUDES += -I${prefix}/opt/android-source/system/core/include - INCLUDES += -I${prefix}/opt/android-source/libhardware/include - endif - -+ifeq (@USE_XVBA@,1) -+SRCS += XVBA.cpp -+endif -+ - ifeq (@USE_LIBAMCODEC@,1) - SRCS += AMLCodec.cpp - SRCS += DVDVideoCodecAmlogic.cpp -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp -new file mode 100644 -index 0000000..5845dbf ---- /dev/null -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp -@@ -0,0 +1,2375 @@ -+/* -+ * Copyright (C) 2005-2011 Team XBMC -+ * http://www.xbmc.org -+ * -+ * This Program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2, or (at your option) -+ * any later version. -+ * -+ * This Program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with XBMC; see the file COPYING. If not, write to -+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -+ * http://www.gnu.org/copyleft/gpl.html -+ * -+ */ -+ -+#include "system.h" -+#ifdef HAVE_LIBXVBA -+ -+#include "system_gl.h" -+#include -+#include -+#include "XVBA.h" -+#include "windowing/WindowingFactory.h" -+#include "guilib/GraphicContext.h" -+#include "settings/Settings.h" -+#include "settings/MediaSettings.h" -+#include "utils/TimeUtils.h" -+#include "cores/dvdplayer/DVDClock.h" -+ -+using namespace XVBA; -+ -+// XVBA interface -+ -+#define XVBA_LIBRARY "libXvBAW.so.1" -+ -+typedef Bool (*XVBAQueryExtensionProc) (Display *dpy, int *vers); -+typedef Status (*XVBACreateContextProc) (void *input, void *output); -+typedef Status (*XVBADestroyContextProc) (void *context); -+typedef Bool (*XVBAGetSessionInfoProc) (void *input, void *output); -+typedef Status (*XVBACreateSurfaceProc) (void *input, void *output); -+typedef Status (*XVBACreateGLSharedSurfaceProc)(void *input, void *output); -+typedef Status (*XVBADestroySurfaceProc) (void *surface); -+typedef Status (*XVBACreateDecodeBuffersProc) (void *input, void *output); -+typedef Status (*XVBADestroyDecodeBuffersProc) (void *input); -+typedef Status (*XVBAGetCapDecodeProc) (void *input, void *output); -+typedef Status (*XVBACreateDecodeProc) (void *input, void *output); -+typedef Status (*XVBADestroyDecodeProc) (void *session); -+typedef Status (*XVBAStartDecodePictureProc) (void *input); -+typedef Status (*XVBADecodePictureProc) (void *input); -+typedef Status (*XVBAEndDecodePictureProc) (void *input); -+typedef Status (*XVBASyncSurfaceProc) (void *input, void *output); -+typedef Status (*XVBAGetSurfaceProc) (void *input); -+typedef Status (*XVBATransferSurfaceProc) (void *input); -+ -+static struct -+{ -+ XVBAQueryExtensionProc QueryExtension; -+ XVBACreateContextProc CreateContext; -+ XVBADestroyContextProc DestroyContext; -+ XVBAGetSessionInfoProc GetSessionInfo; -+ XVBACreateSurfaceProc CreateSurface; -+ XVBACreateGLSharedSurfaceProc CreateGLSharedSurface; -+ XVBADestroySurfaceProc DestroySurface; -+ XVBACreateDecodeBuffersProc CreateDecodeBuffers; -+ XVBADestroyDecodeBuffersProc DestroyDecodeBuffers; -+ XVBAGetCapDecodeProc GetCapDecode; -+ XVBACreateDecodeProc CreateDecode; -+ XVBADestroyDecodeProc DestroyDecode; -+ XVBAStartDecodePictureProc StartDecodePicture; -+ XVBADecodePictureProc DecodePicture; -+ XVBAEndDecodePictureProc EndDecodePicture; -+ XVBASyncSurfaceProc SyncSurface; -+ XVBAGetSurfaceProc GetSurface; -+ XVBATransferSurfaceProc TransferSurface; -+}g_XVBA_vtable; -+ -+//----------------------------------------------------------------------------- -+//----------------------------------------------------------------------------- -+ -+CXVBAContext *CXVBAContext::m_context = 0; -+CCriticalSection CXVBAContext::m_section; -+Display *CXVBAContext::m_display = 0; -+void *CXVBAContext::m_dlHandle = 0; -+ -+CXVBAContext::CXVBAContext() -+{ -+ m_context = 0; -+// m_dlHandle = 0; -+ m_xvbaContext = 0; -+ m_refCount = 0; -+} -+ -+void CXVBAContext::Release() -+{ -+ CSingleLock lock(m_section); -+ -+ m_refCount--; -+ if (m_refCount <= 0) -+ { -+ Close(); -+ delete this; -+ m_context = 0; -+ } -+} -+ -+void CXVBAContext::Close() -+{ -+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder context"); -+ -+ DestroyContext(); -+// if (m_dlHandle) -+// { -+// dlclose(m_dlHandle); -+// m_dlHandle = 0; -+// } -+} -+ -+bool CXVBAContext::EnsureContext(CXVBAContext **ctx) -+{ -+ CSingleLock lock(m_section); -+ -+ if (m_context) -+ { -+ m_context->m_refCount++; -+ *ctx = m_context; -+ return true; -+ } -+ -+ m_context = new CXVBAContext(); -+ *ctx = m_context; -+ { -+ CSingleLock gLock(g_graphicsContext); -+ if (!m_context->LoadSymbols() || !m_context->CreateContext()) -+ { -+ delete m_context; -+ m_context = 0; -+ return false; -+ } -+ } -+ -+ m_context->m_refCount++; -+ -+ *ctx = m_context; -+ return true; -+} -+ -+bool CXVBAContext::LoadSymbols() -+{ -+ if (!m_dlHandle) -+ { -+ m_dlHandle = dlopen(XVBA_LIBRARY, RTLD_LAZY); -+ if (!m_dlHandle) -+ { -+ const char* error = dlerror(); -+ if (!error) -+ error = "dlerror() returned NULL"; -+ -+ CLog::Log(LOGERROR,"XVBA::LoadSymbols: Unable to get handle to lib: %s", error); -+ return false; -+ } -+ } -+ else -+ return true; -+ -+#define INIT_PROC(PREFIX, PROC) do { \ -+ g_##PREFIX##_vtable.PROC = (PREFIX##PROC##Proc) \ -+ dlsym(m_dlHandle, #PREFIX #PROC); \ -+ } while (0) -+ -+#define INIT_PROC_CHECK(PREFIX, PROC) do { \ -+ dlerror(); \ -+ INIT_PROC(PREFIX, PROC); \ -+ if (dlerror()) { \ -+ dlclose(m_dlHandle); \ -+ m_dlHandle = NULL; \ -+ return false; \ -+ } \ -+ } while (0) -+ -+#define XVBA_INIT_PROC(PROC) INIT_PROC_CHECK(XVBA, PROC) -+ -+ XVBA_INIT_PROC(QueryExtension); -+ XVBA_INIT_PROC(CreateContext); -+ XVBA_INIT_PROC(DestroyContext); -+ XVBA_INIT_PROC(GetSessionInfo); -+ XVBA_INIT_PROC(CreateSurface); -+ XVBA_INIT_PROC(CreateGLSharedSurface); -+ XVBA_INIT_PROC(DestroySurface); -+ XVBA_INIT_PROC(CreateDecodeBuffers); -+ XVBA_INIT_PROC(DestroyDecodeBuffers); -+ XVBA_INIT_PROC(GetCapDecode); -+ XVBA_INIT_PROC(CreateDecode); -+ XVBA_INIT_PROC(DestroyDecode); -+ XVBA_INIT_PROC(StartDecodePicture); -+ XVBA_INIT_PROC(DecodePicture); -+ XVBA_INIT_PROC(EndDecodePicture); -+ XVBA_INIT_PROC(SyncSurface); -+ XVBA_INIT_PROC(GetSurface); -+ XVBA_INIT_PROC(TransferSurface); -+ -+#undef XVBA_INIT_PROC -+#undef INIT_PROC -+ -+ return true; -+} -+ -+bool CXVBAContext::CreateContext() -+{ -+ if (m_xvbaContext) -+ return true; -+ -+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - creating decoder context"); -+ -+ Drawable window; -+ { CSingleLock lock(g_graphicsContext); -+ if (!m_display) -+ m_display = XOpenDisplay(NULL); -+ window = 0; -+ } -+ -+ int version; -+ if (!g_XVBA_vtable.QueryExtension(m_display, &version)) -+ return false; -+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - opening xvba version: %i", version); -+ -+ // create XVBA Context -+ XVBA_Create_Context_Input contextInput; -+ XVBA_Create_Context_Output contextOutput; -+ contextInput.size = sizeof(contextInput); -+ contextInput.display = m_display; -+ contextInput.draw = window; -+ contextOutput.size = sizeof(contextOutput); -+ if(Success != g_XVBA_vtable.CreateContext(&contextInput, &contextOutput)) -+ { -+ CLog::Log(LOGERROR,"XVBA::CreateContext - failed to create context"); -+ return false; -+ } -+ m_xvbaContext = contextOutput.context; -+ -+ return true; -+} -+ -+void CXVBAContext::DestroyContext() -+{ -+ if (!m_xvbaContext) -+ return; -+ -+ g_XVBA_vtable.DestroyContext(m_xvbaContext); -+ m_xvbaContext = 0; -+// XCloseDisplay(m_display); -+} -+ -+void *CXVBAContext::GetContext() -+{ -+ return m_xvbaContext; -+} -+ -+//----------------------------------------------------------------------------- -+//----------------------------------------------------------------------------- -+ -+static unsigned int decoderId = 0; -+ -+CDecoder::CDecoder() : m_xvbaOutput(&m_inMsgEvent) -+{ -+ m_xvbaConfig.context = 0; -+ m_xvbaConfig.xvbaSession = 0; -+ m_xvbaConfig.videoSurfaces = &m_videoSurfaces; -+ m_xvbaConfig.videoSurfaceSec = &m_videoSurfaceSec; -+ m_xvbaConfig.apiSec = &m_apiSec; -+ -+ m_displayState = XVBA_OPEN; -+} -+ -+CDecoder::~CDecoder() -+{ -+ Close(); -+} -+ -+typedef struct { -+ unsigned int size; -+ unsigned int num_of_decodecaps; -+ XVBADecodeCap decode_caps_list[]; -+} XVBA_GetCapDecode_Output_Base; -+ -+void CDecoder::OnLostDevice() -+{ -+ CLog::Log(LOGNOTICE,"XVBA::OnLostDevice event"); -+ -+ CSingleLock lock(m_decoderSection); -+ DestroySession(); -+ if (m_xvbaConfig.context) -+ m_xvbaConfig.context->Release(); -+ m_xvbaConfig.context = 0; -+ -+ m_displayState = XVBA_LOST; -+ m_displayEvent.Reset(); -+} -+ -+void CDecoder::OnResetDevice() -+{ -+ CLog::Log(LOGNOTICE,"XVBA::OnResetDevice event"); -+ -+ CSingleLock lock(m_decoderSection); -+ if (m_displayState == XVBA_LOST) -+ { -+ m_displayState = XVBA_RESET; -+ lock.Leave(); -+ m_displayEvent.Set(); -+ } -+} -+ -+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces) -+{ -+ std::string Vendor = g_Windowing.GetRenderVendor(); -+ std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower); -+ if (Vendor.compare(0, 3, "ati") != 0) -+ { -+ return false; -+ } -+ -+ m_decoderId = decoderId++; -+ -+ CLog::Log(LOGNOTICE,"(XVBA::Open) opening xvba decoder, id: %d", m_decoderId); -+ -+ if(avctx->coded_width == 0 -+ || avctx->coded_height == 0) -+ { -+ CLog::Log(LOGWARNING,"(XVBA) no width/height available, can't init"); -+ return false; -+ } -+ -+ // Fixme: Revisit with new SDK -+ // Workaround for 0.74.01-AES-2 that does not signal if surfaces are too large -+ // it seems that xvba does not support anything > 2k -+ // return false, for files that are larger -+ // if you are unlucky, this would kill your decoder -+ // we limit to 2048x1152 now - as this was reported by ckoenig the UVD OSS -+ // engineer to be the maximum technically possible for all hardware with UVD. -+ // Some chips can do a bit more, but we use the safe default. -+ int surfaceWidth = (avctx->coded_width+15) & ~15; -+ int surfaceHeight = (avctx->coded_height+15) & ~15; -+ if(surfaceHeight > 1152 || surfaceWidth > 2048) -+ { -+ CLog::Log(LOGERROR, "Surface too large, decoder skipped: surfaceWidth %u, surfaceHeight %u", -+ surfaceWidth, surfaceHeight); -+ return false; -+ } -+ -+ if (!m_dllAvUtil.Load()) -+ return false; -+ -+ if (!CXVBAContext::EnsureContext(&m_xvbaConfig.context)) -+ return false; -+ -+ // xvba get session info -+ XVBA_GetSessionInfo_Input sessionInput; -+ XVBA_GetSessionInfo_Output sessionOutput; -+ sessionInput.size = sizeof(sessionInput); -+ sessionInput.context = m_xvbaConfig.context->GetContext(); -+ sessionOutput.size = sizeof(sessionOutput); -+ if (Success != g_XVBA_vtable.GetSessionInfo(&sessionInput, &sessionOutput)) -+ { -+ CLog::Log(LOGERROR,"(XVBA) can't get session info"); -+ return false; -+ } -+ if (sessionOutput.getcapdecode_output_size == 0) -+ { -+ CLog::Log(LOGERROR,"(XVBA) session decode not supported"); -+ return false; -+ } -+ -+ // get decoder capabilities -+ XVBA_GetCapDecode_Input capInput; -+ XVBA_GetCapDecode_Output *capOutput; -+ capInput.size = sizeof(capInput); -+ capInput.context = m_xvbaConfig.context->GetContext(); -+ capOutput = (XVBA_GetCapDecode_Output *)calloc(sessionOutput.getcapdecode_output_size, 1); -+ capOutput->size = sessionOutput.getcapdecode_output_size; -+ if (Success != g_XVBA_vtable.GetCapDecode(&capInput, capOutput)) -+ { -+ CLog::Log(LOGERROR,"(XVBA) can't get decode capabilities"); -+ return false; -+ } -+ -+ int match = -1; -+ if (avctx->codec_id == AV_CODEC_ID_H264) -+ { -+ // search for profile high -+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i) -+ { -+ if (capOutput->decode_caps_list[i].capability_id == XVBA_H264 && -+ capOutput->decode_caps_list[i].flags == XVBA_H264_HIGH) -+ { -+ match = (int) i; -+ break; -+ } -+ } -+ if (match < 0) -+ { -+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_H264_HIGH not found"); -+ } -+ } -+ else if (avctx->codec_id == AV_CODEC_ID_VC1) -+ { -+ // search for profile advanced -+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i) -+ { -+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 && -+ capOutput->decode_caps_list[i].flags == XVBA_VC1_ADVANCED) -+ { -+ match = (int) i; -+ break; -+ } -+ } -+ if (match < 0) -+ { -+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_ADVANCED not found"); -+ } -+ } -+ else if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO) -+ { -+ // search for profile high -+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i) -+ { -+ if (capOutput->decode_caps_list[i].capability_id == XVBA_MPEG2_VLD) -+ { -+ // XXX: uncomment when implemented -+ // match = (int) i; -+ // break; -+ } -+ } -+ if (match < 0) -+ { -+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_MPEG2_VLD not found"); -+ } -+ } -+ else if (avctx->codec_id == AV_CODEC_ID_WMV3) -+ { -+ // search for profile high -+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i) -+ { -+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 && -+ capOutput->decode_caps_list[i].flags == XVBA_VC1_MAIN) -+ { -+ match = (int) i; -+ break; -+ } -+ } -+ if (match < 0) -+ { -+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_MAIN not found"); -+ } -+ } -+ -+ if (match < 0) -+ { -+ free(capOutput); -+ return false; -+ } -+ -+ CLog::Log(LOGNOTICE,"(XVBA) using decoder capability id: %i flags: %i", -+ capOutput->decode_caps_list[match].capability_id, -+ capOutput->decode_caps_list[match].flags); -+ CLog::Log(LOGNOTICE,"(XVBA) using surface type: %x", -+ capOutput->decode_caps_list[match].surface_type); -+ -+ m_xvbaConfig.decoderCap = capOutput->decode_caps_list[match]; -+ -+ free(capOutput); -+ -+ // set some varables -+ m_xvbaConfig.xvbaSession = 0; -+ m_xvbaBufferPool.data_buffer = 0; -+ m_xvbaBufferPool.iq_matrix_buffer = 0; -+ m_xvbaBufferPool.picture_descriptor_buffer = 0; -+ m_presentPicture = 0; -+ m_xvbaConfig.numRenderBuffers = surfaces; -+ m_decoderThread = CThread::GetCurrentThreadId(); -+ m_speed = DVD_PLAYSPEED_NORMAL; -+ -+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface")) -+ m_xvbaConfig.useSharedSurfaces = true; -+ else -+ m_xvbaConfig.useSharedSurfaces = false; -+ -+ m_displayState = XVBA_OPEN; -+ -+ // setup ffmpeg -+ avctx->thread_count = 1; -+ avctx->get_buffer = CDecoder::FFGetBuffer; -+ avctx->release_buffer = CDecoder::FFReleaseBuffer; -+ avctx->draw_horiz_band = CDecoder::FFDrawSlice; -+ avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; -+ -+ g_Windowing.Register(this); -+ return true; -+} -+ -+void CDecoder::Close() -+{ -+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder, id: %d", m_decoderId); -+ -+ if (!m_xvbaConfig.context) -+ return; -+ -+ DestroySession(); -+ if (m_xvbaConfig.context) -+ m_xvbaConfig.context->Release(); -+ m_xvbaConfig.context = 0; -+ -+ while (!m_videoSurfaces.empty()) -+ { -+ xvba_render_state *render = m_videoSurfaces.back(); -+ if(render->buffers_alllocated > 0) -+ m_dllAvUtil.av_free(render->buffers); -+ m_videoSurfaces.pop_back(); -+ free(render); -+ } -+ -+ g_Windowing.Unregister(this); -+ m_dllAvUtil.Unload(); -+} -+ -+long CDecoder::Release() -+{ -+ // check if we should do some pre-cleanup here -+ // a second decoder might need resources -+ if (m_xvbaConfig.xvbaSession) -+ { -+ CSingleLock lock(m_decoderSection); -+ CLog::Log(LOGNOTICE,"XVBA::Release pre-cleanup"); -+ DestroySession(true); -+ } -+ return IHardwareDecoder::Release(); -+} -+ -+long CDecoder::ReleasePicReference() -+{ -+ return IHardwareDecoder::Release(); -+} -+ -+bool CDecoder::Supports(EINTERLACEMETHOD method) -+{ -+ if(method == VS_INTERLACEMETHOD_AUTO) -+ return true; -+ -+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface")) -+ { -+ if (method == VS_INTERLACEMETHOD_XVBA) -+ return true; -+ } -+ -+ return false; -+} -+ -+void CDecoder::ResetState() -+{ -+ m_displayState = XVBA_OPEN; -+} -+ -+int CDecoder::Check(AVCodecContext* avctx) -+{ -+ EDisplayState state; -+ -+ { CSingleLock lock(m_decoderSection); -+ state = m_displayState; -+ } -+ -+ if (state == XVBA_LOST) -+ { -+ CLog::Log(LOGNOTICE,"XVBA::Check waiting for display reset event"); -+ if (!m_displayEvent.WaitMSec(2000)) -+ { -+ CLog::Log(LOGERROR, "XVBA::Check - device didn't reset in reasonable time"); -+ state = XVBA_RESET;; -+ } -+ else -+ { CSingleLock lock(m_decoderSection); -+ state = m_displayState; -+ } -+ } -+ if (state == XVBA_RESET || state == XVBA_ERROR) -+ { -+ CLog::Log(LOGNOTICE,"XVBA::Check - Attempting recovery"); -+ -+ CSingleLock gLock(g_graphicsContext); -+ CSingleLock lock(m_decoderSection); -+ -+ DestroySession(); -+ ResetState(); -+ CXVBAContext::EnsureContext(&m_xvbaConfig.context); -+ -+ if (state == XVBA_RESET) -+ return VC_FLUSHED; -+ else -+ return VC_ERROR; -+ } -+ return 0; -+} -+ -+void CDecoder::SetError(const char* function, const char* msg, int line) -+{ -+ CLog::Log(LOGERROR, "XVBA::%s - %s, line %d", function, msg, line); -+ CSingleLock lock(m_decoderSection); -+ m_displayState = XVBA_ERROR; -+} -+ -+bool CDecoder::CreateSession(AVCodecContext* avctx) -+{ -+ m_xvbaConfig.surfaceWidth = (avctx->coded_width+15) & ~15; -+ m_xvbaConfig.surfaceHeight = (avctx->coded_height+15) & ~15; -+ -+ m_xvbaConfig.vidWidth = avctx->width; -+ m_xvbaConfig.vidHeight = avctx->height; -+ -+ XVBA_Create_Decode_Session_Input sessionInput; -+ XVBA_Create_Decode_Session_Output sessionOutput; -+ -+ sessionInput.size = sizeof(sessionInput); -+ sessionInput.width = m_xvbaConfig.surfaceWidth; -+ sessionInput.height = m_xvbaConfig.surfaceHeight; -+ sessionInput.context = m_xvbaConfig.context->GetContext(); -+ sessionInput.decode_cap = &m_xvbaConfig.decoderCap; -+ sessionOutput.size = sizeof(sessionOutput); -+ -+ if (Success != g_XVBA_vtable.CreateDecode(&sessionInput, &sessionOutput)) -+ { -+ SetError(__FUNCTION__, "failed to create decoder session", __LINE__); -+ CLog::Log(LOGERROR, "Decoder failed with following stats: m_surfaceWidth %u, m_surfaceHeight %u," -+ " m_vidWidth %u, m_vidHeight %u, coded_width %d, coded_height %d", -+ m_xvbaConfig.surfaceWidth, -+ m_xvbaConfig.surfaceHeight, -+ m_xvbaConfig.vidWidth, -+ m_xvbaConfig.vidHeight, -+ avctx->coded_width, -+ avctx->coded_height); -+ return false; -+ } -+ m_xvbaConfig.xvbaSession = sessionOutput.session; -+ -+ // create decode buffers -+ XVBA_Create_DecodeBuff_Input bufferInput; -+ XVBA_Create_DecodeBuff_Output bufferOutput; -+ -+ bufferInput.size = sizeof(bufferInput); -+ bufferInput.session = m_xvbaConfig.xvbaSession; -+ bufferInput.buffer_type = XVBA_PICTURE_DESCRIPTION_BUFFER; -+ bufferInput.num_of_buffers = 1; -+ bufferOutput.size = sizeof(bufferOutput); -+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput) -+ || bufferOutput.num_of_buffers_in_list != 1) -+ { -+ SetError(__FUNCTION__, "failed to create picture buffer", __LINE__); -+ return false; -+ } -+ m_xvbaBufferPool.picture_descriptor_buffer = bufferOutput.buffer_list; -+ -+ // data buffer -+ bufferInput.buffer_type = XVBA_DATA_BUFFER; -+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput) -+ || bufferOutput.num_of_buffers_in_list != 1) -+ { -+ SetError(__FUNCTION__, "failed to create data buffer", __LINE__); -+ return false; -+ } -+ m_xvbaBufferPool.data_buffer = bufferOutput.buffer_list; -+ -+ // QO Buffer -+ bufferInput.buffer_type = XVBA_QM_BUFFER; -+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput) -+ || bufferOutput.num_of_buffers_in_list != 1) -+ { -+ SetError(__FUNCTION__, "failed to create qm buffer", __LINE__); -+ return false; -+ } -+ m_xvbaBufferPool.iq_matrix_buffer = bufferOutput.buffer_list; -+ -+ -+ // initialize output -+ CSingleLock lock(g_graphicsContext); -+ m_xvbaConfig.stats = &m_bufferStats; -+ m_bufferStats.Reset(); -+ m_xvbaOutput.Start(); -+ Message *reply; -+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::INIT, -+ &reply, -+ 2000, -+ &m_xvbaConfig, -+ sizeof(m_xvbaConfig))) -+ { -+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false; -+ reply->Release(); -+ if (!success) -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - vdpau output returned error", __FUNCTION__); -+ m_xvbaOutput.Dispose(); -+ return false; -+ } -+ } -+ else -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - failed to init output", __FUNCTION__); -+ m_xvbaOutput.Dispose(); -+ return false; -+ } -+ m_inMsgEvent.Reset(); -+ -+ return true; -+} -+ -+void CDecoder::DestroySession(bool precleanup /*= false*/) -+{ -+ // wait for unfinished decoding jobs -+ XbmcThreads::EndTime timer; -+ if (m_xvbaConfig.xvbaSession) -+ { -+ for (unsigned int i = 0; i < m_videoSurfaces.size(); ++i) -+ { -+ xvba_render_state *render = m_videoSurfaces[i]; -+ if (render->surface) -+ { -+ XVBA_Surface_Sync_Input syncInput; -+ XVBA_Surface_Sync_Output syncOutput; -+ syncInput.size = sizeof(syncInput); -+ syncInput.session = m_xvbaConfig.xvbaSession; -+ syncInput.surface = render->surface; -+ syncInput.query_status = XVBA_GET_SURFACE_STATUS; -+ syncOutput.size = sizeof(syncOutput); -+ timer.Set(1000); -+ while(!timer.IsTimePast()) -+ { -+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput)) -+ { -+ CLog::Log(LOGERROR,"XVBA::DestroySession - failed sync surface"); -+ break; -+ } -+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING)) -+ break; -+ Sleep(10); -+ } -+ if (timer.IsTimePast()) -+ CLog::Log(LOGERROR,"XVBA::DestroySession - unfinished decoding job"); -+ } -+ } -+ } -+ -+ if (precleanup) -+ { -+ Message *reply; -+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::PRECLEANUP, -+ &reply, -+ 2000)) -+ { -+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false; -+ reply->Release(); -+ if (!success) -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup returned error", __FUNCTION__); -+ m_displayState = XVBA_ERROR; -+ } -+ } -+ else -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup timed out", __FUNCTION__); -+ m_displayState = XVBA_ERROR; -+ } -+ } -+ else -+ m_xvbaOutput.Dispose(); -+ -+ XVBA_Destroy_Decode_Buffers_Input bufInput; -+ bufInput.size = sizeof(bufInput); -+ bufInput.num_of_buffers_in_list = 1; -+ bufInput.session = m_xvbaConfig.xvbaSession; -+ -+ for (unsigned int i=0; isurface) -+ { -+ g_XVBA_vtable.DestroySurface(render->surface); -+ render->surface = 0; -+ render->state = 0; -+ render->picture_descriptor = 0; -+ render->iq_matrix = 0; -+ } -+ } -+ -+ if (m_xvbaConfig.xvbaSession) -+ g_XVBA_vtable.DestroyDecode(m_xvbaConfig.xvbaSession); -+ m_xvbaConfig.xvbaSession = 0; -+} -+ -+bool CDecoder::IsSurfaceValid(xvba_render_state *render) -+{ -+ // find render state in queue -+ bool found(false); -+ unsigned int i; -+ for(i = 0; i < m_videoSurfaces.size(); ++i) -+ { -+ if(m_videoSurfaces[i] == render) -+ { -+ found = true; -+ break; -+ } -+ } -+ if (!found) -+ { -+ CLog::Log(LOGERROR,"%s - video surface not found", __FUNCTION__); -+ return false; -+ } -+ if (m_videoSurfaces[i]->surface == 0) -+ { -+ m_videoSurfaces[i]->state = 0; -+ return false; -+ } -+ -+ return true; -+} -+ -+bool CDecoder::EnsureDataControlBuffers(unsigned int num) -+{ -+ if (m_xvbaBufferPool.data_control_buffers.size() >= num) -+ return true; -+ -+ unsigned int missing = num - m_xvbaBufferPool.data_control_buffers.size(); -+ -+ XVBA_Create_DecodeBuff_Input bufferInput; -+ XVBA_Create_DecodeBuff_Output bufferOutput; -+ bufferInput.size = sizeof(bufferInput); -+ bufferInput.session = m_xvbaConfig.xvbaSession; -+ bufferInput.buffer_type = XVBA_DATA_CTRL_BUFFER; -+ bufferInput.num_of_buffers = 1; -+ bufferOutput.size = sizeof(bufferOutput); -+ -+ for (unsigned int i=0; iopaque; -+ CDecoder* xvba = (CDecoder*)ctx->GetHardware(); -+ unsigned int i; -+ -+ CSingleLock lock(xvba->m_decoderSection); -+ -+ xvba_render_state * render = NULL; -+ render = (xvba_render_state*)pic->data[0]; -+ if(!render) -+ { -+ CLog::Log(LOGERROR, "XVBA::FFReleaseBuffer - invalid context handle provided"); -+ return; -+ } -+ -+ for(i=0; i<4; i++) -+ pic->data[i]= NULL; -+ -+ // find render state in queue -+ if (!xvba->IsSurfaceValid(render)) -+ { -+ CLog::Log(LOGDEBUG, "XVBA::FFReleaseBuffer - ignoring invalid buffer"); -+ return; -+ } -+ -+ render->state &= ~FF_XVBA_STATE_USED_FOR_REFERENCE; -+} -+ -+void CDecoder::FFDrawSlice(struct AVCodecContext *avctx, -+ const AVFrame *src, int offset[4], -+ int y, int type, int height) -+{ -+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; -+ CDecoder* xvba = (CDecoder*)ctx->GetHardware(); -+ -+ CSingleLock lock(xvba->m_decoderSection); -+ -+ if(xvba->m_displayState != XVBA_OPEN) -+ return; -+ -+ if(src->linesize[0] || src->linesize[1] || src->linesize[2] -+ || offset[0] || offset[1] || offset[2]) -+ { -+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid linesizes or offsets provided"); -+ return; -+ } -+ -+ xvba_render_state * render; -+ -+ render = (xvba_render_state*)src->data[0]; -+ if(!render) -+ { -+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid context handle provided"); -+ return; -+ } -+ -+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid -+ if (!xvba->IsSurfaceValid(render)) -+ { -+ CLog::Log(LOGWARNING, "XVBA::FFDrawSlice - ignoring invalid buffer"); -+ return; -+ } -+ -+ // decoding -+ XVBA_Decode_Picture_Start_Input startInput; -+ startInput.size = sizeof(startInput); -+ startInput.session = xvba->m_xvbaConfig.xvbaSession; -+ startInput.target_surface = render->surface; -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.StartDecodePicture(&startInput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed to start decoding", __LINE__); -+ return; -+ } -+ } -+ -+ XVBA_Decode_Picture_Input picInput; -+ picInput.size = sizeof(picInput); -+ picInput.session = xvba->m_xvbaConfig.xvbaSession; -+ XVBABufferDescriptor *list[2]; -+ picInput.buffer_list = list; -+ list[0] = xvba->m_xvbaBufferPool.picture_descriptor_buffer; -+ picInput.num_of_buffers_in_list = 1; -+ if (avctx->codec_id == AV_CODEC_ID_H264) -+ { -+ list[1] = xvba->m_xvbaBufferPool.iq_matrix_buffer; -+ picInput.num_of_buffers_in_list = 2; -+ } -+ -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.DecodePicture(&picInput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed to decode picture 1", __LINE__); -+ return; -+ } -+ } -+ -+ if (!xvba->EnsureDataControlBuffers(render->num_slices)) -+ return; -+ -+ XVBADataCtrl *dataControl; -+ int location = 0; -+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer = 0; -+ for (unsigned int j = 0; j < render->num_slices; ++j) -+ { -+ int startCodeSize = 0; -+ uint8_t startCode[] = {0x00,0x00,0x01}; -+ if (avctx->codec_id == AV_CODEC_ID_H264) -+ { -+ startCodeSize = 3; -+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location, -+ startCode, 3); -+ } -+ else if (avctx->codec_id == AV_CODEC_ID_VC1 && -+ (memcmp(render->buffers[j].buffer, startCode, 3) != 0)) -+ { -+ startCodeSize = 4; -+ uint8_t sdf = 0x0d; -+ if (render->picture_descriptor->sps_info.vc1.second_field) -+ sdf = 0x0c; -+ -+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location, -+ startCode, 3); -+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+3, -+ &sdf, 1); -+ } -+ // check for potential buffer overwrite -+ unsigned int bytesToCopy = render->buffers[j].size; -+ unsigned int freeBufferSize = xvba->m_xvbaBufferPool.data_buffer->buffer_size - -+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer; -+ if (bytesToCopy >= freeBufferSize) -+ { -+ xvba->SetError(__FUNCTION__, "bitstream buffer too large, maybe corrupted packet", __LINE__); -+ return; -+ } -+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+startCodeSize, -+ render->buffers[j].buffer, -+ render->buffers[j].size); -+ dataControl = (XVBADataCtrl*)xvba->m_xvbaBufferPool.data_control_buffers[j]->bufferXVBA; -+ dataControl->SliceDataLocation = location; -+ dataControl->SliceBytesInBuffer = render->buffers[j].size+startCodeSize; -+ dataControl->SliceBitsInBuffer = dataControl->SliceBytesInBuffer * 8; -+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += dataControl->SliceBytesInBuffer; -+ location += dataControl->SliceBytesInBuffer; -+ } -+ -+ int bufSize = xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer; -+ int padding = bufSize % 128; -+ if (padding) -+ { -+ padding = 128 - padding; -+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += padding; -+ memset((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+bufSize,0,padding); -+ } -+ -+ picInput.num_of_buffers_in_list = 2; -+ for (unsigned int i = 0; i < render->num_slices; ++i) -+ { -+ list[0] = xvba->m_xvbaBufferPool.data_buffer; -+ list[0]->data_offset = 0; -+ list[1] = xvba->m_xvbaBufferPool.data_control_buffers[i]; -+ list[1]->data_size_in_buffer = sizeof(*dataControl); -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.DecodePicture(&picInput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed to decode picture 2", __LINE__); -+ return; -+ } -+ } -+ } -+ XVBA_Decode_Picture_End_Input endInput; -+ endInput.size = sizeof(endInput); -+ endInput.session = xvba->m_xvbaConfig.xvbaSession; -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.EndDecodePicture(&endInput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed to decode picture 3", __LINE__); -+ return; -+ } -+ } -+ -+ // decode sync and error -+ XVBA_Surface_Sync_Input syncInput; -+ XVBA_Surface_Sync_Output syncOutput; -+ syncInput.size = sizeof(syncInput); -+ syncInput.session = xvba->m_xvbaConfig.xvbaSession; -+ syncInput.surface = render->surface; -+ syncInput.query_status = XVBA_GET_SURFACE_STATUS; -+ syncOutput.size = sizeof(syncOutput); -+ int64_t start = CurrentHostCounter(); -+ while (1) -+ { -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed sync surface 1", __LINE__); -+ return; -+ } -+ } -+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING)) -+ break; -+ if (CurrentHostCounter() - start > CurrentHostFrequency()) -+ { -+ xvba->SetError(__FUNCTION__, "timed out waiting for surface", __LINE__); -+ break; -+ } -+ usleep(100); -+ } -+ render->state |= FF_XVBA_STATE_DECODED; -+} -+ -+int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) -+{ -+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; -+ CDecoder* xvba = (CDecoder*)ctx->GetHardware(); -+ -+ pic->data[0] = -+ pic->data[1] = -+ pic->data[2] = -+ pic->data[3] = 0; -+ -+ pic->linesize[0] = -+ pic->linesize[1] = -+ pic->linesize[2] = -+ pic->linesize[3] = 0; -+ -+ CSingleLock lock(xvba->m_decoderSection); -+ -+ if(xvba->m_displayState != XVBA_OPEN) -+ return -1; -+ -+ if (xvba->m_xvbaConfig.xvbaSession == 0) -+ { -+ if (!xvba->CreateSession(avctx)) -+ return -1; -+ } -+ -+ xvba_render_state * render = NULL; -+ // find unused surface -+ { CSingleLock lock(xvba->m_videoSurfaceSec); -+ for(unsigned int i = 0; i < xvba->m_videoSurfaces.size(); ++i) -+ { -+ if(!(xvba->m_videoSurfaces[i]->state & (FF_XVBA_STATE_USED_FOR_REFERENCE | FF_XVBA_STATE_USED_FOR_RENDER))) -+ { -+ render = xvba->m_videoSurfaces[i]; -+ render->state = 0; -+ break; -+ } -+ } -+ } -+ -+ // create a new render state -+ if (render == NULL) -+ { -+ render = (xvba_render_state*)calloc(sizeof(xvba_render_state), 1); -+ if (render == NULL) -+ { -+ CLog::Log(LOGERROR, "XVBA::FFGetBuffer - calloc failed"); -+ return -1; -+ } -+ render->surface = 0; -+ render->buffers_alllocated = 0; -+ CSingleLock lock(xvba->m_videoSurfaceSec); -+ xvba->m_videoSurfaces.push_back(render); -+ } -+ -+ // create a new surface -+ if (render->surface == 0) -+ { -+ XVBA_Create_Surface_Input surfaceInput; -+ XVBA_Create_Surface_Output surfaceOutput; -+ surfaceInput.size = sizeof(surfaceInput); -+ surfaceInput.surface_type = xvba->m_xvbaConfig.decoderCap.surface_type; -+ surfaceInput.width = xvba->m_xvbaConfig.surfaceWidth; -+ surfaceInput.height = xvba->m_xvbaConfig.surfaceHeight; -+ surfaceInput.session = xvba->m_xvbaConfig.xvbaSession; -+ surfaceOutput.size = sizeof(surfaceOutput); -+ { CSingleLock lock(xvba->m_apiSec); -+ if (Success != g_XVBA_vtable.CreateSurface(&surfaceInput, &surfaceOutput)) -+ { -+ xvba->SetError(__FUNCTION__, "failed to create video surface", __LINE__); -+ return -1; -+ } -+ } -+ render->surface = surfaceOutput.surface; -+ render->picture_descriptor = (XVBAPictureDescriptor *)xvba->m_xvbaBufferPool.picture_descriptor_buffer->bufferXVBA; -+ render->iq_matrix = (XVBAQuantMatrixAvc *)xvba->m_xvbaBufferPool.iq_matrix_buffer->bufferXVBA; -+ CLog::Log(LOGDEBUG, "XVBA::FFGetBuffer - created video surface"); -+ } -+ -+ if (render == NULL) -+ return -1; -+ -+ pic->data[0] = (uint8_t*)render; -+ -+ pic->type= FF_BUFFER_TYPE_USER; -+ -+ render->state |= FF_XVBA_STATE_USED_FOR_REFERENCE; -+ render->state &= ~FF_XVBA_STATE_DECODED; -+ render->psf = 0; -+ pic->reordered_opaque= avctx->reordered_opaque; -+ -+ return 0; -+} -+ -+int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame) -+{ -+ int result = Check(avctx); -+ if (result) -+ return result; -+ -+ CSingleLock lock(m_decoderSection); -+ -+ if(frame) -+ { // we have a new frame from decoder -+ -+ xvba_render_state * render = (xvba_render_state*)frame->data[0]; -+ if(!render) -+ { -+ CLog::Log(LOGERROR, "XVBA::Decode - no render buffer"); -+ return VC_ERROR; -+ } -+ -+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid -+ if (!IsSurfaceValid(render)) -+ { -+ CLog::Log(LOGWARNING, "XVBA::Decode - ignoring invalid buffer"); -+ return VC_BUFFER; -+ } -+ if (!(render->state & FF_XVBA_STATE_DECODED)) -+ { -+ CLog::Log(LOGDEBUG, "XVBA::Decode - ffmpeg failed"); -+ return VC_BUFFER; -+ } -+ -+ CSingleLock lock(m_videoSurfaceSec); -+ render->state |= FF_XVBA_STATE_USED_FOR_RENDER; -+ lock.Leave(); -+ -+ // send frame to output for processing -+ CXvbaDecodedPicture pic; -+ memset(&pic.DVDPic, 0, sizeof(pic.DVDPic)); -+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic); -+ pic.render = render; -+ if (render->psf) -+ pic.DVDPic.iFlags &= ~DVP_FLAG_INTERLACED; -+ m_bufferStats.IncDecoded(); -+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic)); -+ -+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_NO_POSTPROC); -+ } -+ -+ int retval = 0; -+ uint16_t decoded, processed, render; -+ Message *msg; -+ while (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg)) -+ { -+ if (msg->signal == COutputControlProtocol::ERROR) -+ { -+ m_displayState = XVBA_ERROR; -+ retval |= VC_ERROR; -+ } -+ msg->Release(); -+ } -+ -+ m_bufferStats.Get(decoded, processed, render); -+ -+ uint64_t startTime = CurrentHostCounter(); -+ while (!retval) -+ { -+ if (m_xvbaOutput.m_dataPort.ReceiveInMessage(&msg)) -+ { -+ if (msg->signal == COutputDataProtocol::PICTURE) -+ { -+ if (m_presentPicture) -+ { -+ m_presentPicture->ReturnUnused(); -+ m_presentPicture = 0; -+ } -+ -+ m_presentPicture = *(CXvbaRenderPicture**)msg->data; -+ m_presentPicture->xvba = this; -+ m_bufferStats.DecRender(); -+ m_bufferStats.Get(decoded, processed, render); -+ retval |= VC_PICTURE; -+ } -+ msg->Release(); -+ } -+ else if (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg)) -+ { -+ if (msg->signal == COutputControlProtocol::STATS) -+ { -+ m_bufferStats.Get(decoded, processed, render); -+ } -+ else -+ { -+ m_displayState = XVBA_ERROR; -+ retval |= VC_ERROR; -+ } -+ msg->Release(); -+ } -+ -+ if ((m_codecControl & DVP_FLAG_DRAIN)) -+ { -+ if (decoded + processed + render < 2) -+ { -+ retval |= VC_BUFFER; -+ } -+ } -+ else -+ { -+ if (decoded + processed + render < 4) -+ { -+ retval |= VC_BUFFER; -+ } -+ } -+ -+ if (!retval && !m_inMsgEvent.WaitMSec(2000)) -+ break; -+ } -+ uint64_t diff = CurrentHostCounter() - startTime; -+ if (retval & VC_PICTURE) -+ { -+ m_bufferStats.SetParams(diff, m_speed); -+ if (diff*1000/CurrentHostFrequency() > 50) -+ CLog::Log(LOGDEBUG,"XVBA::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency())); -+ } -+ -+ if (!retval) -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - timed out waiting for output message", __FUNCTION__); -+ m_displayState = XVBA_ERROR; -+ retval |= VC_ERROR; -+ } -+ -+ return retval; -+ -+} -+ -+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture) -+{ -+ CSingleLock lock(m_decoderSection); -+ -+ if (m_displayState != XVBA_OPEN) -+ return false; -+ -+ *picture = m_presentPicture->DVDPic; -+ picture->xvba = m_presentPicture; -+ -+ return true; -+} -+ -+void CDecoder::ReturnRenderPicture(CXvbaRenderPicture *renderPic) -+{ -+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic)); -+} -+ -+ -+//void CDecoder::CopyYV12(int index, uint8_t *dest) -+//{ -+// CSharedLock lock(m_decoderSection); -+// -+// { CSharedLock dLock(m_displaySection); -+// if(m_displayState != XVBA_OPEN) -+// return; -+// } -+// -+// if (!m_flipBuffer[index].outPic) -+// { -+// CLog::Log(LOGWARNING, "XVBA::Present: present picture is NULL"); -+// return; -+// } -+// -+// XVBA_GetSurface_Target target; -+// target.size = sizeof(target); -+// target.surfaceType = XVBA_YV12; -+// target.flag = XVBA_FRAME; -+// -+// XVBA_Get_Surface_Input input; -+// input.size = sizeof(input); -+// input.session = m_xvbaSession; -+// input.src_surface = m_flipBuffer[index].outPic->render->surface; -+// input.target_buffer = dest; -+// input.target_pitch = m_surfaceWidth; -+// input.target_width = m_surfaceWidth; -+// input.target_height = m_surfaceHeight; -+// input.target_parameter = target; -+// { CSingleLock lock(m_apiSec); -+// if (Success != g_XVBA_vtable.GetSurface(&input)) -+// { -+// CLog::Log(LOGERROR,"(XVBA::CopyYV12) failed to get surface"); -+// } -+// } -+//} -+ -+void CDecoder::Reset() -+{ -+ CSingleLock lock(m_decoderSection); -+ -+ if (!m_xvbaConfig.xvbaSession) -+ return; -+ -+ Message *reply; -+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::FLUSH, -+ &reply, -+ 2000)) -+ { -+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false; -+ reply->Release(); -+ if (!success) -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - flush returned error", __FUNCTION__); -+ m_displayState = XVBA_ERROR; -+ } -+ else -+ m_bufferStats.Reset(); -+ } -+ else -+ { -+ CLog::Log(LOGERROR, "XVBA::%s - flush timed out", __FUNCTION__); -+ m_displayState = XVBA_ERROR; -+ } -+} -+ -+bool CDecoder::CanSkipDeint() -+{ -+ return m_bufferStats.CanSkipDeint(); -+} -+ -+void CDecoder::SetSpeed(int speed) -+{ -+ m_speed = speed; -+} -+ -+//----------------------------------------------------------------------------- -+// RenderPicture -+//----------------------------------------------------------------------------- -+ -+CXvbaRenderPicture* CXvbaRenderPicture::Acquire() -+{ -+ CSingleLock lock(*renderPicSection); -+ -+ if (refCount == 0) -+ xvba->Acquire(); -+ -+ refCount++; -+ return this; -+} -+ -+long CXvbaRenderPicture::Release() -+{ -+ CSingleLock lock(*renderPicSection); -+ -+ refCount--; -+ if (refCount > 0) -+ return refCount; -+ -+ lock.Leave(); -+ xvba->ReturnRenderPicture(this); -+ xvba->ReleasePicReference(); -+ -+ return refCount; -+} -+ -+void CXvbaRenderPicture::ReturnUnused() -+{ -+ { CSingleLock lock(*renderPicSection); -+ if (refCount > 0) -+ return; -+ } -+ if (xvba) -+ xvba->ReturnRenderPicture(this); -+} -+ -+//----------------------------------------------------------------------------- -+// Output -+//----------------------------------------------------------------------------- -+COutput::COutput(CEvent *inMsgEvent) : -+ CThread("XVBA Output Thread"), -+ m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent), -+ m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent) -+{ -+ m_inMsgEvent = inMsgEvent; -+ -+ CXvbaRenderPicture pic; -+ pic.renderPicSection = &m_bufferPool.renderPicSec; -+ pic.refCount = 0; -+ for (unsigned int i = 0; i < NUM_RENDER_PICS; i++) -+ { -+ m_bufferPool.allRenderPics.push_back(pic); -+ } -+ for (unsigned int i = 0; i < m_bufferPool.allRenderPics.size(); ++i) -+ { -+ m_bufferPool.freeRenderPics.push_back(&m_bufferPool.allRenderPics[i]); -+ } -+} -+ -+void COutput::Start() -+{ -+ Create(); -+} -+ -+COutput::~COutput() -+{ -+ Dispose(); -+ -+ m_bufferPool.freeRenderPics.clear(); -+ m_bufferPool.usedRenderPics.clear(); -+ m_bufferPool.allRenderPics.clear(); -+} -+ -+void COutput::Dispose() -+{ -+ CSingleLock lock(g_graphicsContext); -+ m_bStop = true; -+ m_outMsgEvent.Set(); -+ StopThread(); -+ m_controlPort.Purge(); -+ m_dataPort.Purge(); -+} -+ -+void COutput::OnStartup() -+{ -+ CLog::Log(LOGNOTICE, "COutput::OnStartup: Output Thread created"); -+} -+ -+void COutput::OnExit() -+{ -+ CLog::Log(LOGNOTICE, "COutput::OnExit: Output Thread terminated"); -+} -+ -+enum OUTPUT_STATES -+{ -+ O_TOP = 0, // 0 -+ O_TOP_ERROR, // 1 -+ O_TOP_UNCONFIGURED, // 2 -+ O_TOP_CONFIGURED, // 3 -+ O_TOP_CONFIGURED_WAIT_RES1, // 4 -+ O_TOP_CONFIGURED_WAIT_DEC, // 5 -+ O_TOP_CONFIGURED_STEP1, // 6 -+ O_TOP_CONFIGURED_WAIT_RES2, // 7 -+ O_TOP_CONFIGURED_STEP2, // 8 -+}; -+ -+int OUTPUT_parentStates[] = { -+ -1, -+ 0, //TOP_ERROR -+ 0, //TOP_UNCONFIGURED -+ 0, //TOP_CONFIGURED -+ 3, //TOP_CONFIGURED_WAIT_RES1 -+ 3, //TOP_CONFIGURED_WAIT_DEC -+ 3, //TOP_CONFIGURED_STEP1 -+ 3, //TOP_CONFIGURED_WAIT_RES2 -+ 3, //TOP_CONFIGURED_STEP2 -+}; -+ -+void COutput::StateMachine(int signal, Protocol *port, Message *msg) -+{ -+ for (int state = m_state; ; state = OUTPUT_parentStates[state]) -+ { -+ switch (state) -+ { -+ case O_TOP: // TOP -+ if (port == &m_controlPort) -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::FLUSH: -+ msg->Reply(COutputControlProtocol::ACC); -+ return; -+ case COutputControlProtocol::PRECLEANUP: -+ msg->Reply(COutputControlProtocol::ACC); -+ return; -+ default: -+ break; -+ } -+ } -+ else if (port == &m_dataPort) -+ { -+ switch (signal) -+ { -+ case COutputDataProtocol::RETURNPIC: -+ CXvbaRenderPicture *pic; -+ pic = *((CXvbaRenderPicture**)msg->data); -+ ProcessReturnPicture(pic); -+ return; -+ default: -+ break; -+ } -+ } -+ { -+ std::string portName = port == NULL ? "timer" : port->portName; -+ CLog::Log(LOGWARNING, "COutput::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state); -+ } -+ return; -+ -+ case O_TOP_ERROR: -+ m_extTimeout = 1000; -+ break; -+ -+ case O_TOP_UNCONFIGURED: -+ if (port == &m_controlPort) -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::INIT: -+ CXvbaConfig *data; -+ data = (CXvbaConfig*)msg->data; -+ if (data) -+ { -+ m_config = *data; -+ } -+ Init(); -+ EnsureBufferPool(); -+ if (!m_xvbaError) -+ { -+ m_state = O_TOP_CONFIGURED_WAIT_RES1; -+ msg->Reply(COutputControlProtocol::ACC); -+ } -+ else -+ { -+ m_state = O_TOP_ERROR; -+ msg->Reply(COutputControlProtocol::ERROR); -+ } -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED: -+ if (port == &m_controlPort) -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::FLUSH: -+ m_state = O_TOP_CONFIGURED_WAIT_RES1; -+ Flush(); -+ msg->Reply(COutputControlProtocol::ACC); -+ return; -+ case COutputControlProtocol::PRECLEANUP: -+ m_state = O_TOP_UNCONFIGURED; -+ m_extTimeout = 10000; -+ Flush(); -+ ReleaseBufferPool(true); -+ msg->Reply(COutputControlProtocol::ACC); -+ return; -+ default: -+ break; -+ } -+ } -+ else if (port == &m_dataPort) -+ { -+ switch (signal) -+ { -+ case COutputDataProtocol::NEWFRAME: -+ CXvbaDecodedPicture *frame; -+ frame = (CXvbaDecodedPicture*)msg->data; -+ if (frame) -+ { -+ m_decodedPics.push(*frame); -+ m_extTimeout = 0; -+ } -+ return; -+ case COutputDataProtocol::RETURNPIC: -+ CXvbaRenderPicture *pic; -+ pic = *((CXvbaRenderPicture**)msg->data); -+ ProcessReturnPicture(pic); -+ m_controlPort.SendInMessage(COutputControlProtocol::STATS); -+ m_extTimeout = 0; -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED_WAIT_RES1: -+ if (port == NULL) // timeout -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::TIMEOUT: -+ if (!m_decodedPics.empty() && FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty()) -+ { -+ m_state = O_TOP_CONFIGURED_WAIT_DEC; -+ m_bStateMachineSelfTrigger = true; -+ } -+ else -+ { -+ if (m_extTimeout != 0) -+ { -+ uint16_t decoded, processed, render; -+ m_config.stats->Get(decoded, processed, render); -+// CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render); -+ } -+ m_extTimeout = 100; -+ } -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED_WAIT_DEC: -+ if (port == NULL) // timeout -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::TIMEOUT: -+ if (IsDecodingFinished()) -+ { -+ m_state = O_TOP_CONFIGURED_STEP1; -+ m_bStateMachineSelfTrigger = true; -+ } -+ else -+ { -+ m_extTimeout = 1; -+ } -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED_STEP1: -+ if (port == NULL) // timeout -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::TIMEOUT: -+ m_processPicture = m_decodedPics.front(); -+ m_decodedPics.pop(); -+ InitCycle(); -+ CXvbaRenderPicture *pic; -+ pic = ProcessPicture(); -+ if (pic) -+ { -+ m_config.stats->IncRender(); -+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic)); -+ } -+ if (m_xvbaError) -+ { -+ m_state = O_TOP_ERROR; -+ return; -+ } -+ if (m_deinterlacing && !m_deintSkip) -+ { -+ m_state = O_TOP_CONFIGURED_WAIT_RES2; -+ m_extTimeout = 0; -+ } -+ else -+ { -+ FiniCycle(); -+ m_state = O_TOP_CONFIGURED_WAIT_RES1; -+ m_extTimeout = 0; -+ } -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED_WAIT_RES2: -+ if (port == NULL) // timeout -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::TIMEOUT: -+ if (FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty()) -+ { -+ m_state = O_TOP_CONFIGURED_STEP2; -+ m_bStateMachineSelfTrigger = true; -+ } -+ else -+ { -+ if (m_extTimeout != 0) -+ { -+ uint16_t decoded, processed, render; -+ m_config.stats->Get(decoded, processed, render); -+ CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render); -+ } -+ m_extTimeout = 100; -+ } -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ case O_TOP_CONFIGURED_STEP2: -+ if (port == NULL) // timeout -+ { -+ switch (signal) -+ { -+ case COutputControlProtocol::TIMEOUT: -+ CXvbaRenderPicture *pic; -+ m_deintStep = 1; -+ pic = ProcessPicture(); -+ if (pic) -+ { -+ m_config.stats->IncRender(); -+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic)); -+ } -+ if (m_xvbaError) -+ { -+ m_state = O_TOP_ERROR; -+ return; -+ } -+ FiniCycle(); -+ m_state = O_TOP_CONFIGURED_WAIT_RES1; -+ m_extTimeout = 0; -+ return; -+ default: -+ break; -+ } -+ } -+ break; -+ -+ default: // we are in no state, should not happen -+ CLog::Log(LOGERROR, "COutput::%s - no valid state: %d", __FUNCTION__, m_state); -+ return; -+ } -+ } // for -+} -+ -+void COutput::Process() -+{ -+ Message *msg = NULL; -+ Protocol *port = NULL; -+ bool gotMsg; -+ -+ m_state = O_TOP_UNCONFIGURED; -+ m_extTimeout = 1000; -+ m_bStateMachineSelfTrigger = false; -+ -+ while (!m_bStop) -+ { -+ gotMsg = false; -+ -+ if (m_bStateMachineSelfTrigger) -+ { -+ m_bStateMachineSelfTrigger = false; -+ // self trigger state machine -+ StateMachine(msg->signal, port, msg); -+ if (!m_bStateMachineSelfTrigger) -+ { -+ msg->Release(); -+ msg = NULL; -+ } -+ continue; -+ } -+ // check control port -+ else if (m_controlPort.ReceiveOutMessage(&msg)) -+ { -+ gotMsg = true; -+ port = &m_controlPort; -+ } -+ // check data port -+ else if (m_dataPort.ReceiveOutMessage(&msg)) -+ { -+ gotMsg = true; -+ port = &m_dataPort; -+ } -+ if (gotMsg) -+ { -+ StateMachine(msg->signal, port, msg); -+ if (!m_bStateMachineSelfTrigger) -+ { -+ msg->Release(); -+ msg = NULL; -+ } -+ continue; -+ } -+ -+ // wait for message -+ else if (m_outMsgEvent.WaitMSec(m_extTimeout)) -+ { -+ continue; -+ } -+ // time out -+ else -+ { -+ msg = m_controlPort.GetMessage(); -+ msg->signal = COutputControlProtocol::TIMEOUT; -+ port = 0; -+ // signal timeout to state machine -+ StateMachine(msg->signal, port, msg); -+ if (!m_bStateMachineSelfTrigger) -+ { -+ msg->Release(); -+ msg = NULL; -+ } -+ } -+ } -+ Flush(); -+ Uninit(); -+} -+ -+bool COutput::Init() -+{ -+ if (!CreateGlxContext()) -+ return false; -+ -+ m_xvbaError = false; -+ m_processPicture.render = 0; -+ m_fence = None; -+ -+ return true; -+} -+ -+bool COutput::Uninit() -+{ -+ ReleaseBufferPool(); -+ DestroyGlxContext(); -+ return true; -+} -+ -+void COutput::Flush() -+{ -+ while (!m_decodedPics.empty()) -+ { -+ CXvbaDecodedPicture pic = m_decodedPics.front(); -+ m_decodedPics.pop(); -+ CSingleLock lock(*m_config.videoSurfaceSec); -+ if (pic.render) -+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED); -+ } -+ -+ if (m_processPicture.render) -+ { -+ CSingleLock lock(*m_config.videoSurfaceSec); -+ m_processPicture.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED); -+ m_processPicture.render = 0; -+ } -+ -+ Message *msg; -+ while (m_dataPort.ReceiveOutMessage(&msg)) -+ { -+ if (msg->signal == COutputDataProtocol::NEWFRAME) -+ { -+ CXvbaDecodedPicture pic = *(CXvbaDecodedPicture*)msg->data; -+ CSingleLock lock(*m_config.videoSurfaceSec); -+ if (pic.render) -+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED); -+ } -+ else if (msg->signal == COutputDataProtocol::RETURNPIC) -+ { -+ CXvbaRenderPicture *pic; -+ pic = *((CXvbaRenderPicture**)msg->data); -+ ProcessReturnPicture(pic); -+ } -+ msg->Release(); -+ } -+ -+ while (m_dataPort.ReceiveInMessage(&msg)) -+ { -+ if (msg->signal == COutputDataProtocol::PICTURE) -+ { -+ CXvbaRenderPicture *pic; -+ pic = *((CXvbaRenderPicture**)msg->data); -+ ProcessReturnPicture(pic); -+ } -+ } -+} -+ -+bool COutput::IsDecodingFinished() -+{ -+ // check for decoding to be finished -+ CXvbaDecodedPicture decodedPic = m_decodedPics.front(); -+ -+ XVBA_Surface_Sync_Input syncInput; -+ XVBA_Surface_Sync_Output syncOutput; -+ syncInput.size = sizeof(syncInput); -+ syncInput.session = m_config.xvbaSession; -+ syncInput.surface = decodedPic.render->surface; -+ syncInput.query_status = XVBA_GET_SURFACE_STATUS; -+ syncOutput.size = sizeof(syncOutput); -+ { CSingleLock lock(*(m_config.apiSec)); -+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput)) -+ { -+ CLog::Log(LOGERROR,"XVBA - failed sync surface"); -+ m_xvbaError = true; -+ return false; -+ } -+ } -+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING)) -+ return true; -+ -+ return false; -+} -+ -+CXvbaRenderPicture* COutput::ProcessPicture() -+{ -+ CXvbaRenderPicture *retPic = 0; -+ -+ if (m_deintStep == 1) -+ { -+ if(m_field == XVBA_TOP_FIELD) -+ m_field = XVBA_BOTTOM_FIELD; -+ else -+ m_field = XVBA_TOP_FIELD; -+ } -+ -+ // find unused shared surface -+ unsigned int idx = FindFreeSurface(); -+ XvbaBufferPool::GLVideoSurface *glSurface = &m_bufferPool.glSurfaces[idx]; -+ glSurface->used = true; -+ glSurface->field = m_field; -+ glSurface->render = m_processPicture.render; -+ glSurface->transferred = false; -+ -+ int cmd = 0; -+ m_config.stats->GetCmd(cmd); -+ -+// if (m_fence) -+// glDeleteSync(m_fence); -+// m_fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); -+ -+ // transfer surface -+ XVBA_Transfer_Surface_Input transInput; -+ transInput.size = sizeof(transInput); -+ transInput.session = m_config.xvbaSession; -+ transInput.src_surface = m_processPicture.render->surface; -+ transInput.target_surface = glSurface->glSurface; -+ transInput.flag = m_field; -+ { CSingleLock lock(*(m_config.apiSec)); -+ if (Success != g_XVBA_vtable.TransferSurface(&transInput)) -+ { -+ CLog::Log(LOGERROR,"(XVBA) failed to transfer surface"); -+ m_xvbaError = true; -+ return retPic; -+ } -+ } -+ -+ // prepare render pic -+ retPic = m_bufferPool.freeRenderPics.front(); -+ m_bufferPool.freeRenderPics.pop_front(); -+ m_bufferPool.usedRenderPics.push_back(retPic); -+ retPic->sourceIdx = glSurface->id; -+ retPic->DVDPic = m_processPicture.DVDPic; -+ retPic->valid = true; -+ retPic->texture = glSurface->texture; -+ retPic->crop = CRect(0,0,0,0); -+ retPic->texWidth = m_config.surfaceWidth; -+ retPic->texHeight = m_config.surfaceHeight; -+ retPic->xvbaOutput = this; -+ -+ // set repeat pic for de-interlacing -+ if (m_deinterlacing) -+ { -+ if (m_deintStep == 1) -+ { -+ retPic->DVDPic.pts = DVD_NOPTS_VALUE; -+ retPic->DVDPic.dts = DVD_NOPTS_VALUE; -+ } -+ retPic->DVDPic.iRepeatPicture = 0.0; -+ } -+ -+ return retPic; -+} -+ -+void COutput::ProcessReturnPicture(CXvbaRenderPicture *pic) -+{ -+ std::deque::iterator it; -+ it = std::find(m_bufferPool.usedRenderPics.begin(), m_bufferPool.usedRenderPics.end(), pic); -+ if (it == m_bufferPool.usedRenderPics.end()) -+ { -+ CLog::Log(LOGWARNING, "COutput::ProcessReturnPicture - pic not found"); -+ return; -+ } -+ m_bufferPool.usedRenderPics.erase(it); -+ m_bufferPool.freeRenderPics.push_back(pic); -+ if (!pic->valid) -+ { -+ CLog::Log(LOGDEBUG, "COutput::%s - return of invalid render pic", __FUNCTION__); -+ return; -+ } -+ -+ xvba_render_state *render = m_bufferPool.glSurfaces[pic->sourceIdx].render; -+ if (render) -+ { -+ // check if video surface is referenced by other glSurfaces -+ bool referenced(false); -+ for (unsigned int i=0; isourceIdx) -+ continue; -+ if (m_bufferPool.glSurfaces[i].render == render) -+ { -+ referenced = true; -+ break; -+ } -+ } -+ if (m_processPicture.render == render) -+ referenced = true; -+ -+ // release video surface -+ if (!referenced) -+ { -+ CSingleLock lock(*m_config.videoSurfaceSec); -+ render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED); -+ } -+ -+ // unreference video surface -+ m_bufferPool.glSurfaces[pic->sourceIdx].render = 0; -+ -+ m_bufferPool.glSurfaces[pic->sourceIdx].used = false; -+ return; -+ } -+} -+ -+int COutput::FindFreeSurface() -+{ -+ // find free shared surface -+ unsigned int i; -+ for (i = 0; i < m_bufferPool.glSurfaces.size(); ++i) -+ { -+ if (!m_bufferPool.glSurfaces[i].used) -+ break; -+ } -+ if (i == m_bufferPool.glSurfaces.size()) -+ return -1; -+ else -+ return i; -+} -+ -+void COutput::InitCycle() -+{ -+ uint64_t latency; -+ int speed; -+ m_config.stats->GetParams(latency, speed); -+ latency = (latency*1000)/CurrentHostFrequency(); -+ -+ m_config.stats->SetCanSkipDeint(false); -+ -+ EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode; -+ EINTERLACEMETHOD method = CMediaSettings::Get().GetCurrentVideoSettings().m_InterlaceMethod; -+ bool interlaced = m_processPicture.DVDPic.iFlags & DVP_FLAG_INTERLACED; -+ -+ if (mode == VS_DEINTERLACEMODE_FORCE || -+ (mode == VS_DEINTERLACEMODE_AUTO && interlaced)) -+ { -+ if((method == VS_INTERLACEMETHOD_AUTO && interlaced) -+ || method == VS_INTERLACEMETHOD_XVBA) -+ { -+ m_deinterlacing = true; -+ m_deintSkip = false; -+ m_config.stats->SetCanSkipDeint(true); -+ -+ if (m_processPicture.DVDPic.iFlags & DVP_FLAG_DROPDEINT) -+ { -+ m_deintSkip = true; -+ } -+ -+ // do only half deinterlacing -+ if (speed != DVD_PLAYSPEED_NORMAL || !g_graphicsContext.IsFullScreenVideo()) -+ { -+ m_config.stats->SetCanSkipDeint(false); -+ m_deintSkip = true; -+ } -+ -+ if(m_processPicture.DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST) -+ m_field = XVBA_TOP_FIELD; -+ else -+ m_field = XVBA_BOTTOM_FIELD; -+ } -+ } -+ else -+ { -+ m_deinterlacing = false; -+ m_field = XVBA_FRAME; -+ } -+ -+ m_processPicture.DVDPic.format = RENDER_FMT_XVBA; -+ m_processPicture.DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST | -+ DVP_FLAG_REPEAT_TOP_FIELD | -+ DVP_FLAG_INTERLACED); -+ m_processPicture.DVDPic.iWidth = m_config.vidWidth; -+ m_processPicture.DVDPic.iHeight = m_config.vidHeight; -+ -+ m_deintStep = 0; -+} -+ -+void COutput::FiniCycle() -+{ -+// { CSingleLock lock(*m_config.videoSurfaceSec); -+// m_processPicture.render->state &= ~FF_XVBA_STATE_USED_FOR_RENDER; -+// } -+ m_processPicture.render = 0; -+ m_config.stats->DecDecoded(); -+} -+ -+bool COutput::EnsureBufferPool() -+{ -+ if (m_config.useSharedSurfaces && m_bufferPool.glSurfaces.empty()) -+ { -+ GLenum textureTarget; -+ if (!glewIsSupported("GL_ARB_texture_non_power_of_two") && glewIsSupported("GL_ARB_texture_rectangle")) -+ { -+ textureTarget = GL_TEXTURE_RECTANGLE_ARB; -+ } -+ else -+ textureTarget = GL_TEXTURE_2D; -+ -+ // create shared surfaces -+ XvbaBufferPool::GLVideoSurface surface; -+ for (unsigned int i = 0; i < NUM_RENDER_PICS; ++i) -+ { -+ glEnable(textureTarget); -+ glGenTextures(1, &surface.texture); -+ glBindTexture(textureTarget, surface.texture); -+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); -+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -+ glTexImage2D(textureTarget, 0, GL_RGBA, m_config.surfaceWidth, m_config.surfaceHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); -+ -+ XVBA_Create_GLShared_Surface_Input surfInput; -+ XVBA_Create_GLShared_Surface_Output surfOutput; -+ surfInput.size = sizeof(surfInput); -+ surfInput.session = m_config.xvbaSession; -+ surfInput.gltexture = surface.texture; -+ surfInput.glcontext = m_glContext; -+ surfOutput.size = sizeof(surfOutput); -+ surfOutput.surface = 0; -+ if (Success != g_XVBA_vtable.CreateGLSharedSurface(&surfInput, &surfOutput)) -+ { -+ CLog::Log(LOGERROR,"(XVBA) failed to create shared surface"); -+ m_xvbaError = true; -+ break; -+ } -+ CLog::Log(LOGDEBUG, "XVBA::GetTexture - created shared surface"); -+ -+ surface.glSurface = surfOutput.surface; -+ surface.id = i; -+ surface.used = false; -+ surface.render = 0; -+ m_bufferPool.glSurfaces.push_back(surface); -+ } -+ glDisable(textureTarget); -+ } -+ -+ return true; -+} -+ -+void COutput::ReleaseBufferPool(bool precleanup /*= false*/) -+{ -+// if (m_fence) -+// { -+// uint64_t maxTimeout = 1000000000LL; -+// glClientWaitSync(m_fence, GL_SYNC_FLUSH_COMMANDS_BIT, maxTimeout); -+// glDeleteSync(m_fence); -+// m_fence = None; -+// } -+ -+ CSingleLock lock(m_bufferPool.renderPicSec); -+ -+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i) -+ { -+ if (m_bufferPool.glSurfaces[i].glSurface) -+ { -+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface); -+ m_bufferPool.glSurfaces[i].glSurface = 0; -+ } -+ if (m_bufferPool.glSurfaces[i].texture && !precleanup) -+ { -+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture); -+ m_bufferPool.glSurfaces[i].texture = 0; -+ } -+ m_bufferPool.glSurfaces[i].render = 0; -+ m_bufferPool.glSurfaces[i].used = true; -+ } -+ -+ if (!precleanup) -+ { -+ m_bufferPool.glSurfaces.clear(); -+ -+ // invalidate all used render pictures -+ for (unsigned int i = 0; i < m_bufferPool.usedRenderPics.size(); ++i) -+ { -+ m_bufferPool.usedRenderPics[i]->valid = false; -+ } -+ } -+} -+ -+void COutput::PreReleaseBufferPool() -+{ -+ CSingleLock lock(m_bufferPool.renderPicSec); -+ -+ if (m_config.useSharedSurfaces) -+ { -+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i) -+ { -+ if (!m_bufferPool.glSurfaces[i].used) -+ { -+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface); -+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture); -+ m_bufferPool.glSurfaces[i].glSurface = 0; -+ m_bufferPool.glSurfaces[i].used = true; -+ } -+ } -+ } -+} -+ -+bool COutput::CreateGlxContext() -+{ -+ GLXContext glContext; -+ -+ m_Display = g_Windowing.GetDisplay(); -+ glContext = g_Windowing.GetGlxContext(); -+ m_Window = g_Windowing.GetWindow(); -+ -+ // Get our window attribs. -+ XWindowAttributes wndattribs; -+ XGetWindowAttributes(m_Display, m_Window, &wndattribs); -+ -+ // Get visual Info -+ XVisualInfo visInfo; -+ visInfo.visualid = wndattribs.visual->visualid; -+ int nvisuals = 0; -+ XVisualInfo* visuals = XGetVisualInfo(m_Display, VisualIDMask, &visInfo, &nvisuals); -+ if (nvisuals != 1) -+ { -+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - could not find visual"); -+ return false; -+ } -+ visInfo = visuals[0]; -+ XFree(visuals); -+ -+ m_pixmap = XCreatePixmap(m_Display, -+ m_Window, -+ 192, -+ 108, -+ visInfo.depth); -+ if (!m_pixmap) -+ { -+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - Unable to create XPixmap"); -+ return false; -+ } -+ -+ // create gl pixmap -+ m_glPixmap = glXCreateGLXPixmap(m_Display, &visInfo, m_pixmap); -+ -+ if (!m_glPixmap) -+ { -+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not create glPixmap"); -+ return false; -+ } -+ -+ m_glContext = glXCreateContext(m_Display, &visInfo, glContext, True); -+ -+ if (!glXMakeCurrent(m_Display, m_glPixmap, m_glContext)) -+ { -+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not make Pixmap current"); -+ return false; -+ } -+ -+ CLog::Log(LOGNOTICE, "XVBA::COutput::CreateGlxContext - created context"); -+ return true; -+} -+ -+bool COutput::DestroyGlxContext() -+{ -+ if (m_glContext) -+ { -+ glXMakeCurrent(m_Display, None, NULL); -+ glXDestroyContext(m_Display, m_glContext); -+ } -+ m_glContext = 0; -+ -+ if (m_glPixmap) -+ glXDestroyPixmap(m_Display, m_glPixmap); -+ m_glPixmap = 0; -+ -+ if (m_pixmap) -+ XFreePixmap(m_Display, m_pixmap); -+ m_pixmap = 0; -+ -+ return true; -+} -+ -+#endif -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h -new file mode 100644 -index 0000000..3bd0cea ---- /dev/null -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h -@@ -0,0 +1,383 @@ -+/* -+ * Copyright (C) 2005-2011 Team XBMC -+ * http://www.xbmc.org -+ * -+ * This Program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2, or (at your option) -+ * any later version. -+ * -+ * This Program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with XBMC; see the file COPYING. If not, write to -+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -+ * http://www.gnu.org/copyleft/gpl.html -+ * -+ */ -+#pragma once -+ -+#include "X11/Xlib.h" -+#include "amd/amdxvba.h" -+#include "DllAvCodec.h" -+#include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h" -+#include "threads/Thread.h" -+#include "threads/CriticalSection.h" -+#include "threads/SharedSection.h" -+#include "threads/Event.h" -+#include "guilib/DispResource.h" -+#include "guilib/Geometry.h" -+#include "libavcodec/xvba.h" -+#include "utils/ActorProtocol.h" -+#include "settings/VideoSettings.h" -+#include -+#include -+#include -+ -+using namespace Actor; -+ -+ -+namespace XVBA -+{ -+ -+//----------------------------------------------------------------------------- -+// XVBA data structs -+//----------------------------------------------------------------------------- -+ -+class CDecoder; -+class CXVBAContext; -+class COutput; -+ -+#define NUM_RENDER_PICS 9 -+ -+/** -+ * Buffer statistics used to control number of frames in queue -+ */ -+ -+class CXvbaBufferStats -+{ -+public: -+ uint16_t decodedPics; -+ uint16_t processedPics; -+ uint16_t renderPics; -+ uint64_t latency; // time decoder has waited for a frame, ideally there is no latency -+ int playSpeed; -+ bool canSkipDeint; -+ int processCmd; -+ -+ void IncDecoded() { CSingleLock l(m_sec); decodedPics++;} -+ void DecDecoded() { CSingleLock l(m_sec); decodedPics--;} -+ void IncProcessed() { CSingleLock l(m_sec); processedPics++;} -+ void DecProcessed() { CSingleLock l(m_sec); processedPics--;} -+ void IncRender() { CSingleLock l(m_sec); renderPics++;} -+ void DecRender() { CSingleLock l(m_sec); renderPics--;} -+ void Reset() { CSingleLock l(m_sec); decodedPics=0; processedPics=0;renderPics=0;latency=0;} -+ void Get(uint16_t &decoded, uint16_t &processed, uint16_t &render) {CSingleLock l(m_sec); decoded = decodedPics, processed=processedPics, render=renderPics;} -+ void SetParams(uint64_t time, int speed) { CSingleLock l(m_sec); latency = time; playSpeed = speed; } -+ void GetParams(uint64_t &lat, int &speed) { CSingleLock l(m_sec); lat = latency; speed = playSpeed; } -+ void SetCmd(int cmd) { CSingleLock l(m_sec); processCmd = cmd; } -+ void GetCmd(int &cmd) { CSingleLock l(m_sec); cmd = processCmd; processCmd = 0; } -+ void SetCanSkipDeint(bool canSkip) { CSingleLock l(m_sec); canSkipDeint = canSkip; } -+ bool CanSkipDeint() { CSingleLock l(m_sec); if (canSkipDeint) return true; else return false;} -+private: -+ CCriticalSection m_sec; -+}; -+ -+/** -+ * CXvbaConfig holds all configuration parameters needed by vdpau -+ * The structure is sent to the internal classes CMixer and COutput -+ * for init. -+ */ -+ -+struct CXvbaConfig -+{ -+ int surfaceWidth; -+ int surfaceHeight; -+ int vidWidth; -+ int vidHeight; -+ int outWidth; -+ int outHeight; -+ bool useSharedSurfaces; -+ -+ CXVBAContext *context; -+ XVBADecodeCap decoderCap; -+ void *xvbaSession; -+ std::vector *videoSurfaces; -+ CCriticalSection *videoSurfaceSec; -+ CCriticalSection *apiSec; -+ -+ CXvbaBufferStats *stats; -+ int numRenderBuffers; -+ uint32_t maxReferences; -+}; -+ -+/** -+ * Holds a decoded frame -+ * Input to COutput for further processing -+ */ -+struct CXvbaDecodedPicture -+{ -+ DVDVideoPicture DVDPic; -+ xvba_render_state *render; -+}; -+ -+/** -+ * Ready to render textures -+ * Sent from COutput back to CDecoder -+ * Objects are referenced by DVDVideoPicture and are sent -+ * to renderer -+ */ -+class CXvbaRenderPicture -+{ -+ friend class CDecoder; -+ friend class COutput; -+public: -+ DVDVideoPicture DVDPic; -+ int texWidth, texHeight; -+ CRect crop; -+ GLuint texture; -+ uint32_t sourceIdx; -+ bool valid; -+ CDecoder *xvba; -+ CXvbaRenderPicture* Acquire(); -+ long Release(); -+private: -+ void ReturnUnused(); -+ int refCount; -+ CCriticalSection *renderPicSection; -+ COutput *xvbaOutput; -+}; -+ -+//----------------------------------------------------------------------------- -+// Output -+//----------------------------------------------------------------------------- -+ -+/** -+ * Buffer pool holds allocated xvba and gl resources -+ * Embedded in COutput -+ */ -+struct XvbaBufferPool -+{ -+ struct GLVideoSurface -+ { -+ unsigned int id; -+ bool used; -+ bool transferred; -+ GLuint texture; -+ void *glSurface; -+ xvba_render_state *render; -+ XVBA_SURFACE_FLAG field; -+ }; -+ std::vector glSurfaces; -+ std::vector allRenderPics; -+ std::deque usedRenderPics; -+ std::deque freeRenderPics; -+ CCriticalSection renderPicSec; -+}; -+ -+class COutputControlProtocol : public Protocol -+{ -+public: -+ COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; -+ enum OutSignal -+ { -+ INIT, -+ FLUSH, -+ PRECLEANUP, -+ TIMEOUT, -+ }; -+ enum InSignal -+ { -+ ACC, -+ ERROR, -+ STATS, -+ }; -+}; -+ -+class COutputDataProtocol : public Protocol -+{ -+public: -+ COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {}; -+ enum OutSignal -+ { -+ NEWFRAME = 0, -+ RETURNPIC, -+ }; -+ enum InSignal -+ { -+ PICTURE, -+ }; -+}; -+ -+/** -+ * COutput is embedded in CDecoder and embeds CMixer -+ * The class has its own OpenGl context which is shared with render thread -+ * COuput generated ready to render textures and passes them back to -+ * CDecoder -+ */ -+class COutput : private CThread -+{ -+public: -+ COutput(CEvent *inMsgEvent); -+ virtual ~COutput(); -+ void Start(); -+ void Dispose(); -+ COutputControlProtocol m_controlPort; -+ COutputDataProtocol m_dataPort; -+protected: -+ void OnStartup(); -+ void OnExit(); -+ void Process(); -+ void StateMachine(int signal, Protocol *port, Message *msg); -+ bool HasWork(); -+ bool IsDecodingFinished(); -+ CXvbaRenderPicture* ProcessPicture(); -+ void ProcessReturnPicture(CXvbaRenderPicture *pic); -+ int FindFreeSurface(); -+ void InitCycle(); -+ void FiniCycle(); -+ bool Init(); -+ bool Uninit(); -+ void Flush(); -+ bool CreateGlxContext(); -+ bool DestroyGlxContext(); -+ bool EnsureBufferPool(); -+ void ReleaseBufferPool(bool precleanup = false); -+ void PreReleaseBufferPool(); -+ CEvent m_outMsgEvent; -+ CEvent *m_inMsgEvent; -+ int m_state; -+ bool m_bStateMachineSelfTrigger; -+ -+ // extended state variables for state machine -+ int m_extTimeout; -+ bool m_xvbaError; -+ CXvbaConfig m_config; -+ XvbaBufferPool m_bufferPool; -+ Display *m_Display; -+ Window m_Window; -+ GLXContext m_glContext; -+ GLXWindow m_glWindow; -+ Pixmap m_pixmap; -+ GLXPixmap m_glPixmap; -+ GLsync m_fence; -+ std::queue m_decodedPics; -+ CXvbaDecodedPicture m_processPicture; -+ XVBA_SURFACE_FLAG m_field; -+ bool m_deinterlacing; -+ int m_deintStep; -+ bool m_deintSkip; -+}; -+ -+//----------------------------------------------------------------------------- -+// XVBA decoder -+//----------------------------------------------------------------------------- -+ -+class CXVBAContext -+{ -+public: -+ static bool EnsureContext(CXVBAContext **ctx); -+ void *GetContext(); -+ void Release(); -+private: -+ CXVBAContext(); -+ void Close(); -+ bool LoadSymbols(); -+ bool CreateContext(); -+ void DestroyContext(); -+ static CXVBAContext *m_context; -+ static CCriticalSection m_section; -+ static Display *m_display; -+ int m_refCount; -+ static void *m_dlHandle; -+ void *m_xvbaContext; -+}; -+ -+class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder, -+ public IDispResource -+{ -+ friend class CXvbaRenderPicture; -+ -+public: -+ -+ struct pictureAge -+ { -+ int b_age; -+ int ip_age[2]; -+ }; -+ -+ enum EDisplayState -+ { XVBA_OPEN -+ , XVBA_RESET -+ , XVBA_LOST -+ , XVBA_ERROR -+ }; -+ -+ CDecoder(); -+ virtual ~CDecoder(); -+ virtual void OnLostDevice(); -+ virtual void OnResetDevice(); -+ -+ virtual bool Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces = 0); -+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame); -+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture); -+ virtual void Reset(); -+ virtual void Close(); -+ virtual int Check(AVCodecContext* avctx); -+ virtual long Release(); -+ virtual const std::string Name() { return "xvba"; } -+ virtual bool CanSkipDeint(); -+ virtual void SetSpeed(int speed); -+ virtual unsigned GetAllowedReferences() { return 5; } -+ -+ bool Supports(EINTERLACEMETHOD method); -+ long ReleasePicReference(); -+ -+protected: -+ bool CreateSession(AVCodecContext* avctx); -+ void DestroySession(bool precleanup = false); -+ bool EnsureDataControlBuffers(unsigned int num); -+ void ResetState(); -+ void SetError(const char* function, const char* msg, int line); -+ bool IsSurfaceValid(xvba_render_state *render); -+ void ReturnRenderPicture(CXvbaRenderPicture *renderPic); -+ -+ // callbacks for ffmpeg -+ static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic); -+ static void FFDrawSlice(struct AVCodecContext *avctx, -+ const AVFrame *src, int offset[4], -+ int y, int type, int height); -+ static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic); -+ -+ DllAvUtil m_dllAvUtil; -+ CCriticalSection m_decoderSection; -+ CEvent m_displayEvent; -+ EDisplayState m_displayState; -+ CXvbaConfig m_xvbaConfig; -+ std::vector m_videoSurfaces; -+ CCriticalSection m_apiSec, m_videoSurfaceSec; -+ ThreadIdentifier m_decoderThread; -+ -+ unsigned int m_decoderId; -+ struct XVBABufferPool -+ { -+ XVBABufferDescriptor *picture_descriptor_buffer; -+ XVBABufferDescriptor *iq_matrix_buffer; -+ XVBABufferDescriptor *data_buffer; -+ std::vector data_control_buffers; -+ }; -+ XVBABufferPool m_xvbaBufferPool; -+ -+ COutput m_xvbaOutput; -+ CXvbaBufferStats m_bufferStats; -+ CEvent m_inMsgEvent; -+ CXvbaRenderPicture *m_presentPicture; -+ -+ int m_speed; -+ int m_codecControl; -+}; -+ -+} -diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index eb443af..c2808c3 100644 ---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -@@ -1022,6 +1022,7 @@ static std::string GetRenderFormatName(ERenderFormat format) - case RENDER_FMT_CVBREF: return "BGRA"; - case RENDER_FMT_EGLIMG: return "EGLIMG"; - case RENDER_FMT_BYPASS: return "BYPASS"; -+ case RENDER_FMT_XVBA: return "XVBA"; - case RENDER_FMT_NONE: return "NONE"; - } - return "UNKNOWN"; -diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp -index 7bd8607..c8782d6 100644 ---- a/xbmc/settings/Settings.cpp -+++ b/xbmc/settings/Settings.cpp -@@ -764,6 +764,9 @@ void CSettings::InitializeConditions() - #ifdef HAVE_LIBVDPAU - m_settingsManager->AddCondition("have_libvdpau"); - #endif -+#ifdef HAVE_LIBXVBA -+ m_settingsManager->AddCondition("have_libxvba"); -+#endif - #ifdef HAVE_VIDEOTOOLBOXDECODER - m_settingsManager->AddCondition("have_videotoolboxdecoder"); - if (g_sysinfo.HasVideoToolBoxDecoder()) -diff --git a/xbmc/settings/VideoSettings.h b/xbmc/settings/VideoSettings.h -index 293f363..3db70fb 100644 ---- a/xbmc/settings/VideoSettings.h -+++ b/xbmc/settings/VideoSettings.h -@@ -63,6 +63,8 @@ enum EINTERLACEMETHOD - VS_INTERLACEMETHOD_SW_BLEND = 20, - VS_INTERLACEMETHOD_AUTO_ION = 21, - -+ VS_INTERLACEMETHOD_XVBA = 22, -+ - VS_INTERLACEMETHOD_MAX // do not use and keep as last enum value. - }; - -diff --git a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp -index 8f30248..db58075 100644 ---- a/xbmc/video/dialogs/GUIDialogVideoSettings.cpp -+++ b/xbmc/video/dialogs/GUIDialogVideoSettings.cpp -@@ -115,6 +115,7 @@ void CGUIDialogVideoSettings::CreateSettings() - entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BOB , 16320)); - entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BEST , 16321)); - entries.push_back(make_pair(VS_INTERLACEMETHOD_AUTO_ION , 16325)); -+ entries.push_back(make_pair(VS_INTERLACEMETHOD_XVBA , 16326)); - - /* remove unsupported methods */ - for(vector >::iterator it = entries.begin(); it != entries.end();) --- -1.8.4 - - -From 3b2d656d2805d364fbf0580b79ba895250e3bee6 Mon Sep 17 00:00:00 2001 -From: xbmc -Date: Sat, 16 Jun 2012 12:46:30 +0200 -Subject: [PATCH 37/89] xvba: do not use vaapi if xvba is present - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp -index 3facfce..298bcad 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp -@@ -269,6 +269,15 @@ void CDecoder::Close() - - bool CDecoder::Open(AVCodecContext *avctx, enum PixelFormat fmt, unsigned int surfaces) - { -+#ifdef HAVE_LIBXVBA -+ std::string Vendor = g_Windowing.GetRenderVendor(); -+ std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower); -+ if (Vendor.compare(0, 3, "ati") == 0) -+ { -+ return false; -+ } -+#endif -+ - VAEntrypoint entrypoint = VAEntrypointVLD; - VAProfile profile; - --- -1.8.4 - - -From 2ee898fee38085716af4d1383c1b746fa0575896 Mon Sep 17 00:00:00 2001 +From 38d48afa96600f138088664813ea4dc0574515a8 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 23 Aug 2012 19:39:49 +0200 -Subject: [PATCH 38/89] ffmpeg: add av_find_default_stream_index to interface +Subject: [PATCH 48/87] ffmpeg: add av_find_default_stream_index to interface --- lib/DllAvFormat.h | 4 ++++ @@ -10048,10 +8789,10 @@ index 0016c0b..3514856 100644 1.8.4 -From a7254d8f2ce24f090d34d24ed994703353c45204 Mon Sep 17 00:00:00 2001 +From c3dfdf12a46f1a06acc0ed8c7b35b2eb449f9b3c Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 20 Aug 2012 16:06:39 +0200 -Subject: [PATCH 39/89] dvdplayer: observe pts counter overflow +Subject: [PATCH 49/87] dvdplayer: observe pts counter overflow --- .../cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 198 ++++++++++++++++++++- @@ -10338,10 +9079,10 @@ index aef5ab1..35abbdf 100644 1.8.4 -From 4641682c080ab7d9bd951caab7feb705dc854a3a Mon Sep 17 00:00:00 2001 +From 4226b2ae2d87583dcb2c301e6f00fa938529e12b Mon Sep 17 00:00:00 2001 From: xbmc Date: Tue, 2 Oct 2012 13:02:10 +0200 -Subject: [PATCH 40/89] dvdplayer: avoid short screen flicker caused by +Subject: [PATCH 50/87] dvdplayer: avoid short screen flicker caused by unnecessary reconfigure of renderer --- @@ -10349,7 +9090,7 @@ Subject: [PATCH 40/89] dvdplayer: avoid short screen flicker caused by 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index c2808c3..5d487f4 100644 +index c40d193..6419951 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -1065,7 +1065,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts) @@ -10374,10 +9115,10 @@ index c2808c3..5d487f4 100644 1.8.4 -From 9a48b94d1a01273f37583bd6f3784a71843682b4 Mon Sep 17 00:00:00 2001 +From f89eac396a55c37bd13f32a32924e0450bc22838 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 11 Oct 2012 12:05:50 +0200 -Subject: [PATCH 41/89] vdpau: advanced settings for auto deinterlacing +Subject: [PATCH 51/87] vdpau: advanced settings for auto deinterlacing --- xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 8 ++++---- @@ -10386,10 +9127,10 @@ Subject: [PATCH 41/89] vdpau: advanced settings for auto deinterlacing 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index adf7413..733f4f8 100644 +index f57935e..7ee2ed9 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -1827,10 +1827,10 @@ EINTERLACEMETHOD CMixer::GetDeinterlacingMethod(bool log /* = false */) +@@ -1949,10 +1949,10 @@ EINTERLACEMETHOD CMixer::GetDeinterlacingMethod(bool log /* = false */) if (method == VS_INTERLACEMETHOD_AUTO) { int deint = -1; @@ -10405,7 +9146,7 @@ index adf7413..733f4f8 100644 if (deint != -1) { diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp -index 1e162f9..2a0c9f3 100644 +index 4e1a28c..2a25330 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -168,6 +168,8 @@ void CAdvancedSettings::Initialize() @@ -10417,7 +9158,7 @@ index 1e162f9..2a0c9f3 100644 m_videoVDPAUtelecine = false; m_videoVDPAUdeintSkipChromaHD = false; m_DXVACheckCompatibility = false; -@@ -608,6 +610,8 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) +@@ -609,6 +611,8 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file) XMLUtils::GetBoolean(pElement,"allowmpeg4vaapi",m_videoAllowMpeg4VAAPI); XMLUtils::GetBoolean(pElement, "disablebackgrounddeinterlace", m_videoDisableBackgroundDeinterlace); XMLUtils::GetInt(pElement, "useocclusionquery", m_videoCaptureUseOcclusionQuery, -1, 1); @@ -10427,7 +9168,7 @@ index 1e162f9..2a0c9f3 100644 XMLUtils::GetBoolean(pElement,"vdpauHDdeintSkipChroma",m_videoVDPAUdeintSkipChromaHD); diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h -index 0d792af..b7b7a80 100644 +index 05e670b..a67ac36 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -157,6 +157,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler @@ -10443,10 +9184,10 @@ index 0d792af..b7b7a80 100644 1.8.4 -From 1e305ff642fe80dbc0ab98eec3b2f49f32be4c73 Mon Sep 17 00:00:00 2001 +From 987462e79994ce505053dcd3f767b9f41d0e3416 Mon Sep 17 00:00:00 2001 From: xbmc Date: Fri, 2 Nov 2012 13:20:03 +0100 -Subject: [PATCH 42/89] player: fix rewind +Subject: [PATCH 52/87] player: fix rewind --- xbmc/cores/dvdplayer/DVDMessage.h | 5 ++++- @@ -10494,7 +9235,7 @@ index 2ea8b8f..e8274f9 100644 class CDVDMsgPlayerSeekChapter : public CDVDMsg diff --git a/xbmc/cores/dvdplayer/DVDPlayer.cpp b/xbmc/cores/dvdplayer/DVDPlayer.cpp -index 53f82a0..43d2250 100644 +index 964ea2e..35724b9 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayer.cpp @@ -1553,11 +1553,13 @@ void CDVDPlayer::HandlePlaySpeed() @@ -10552,7 +9293,7 @@ index 53f82a0..43d2250 100644 } // if playspeed is different then DVD_PLAYSPEED_NORMAL or DVD_PLAYSPEED_PAUSE -@@ -3173,7 +3177,7 @@ bool CDVDPlayer::CloseTeletextStream(bool bWaitForBuffers) +@@ -3177,7 +3181,7 @@ bool CDVDPlayer::CloseTeletextStream(bool bWaitForBuffers) return true; } @@ -10561,7 +9302,7 @@ index 53f82a0..43d2250 100644 { double startpts; if(accurate) -@@ -3185,19 +3189,23 @@ void CDVDPlayer::FlushBuffers(bool queued, double pts, bool accurate) +@@ -3189,19 +3193,23 @@ void CDVDPlayer::FlushBuffers(bool queued, double pts, bool accurate) if(startpts != DVD_NOPTS_VALUE) startpts -= m_offset_pts; @@ -10589,7 +9330,7 @@ index 53f82a0..43d2250 100644 m_CurrentTeletext.dts = DVD_NOPTS_VALUE; m_CurrentTeletext.startpts = startpts; -@@ -3241,7 +3249,7 @@ void CDVDPlayer::FlushBuffers(bool queued, double pts, bool accurate) +@@ -3245,7 +3253,7 @@ void CDVDPlayer::FlushBuffers(bool queued, double pts, bool accurate) m_CurrentTeletext.started = false; } @@ -10599,10 +9340,10 @@ index 53f82a0..43d2250 100644 UpdatePlayState(0); diff --git a/xbmc/cores/dvdplayer/DVDPlayer.h b/xbmc/cores/dvdplayer/DVDPlayer.h -index 237aba4d..9e54bc8 100644 +index 29dd12a..fa96b24 100644 --- a/xbmc/cores/dvdplayer/DVDPlayer.h +++ b/xbmc/cores/dvdplayer/DVDPlayer.h -@@ -303,7 +303,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer +@@ -304,7 +304,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer bool GetCachingTimes(double& play_left, double& cache_left, double& file_offset); @@ -10611,7 +9352,7 @@ index 237aba4d..9e54bc8 100644 void HandleMessages(); void HandlePlaySpeed(); -@@ -352,8 +352,9 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer +@@ -353,8 +353,9 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer int m_playSpeed; struct SSpeedState { @@ -10624,7 +9365,7 @@ index 237aba4d..9e54bc8 100644 int m_errorCount; diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp -index 5d487f4..8ebe591 100644 +index 6419951..f10aef6 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp @@ -1474,7 +1474,7 @@ double CDVDPlayerVideo::GetCurrentPts() @@ -10661,10 +9402,10 @@ index 59c7f09..65dea76 100644 1.8.4 -From 5de9ba62a3d8a5edf85fdfa511d20cd5734abb56 Mon Sep 17 00:00:00 2001 +From 9c49b80fbd29ca15e4a6db4cabdf6e1344cac8d1 Mon Sep 17 00:00:00 2001 From: xbmc Date: Fri, 23 Nov 2012 17:41:12 +0100 -Subject: [PATCH 43/89] xrandr: fix query for multiple screens +Subject: [PATCH 53/87] xrandr: fix query for multiple screens --- xbmc/windowing/X11/XRandR.cpp | 10 ++++++---- @@ -10705,17 +9446,17 @@ index 9e181f2..ce0a02b 100644 1.8.4 -From 63ff159d4c293343bb4e2f4623960d5cca9fe08b Mon Sep 17 00:00:00 2001 +From 124a74de5613715fd8b9335582f6a59203a2cb02 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 2 Dec 2012 15:46:55 +0100 -Subject: [PATCH 44/89] X11: add debug log to print out refresh after xrr event +Subject: [PATCH 54/87] X11: add debug log to print out refresh after xrr event --- xbmc/windowing/X11/WinSystemX11.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 9ff947c..a3394e6 100644 +index 974ce96..52f3eb2 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -683,6 +683,12 @@ void CWinSystemX11::NotifyXRREvent() @@ -10735,10 +9476,10 @@ index 9ff947c..a3394e6 100644 1.8.4 -From 99677d88e12e04c1f55df152ed91b2b45a0ca84f Mon Sep 17 00:00:00 2001 +From 41932f475debd28e7ce5b2ae48131fc4f78f1691 Mon Sep 17 00:00:00 2001 From: xbmc Date: Tue, 11 Dec 2012 11:08:13 +0100 -Subject: [PATCH 45/89] X11: dont call XCloseDisplay on shutdown, it crashes +Subject: [PATCH 55/87] X11: dont call XCloseDisplay on shutdown, it crashes when powered doen by cec on ATI --- @@ -10746,7 +9487,7 @@ Subject: [PATCH 45/89] X11: dont call XCloseDisplay on shutdown, it crashes 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index a3394e6..b941c14 100644 +index 52f3eb2..54b04b7 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -110,7 +110,8 @@ bool CWinSystemX11::DestroyWindowSystem() @@ -10763,10 +9504,10 @@ index a3394e6..b941c14 100644 1.8.4 -From b4611139075e55b2d1ee293b92b0d71be03a102d Mon Sep 17 00:00:00 2001 +From 2380c28cc3657707f07ad1f4e3852f8d62722e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Coutant?= Date: Wed, 12 Dec 2012 19:49:47 +0100 -Subject: [PATCH 46/89] x11: support for multiple x screens +Subject: [PATCH 56/87] x11: support for multiple x screens --- xbmc/windowing/X11/XRandR.cpp | 2 +- @@ -10789,10 +9530,10 @@ index ce0a02b..aa27d2b 100644 1.8.4 -From df3f1fbff9606b0cb300f93092741f4bfbcfc3a0 Mon Sep 17 00:00:00 2001 +From 77097cfd1cb68cc77ab0d9956027c91a77bd70d4 Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 24 Dec 2012 16:02:42 +0100 -Subject: [PATCH 47/89] pvr: increase changes counter of stream on stream +Subject: [PATCH 57/87] pvr: increase changes counter of stream on stream change, cosmetics after dd307930d39d92f145a01a16600cd00e01ec39be --- @@ -10826,17 +9567,17 @@ index b96d520..df89f6f 100644 1.8.4 -From f5e98c1e09c8d94f9cf21a53ffe2a344fa014c62 Mon Sep 17 00:00:00 2001 +From eee08ebfe9afa7f06ece5767637936bcce583d7e Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 17 Jan 2013 16:03:22 +0100 -Subject: [PATCH 48/89] X11: add keymapping for XF86XK_Sleep +Subject: [PATCH 58/87] X11: add keymapping for XF86XK_Sleep --- xbmc/windowing/WinEventsX11.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 4a5aab4..da5d412 100644 +index a62521f..263cb5a 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp @@ -143,6 +143,7 @@ @@ -10851,10 +9592,10 @@ index 4a5aab4..da5d412 100644 1.8.4 -From 5dd2852d1483975f4fc680011ed8d5bcae0d3fbb Mon Sep 17 00:00:00 2001 +From bf89fb504483cb881b33b4e9993b059844192513 Mon Sep 17 00:00:00 2001 From: xbmc Date: Mon, 21 Jan 2013 09:00:19 +0100 -Subject: [PATCH 49/89] X11: remove toggle full screen after resume +Subject: [PATCH 59/87] X11: remove toggle full screen after resume --- xbmc/powermanagement/PowerManager.cpp | 5 ----- @@ -10880,10 +9621,10 @@ index 2033574..c79bbc1 100644 1.8.4 -From 481f914d9b718fbf7545843e1024bef23363432a Mon Sep 17 00:00:00 2001 +From 7596bd39358cf811a7b52488e0624623812c7572 Mon Sep 17 00:00:00 2001 From: xbmc Date: Wed, 23 Jan 2013 17:03:02 +0100 -Subject: [PATCH 50/89] xrandr: set screen on mode change command +Subject: [PATCH 60/87] xrandr: set screen on mode change command --- xbmc/windowing/X11/XRandR.cpp | 2 +- @@ -10906,10 +9647,10 @@ index aa27d2b..67bf6ca 100644 1.8.4 -From ccaa444562352a6df72c01a2d939f22ef72b7026 Mon Sep 17 00:00:00 2001 +From e408fefbfeccb1eb8fbf525fda547dbdbada9279 Mon Sep 17 00:00:00 2001 From: xbmc Date: Wed, 23 Jan 2013 17:03:39 +0100 -Subject: [PATCH 51/89] X11: recreate glx context when output changes +Subject: [PATCH 61/87] X11: recreate glx context when output changes --- xbmc/windowing/X11/WinSystemX11.cpp | 6 +++--- @@ -10917,7 +9658,7 @@ Subject: [PATCH 51/89] X11: recreate glx context when output changes 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index b941c14..c84e793 100644 +index 54b04b7..6a5a4c2 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -407,11 +407,11 @@ bool CWinSystemX11::IsSuitableVisual(XVisualInfo *vInfo) @@ -10944,10 +9685,10 @@ index b941c14..c84e793 100644 g_graphicsContext.Clear(0); g_graphicsContext.Flip(dr); diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index ce3c289..311e4cc 100644 +index 4175556..11c40f7 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -74,7 +74,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -75,7 +75,7 @@ class CWinSystemX11 : public CWinSystemBase void NotifyMouseCoverage(bool covered); protected: @@ -10960,10 +9701,10 @@ index ce3c289..311e4cc 100644 1.8.4 -From 987b677f98e3e815f9572fee0c3ae75838e5d62b Mon Sep 17 00:00:00 2001 +From 98e2d3b7343c9faa99754c8c10b679f5819316c1 Mon Sep 17 00:00:00 2001 From: xbmc Date: Fri, 14 Dec 2012 14:19:15 +0100 -Subject: [PATCH 52/89] pvr: do not show selection dialog for a single menu +Subject: [PATCH 62/87] pvr: do not show selection dialog for a single menu hook --- @@ -11001,10 +9742,10 @@ index aab6345..a880778 100644 1.8.4 -From 11e37f44d0bfd4f434ab569179656edf45b03ce9 Mon Sep 17 00:00:00 2001 +From 65c92037b8048b87ac1499888f14fbbe3c9efd8e Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 3 Feb 2013 08:17:16 +0100 -Subject: [PATCH 53/89] X11: use default screen parameters if no output +Subject: [PATCH 63/87] X11: use default screen parameters if no output connected --- @@ -11012,7 +9753,7 @@ Subject: [PATCH 53/89] X11: use default screen parameters if no output 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index c84e793..5215f4d 100644 +index 6a5a4c2..369d17d 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -205,25 +205,27 @@ bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool bl @@ -11108,10 +9849,10 @@ index c84e793..5215f4d 100644 1.8.4 -From 33f5ae6ede1dcda97e5813b4aa7f3a312aed3cb4 Mon Sep 17 00:00:00 2001 +From f1bbc4ccc203f0eca551d8e651655d378622e433 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sat, 23 Mar 2013 15:13:32 +0100 -Subject: [PATCH 54/89] X11: create parent window +Subject: [PATCH 64/87] X11: create parent window --- xbmc/windowing/X11/WinSystemX11.cpp | 69 +++++++++++++++++++++++-------------- @@ -11119,7 +9860,7 @@ Subject: [PATCH 54/89] X11: create parent window 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 5215f4d..e49fa98 100644 +index 369d17d..3f52bef 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -53,6 +53,7 @@ @@ -11149,7 +9890,7 @@ index 5215f4d..e49fa98 100644 m_invisibleCursor = 0; } - CWinEvents::Quit(); + CWinEventsX11Imp::Quit(); - XUnmapWindow(m_dpy, m_glWindow); + XUnmapWindow(m_dpy, m_mainWindow); @@ -11297,8 +10038,8 @@ index 5215f4d..e49fa98 100644 + XDefineCursor(m_dpy,m_mainWindow, m_invisibleCursor); //init X11 events -- CWinEvents::Init(m_dpy, m_glWindow); -+ CWinEvents::Init(m_dpy, m_mainWindow); +- CWinEventsX11Imp::Init(m_dpy, m_glWindow); ++ CWinEventsX11Imp::Init(m_dpy, m_mainWindow); changeWindow = true; changeSize = true; @@ -11361,10 +10102,10 @@ index 5215f4d..e49fa98 100644 CDirtyRegionList dr; diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 311e4cc..49365a8 100644 +index 11c40f7..7a4421b 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -79,7 +79,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -80,7 +80,7 @@ class CWinSystemX11 : public CWinSystemBase void OnLostDevice(); bool SetWindow(int width, int height, bool fullscreen, const CStdString &output); @@ -11377,10 +10118,10 @@ index 311e4cc..49365a8 100644 1.8.4 -From b69f89c3983a607eabae8397d50ba5e075c003d0 Mon Sep 17 00:00:00 2001 +From 9ab16e792d80f09cf64a26ecd3cbc8407a750757 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 24 Mar 2013 12:30:12 +0100 -Subject: [PATCH 55/89] X11: use system key repeat rate instead of hardcoded +Subject: [PATCH 65/87] X11: use system key repeat rate instead of hardcoded one, taken from 58fd64b194e38b73b5f3132744bab35e994e7441 --- @@ -11389,10 +10130,10 @@ Subject: [PATCH 55/89] X11: use system key repeat rate instead of hardcoded 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index da5d412..9caeabf 100644 +index 263cb5a..09f56ff 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -204,7 +204,6 @@ bool CWinEventsX11::Init(Display *dpy, Window win) +@@ -213,7 +213,6 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False); WinEvents->m_structureChanged = false; WinEvents->m_xrrEventPending = false; @@ -11400,7 +10141,7 @@ index da5d412..9caeabf 100644 // open input method char *old_locale = NULL, *old_modifiers = NULL; -@@ -319,20 +318,6 @@ bool CWinEventsX11::MessagePump() +@@ -328,20 +327,6 @@ bool CWinEventsX11Imp::MessagePump() memset(&xevent, 0, sizeof (XEvent)); XNextEvent(WinEvents->m_display, &xevent); @@ -11421,7 +10162,7 @@ index da5d412..9caeabf 100644 if (XFilterEvent(&xevent, None)) continue; -@@ -355,7 +340,6 @@ bool CWinEventsX11::MessagePump() +@@ -364,7 +349,6 @@ bool CWinEventsX11Imp::MessagePump() if (WinEvents->m_xic) XSetICFocus(WinEvents->m_xic); g_application.m_AppFocused = true; @@ -11429,7 +10170,7 @@ index da5d412..9caeabf 100644 WinEvents->m_keymodState = 0; if (serial == xevent.xfocus.serial) break; -@@ -368,7 +352,6 @@ bool CWinEventsX11::MessagePump() +@@ -377,7 +361,6 @@ bool CWinEventsX11Imp::MessagePump() if (WinEvents->m_xic) XUnsetICFocus(WinEvents->m_xic); g_application.m_AppFocused = false; @@ -11437,7 +10178,7 @@ index da5d412..9caeabf 100644 g_Windowing.NotifyAppFocusChange(g_application.m_AppFocused); serial = xevent.xfocus.serial; break; -@@ -424,7 +407,7 @@ bool CWinEventsX11::MessagePump() +@@ -433,7 +416,7 @@ bool CWinEventsX11Imp::MessagePump() { newEvent.key.keysym.unicode = keybuf[0]; } @@ -11446,7 +10187,7 @@ index da5d412..9caeabf 100644 break; } -@@ -463,7 +446,7 @@ bool CWinEventsX11::MessagePump() +@@ -472,7 +455,7 @@ bool CWinEventsX11Imp::MessagePump() newEvent.key.keysym.unicode = keys[i]; newEvent.key.state = xevent.xkey.state; newEvent.key.type = xevent.xkey.type; @@ -11455,7 +10196,7 @@ index da5d412..9caeabf 100644 } if (keys.length() > 0) { -@@ -474,7 +457,7 @@ bool CWinEventsX11::MessagePump() +@@ -483,7 +466,7 @@ bool CWinEventsX11Imp::MessagePump() newEvent.key.state = xevent.xkey.state; newEvent.key.type = xevent.xkey.type; @@ -11464,7 +10205,7 @@ index da5d412..9caeabf 100644 } break; } -@@ -485,7 +468,7 @@ bool CWinEventsX11::MessagePump() +@@ -494,7 +477,7 @@ bool CWinEventsX11Imp::MessagePump() newEvent.key.keysym.sym = LookupXbmcKeySym(xkeysym); newEvent.key.state = xevent.xkey.state; newEvent.key.type = xevent.xkey.type; @@ -11473,7 +10214,7 @@ index da5d412..9caeabf 100644 break; } -@@ -495,6 +478,18 @@ bool CWinEventsX11::MessagePump() +@@ -504,6 +487,18 @@ bool CWinEventsX11Imp::MessagePump() case KeyRelease: { @@ -11492,7 +10233,7 @@ index da5d412..9caeabf 100644 XBMC_Event newEvent; KeySym xkeysym; memset(&newEvent, 0, sizeof(newEvent)); -@@ -504,7 +499,7 @@ bool CWinEventsX11::MessagePump() +@@ -513,7 +508,7 @@ bool CWinEventsX11Imp::MessagePump() newEvent.key.keysym.sym = LookupXbmcKeySym(xkeysym); newEvent.key.state = xevent.xkey.state; newEvent.key.type = xevent.xkey.type; @@ -11501,7 +10242,7 @@ index da5d412..9caeabf 100644 break; } -@@ -580,8 +575,6 @@ bool CWinEventsX11::MessagePump() +@@ -589,8 +584,6 @@ bool CWinEventsX11Imp::MessagePump() }// while @@ -11510,16 +10251,16 @@ index da5d412..9caeabf 100644 #if defined(HAS_XRANDR) if (WinEvents && WinEvents->m_xrrEventPending && WinEvents->m_xrrFailSafeTimer.IsTimePast()) { -@@ -616,7 +609,7 @@ bool CWinEventsX11::MessagePump() +@@ -635,7 +628,7 @@ size_t CWinEventsX11Imp::GetQueueSize() return ret; } --bool CWinEventsX11::ProcessKey(XBMC_Event &event, int repeatDelay) -+bool CWinEventsX11::ProcessKey(XBMC_Event &event) +-bool CWinEventsX11Imp::ProcessKey(XBMC_Event &event, int repeatDelay) ++bool CWinEventsX11Imp::ProcessKey(XBMC_Event &event) { if (event.type == XBMC_KEYDOWN) { -@@ -654,8 +647,6 @@ bool CWinEventsX11::ProcessKey(XBMC_Event &event, int repeatDelay) +@@ -673,8 +666,6 @@ bool CWinEventsX11Imp::ProcessKey(XBMC_Event &event, int repeatDelay) break; } event.key.keysym.mod = (XBMCMod)WinEvents->m_keymodState; @@ -11528,7 +10269,7 @@ index da5d412..9caeabf 100644 bool ret = ProcessShortcuts(event); if (ret) -@@ -696,7 +687,6 @@ bool CWinEventsX11::ProcessKey(XBMC_Event &event, int repeatDelay) +@@ -715,7 +706,6 @@ bool CWinEventsX11Imp::ProcessKey(XBMC_Event &event, int repeatDelay) break; } event.key.keysym.mod = (XBMCMod)WinEvents->m_keymodState; @@ -11536,11 +10277,11 @@ index da5d412..9caeabf 100644 } return g_application.OnEvent(event); -@@ -719,18 +709,6 @@ bool CWinEventsX11::ProcessShortcuts(XBMC_Event& event) +@@ -738,18 +728,6 @@ bool CWinEventsX11Imp::ProcessShortcuts(XBMC_Event& event) return false; } --bool CWinEventsX11::ProcessKeyRepeat() +-bool CWinEventsX11Imp::ProcessKeyRepeat() -{ - if (WinEvents && (WinEvents->m_lastKey.type == XBMC_KEYDOWN)) - { @@ -11552,14 +10293,14 @@ index da5d412..9caeabf 100644 - return false; -} - - XBMCKey CWinEventsX11::LookupXbmcKeySym(KeySym keysym) + XBMCKey CWinEventsX11Imp::LookupXbmcKeySym(KeySym keysym) { // try direct mapping first diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h -index 102a076..5b1f3fa 100644 +index c69169c..6429291 100644 --- a/xbmc/windowing/WinEventsX11.h +++ b/xbmc/windowing/WinEventsX11.h -@@ -39,8 +39,7 @@ class CWinEventsX11 : public CWinEventsBase +@@ -47,8 +47,7 @@ class CWinEventsX11Imp protected: static XBMCKey LookupXbmcKeySym(KeySym keysym); @@ -11567,9 +10308,9 @@ index 102a076..5b1f3fa 100644 - static bool ProcessKeyRepeat(); + static bool ProcessKey(XBMC_Event &event); static bool ProcessShortcuts(XBMC_Event& event); - static CWinEventsX11 *WinEvents; + static CWinEventsX11Imp *WinEvents; Display *m_display; -@@ -50,8 +49,6 @@ class CWinEventsX11 : public CWinEventsBase +@@ -58,8 +57,6 @@ class CWinEventsX11Imp size_t m_keybuf_len; XIM m_xim; XIC m_xic; @@ -11582,10 +10323,10 @@ index 102a076..5b1f3fa 100644 1.8.4 -From 27e135bea951de724c15336a1011ee37aa800fb8 Mon Sep 17 00:00:00 2001 +From 860b54d09e2ad226db3a9815d38adb6ae810fe66 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 24 Mar 2013 16:04:48 +0100 -Subject: [PATCH 56/89] linux: use CLOCK_MONOTONIC_RAW as this is not subject +Subject: [PATCH 66/87] linux: use CLOCK_MONOTONIC_RAW as this is not subject to NTP --- @@ -11623,17 +10364,17 @@ index c06b8c5..4390d2e 100644 1.8.4 -From ae3cab96cd87fb187eaea93d8ae7c3d5587cacd7 Mon Sep 17 00:00:00 2001 +From e49abd4cb3403d922a9502a6afb8baffd01d54f0 Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 28 Mar 2013 15:18:53 +0100 -Subject: [PATCH 57/89] OMXPlayer: some caching fixes for pvr +Subject: [PATCH 67/87] OMXPlayer: some caching fixes for pvr --- xbmc/cores/omxplayer/OMXPlayer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/cores/omxplayer/OMXPlayer.cpp b/xbmc/cores/omxplayer/OMXPlayer.cpp -index 5efe74c..073c40a 100644 +index 401b7a9..733514e 100644 --- a/xbmc/cores/omxplayer/OMXPlayer.cpp +++ b/xbmc/cores/omxplayer/OMXPlayer.cpp @@ -2465,7 +2465,8 @@ void COMXPlayer::HandleMessages() @@ -11650,17 +10391,17 @@ index 5efe74c..073c40a 100644 1.8.4 -From cc370216e640ae4598ba861cd0cde12a89ebc7ff Mon Sep 17 00:00:00 2001 +From ea1fb64f2aabbb9956c094c9fe15075025afb37e Mon Sep 17 00:00:00 2001 From: xbmc Date: Thu, 28 Mar 2013 20:50:59 +0100 -Subject: [PATCH 58/89] fix incorrect display of fps when dr kicks in +Subject: [PATCH 68/87] fix incorrect display of fps when dr kicks in --- xbmc/Application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp -index 1062469..29e9aa9 100644 +index 3dbc541..b5d40c0 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -2190,10 +2190,11 @@ void CApplication::Render() @@ -11680,10 +10421,10 @@ index 1062469..29e9aa9 100644 1.8.4 -From dcff2ce062d717c0e80f1a05b6bf59fb593dec3c Mon Sep 17 00:00:00 2001 +From 009d185d231458647c50ecb743ae8ef03f47f263 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sat, 13 Apr 2013 08:32:06 +0200 -Subject: [PATCH 59/89] X11: fix mouse coverage +Subject: [PATCH 69/87] X11: fix mouse coverage --- xbmc/windowing/X11/WinSystemX11.cpp | 11 ++++++++--- @@ -11691,7 +10432,7 @@ Subject: [PATCH 59/89] X11: fix mouse coverage 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index e49fa98..186a28e 100644 +index 3f52bef..9467e00 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -581,10 +581,10 @@ void CWinSystemX11::NotifyAppFocusChange(bool bGaining) @@ -11734,10 +10475,10 @@ index e49fa98..186a28e 100644 CDirtyRegionList dr; RefreshGlxContext(!m_currentOutput.Equals(output)); diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 49365a8..924af1d 100644 +index 7a4421b..4259394 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -88,6 +88,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -89,6 +89,7 @@ class CWinSystemX11 : public CWinSystemBase bool m_bWasFullScreenBeforeMinimize; bool m_minimized; bool m_bIgnoreNextFocusMessage; @@ -11749,10 +10490,10 @@ index 49365a8..924af1d 100644 1.8.4 -From 744f793f1d5fea28caec58a72fc6f034afbf72c8 Mon Sep 17 00:00:00 2001 +From be8e42ae76420089bd7e0fef4a30511eefc0c55b Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Wed, 8 May 2013 13:14:58 +0200 -Subject: [PATCH 60/89] X11: fix incorrectly used screen num in desktop +Subject: [PATCH 70/87] X11: fix incorrectly used screen num in desktop resolution --- @@ -11760,7 +10501,7 @@ Subject: [PATCH 60/89] X11: fix incorrectly used screen num in desktop 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 186a28e..66955b8 100644 +index 9467e00..18c2d8b 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -266,9 +266,9 @@ void CWinSystemX11::UpdateResolutions() @@ -11787,10 +10528,10 @@ index 186a28e..66955b8 100644 1.8.4 -From 34bd5e81577cea971b77f023da077fa8760884be Mon Sep 17 00:00:00 2001 +From 2a4a307eae1b09e20e6a6e0037c4429c18c717ac Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Thu, 9 May 2013 12:07:09 +0200 -Subject: [PATCH 61/89] X11: do not overwrite user selected monitor with +Subject: [PATCH 71/87] X11: do not overwrite user selected monitor with fallback --- @@ -11799,7 +10540,7 @@ Subject: [PATCH 61/89] X11: do not overwrite user selected monitor with 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 66955b8..2ce64af 100644 +index 18c2d8b..26c7363 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -170,7 +170,7 @@ bool CWinSystemX11::ResizeWindow(int newWidth, int newHeight, int newLeft, int n @@ -11900,10 +10641,10 @@ index 66955b8..2ce64af 100644 if (out) CLog::Log(LOGDEBUG, "%s - current output: %s, mode: %s, refresh: %.3f", __FUNCTION__ diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 924af1d..2fb9e0f 100644 +index 4259394..c670129 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -94,6 +94,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -95,6 +95,7 @@ class CWinSystemX11 : public CWinSystemBase std::vector m_resources; uint64_t m_dpyLostTime; CStdString m_currentOutput; @@ -11915,10 +10656,10 @@ index 924af1d..2fb9e0f 100644 1.8.4 -From 4c883e3564fcf25ac3e00c54678c9dbd0469a014 Mon Sep 17 00:00:00 2001 +From 5ed22fb0a820e10c05c8bf625a151e392e122c77 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 12 May 2013 10:50:30 +0200 -Subject: [PATCH 62/89] xrandr: add turn on/off to wrapper +Subject: [PATCH 72/87] xrandr: add turn on/off to wrapper --- xbmc/windowing/X11/XRandR.cpp | 78 +++++++++++++++++++++++++++++++++++++++---- @@ -12084,10 +10825,10 @@ index d37838a..059062f 100644 1.8.4 -From 8b5ab736c4088315dd6014ac868a80a6e637b90f Mon Sep 17 00:00:00 2001 +From 648277b1429883e019ff8d6e5539046a8fedb96d Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 19 May 2013 12:55:35 +0200 -Subject: [PATCH 63/89] xrandr: add GetPreferredMode to wrapper +Subject: [PATCH 73/87] xrandr: add GetPreferredMode to wrapper --- xbmc/windowing/X11/XRandR.cpp | 23 +++++++++++++++++++++++ @@ -12144,10 +10885,10 @@ index 059062f..ab7cc63 100644 1.8.4 -From 11bd4c6b9f4f0b607644f98d21f8d03317725d40 Mon Sep 17 00:00:00 2001 +From 594130e8ad3581d6aba24af269ac15a9416e6c2c Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 11 May 2013 17:12:12 +0200 -Subject: [PATCH 64/89] X11: multi-head improvement - poll for desired output +Subject: [PATCH 74/87] X11: multi-head improvement - poll for desired output if we do not get an xrr event --- @@ -12162,10 +10903,10 @@ Subject: [PATCH 64/89] X11: multi-head improvement - poll for desired output 8 files changed, 105 insertions(+), 12 deletions(-) diff --git a/language/English/strings.po b/language/English/strings.po -index e22508c..bbc73f8 100755 +index c8734c1..b5dc856 100755 --- a/language/English/strings.po +++ b/language/English/strings.po -@@ -6263,7 +6263,7 @@ msgctxt "#14071" +@@ -6262,7 +6262,7 @@ msgctxt "#14071" msgid "Allow file renaming and deletion" msgstr "" @@ -12174,7 +10915,7 @@ index e22508c..bbc73f8 100755 msgctxt "#14074" msgid "Set timezone" -@@ -6395,7 +6395,12 @@ msgctxt "#14100" +@@ -6394,7 +6394,12 @@ msgctxt "#14100" msgid "Stop ripping CD" msgstr "" @@ -12189,10 +10930,10 @@ index e22508c..bbc73f8 100755 #: xbmc/dialogs/GUIDialogFavourites.cpp msgctxt "#15015" diff --git a/system/settings/settings.xml b/system/settings/settings.xml -index e117a9d..bd0f3c7 100644 +index 9312642..f39ca48 100644 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml -@@ -1858,6 +1858,11 @@ +@@ -1853,6 +1853,11 @@ @@ -12204,7 +10945,7 @@ index e117a9d..bd0f3c7 100644 0 0 -@@ -1909,6 +1914,7 @@ +@@ -1904,6 +1909,7 @@ @@ -12228,10 +10969,10 @@ index 1a85651..46895d2 100644 return true; } diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 9caeabf..6ddaead 100644 +index 09f56ff..908c8b6 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -204,6 +204,7 @@ bool CWinEventsX11::Init(Display *dpy, Window win) +@@ -213,6 +213,7 @@ bool CWinEventsX11Imp::Init(Display *dpy, Window win) WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False); WinEvents->m_structureChanged = false; WinEvents->m_xrrEventPending = false; @@ -12239,7 +10980,7 @@ index 9caeabf..6ddaead 100644 // open input method char *old_locale = NULL, *old_modifiers = NULL; -@@ -582,6 +583,11 @@ bool CWinEventsX11::MessagePump() +@@ -591,6 +592,11 @@ bool CWinEventsX11Imp::MessagePump() g_Windowing.NotifyXRREvent(); WinEvents->m_xrrEventPending = false; } @@ -12252,10 +10993,10 @@ index 9caeabf..6ddaead 100644 #ifdef HAS_SDL_JOYSTICK diff --git a/xbmc/windowing/WinEventsX11.h b/xbmc/windowing/WinEventsX11.h -index 5b1f3fa..d4a4b47 100644 +index 6429291..91a604f 100644 --- a/xbmc/windowing/WinEventsX11.h +++ b/xbmc/windowing/WinEventsX11.h -@@ -54,5 +54,6 @@ class CWinEventsX11 : public CWinEventsBase +@@ -62,5 +62,6 @@ class CWinEventsX11Imp bool m_structureChanged; int m_RREventBase; XbmcThreads::EndTime m_xrrFailSafeTimer; @@ -12263,7 +11004,7 @@ index 5b1f3fa..d4a4b47 100644 bool m_xrrEventPending; }; diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 2ce64af..7e4b637 100644 +index 26c7363..cc3ac9f 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -250,18 +250,62 @@ void CWinSystemX11::UpdateResolutions() @@ -12392,10 +11133,10 @@ index 2ce64af..7e4b637 100644 found = true; break; diff --git a/xbmc/windowing/X11/WinSystemX11.h b/xbmc/windowing/X11/WinSystemX11.h -index 2fb9e0f..ec01bf7 100644 +index c670129..776dd59 100644 --- a/xbmc/windowing/X11/WinSystemX11.h +++ b/xbmc/windowing/X11/WinSystemX11.h -@@ -68,7 +68,7 @@ class CWinSystemX11 : public CWinSystemBase +@@ -69,7 +69,7 @@ class CWinSystemX11 : public CWinSystemBase Display* GetDisplay() { return m_dpy; } GLXWindow GetWindow() { return m_glWindow; } GLXContext GetGlxContext() { return m_glContext; } @@ -12428,20 +11169,20 @@ index 4809821..1ad26b2 100644 1.8.4 -From de1a796eb8d68ec88ffc3b4b4431e433ba76b288 Mon Sep 17 00:00:00 2001 +From 30958530b5ed9bc69087f13d4cc07134868396b8 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Wed, 15 May 2013 09:14:34 +0200 -Subject: [PATCH 65/89] X11: ignore mouse move event form other windows +Subject: [PATCH 75/87] X11: ignore mouse move event form other windows --- xbmc/windowing/WinEventsX11.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 6ddaead..e4451fe 100644 +index 908c8b6..938ad26 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -319,7 +319,7 @@ bool CWinEventsX11::MessagePump() +@@ -328,7 +328,7 @@ bool CWinEventsX11Imp::MessagePump() memset(&xevent, 0, sizeof (XEvent)); XNextEvent(WinEvents->m_display, &xevent); @@ -12450,7 +11191,7 @@ index 6ddaead..e4451fe 100644 continue; switch (xevent.type) -@@ -520,6 +520,8 @@ bool CWinEventsX11::MessagePump() +@@ -529,6 +529,8 @@ bool CWinEventsX11Imp::MessagePump() case MotionNotify: { @@ -12463,10 +11204,10 @@ index 6ddaead..e4451fe 100644 1.8.4 -From b2f394a293f888a23aac68a5470bdbe8ff1b051d Mon Sep 17 00:00:00 2001 +From 27760ac79b856d7ecbb11f41c9317bb89412a626 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Tue, 11 Jun 2013 16:20:29 +0200 -Subject: [PATCH 66/89] renderer: allow some lateness within vblank interval +Subject: [PATCH 76/87] renderer: allow some lateness within vblank interval --- xbmc/cores/VideoRenderers/RenderManager.cpp | 12 ++++++++++-- @@ -12474,10 +11215,10 @@ Subject: [PATCH 66/89] renderer: allow some lateness within vblank interval 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp -index 08d6230..d8eaac9 100644 +index c0a6409..8539e0f 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp -@@ -393,6 +393,8 @@ void CXBMCRenderManager::FrameFinish() +@@ -394,6 +394,8 @@ void CXBMCRenderManager::FrameFinish() if(g_graphicsContext.IsFullScreenVideo()) WaitPresentTime(m.timestamp); @@ -12486,7 +11227,7 @@ index 08d6230..d8eaac9 100644 { CSingleLock lock(m_presentlock); if(m_presentstep == PRESENT_FRAME) -@@ -1045,6 +1047,12 @@ void CXBMCRenderManager::PrepareNextRender() +@@ -1044,6 +1046,12 @@ void CXBMCRenderManager::PrepareNextRender() double clocktime = GetPresentTime(); double frametime = 1.0 / GetMaximumFPS(); @@ -12499,7 +11240,7 @@ index 08d6230..d8eaac9 100644 /* see if any future queued frames are already due */ std::deque::reverse_iterator curr, prev; -@@ -1053,8 +1061,8 @@ void CXBMCRenderManager::PrepareNextRender() +@@ -1052,8 +1060,8 @@ void CXBMCRenderManager::PrepareNextRender() ++prev; while (prev != m_queued.rend()) { @@ -12526,20 +11267,20 @@ index befd851..27283ec 100644 1.8.4 -From b366859f9f850e5ebd9db110f0a59f6799a549eb Mon Sep 17 00:00:00 2001 +From 248554d928f50ff7fc5c50771bc6664e5df09596 Mon Sep 17 00:00:00 2001 From: xbmc Date: Sun, 16 Jun 2013 13:22:58 +0200 -Subject: [PATCH 67/89] X11: another fix for mouse coverage +Subject: [PATCH 77/87] X11: another fix for mouse coverage --- xbmc/windowing/WinEventsX11.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index e4451fe..582b9f5 100644 +index 938ad26..e4ca56d 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -506,14 +506,16 @@ bool CWinEventsX11::MessagePump() +@@ -515,14 +515,16 @@ bool CWinEventsX11Imp::MessagePump() case EnterNotify: { @@ -12562,17 +11303,17 @@ index e4451fe..582b9f5 100644 1.8.4 -From 076fd44cb2667c74187aadee6bef4a0f9c6638f4 Mon Sep 17 00:00:00 2001 +From c686dbe23d86f0b39ff8a401a630856ffc4ded9e Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 5 Jul 2013 12:14:00 +0200 -Subject: [PATCH 68/89] X11: set windows class name +Subject: [PATCH 78/87] X11: set windows class name --- xbmc/windowing/X11/WinSystemX11.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 7e4b637..44e40a3 100644 +index cc3ac9f..46cbd34 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -980,8 +980,10 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const CStd @@ -12607,20 +11348,20 @@ index 7e4b637..44e40a3 100644 1.8.4 -From a04263e214ef25e47ac54b1002bfdec4beb4f008 Mon Sep 17 00:00:00 2001 +From 18555953f53ad9dc0339b853ae471de550cf42f9 Mon Sep 17 00:00:00 2001 From: spiff Date: Tue, 16 Jul 2013 14:34:04 +0200 -Subject: [PATCH 69/89] fixed: typo +Subject: [PATCH 79/87] fixed: typo --- language/English/strings.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/English/strings.po b/language/English/strings.po -index bbc73f8..a29df53 100755 +index b5dc856..4c8ceac 100755 --- a/language/English/strings.po +++ b/language/English/strings.po -@@ -6397,7 +6397,7 @@ msgstr "" +@@ -6396,7 +6396,7 @@ msgstr "" #: xbmc/settings/settings.xml msgctxt "#14101" @@ -12633,17 +11374,17 @@ index bbc73f8..a29df53 100755 1.8.4 -From e66a57e5f4449af10305799b3db8d73dd47c484e Mon Sep 17 00:00:00 2001 +From 8d4aafdb39f507d4f498eac066bae45b7f2415c2 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Thu, 25 Jul 2013 17:18:13 +0200 -Subject: [PATCH 70/89] ActiveAE: slightly reduce buffer size +Subject: [PATCH 80/87] ActiveAE: slightly reduce buffer size --- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -index c0746dc..e20c12e 100644 +index 6fbed5c..4cae9e8 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp @@ -30,8 +30,8 @@ @@ -12661,22 +11402,22 @@ index c0746dc..e20c12e 100644 1.8.4 -From 2b8502e684260155b8940b1895e20b15643b4f09 Mon Sep 17 00:00:00 2001 +From 8f8488b32d1f92ab11e92fc3e9278474c92de57b Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sun, 4 Aug 2013 10:11:16 +0200 -Subject: [PATCH 71/89] Revert "vdpau: comment some features that will be added +Subject: [PATCH 81/87] Revert "vdpau: comment some features that will be added later" This reverts commit e00b4f65864d623ab4d2e9e5c06db138e661f1cf. --- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 15 +++++---------- - 1 file changed, 5 insertions(+), 10 deletions(-) + xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 12 ++++-------- + 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index 733f4f8..33bd873 100644 +index 7ee2ed9..7201c21 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -938,8 +938,7 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) +@@ -1074,8 +1074,7 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) m_bufferStats.IncDecoded(); m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic)); @@ -12686,27 +11427,17 @@ index 733f4f8..33bd873 100644 } int retval = 0; -@@ -994,8 +993,7 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) - msg->Release(); - } - -- // TODO -- if (1) //(m_codecControl & DVP_FLAG_DRAIN)) -+ if ((m_codecControl & DVP_FLAG_DRAIN)) - { - if (decoded + processed + render < 4) - { -@@ -2159,8 +2157,7 @@ void CMixer::InitCycle() +@@ -2273,8 +2272,7 @@ void CMixer::InitCycle() int flags; + uint64_t latency; m_config.stats->GetParams(latency, flags); - latency = (latency*1000)/CurrentHostFrequency(); - // TODO - if (0) //flags & DVP_FLAG_NO_POSTPROC) + if (flags & DVP_FLAG_NO_POSTPROC) SetPostProcFeatures(false); else SetPostProcFeatures(true); -@@ -2171,8 +2168,7 @@ void CMixer::InitCycle() +@@ -2285,8 +2283,7 @@ void CMixer::InitCycle() EINTERLACEMETHOD method = GetDeinterlacingMethod(); bool interlaced = m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_INTERLACED; @@ -12716,7 +11447,7 @@ index 733f4f8..33bd873 100644 (mode == VS_DEINTERLACEMODE_FORCE || (mode == VS_DEINTERLACEMODE_AUTO && interlaced))) { -@@ -2194,8 +2190,7 @@ void CMixer::InitCycle() +@@ -2308,8 +2305,7 @@ void CMixer::InitCycle() m_config.stats->SetCanSkipDeint(true); } @@ -12730,20 +11461,20 @@ index 733f4f8..33bd873 100644 1.8.4 -From 40eb45cffaf2e9bfdc415e8bb1dcc4cd85ad31ea Mon Sep 17 00:00:00 2001 +From e708771b67ec04ff8bf659340f7f8c54ca299277 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 9 Aug 2013 18:01:40 +0200 -Subject: [PATCH 72/89] X11: fix keysyms +Subject: [PATCH 82/87] X11: fix keysyms --- xbmc/windowing/WinEventsX11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index 582b9f5..ca31278 100644 +index e4ca56d..b20130c 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -452,7 +452,7 @@ bool CWinEventsX11::MessagePump() +@@ -461,7 +461,7 @@ bool CWinEventsX11Imp::MessagePump() if (keys.length() > 0) { newEvent.key.keysym.scancode = xevent.xkey.keycode; @@ -12756,20 +11487,20 @@ index 582b9f5..ca31278 100644 1.8.4 -From be7f6e19950c2e8d27e8d1610582014cb462d49c Mon Sep 17 00:00:00 2001 +From 94d6da106b1afcf17c6bfae19d93b4a1fe6f468f Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 9 Aug 2013 18:42:36 +0200 -Subject: [PATCH 73/89] X11: fix keysym for non-IM +Subject: [PATCH 83/87] X11: fix keysym for non-IM --- xbmc/windowing/WinEventsX11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/windowing/WinEventsX11.cpp b/xbmc/windowing/WinEventsX11.cpp -index ca31278..db50d3c 100644 +index b20130c..a38890c 100644 --- a/xbmc/windowing/WinEventsX11.cpp +++ b/xbmc/windowing/WinEventsX11.cpp -@@ -399,7 +399,7 @@ bool CWinEventsX11::MessagePump() +@@ -408,7 +408,7 @@ bool CWinEventsX11Imp::MessagePump() { static XComposeStatus state; char keybuf[32]; @@ -12782,10 +11513,10 @@ index ca31278..db50d3c 100644 1.8.4 -From 454d6cd04fe4b9af30dec0d6e908d4d64add4c08 Mon Sep 17 00:00:00 2001 +From dacba102b96636a741e22c55534fdc84e66755a9 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 10 Aug 2013 11:18:16 +0200 -Subject: [PATCH 74/89] add some missing multi media keys +Subject: [PATCH 84/87] add some missing multi media keys --- system/keymaps/keyboard.xml | 3 +++ @@ -12840,10 +11571,10 @@ index ee6bb69..364b45a 100644 1.8.4 -From b9fbe60eca67a541e5f4b9e22a22e3db60c9908e Mon Sep 17 00:00:00 2001 +From dfb632797b50b0c4e0121f1befd1c9ca62652c32 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 10 Aug 2013 15:32:06 +0200 -Subject: [PATCH 75/89] CWinSystemBase: keep RES_DESKTOP untouched at pos 0, +Subject: [PATCH 85/87] CWinSystemBase: keep RES_DESKTOP untouched at pos 0, fixes toggle fullscreen --- @@ -12878,17 +11609,17 @@ index bad5c95..b789134 100644 1.8.4 -From a12a98d75ca173e9ceae7add9e33b9bd4cca1976 Mon Sep 17 00:00:00 2001 +From b840e9ebe2dcc8297a8a27e0b153b651d56b991e Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 10 Aug 2013 15:53:45 +0200 -Subject: [PATCH 76/89] X11: squash multi +Subject: [PATCH 86/87] X11: squash multi --- xbmc/windowing/X11/WinSystemX11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index 44e40a3..a00481e 100644 +index 46cbd34..a557978 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -435,7 +435,7 @@ void CWinSystemX11::GetConnectedOutputs(std::vector *outputs) @@ -12904,17 +11635,17 @@ index 44e40a3..a00481e 100644 1.8.4 -From 36dc908397084f27c11576cef38b69dff14a292b Mon Sep 17 00:00:00 2001 +From e7eb33d4919038180956310793592c9af0ba5d65 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Tue, 3 Sep 2013 20:46:17 +0200 -Subject: [PATCH 77/89] X11: do not poll default monitor +Subject: [PATCH 87/87] X11: do not poll default monitor --- xbmc/windowing/X11/WinSystemX11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp -index a00481e..58ee352 100644 +index a557978..87e820e 100644 --- a/xbmc/windowing/X11/WinSystemX11.cpp +++ b/xbmc/windowing/X11/WinSystemX11.cpp @@ -720,7 +720,7 @@ void CWinSystemX11::NotifyXRREvent(bool poll) @@ -12929,3117 +11660,3 @@ index a00481e..58ee352 100644 -- 1.8.4 - -From b0094b70a6eb9aaa21277cbb8d917a5793f979b3 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Thu, 12 Sep 2013 22:28:50 +0200 -Subject: [PATCH 78/89] vdpau: exit gfx lock in OnLostDevice and OnResetDevice - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index 33bd873..f318216 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -289,6 +289,8 @@ void CDecoder::OnLostDevice() - { - CLog::Log(LOGNOTICE,"CVDPAU::OnLostDevice event"); - -+ int count = g_graphicsContext.exit(); -+ - CSingleLock lock(m_DecoderSection); - FiniVDPAUOutput(); - FiniVDPAUProcs(); -@@ -296,12 +298,16 @@ void CDecoder::OnLostDevice() - m_DisplayState = VDPAU_LOST; - lock.Leave(); - m_DisplayEvent.Reset(); -+ -+ g_graphicsContext.restore(count); - } - - void CDecoder::OnResetDevice() - { - CLog::Log(LOGNOTICE,"CVDPAU::OnResetDevice event"); - -+ int count = g_graphicsContext.exit(); -+ - CSingleLock lock(m_DecoderSection); - if (m_DisplayState == VDPAU_LOST) - { -@@ -309,6 +315,8 @@ void CDecoder::OnResetDevice() - lock.Leave(); - m_DisplayEvent.Set(); - } -+ -+ g_graphicsContext.restore(count); - } - - int CDecoder::Check(AVCodecContext* avctx) --- -1.8.4 - - -From ca6baa72209d77f965ca73e27ff8eb83d9b930f0 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Tue, 17 Sep 2013 18:21:43 +0200 -Subject: [PATCH 79/89] vdpau: increase timeout for display event, some systems - are too slow switching refresh rate - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index f318216..605d83b 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -330,7 +330,7 @@ int CDecoder::Check(AVCodecContext* avctx) - if (state == VDPAU_LOST) - { - CLog::Log(LOGNOTICE,"CVDPAU::Check waiting for display reset event"); -- if (!m_DisplayEvent.WaitMSec(2000)) -+ if (!m_DisplayEvent.WaitMSec(4000)) - { - CLog::Log(LOGERROR, "CVDPAU::Check - device didn't reset in reasonable time"); - state = VDPAU_RESET; --- -1.8.4 - - -From 75be1c5fcf7b69b1daa95620d3450322b171ddb1 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Sat, 21 Sep 2013 14:17:09 +0200 -Subject: [PATCH 80/89] vdpau: drop old ffmpeg vdpau_render_state - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 392 ++++++++++++++----------- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 39 ++- - 2 files changed, 244 insertions(+), 187 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index 605d83b..e0784c4 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -80,6 +80,152 @@ - void* CDecoder::dl_handle; - - //----------------------------------------------------------------------------- -+// VDPAU Video Surface states -+//----------------------------------------------------------------------------- -+ -+#define SURFACE_USED_FOR_REFERENCE 0x01 -+#define SURFACE_USED_FOR_RENDER 0x02 -+ -+void CVideoSurfaces::AddSurface(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ m_state[surf] = SURFACE_USED_FOR_REFERENCE; -+} -+ -+void CVideoSurfaces::ClearReference(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ if (m_state.find(surf) == m_state.end()) -+ { -+ CLog::Log(LOGWARNING, "CVideoSurfaces::ClearReference - surface invalid"); -+ return; -+ } -+ m_state[surf] &= ~SURFACE_USED_FOR_REFERENCE; -+ if (m_state[surf] == 0) -+ { -+ m_freeSurfaces.push_back(surf); -+ } -+} -+ -+bool CVideoSurfaces::MarkRender(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ if (m_state.find(surf) == m_state.end()) -+ { -+ CLog::Log(LOGWARNING, "CVideoSurfaces::MarkRender - surface invalid"); -+ return false; -+ } -+ std::list::iterator it; -+ it = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); -+ if (it != m_freeSurfaces.end()) -+ { -+ CLog::Log(LOGWARNING, "CVideoSurfaces::MarkRender - surface invalid 2"); -+ return false; -+ } -+ m_state[surf] |= SURFACE_USED_FOR_RENDER; -+ return true; -+} -+ -+void CVideoSurfaces::ClearRender(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ if (m_state.find(surf) == m_state.end()) -+ { -+ CLog::Log(LOGWARNING, "CVideoSurfaces::ClearRender - surface invalid"); -+ return; -+ } -+ m_state[surf] &= ~SURFACE_USED_FOR_RENDER; -+ if (m_state[surf] == 0) -+ { -+ m_freeSurfaces.push_back(surf); -+ } -+} -+ -+bool CVideoSurfaces::IsValid(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ if (m_state.find(surf) != m_state.end()) -+ return true; -+ else -+ return false; -+} -+ -+VdpVideoSurface CVideoSurfaces::GetFree(VdpVideoSurface surf) -+{ -+ CSingleLock lock(m_section); -+ if (m_state.find(surf) != m_state.end()) -+ { -+ std::list::iterator it; -+ it = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); -+ if (it == m_freeSurfaces.end()) -+ { -+ CLog::Log(LOGWARNING, "CVideoSurfaces::GetFree - surface not free"); -+ } -+ else -+ { -+ m_freeSurfaces.erase(it); -+ m_state[surf] = SURFACE_USED_FOR_REFERENCE; -+ return surf; -+ } -+ } -+ -+ if (!m_freeSurfaces.empty()) -+ { -+ VdpVideoSurface freeSurf = m_freeSurfaces.front(); -+ m_freeSurfaces.pop_front(); -+ m_state[freeSurf] = SURFACE_USED_FOR_REFERENCE; -+ return freeSurf; -+ } -+ -+ return VDP_INVALID_HANDLE; -+} -+ -+VdpVideoSurface CVideoSurfaces::GetAtIndex(int idx) -+{ -+ if (idx >= m_state.size()) -+ return VDP_INVALID_HANDLE; -+ -+ std::map::iterator it = m_state.begin(); -+ for(int i = 0; i < idx; i++) -+ ++it; -+ return it->first; -+} -+ -+VdpVideoSurface CVideoSurfaces::RemoveNext(bool skiprender) -+{ -+ CSingleLock lock(m_section); -+ VdpVideoSurface surf; -+ std::map::iterator it; -+ for(it = m_state.begin(); it != m_state.end(); ++it) -+ { -+ if (skiprender && it->second & SURFACE_USED_FOR_RENDER) -+ continue; -+ surf = it->first; -+ m_state.erase(surf); -+ -+ std::list::iterator it2; -+ it2 = std::find(m_freeSurfaces.begin(), m_freeSurfaces.end(), surf); -+ if (it2 != m_freeSurfaces.end()) -+ m_freeSurfaces.erase(it2); -+ return surf; -+ } -+ return VDP_INVALID_HANDLE; -+} -+ -+void CVideoSurfaces::Reset() -+{ -+ CSingleLock lock(m_section); -+ m_freeSurfaces.clear(); -+ m_state.clear(); -+} -+ -+int CVideoSurfaces::Size() -+{ -+ CSingleLock lock(m_section); -+ return m_state.size(); -+} -+ -+//----------------------------------------------------------------------------- - // CVDPAU - //----------------------------------------------------------------------------- - -@@ -87,7 +233,6 @@ - { - m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; - m_vdpauConfig.videoSurfaces = &m_videoSurfaces; -- m_vdpauConfig.videoSurfaceSec = &m_videoSurfaceSec; - - m_vdpauConfigured = false; - m_hwContext.bitstream_buffers_allocated = 0; -@@ -164,6 +309,7 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int - m_hwContext.render = CDecoder::Render; - m_hwContext.bitstream_buffers_allocated = 0; - avctx->get_buffer = CDecoder::FFGetBuffer; -+ avctx->reget_buffer = CDecoder::FFGetBuffer; - avctx->release_buffer = CDecoder::FFReleaseBuffer; - avctx->draw_horiz_band = CDecoder::FFDrawSlice; - avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD; -@@ -193,16 +339,6 @@ void CDecoder::Close() - FiniVDPAUProcs(); - m_vdpauOutput.Dispose(); - -- while (!m_videoSurfaces.empty()) -- { -- vdpau_render_state *render = m_videoSurfaces.back(); -- m_videoSurfaces.pop_back(); -- if (render->bitstream_buffers_allocated) -- m_dllAvUtil.av_freep(&render->bitstream_buffers); -- render->bitstream_buffers_allocated = 0; -- free(render); -- } -- - if (m_hwContext.bitstream_buffers_allocated) - { - m_dllAvUtil.av_freep(&m_hwContext.bitstream_buffers); -@@ -239,14 +375,10 @@ long CDecoder::Release() - m_DisplayState = VDPAU_ERROR; - } - -- for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i) -+ VdpVideoSurface surf; -+ while((surf = m_videoSurfaces.RemoveNext(true)) != VDP_INVALID_HANDLE) - { -- vdpau_render_state *render = m_videoSurfaces[i]; -- if (render->surface != VDP_INVALID_HANDLE && !(render->state & FF_VDPAU_STATE_USED_FOR_RENDER)) -- { -- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface); -- render->surface = VDP_INVALID_HANDLE; -- } -+ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); - } - } - return IHardwareDecoder::Release(); -@@ -514,20 +646,16 @@ void CDecoder::FiniVDPAUOutput() - return; - m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE; - -- CSingleLock lock(m_videoSurfaceSec); -- CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", (int)m_videoSurfaces.size()); -+ CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", m_videoSurfaces.Size()); - -- for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i) -+ VdpVideoSurface surf; -+ while((surf = m_videoSurfaces.RemoveNext()) != VDP_INVALID_HANDLE) - { -- vdpau_render_state *render = m_videoSurfaces[i]; -- if (render->surface != VDP_INVALID_HANDLE) -- { -- vdp_st = m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface); -- render->surface = VDP_INVALID_HANDLE; -- } -+ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); - if (CheckStatus(vdp_st, __LINE__)) - return; - } -+ m_videoSurfaces.Reset(); - } - - void CDecoder::ReadFormatOf( AVCodecID codec -@@ -696,33 +824,6 @@ void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. va - - } - --bool CDecoder::IsSurfaceValid(vdpau_render_state *render) --{ -- // find render state in queue -- bool found(false); -- unsigned int i; -- for(i = 0; i < m_videoSurfaces.size(); ++i) -- { -- if(m_videoSurfaces[i] == render) -- { -- found = true; -- break; -- } -- } -- if (!found) -- { -- CLog::Log(LOGERROR,"%s - video surface not found", __FUNCTION__); -- return false; -- } -- if (m_videoSurfaces[i]->surface == VDP_INVALID_HANDLE) -- { -- m_videoSurfaces[i]->state = 0; -- return false; -- } -- -- return true; --} -- - int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) - { - //CLog::Log(LOGNOTICE,"%s",__FUNCTION__); -@@ -738,63 +839,38 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) - return -1; - } - -- vdpau_render_state * render = NULL; -- -- // find unused surface -- { CSingleLock lock(vdp->m_videoSurfaceSec); -- for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++) -- { -- if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER))) -- { -- render = vdp->m_videoSurfaces[i]; -- render->state = 0; -- break; -- } -- } -- } -+ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)pic->data[3]; -+ surf = vdp->m_videoSurfaces.GetFree(surf != 0 ? surf : VDP_INVALID_HANDLE); - - VdpStatus vdp_st = VDP_STATUS_ERROR; -- if (render == NULL) -+ if (surf == VDP_INVALID_HANDLE) - { - // create a new surface - VdpDecoderProfile profile; - ReadFormatOf(avctx->codec_id, profile, vdp->m_vdpauConfig.vdpChromaType); -- render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1); -- if (render == NULL) -- { -- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - calloc failed"); -- return -1; -- } -- CSingleLock lock(vdp->m_videoSurfaceSec); -- render->surface = VDP_INVALID_HANDLE; -- vdp->m_videoSurfaces.push_back(render); -- } - -- if (render->surface == VDP_INVALID_HANDLE) -- { - vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice, - vdp->m_vdpauConfig.vdpChromaType, - avctx->coded_width, - avctx->coded_height, -- &render->surface); -+ &surf); - vdp->CheckStatus(vdp_st, __LINE__); - if (vdp_st != VDP_STATUS_OK) - { -- free(render); - CLog::Log(LOGERROR, "CVDPAU::FFGetBuffer - No Video surface available could be created"); - return -1; - } -+ vdp->m_videoSurfaces.AddSurface(surf); - } - - pic->data[1] = pic->data[2] = NULL; -- pic->data[0] = (uint8_t*)render; -- pic->data[3] = (uint8_t*)(uintptr_t)render->surface; -+ pic->data[0] = (uint8_t*)(uintptr_t)surf; -+ pic->data[3] = (uint8_t*)(uintptr_t)surf; - - pic->linesize[0] = pic->linesize[1] = pic->linesize[2] = 0; - - pic->type= FF_BUFFER_TYPE_USER; - -- render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE; - pic->reordered_opaque= avctx->reordered_opaque; - return 0; - } -@@ -805,31 +881,17 @@ void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic) - CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; - CDecoder* vdp = (CDecoder*)ctx->GetHardware(); - -- vdpau_render_state * render; -+ VdpVideoSurface surf; - unsigned int i; - - CSingleLock lock(vdp->m_DecoderSection); - -- render=(vdpau_render_state*)pic->data[0]; -- if(!render) -- { -- CLog::Log(LOGERROR, "CVDPAU::FFReleaseBuffer - invalid context handle provided"); -- return; -- } -+ surf = (VdpVideoSurface)(uintptr_t)pic->data[3]; -+ -+ vdp->m_videoSurfaces.ClearReference(surf); - -- CSingleLock vLock(vdp->m_videoSurfaceSec); -- render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE; - for(i=0; i<4; i++) - pic->data[i]= NULL; -- -- // find render state in queue -- if (!vdp->IsSurfaceValid(render)) -- { -- CLog::Log(LOGDEBUG, "CVDPAU::FFReleaseBuffer - ignoring invalid buffer"); -- return; -- } -- -- render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE; - } - - VdpStatus CDecoder::Render( VdpDecoder decoder, VdpVideoSurface target, -@@ -861,17 +923,10 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, - } - - VdpStatus vdp_st; -- vdpau_render_state * render; -- -- render = (vdpau_render_state*)src->data[0]; -- if(!render) -- { -- CLog::Log(LOGERROR, "CVDPAU::FFDrawSlice - invalid context handle provided"); -- return; -- } -+ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)src->data[3]; - - // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid -- if (!vdp->IsSurfaceValid(render)) -+ if (!vdp->m_videoSurfaces.IsValid(surf)) - { - CLog::Log(LOGWARNING, "CVDPAU::FFDrawSlice - ignoring invalid buffer"); - return; -@@ -893,7 +948,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, - uint16_t decoded, processed, rend; - vdp->m_bufferStats.Get(decoded, processed, rend); - vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, -- render->surface, -+ surf, - (VdpPictureInfo const *)&(vdp->m_hwContext.info), - vdp->m_hwContext.bitstream_buffers_used, - vdp->m_hwContext.bitstream_buffers); -@@ -919,29 +974,20 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) - if(pFrame) - { // we have a new frame from decoder - -- vdpau_render_state * render = (vdpau_render_state*)pFrame->data[0]; -- if(!render) -- { -- CLog::Log(LOGERROR, "CVDPAU::Decode: no valid frame"); -- return VC_ERROR; -- } -- -+ VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)pFrame->data[3]; - // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid -- if (!IsSurfaceValid(render)) -+ if (!m_videoSurfaces.IsValid(surf)) - { - CLog::Log(LOGWARNING, "CVDPAU::Decode - ignoring invalid buffer"); - return VC_BUFFER; - } -- -- CSingleLock lock(m_videoSurfaceSec); -- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER; -- lock.Leave(); -+ m_videoSurfaces.MarkRender(surf); - - // send frame to output for processing - CVdpauDecodedPicture pic; - memset(&pic.DVDPic, 0, sizeof(pic.DVDPic)); - ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic); -- pic.render = render; -+ pic.videoSurface = surf; - pic.DVDPic.color_matrix = avctx->colorspace; - m_bufferStats.IncDecoded(); - m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic)); -@@ -2126,17 +2172,13 @@ void CMixer::Flush() - { - CVdpauDecodedPicture pic = m_mixerInput.back(); - m_mixerInput.pop_back(); -- CSingleLock lock(*m_config.videoSurfaceSec); -- if (pic.render) -- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(pic.videoSurface); - } - while (!m_decodedPics.empty()) - { - CVdpauDecodedPicture pic = m_decodedPics.front(); - m_decodedPics.pop(); -- CSingleLock lock(*m_config.videoSurfaceSec); -- if (pic.render) -- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(pic.videoSurface); - } - Message *msg; - while (m_dataPort.ReceiveOutMessage(&msg)) -@@ -2144,9 +2186,7 @@ void CMixer::Flush() - if (msg->signal == CMixerDataProtocol::FRAME) - { - CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data; -- CSingleLock lock(*m_config.videoSurfaceSec); -- if (pic.render) -- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(pic.videoSurface); - } - else if (msg->signal == CMixerDataProtocol::BUFFER) - { -@@ -2264,7 +2304,7 @@ void CMixer::InitCycle() - } - - m_processPicture.DVDPic = m_mixerInput[1].DVDPic; -- m_processPicture.render = m_mixerInput[1].render; -+ m_processPicture.videoSurface = m_mixerInput[1].videoSurface; - } - - void CMixer::FiniCycle() -@@ -2272,10 +2312,9 @@ void CMixer::FiniCycle() - while (m_mixerInput.size() > 3) - { - CVdpauDecodedPicture &tmp = m_mixerInput.back(); -- if (tmp.render && m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) -+ if (m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) - { -- CSingleLock lock(*m_config.videoSurfaceSec); -- tmp.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(tmp.videoSurface); - } - m_mixerInput.pop_back(); - // m_config.stats->DecDecoded(); -@@ -2307,10 +2346,10 @@ void CMixer::ProcessPicture() - // use only 2 past 1 future for progressive/weave - // (only used for postproc anyway eg noise reduction) - if (m_mixerInput.size() > 3) -- past_surfaces[1] = m_mixerInput[3].render->surface; -+ past_surfaces[1] = m_mixerInput[3].videoSurface; - if (m_mixerInput.size() > 2) -- past_surfaces[0] = m_mixerInput[2].render->surface; -- futu_surfaces[0] = m_mixerInput[0].render->surface; -+ past_surfaces[0] = m_mixerInput[2].videoSurface; -+ futu_surfaces[0] = m_mixerInput[0].videoSurface; - pastCount = 2; - futuCount = 1; - } -@@ -2320,31 +2359,31 @@ void CMixer::ProcessPicture() - { // first field - if (m_mixerInput.size() > 3) - { -- past_surfaces[3] = m_mixerInput[3].render->surface; -- past_surfaces[2] = m_mixerInput[3].render->surface; -+ past_surfaces[3] = m_mixerInput[3].videoSurface; -+ past_surfaces[2] = m_mixerInput[3].videoSurface; - } - if (m_mixerInput.size() > 2) - { -- past_surfaces[1] = m_mixerInput[2].render->surface; -- past_surfaces[0] = m_mixerInput[2].render->surface; -+ past_surfaces[1] = m_mixerInput[2].videoSurface; -+ past_surfaces[0] = m_mixerInput[2].videoSurface; - } -- futu_surfaces[0] = m_mixerInput[1].render->surface; -- futu_surfaces[1] = m_mixerInput[0].render->surface;; -+ futu_surfaces[0] = m_mixerInput[1].videoSurface; -+ futu_surfaces[1] = m_mixerInput[0].videoSurface; - } - else - { // second field - if (m_mixerInput.size() > 3) - { -- past_surfaces[3] = m_mixerInput[3].render->surface; -+ past_surfaces[3] = m_mixerInput[3].videoSurface; - } - if (m_mixerInput.size() > 2) - { -- past_surfaces[2] = m_mixerInput[2].render->surface; -- past_surfaces[1] = m_mixerInput[2].render->surface; -+ past_surfaces[2] = m_mixerInput[2].videoSurface; -+ past_surfaces[1] = m_mixerInput[2].videoSurface; - } -- past_surfaces[0] = m_mixerInput[1].render->surface; -- futu_surfaces[0] = m_mixerInput[1].render->surface; -- futu_surfaces[1] = m_mixerInput[1].render->surface; -+ past_surfaces[0] = m_mixerInput[1].videoSurface; -+ futu_surfaces[0] = m_mixerInput[1].videoSurface; -+ futu_surfaces[1] = m_mixerInput[1].videoSurface; - - if (m_mixerInput[0].DVDPic.pts != DVD_NOPTS_VALUE && - m_mixerInput[1].DVDPic.pts != DVD_NOPTS_VALUE) -@@ -2379,7 +2418,7 @@ void CMixer::ProcessPicture() - m_mixerfield, - pastCount, - past_surfaces, -- m_mixerInput[1].render->surface, -+ m_mixerInput[1].videoSurface, - futuCount, - futu_surfaces, - &sourceRect, -@@ -2853,9 +2892,7 @@ void COutput::Flush() - CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data; - if (pic.DVDPic.format == RENDER_FMT_VDPAU_420) - { -- CSingleLock lock(*m_config.videoSurfaceSec); -- if (pic.render) -- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(pic.videoSurface); - } - } - msg->Release(); -@@ -2866,9 +2903,7 @@ void COutput::Flush() - if (msg->signal == COutputDataProtocol::NEWFRAME) - { - CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data; -- CSingleLock lock(*m_config.videoSurfaceSec); -- if (pic.render) -- pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->ClearRender(pic.videoSurface); - } - else if (msg->signal == COutputDataProtocol::RETURNPIC) - { -@@ -2903,9 +2938,7 @@ void COutput::Flush() - CLog::Log(LOGDEBUG, "COutput::Flush - gl surface not found"); - continue; - } -- vdpau_render_state *render = it2->second.sourceVuv; -- if (render) -- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER; -+ m_config.videoSurfaces->MarkRender(it2->second.sourceVuv); - } - } - } -@@ -2999,9 +3032,9 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() - { - m_config.useInteropYuv = true; - GLMapSurfaces(); -- retPic->sourceIdx = procPic.render->surface; -+ retPic->sourceIdx = procPic.videoSurface; - for (unsigned int i=0; i<4; ++i) -- retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.render->surface].texture[i]; -+ retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.videoSurface].texture[i]; - retPic->texWidth = m_config.surfaceWidth; - retPic->texHeight = m_config.surfaceHeight; - retPic->crop.x1 = 0; -@@ -3118,9 +3151,8 @@ void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) - CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found"); - return; - } -- vdpau_render_state *render = it->second.sourceVuv; -- CSingleLock lock(*m_config.videoSurfaceSec); -- render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER; -+ VdpVideoSurface surf = it->second.sourceVuv; -+ m_config.videoSurfaces->ClearRender(surf); - } - else if (pic->DVDPic.format == RENDER_FMT_VDPAU) - { -@@ -3526,17 +3558,19 @@ void COutput::GLMapSurfaces() - if (m_config.useInteropYuv) - { - VdpauBufferPool::GLVideoSurface glSurface; -- if (m_config.videoSurfaces->size() != m_bufferPool.glVideoSurfaceMap.size()) -+ VdpVideoSurface surf; -+ if (m_config.videoSurfaces->Size() != m_bufferPool.glVideoSurfaceMap.size()) - { -- CSingleLock lock(*m_config.videoSurfaceSec); -- for (unsigned int i = 0; i < m_config.videoSurfaces->size(); i++) -+ for (unsigned int i = 0; i < m_config.videoSurfaces->Size(); i++) - { -- if ((*m_config.videoSurfaces)[i]->surface == VDP_INVALID_HANDLE) -+ surf = m_config.videoSurfaces->GetAtIndex(i); -+ -+ if (surf == VDP_INVALID_HANDLE) - continue; - -- if (m_bufferPool.glVideoSurfaceMap.find((*m_config.videoSurfaces)[i]->surface) == m_bufferPool.glVideoSurfaceMap.end()) -+ if (m_bufferPool.glVideoSurfaceMap.find(surf) == m_bufferPool.glVideoSurfaceMap.end()) - { -- glSurface.sourceVuv = (*m_config.videoSurfaces)[i]; -+ glSurface.sourceVuv = surf; - while (glGetError() != GL_NO_ERROR) ; - glGenTextures(4, glSurface.texture); - if (glGetError() != GL_NO_ERROR) -@@ -3544,7 +3578,7 @@ void COutput::GLMapSurfaces() - CLog::Log(LOGERROR, "VDPAU::COutput error creating texture"); - m_vdpError = true; - } -- glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast((*m_config.videoSurfaces)[i]->surface), -+ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast(surf), - GL_TEXTURE_2D, 4, glSurface.texture); - - if (glGetError() != GL_NO_ERROR) -@@ -3564,7 +3598,7 @@ void COutput::GLMapSurfaces() - CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface"); - m_vdpError = true; - } -- m_bufferPool.glVideoSurfaceMap[(*m_config.videoSurfaces)[i]->surface] = glSurface; -+ m_bufferPool.glVideoSurfaceMap[surf] = glSurface; - if (m_vdpError) - return; - CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface"); -@@ -3616,7 +3650,7 @@ void COutput::GLUnmapSurfaces() - if (m_config.usePixmaps) - return; - -- { CSingleLock lock(*m_config.videoSurfaceSec); -+ { - std::map::iterator it; - for (it = m_bufferPool.glVideoSurfaceMap.begin(); it != m_bufferPool.glVideoSurfaceMap.end(); ++it) - { -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -index db2671f..0b5239c 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -@@ -60,6 +60,7 @@ - #include "threads/Event.h" - #include "threads/Thread.h" - #include "utils/ActorProtocol.h" -+#include - - using namespace Actor; - -@@ -167,6 +168,8 @@ class CVdpauBufferStats - * for init. - */ - -+class CVideoSurfaces; -+ - struct CVdpauConfig - { - int surfaceWidth; -@@ -184,8 +187,7 @@ struct CVdpauConfig - int featureCount; - int upscale; - VdpVideoMixerFeature vdpFeatures[14]; -- std::vector *videoSurfaces; -- CCriticalSection *videoSurfaceSec; -+ CVideoSurfaces *videoSurfaces; - bool usePixmaps; - int numRenderBuffers; - uint32_t maxReferences; -@@ -199,7 +201,7 @@ struct CVdpauConfig - struct CVdpauDecodedPicture - { - DVDVideoPicture DVDPic; -- vdpau_render_state *render; -+ VdpVideoSurface videoSurface; - }; - - /** -@@ -208,7 +210,7 @@ struct CVdpauDecodedPicture - struct CVdpauProcessedPicture - { - DVDVideoPicture DVDPic; -- vdpau_render_state *render; -+ VdpVideoSurface videoSurface; - VdpOutputSurface outputSurface; - }; - -@@ -381,7 +383,7 @@ struct VdpauBufferPool - #ifdef GL_NV_vdpau_interop - GLvdpauSurfaceNV glVdpauSurface; - #endif -- vdpau_render_state *sourceVuv; -+ VdpVideoSurface sourceVuv; - VdpOutputSurface sourceRgb; - }; - std::vector allRenderPics; -@@ -511,6 +513,29 @@ class COutput : private CThread - }; - - //----------------------------------------------------------------------------- -+// VDPAU Video Surface states -+//----------------------------------------------------------------------------- -+ -+class CVideoSurfaces -+{ -+public: -+ void AddSurface(VdpVideoSurface surf); -+ void ClearReference(VdpVideoSurface surf); -+ bool MarkRender(VdpVideoSurface surf); -+ void ClearRender(VdpVideoSurface surf); -+ bool IsValid(VdpVideoSurface surf); -+ VdpVideoSurface GetFree(VdpVideoSurface surf); -+ VdpVideoSurface GetAtIndex(int idx); -+ VdpVideoSurface RemoveNext(bool skiprender = false); -+ void Reset(); -+ int Size(); -+protected: -+ std::map m_state; -+ std::list m_freeSurfaces; -+ CCriticalSection m_section; -+}; -+ -+//----------------------------------------------------------------------------- - // VDPAU decoder - //----------------------------------------------------------------------------- - -@@ -570,7 +595,6 @@ class CDecoder - bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); - void SpewHardwareAvailable(); - bool CheckStatus(VdpStatus vdp_st, int line); -- bool IsSurfaceValid(vdpau_render_state *render); - void InitVDPAUProcs(); - void FiniVDPAUProcs(); - void FiniVDPAUOutput(); -@@ -603,9 +627,8 @@ class CDecoder - ThreadIdentifier m_decoderThread; - bool m_vdpauConfigured; - CVdpauConfig m_vdpauConfig; -- std::vector m_videoSurfaces; -+ CVideoSurfaces m_videoSurfaces; - AVVDPAUContext m_hwContext; -- CCriticalSection m_videoSurfaceSec; - - COutput m_vdpauOutput; - CVdpauBufferStats m_bufferStats; --- -1.8.4 - - -From d1a902490ad773e71a4cffeb06f99577e0ab6deb Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Fri, 27 Sep 2013 16:04:45 +0200 -Subject: [PATCH 81/89] vdpau: clear processed pics on flush - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 20 ++++++++++++++++---- - 1 file changed, 16 insertions(+), 4 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index e0784c4..da0a915 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -2890,10 +2890,7 @@ void COutput::Flush() - if (msg->signal == CMixerDataProtocol::PICTURE) - { - CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data; -- if (pic.DVDPic.format == RENDER_FMT_VDPAU_420) -- { -- m_config.videoSurfaces->ClearRender(pic.videoSurface); -- } -+ m_bufferPool.processedPics.push(pic); - } - msg->Release(); - } -@@ -2941,6 +2938,21 @@ void COutput::Flush() - m_config.videoSurfaces->MarkRender(it2->second.sourceVuv); - } - } -+ -+ // clear processed pics -+ while(!m_bufferPool.processedPics.empty()) -+ { -+ CVdpauProcessedPicture procPic = m_bufferPool.processedPics.front(); -+ if (procPic.DVDPic.format == RENDER_FMT_VDPAU) -+ { -+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &procPic.outputSurface, sizeof(procPic.outputSurface)); -+ } -+ else if (procPic.DVDPic.format == RENDER_FMT_VDPAU_420) -+ { -+ m_config.videoSurfaces->ClearRender(procPic.videoSurface); -+ } -+ m_bufferPool.processedPics.pop(); -+ } - } - - bool COutput::HasWork() --- -1.8.4 - - -From eba718f6e4e1879a73e40e9433fe2dedb3005dec Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Sat, 28 Sep 2013 19:56:19 +0200 -Subject: [PATCH 82/89] vdpau: reactivate long decoding time debug message - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index da0a915..c2879bf 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -944,7 +944,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, - return; - } - --// uint64_t startTime = CurrentHostCounter(); -+ uint64_t startTime = CurrentHostCounter(); - uint16_t decoded, processed, rend; - vdp->m_bufferStats.Get(decoded, processed, rend); - vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, -@@ -953,10 +953,9 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, - vdp->m_hwContext.bitstream_buffers_used, - vdp->m_hwContext.bitstream_buffers); - vdp->CheckStatus(vdp_st, __LINE__); --// uint64_t diff = CurrentHostCounter() - startTime; --// if (diff*1000/CurrentHostFrequency() > 30) --// CLog::Log(LOGWARNING,"CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend); -- -+ uint64_t diff = CurrentHostCounter() - startTime; -+ if (diff*1000/CurrentHostFrequency() > 30) -+ CLog::Log(LOGDEBUG, "CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend); - } - - --- -1.8.4 - - -From 7810cda202972dd3374573fa8d46dcf8b036d649 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Sun, 29 Sep 2013 07:30:41 +0200 -Subject: [PATCH 83/89] vdpau: keep video surfaces for another cycle - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index c2879bf..b27b18e 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -2308,7 +2308,9 @@ void CMixer::InitCycle() - - void CMixer::FiniCycle() - { -- while (m_mixerInput.size() > 3) -+ // Keep video surfaces for one cycle longer than used -+ // by mixer. This avoids blocking in decoder. -+ while (m_mixerInput.size() > 4) - { - CVdpauDecodedPicture &tmp = m_mixerInput.back(); - if (m_processPicture.DVDPic.format != RENDER_FMT_VDPAU_420) --- -1.8.4 - - -From a997d61262d4f74ac15178be0427f76bd45db853 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Mon, 30 Sep 2013 10:49:58 +0200 -Subject: [PATCH 84/89] vdpau: create only a single vdpau device - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 322 ++++++++++++++++--------- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 34 ++- - 2 files changed, 232 insertions(+), 124 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index b27b18e..c8b7160 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -74,10 +74,192 @@ - static float studioCSCKCoeffs601[3] = {0.299, 0.587, 0.114}; //BT601 {Kr, Kg, Kb} - static float studioCSCKCoeffs709[3] = {0.2126, 0.7152, 0.0722}; //BT709 {Kr, Kg, Kb} - --//since libvdpau 0.4, vdp_device_create_x11() installs a callback on the Display*, --//if we unload libvdpau with dlclose(), we segfault on XCloseDisplay, --//so we just keep a static handle to libvdpau around --void* CDecoder::dl_handle; -+//----------------------------------------------------------------------------- -+//----------------------------------------------------------------------------- -+ -+CVDPAUContext *CVDPAUContext::m_context = 0; -+CCriticalSection CVDPAUContext::m_section; -+Display *CVDPAUContext::m_display = 0; -+void *CVDPAUContext::m_dlHandle = 0; -+ -+CVDPAUContext::CVDPAUContext() -+{ -+ m_context = 0; -+ m_refCount = 0; -+} -+ -+void CVDPAUContext::Release() -+{ -+ CSingleLock lock(m_section); -+ -+ m_refCount--; -+ if (m_refCount <= 0) -+ { -+ Close(); -+ delete this; -+ m_context = 0; -+ } -+} -+ -+void CVDPAUContext::Close() -+{ -+ CLog::Log(LOGNOTICE, "VDPAU::Close - closing decoder context"); -+ DestroyContext(); -+} -+ -+bool CVDPAUContext::EnsureContext(CVDPAUContext **ctx) -+{ -+ CSingleLock lock(m_section); -+ -+ if (m_context) -+ { -+ m_context->m_refCount++; -+ *ctx = m_context; -+ return true; -+ } -+ -+ m_context = new CVDPAUContext(); -+ *ctx = m_context; -+ { -+ CSingleLock gLock(g_graphicsContext); -+ if (!m_context->LoadSymbols() || !m_context->CreateContext()) -+ { -+ delete m_context; -+ m_context = 0; -+ return false; -+ } -+ } -+ -+ m_context->m_refCount++; -+ -+ *ctx = m_context; -+ return true; -+} -+ -+bool CVDPAUContext::LoadSymbols() -+{ -+ if (!m_dlHandle) -+ { -+ m_dlHandle = dlopen("libvdpau.so.1", RTLD_LAZY); -+ if (!m_dlHandle) -+ { -+ const char* error = dlerror(); -+ if (!error) -+ error = "dlerror() returned NULL"; -+ -+ CLog::Log(LOGERROR,"VDPAU::LoadSymbols: Unable to get handle to lib: %s", error); -+ return false; -+ } -+ } -+ -+ char* error; -+ (void)dlerror(); -+ dl_vdp_device_create_x11 = (VdpStatus (*)(Display*, int, VdpDevice*, VdpStatus (**)(VdpDevice, VdpFuncId, void**)))dlsym(m_dlHandle, (const char*)"vdp_device_create_x11"); -+ error = dlerror(); -+ if (error) -+ { -+ CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__); -+ m_vdpDevice = VDP_INVALID_HANDLE; -+ return false; -+ } -+ return true; -+} -+ -+bool CVDPAUContext::CreateContext() -+{ -+ CLog::Log(LOGNOTICE,"VDPAU::CreateContext - creating decoder context"); -+ -+ int mScreen; -+ { CSingleLock lock(g_graphicsContext); -+ if (!m_display) -+ m_display = XOpenDisplay(NULL); -+ mScreen = g_Windowing.GetCurrentScreen(); -+ } -+ -+ VdpStatus vdp_st; -+ // Create Device -+ vdp_st = dl_vdp_device_create_x11(m_display, -+ mScreen, -+ &m_vdpDevice, -+ &m_vdp_get_proc_address); -+ -+ CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpDevice,vdp_st); -+ if (vdp_st != VDP_STATUS_OK) -+ { -+ CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st); -+ m_vdpDevice = VDP_INVALID_HANDLE; -+ return false; -+ } -+ vdp_st = m_vdp_get_proc_address(m_vdpDevice, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&m_vdp_device_destroy); -+ -+ return true; -+} -+ -+void CVDPAUContext::GetProcs(VDPAU_procs &procs) -+{ -+ VdpStatus vdp_st; -+ -+ procs.vdp_get_proc_address = m_vdp_get_proc_address; -+ -+#define VDP_PROC(id, proc) \ -+ do { \ -+ vdp_st = m_vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ -+ if (vdp_st != VDP_STATUS_OK) \ -+ { \ -+ CLog::Log(LOGERROR, "CVDPAUContext::GetProcs - failed to get proc id"); \ -+ } \ -+ } while(0); -+ -+ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , procs.vdp_get_error_string); -+ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , procs.vdp_device_destroy); -+ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , procs.vdp_generate_csc_matrix); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , procs.vdp_video_surface_create); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , procs.vdp_video_surface_destroy); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_video_surface_put_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , procs.vdp_video_surface_get_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_output_surface_put_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , procs.vdp_output_surface_put_bits_native); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , procs.vdp_output_surface_create); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , procs.vdp_output_surface_destroy); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , procs.vdp_output_surface_get_bits_native); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, procs.vdp_output_surface_render_output_surface); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , procs.vdp_output_surface_put_bits_indexed); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , procs.vdp_video_mixer_create); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , procs.vdp_video_mixer_set_feature_enables); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , procs.vdp_video_mixer_destroy); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , procs.vdp_video_mixer_render); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , procs.vdp_video_mixer_set_attribute_values); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , procs.vdp_video_mixer_query_parameter_support); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , procs.vdp_video_mixer_query_feature_support); -+ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , procs.vdp_decoder_create); -+ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , procs.vdp_decoder_destroy); -+ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , procs.vdp_decoder_render); -+ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , procs.vdp_decoder_query_caps); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , procs.vdp_presentation_queue_target_destroy); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , procs.vdp_presentation_queue_create); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , procs.vdp_presentation_queue_destroy); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , procs.vdp_presentation_queue_display); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, procs.vdp_presentation_queue_block_until_surface_idle); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , procs.vdp_presentation_queue_target_create_x11); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , procs.vdp_presentation_queue_query_surface_status); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , procs.vdp_presentation_queue_get_time); -+ -+#undef VDP_PROC -+} -+ -+VdpDevice CVDPAUContext::GetDevice() -+{ -+ return m_vdpDevice; -+} -+ -+void CVDPAUContext::DestroyContext() -+{ -+ if (!m_vdp_device_destroy) -+ return; -+ -+ m_vdp_device_destroy(m_vdpDevice); -+ m_vdpDevice = VDP_INVALID_HANDLE; -+} - - //----------------------------------------------------------------------------- - // VDPAU Video Surface states -@@ -253,27 +435,19 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int - if ((avctx->codec_id == AV_CODEC_ID_MPEG4) && !g_advancedSettings.m_videoAllowMpeg4VDPAU) - return false; - -- if (!dl_handle) -- { -- dl_handle = dlopen("libvdpau.so.1", RTLD_LAZY); -- if (!dl_handle) -- { -- const char* error = dlerror(); -- if (!error) -- error = "dlerror() returned NULL"; -+ if (!CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) -+ return false; - -- CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error); -- return false; -- } -- } -+ m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); -+ m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); -+ m_DisplayState = VDPAU_OPEN; -+ m_vdpauConfigured = false; - - if (!m_dllAvUtil.Load()) - return false; - -- InitVDPAUProcs(); - m_presentPicture = 0; - -- if (m_vdpauConfig.vdpDevice != VDP_INVALID_HANDLE) - { - SpewHardwareAvailable(); - -@@ -296,7 +470,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int - if(vdp_st != VDP_STATUS_OK) - { - CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st); -- FiniVDPAUProcs(); - return false; - } - -@@ -336,7 +509,6 @@ void CDecoder::Close() - CSingleLock lock(m_DecoderSection); - - FiniVDPAUOutput(); -- FiniVDPAUProcs(); - m_vdpauOutput.Dispose(); - - if (m_hwContext.bitstream_buffers_allocated) -@@ -345,6 +517,10 @@ void CDecoder::Close() - } - - m_dllAvUtil.Unload(); -+ -+ if (m_vdpauConfig.context) -+ m_vdpauConfig.context->Release(); -+ m_vdpauConfig.context = 0; - } - - long CDecoder::Release() -@@ -425,7 +601,9 @@ void CDecoder::OnLostDevice() - - CSingleLock lock(m_DecoderSection); - FiniVDPAUOutput(); -- FiniVDPAUProcs(); -+ if (m_vdpauConfig.context) -+ m_vdpauConfig.context->Release(); -+ m_vdpauConfig.context = 0; - - m_DisplayState = VDPAU_LOST; - lock.Leave(); -@@ -478,9 +656,14 @@ int CDecoder::Check(AVCodecContext* avctx) - CSingleLock lock(m_DecoderSection); - - FiniVDPAUOutput(); -- FiniVDPAUProcs(); - -- InitVDPAUProcs(); -+ if (CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) -+ { -+ m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); -+ m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); -+ m_DisplayState = VDPAU_OPEN; -+ m_vdpauConfigured = false; -+ } - - if (state == VDPAU_RESET) - return VC_FLUSHED; -@@ -536,99 +719,6 @@ EINTERLACEMETHOD CDecoder::AutoInterlaceMethod() - return VS_INTERLACEMETHOD_RENDER_BOB; - } - --void CDecoder::InitVDPAUProcs() --{ -- char* error; -- -- (void)dlerror(); -- dl_vdp_device_create_x11 = (VdpStatus (*)(Display*, int, VdpDevice*, VdpStatus (**)(VdpDevice, VdpFuncId, void**)))dlsym(dl_handle, (const char*)"vdp_device_create_x11"); -- error = dlerror(); -- if (error) -- { -- CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__); -- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; -- return; -- } -- -- if (dl_vdp_device_create_x11) -- { -- m_Display = XOpenDisplay(NULL); -- } -- -- int mScreen = g_Windowing.GetCurrentScreen(); -- VdpStatus vdp_st; -- -- // Create Device -- vdp_st = dl_vdp_device_create_x11(m_Display, //x_display, -- mScreen, //x_screen, -- &m_vdpauConfig.vdpDevice, -- &m_vdpauConfig.vdpProcs.vdp_get_proc_address); -- -- CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpauConfig.vdpDevice,vdp_st); -- if (vdp_st != VDP_STATUS_OK) -- { -- CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st); -- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; -- return; -- } -- --#define VDP_PROC(id, proc) \ -- do { \ -- vdp_st = m_vdpauConfig.vdpProcs.vdp_get_proc_address(m_vdpauConfig.vdpDevice, id, (void**)&proc); \ -- CheckStatus(vdp_st, __LINE__); \ -- } while(0); -- -- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpauConfig.vdpProcs.vdp_get_error_string); -- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpauConfig.vdpProcs.vdp_device_destroy); -- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpauConfig.vdpProcs.vdp_generate_csc_matrix); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_video_surface_create); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_surface_destroy); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_put_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_get_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_native); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_output_surface_create); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_output_surface_destroy); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_get_bits_native); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpauConfig.vdpProcs.vdp_output_surface_render_output_surface); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_indexed); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpauConfig.vdpProcs.vdp_video_mixer_create); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_feature_enables); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_mixer_destroy); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpauConfig.vdpProcs.vdp_video_mixer_render); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_attribute_values); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_parameter_support); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support); -- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpauConfig.vdpProcs.vdp_decoder_create); -- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpauConfig.vdpProcs.vdp_decoder_destroy); -- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpauConfig.vdpProcs.vdp_decoder_render); -- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpauConfig.vdpProcs.vdp_decoder_query_caps); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpauConfig.vdpProcs.vdp_presentation_queue_create); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_display); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpauConfig.vdpProcs.vdp_presentation_queue_block_until_surface_idle); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_create_x11); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpauConfig.vdpProcs.vdp_presentation_queue_query_surface_status); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpauConfig.vdpProcs.vdp_presentation_queue_get_time); -- --#undef VDP_PROC -- -- // set all vdpau resources to invalid -- m_DisplayState = VDPAU_OPEN; -- m_vdpauConfigured = false; --} -- --void CDecoder::FiniVDPAUProcs() --{ -- if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE) return; -- -- VdpStatus vdp_st; -- vdp_st = m_vdpauConfig.vdpProcs.vdp_device_destroy(m_vdpauConfig.vdpDevice); -- CheckStatus(vdp_st, __LINE__); -- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE; --} -- - void CDecoder::FiniVDPAUOutput() - { - if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return; -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -index 0b5239c..c8e89dc 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -@@ -169,6 +169,7 @@ class CVdpauBufferStats - */ - - class CVideoSurfaces; -+class CVDPAUContext; - - struct CVdpauConfig - { -@@ -192,6 +193,7 @@ struct CVdpauConfig - int numRenderBuffers; - uint32_t maxReferences; - bool useInteropYuv; -+ CVDPAUContext *context; - }; - - /** -@@ -539,6 +541,30 @@ class CVideoSurfaces - // VDPAU decoder - //----------------------------------------------------------------------------- - -+class CVDPAUContext -+{ -+public: -+ static bool EnsureContext(CVDPAUContext **ctx); -+ void Release(); -+ void GetProcs(VDPAU_procs &procs); -+ VdpDevice GetDevice(); -+private: -+ CVDPAUContext(); -+ void Close(); -+ bool LoadSymbols(); -+ bool CreateContext(); -+ void DestroyContext(); -+ static CVDPAUContext *m_context; -+ static CCriticalSection m_section; -+ static Display *m_display; -+ int m_refCount; -+ static void *m_dlHandle; -+ VdpDevice m_vdpDevice; -+ VdpGetProcAddress *m_vdp_get_proc_address; -+ VdpDeviceDestroy *m_vdp_device_destroy; -+ VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); -+}; -+ - /** - * VDPAU main class - */ -@@ -595,8 +621,6 @@ class CDecoder - bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); - void SpewHardwareAvailable(); - bool CheckStatus(VdpStatus vdp_st, int line); -- void InitVDPAUProcs(); -- void FiniVDPAUProcs(); - void FiniVDPAUOutput(); - void ReturnRenderPicture(CVdpauRenderPicture *renderPic); - long ReleasePicReference(); -@@ -605,10 +629,6 @@ class CDecoder - , VdpDecoderProfile &decoder_profile - , VdpChromaType &chroma_type); - -- VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); -- VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer); -- VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context); -- - // OnLostDevice triggers transition from all states to LOST - // internal errors trigger transition from OPEN to RESET - // OnResetDevice triggers transition from LOST to RESET -@@ -621,9 +641,7 @@ class CDecoder - CCriticalSection m_DecoderSection; - CEvent m_DisplayEvent; - -- static void* dl_handle; - DllAvUtil m_dllAvUtil; -- Display* m_Display; - ThreadIdentifier m_decoderThread; - bool m_vdpauConfigured; - CVdpauConfig m_vdpauConfig; --- -1.8.4 - - -From c742b186abd9c8fda80291c68b7c3ffca8f5bfe1 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Mon, 30 Sep 2013 18:52:31 +0200 -Subject: [PATCH 85/89] vdpau: make sure buffers a full before returning a - picture - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 21 ++++++++------------- - 1 file changed, 8 insertions(+), 13 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index c8b7160..b5d7932 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -1102,7 +1102,12 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) - uint64_t startTime = CurrentHostCounter(); - while (!retval) - { -- if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg)) -+ // first fill the buffers to keep vdpau busy -+ if (decoded < 3) -+ { -+ retval |= VC_BUFFER; -+ } -+ else if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg)) - { - if (msg->signal == COutputDataProtocol::PICTURE) - { -@@ -1136,19 +1141,9 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame) - msg->Release(); - } - -- if ((m_codecControl & DVP_FLAG_DRAIN)) -+ if (decoded < 3) - { -- if (decoded + processed + render < 4) -- { -- retval |= VC_BUFFER; -- } -- } -- else -- { -- if (decoded < 4 && (processed + render) < 3) -- { -- retval |= VC_BUFFER; -- } -+ retval |= VC_BUFFER; - } - - if (!retval && !m_inMsgEvent.WaitMSec(2000)) --- -1.8.4 - - -From 03fe711f115a81027d12cb5ef676b6ca7539704d Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Mon, 30 Sep 2013 21:05:03 +0200 -Subject: [PATCH 86/89] vdpau: move common attributes into vdpau context - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 350 +++++++++++++------------ - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 17 +- - 2 files changed, 190 insertions(+), 177 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index b5d7932..3b93eda 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -136,6 +136,21 @@ bool CVDPAUContext::EnsureContext(CVDPAUContext **ctx) - return true; - } - -+VDPAU_procs& CVDPAUContext::GetProcs() -+{ -+ return m_vdpProcs; -+} -+ -+VdpVideoMixerFeature* CVDPAUContext::GetFeatures() -+{ -+ return m_vdpFeatures; -+} -+ -+int CVDPAUContext::GetFeatureCount() -+{ -+ return m_featureCount; -+} -+ - bool CVDPAUContext::LoadSymbols() - { - if (!m_dlHandle) -@@ -181,7 +196,7 @@ bool CVDPAUContext::CreateContext() - vdp_st = dl_vdp_device_create_x11(m_display, - mScreen, - &m_vdpDevice, -- &m_vdp_get_proc_address); -+ &m_vdpProcs.vdp_get_proc_address); - - CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpDevice,vdp_st); - if (vdp_st != VDP_STATUS_OK) -@@ -190,59 +205,58 @@ bool CVDPAUContext::CreateContext() - m_vdpDevice = VDP_INVALID_HANDLE; - return false; - } -- vdp_st = m_vdp_get_proc_address(m_vdpDevice, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&m_vdp_device_destroy); - -+ QueryProcs(); -+ SpewHardwareAvailable(); - return true; - } - --void CVDPAUContext::GetProcs(VDPAU_procs &procs) -+void CVDPAUContext::QueryProcs() - { - VdpStatus vdp_st; - -- procs.vdp_get_proc_address = m_vdp_get_proc_address; -- - #define VDP_PROC(id, proc) \ - do { \ -- vdp_st = m_vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ -+ vdp_st = m_vdpProcs.vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \ - if (vdp_st != VDP_STATUS_OK) \ - { \ - CLog::Log(LOGERROR, "CVDPAUContext::GetProcs - failed to get proc id"); \ - } \ - } while(0); - -- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , procs.vdp_get_error_string); -- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , procs.vdp_device_destroy); -- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , procs.vdp_generate_csc_matrix); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , procs.vdp_video_surface_create); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , procs.vdp_video_surface_destroy); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_video_surface_put_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , procs.vdp_video_surface_get_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_output_surface_put_bits_y_cb_cr); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , procs.vdp_output_surface_put_bits_native); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , procs.vdp_output_surface_create); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , procs.vdp_output_surface_destroy); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , procs.vdp_output_surface_get_bits_native); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, procs.vdp_output_surface_render_output_surface); -- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , procs.vdp_output_surface_put_bits_indexed); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , procs.vdp_video_mixer_create); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , procs.vdp_video_mixer_set_feature_enables); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , procs.vdp_video_mixer_destroy); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , procs.vdp_video_mixer_render); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , procs.vdp_video_mixer_set_attribute_values); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , procs.vdp_video_mixer_query_parameter_support); -- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , procs.vdp_video_mixer_query_feature_support); -- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , procs.vdp_decoder_create); -- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , procs.vdp_decoder_destroy); -- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , procs.vdp_decoder_render); -- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , procs.vdp_decoder_query_caps); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , procs.vdp_presentation_queue_target_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , procs.vdp_presentation_queue_create); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , procs.vdp_presentation_queue_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , procs.vdp_presentation_queue_display); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, procs.vdp_presentation_queue_block_until_surface_idle); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , procs.vdp_presentation_queue_target_create_x11); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , procs.vdp_presentation_queue_query_surface_status); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , procs.vdp_presentation_queue_get_time); -+ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpProcs.vdp_get_error_string); -+ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpProcs.vdp_device_destroy); -+ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpProcs.vdp_generate_csc_matrix); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpProcs.vdp_video_surface_create); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpProcs.vdp_video_surface_destroy); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_put_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_get_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_output_surface_put_bits_y_cb_cr); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpProcs.vdp_output_surface_put_bits_native); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpProcs.vdp_output_surface_create); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpProcs.vdp_output_surface_destroy); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpProcs.vdp_output_surface_get_bits_native); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpProcs.vdp_output_surface_render_output_surface); -+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpProcs.vdp_output_surface_put_bits_indexed); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpProcs.vdp_video_mixer_create); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpProcs.vdp_video_mixer_set_feature_enables); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpProcs.vdp_video_mixer_destroy); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpProcs.vdp_video_mixer_render); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpProcs.vdp_video_mixer_set_attribute_values); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpProcs.vdp_video_mixer_query_parameter_support); -+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpProcs.vdp_video_mixer_query_feature_support); -+ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpProcs.vdp_decoder_create); -+ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpProcs.vdp_decoder_destroy); -+ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpProcs.vdp_decoder_render); -+ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpProcs.vdp_decoder_query_caps); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpProcs.vdp_presentation_queue_target_destroy); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpProcs.vdp_presentation_queue_create); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpProcs.vdp_presentation_queue_destroy); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpProcs.vdp_presentation_queue_display); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpProcs.vdp_presentation_queue_block_until_surface_idle); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpProcs.vdp_presentation_queue_target_create_x11); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpProcs.vdp_presentation_queue_query_surface_status); -+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpProcs.vdp_presentation_queue_get_time); - - #undef VDP_PROC - } -@@ -254,13 +268,71 @@ VdpDevice CVDPAUContext::GetDevice() - - void CVDPAUContext::DestroyContext() - { -- if (!m_vdp_device_destroy) -+ if (!m_vdpProcs.vdp_device_destroy) - return; - -- m_vdp_device_destroy(m_vdpDevice); -+ m_vdpProcs.vdp_device_destroy(m_vdpDevice); - m_vdpDevice = VDP_INVALID_HANDLE; - } - -+void CVDPAUContext::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo -+{ -+ VdpStatus rv; -+ CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:"); -+ CLog::Log(LOGNOTICE,"name level macbs width height"); -+ CLog::Log(LOGNOTICE,"------------------------------------"); -+ for(unsigned int x=0; xGetProcs(m_vdpauConfig.vdpProcs); -- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); - m_DisplayState = VDPAU_OPEN; - m_vdpauConfigured = false; - -@@ -449,8 +518,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int - m_presentPicture = 0; - - { -- SpewHardwareAvailable(); -- - VdpDecoderProfile profile = 0; - if(avctx->codec_id == AV_CODEC_ID_H264) - profile = VDP_DECODER_PROFILE_H264_HIGH; -@@ -465,15 +532,15 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int - - /* attempt to create a decoder with this width/height, some sizes are not supported by hw */ - VdpStatus vdp_st; -- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder); -+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(), profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder); - - if(vdp_st != VDP_STATUS_OK) - { -- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st); -+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st); - return false; - } - -- m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); -+ m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); - CheckStatus(vdp_st, __LINE__); - } - -@@ -554,7 +621,7 @@ long CDecoder::Release() - VdpVideoSurface surf; - while((surf = m_videoSurfaces.RemoveNext(true)) != VDP_INVALID_HANDLE) - { -- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); -+ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf); - } - } - return IHardwareDecoder::Release(); -@@ -659,8 +726,6 @@ int CDecoder::Check(AVCodecContext* avctx) - - if (CVDPAUContext::EnsureContext(&m_vdpauConfig.context)) - { -- m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs); -- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice(); - m_DisplayState = VDPAU_OPEN; - m_vdpauConfigured = false; - } -@@ -683,12 +748,7 @@ bool CDecoder::IsVDPAUFormat(PixelFormat format) - - bool CDecoder::Supports(VdpVideoMixerFeature feature) - { -- for(int i = 0; i < m_vdpauConfig.featureCount; i++) -- { -- if(m_vdpauConfig.vdpFeatures[i] == feature) -- return true; -- } -- return false; -+ return m_vdpauConfig.context->Supports(feature); - } - - bool CDecoder::Supports(EINTERLACEMETHOD method) -@@ -721,7 +781,8 @@ EINTERLACEMETHOD CDecoder::AutoInterlaceMethod() - - void CDecoder::FiniVDPAUOutput() - { -- if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return; -+ if (!m_vdpauConfigured) -+ return; - - CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__); - -@@ -731,7 +792,7 @@ void CDecoder::FiniVDPAUOutput() - - VdpStatus vdp_st; - -- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); -+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder); - if (CheckStatus(vdp_st, __LINE__)) - return; - m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE; -@@ -741,7 +802,7 @@ void CDecoder::FiniVDPAUOutput() - VdpVideoSurface surf; - while((surf = m_videoSurfaces.RemoveNext()) != VDP_INVALID_HANDLE) - { -- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf); -+ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf); - if (CheckStatus(vdp_st, __LINE__)) - return; - } -@@ -813,7 +874,7 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) - else - m_vdpauConfig.maxReferences = 2; - -- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, -+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(), - vdp_decoder_profile, - m_vdpauConfig.surfaceWidth, - m_vdpauConfig.surfaceHeight, -@@ -865,55 +926,6 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) - return true; - } - --void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo --{ -- VdpStatus rv; -- CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:"); -- CLog::Log(LOGNOTICE,"name level macbs width height"); -- CLog::Log(LOGNOTICE,"------------------------------------"); -- for(unsigned int x=0; xcodec_id, profile, vdp->m_vdpauConfig.vdpChromaType); - -- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice, -+ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_video_surface_create(vdp->m_vdpauConfig.context->GetDevice(), - vdp->m_vdpauConfig.vdpChromaType, - avctx->coded_width, - avctx->coded_height, -@@ -1037,7 +1049,7 @@ void CDecoder::FFDrawSlice(struct AVCodecContext *s, - uint64_t startTime = CurrentHostCounter(); - uint16_t decoded, processed, rend; - vdp->m_bufferStats.Get(decoded, processed, rend); -- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, -+ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder, - surf, - (VdpPictureInfo const *)&(vdp->m_hwContext.info), - vdp->m_hwContext.bitstream_buffers_used, -@@ -1223,7 +1235,7 @@ bool CDecoder::CheckStatus(VdpStatus vdp_st, int line) - { - if (vdp_st != VDP_STATUS_OK) - { -- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); -+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); - - if(m_DisplayState == VDPAU_OPEN) - { -@@ -1677,9 +1689,9 @@ void CMixer::CreateVdpauMixer() - &m_config.vdpChromaType}; - - VdpStatus vdp_st = VDP_STATUS_ERROR; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_create(m_config.vdpDevice, -- m_config.featureCount, -- m_config.vdpFeatures, -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_create(m_config.context->GetDevice(), -+ m_config.context->GetFeatureCount(), -+ m_config.context->GetFeatures(), - ARSIZE(parameters), - parameters, - parameter_values, -@@ -1766,7 +1778,7 @@ void CMixer::PostProcOff() - VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}; - - VdpBool enabled[]={0,0,0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - - if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION)) -@@ -1774,7 +1786,7 @@ void CMixer::PostProcOff() - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION}; - - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -1783,7 +1795,7 @@ void CMixer::PostProcOff() - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS}; - - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -1895,13 +1907,13 @@ void CMixer::SetColor() - float studioCSC[3][4]; - GenerateStudioCSCMatrix(colorStandard, studioCSC); - void const * pm_CSCMatix[] = { &studioCSC }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); - } - else - { -- vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix); -+ vdp_st = m_config.context->GetProcs().vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix); - void const * pm_CSCMatix[] = { &m_CSCMatrix }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix); - } - - CheckStatus(vdp_st, __LINE__); -@@ -1919,16 +1931,16 @@ void CMixer::SetNoiseReduction() - if (!CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction) - { - VdpBool enabled[]= {0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - return; - } - VdpBool enabled[]={1}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - void* nr[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction }; - CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction); -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr); - CheckStatus(vdp_st, __LINE__); - } - -@@ -1944,16 +1956,16 @@ void CMixer::SetSharpness() - if (!CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness) - { - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - return; - } - VdpBool enabled[]={1}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - void* sh[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness }; - CLog::Log(LOGNOTICE,"Setting Sharpness to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness); -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2003,7 +2015,7 @@ void CMixer::SetDeinterlacing() - if (mode == VS_DEINTERLACEMODE_OFF) - { - VdpBool enabled[] = {0,0,0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - } - else - { -@@ -2012,7 +2024,7 @@ void CMixer::SetDeinterlacing() - VdpBool enabled[] = {1,0,0}; - if (g_advancedSettings.m_videoVDPAUtelecine) - enabled[2] = 1; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - } - else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL - || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF) -@@ -2020,7 +2032,7 @@ void CMixer::SetDeinterlacing() - VdpBool enabled[] = {1,0,0}; - if (g_advancedSettings.m_videoVDPAUtelecine) - enabled[2] = 1; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - } - else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL - || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF) -@@ -2028,12 +2040,12 @@ void CMixer::SetDeinterlacing() - VdpBool enabled[] = {1,1,0}; - if (g_advancedSettings.m_videoVDPAUtelecine) - enabled[2] = 1; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - } - else - { - VdpBool enabled[]={0,0,0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - } - } - CheckStatus(vdp_st, __LINE__); -@@ -2055,7 +2067,7 @@ void CMixer::SetDeintSkipChroma() - val = 0; - - void const *values[]={&val}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values); - - CheckStatus(vdp_st, __LINE__); - } -@@ -2072,63 +2084,63 @@ void CMixer::SetHWUpscaling() - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 8: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 7: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 6: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 5: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 4: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 3: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 2: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - case 1: - if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1)) - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 }; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - break; - } - default: -@@ -2150,7 +2162,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2158,7 +2170,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2166,7 +2178,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2174,7 +2186,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2182,7 +2194,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2190,7 +2202,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2198,7 +2210,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2206,7 +2218,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - -@@ -2214,7 +2226,7 @@ void CMixer::DisableHQScaling() - { - VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 }; - VdpBool enabled[]={0}; -- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled); - CheckStatus(vdp_st, __LINE__); - } - } -@@ -2245,7 +2257,7 @@ void CMixer::Uninit() - { - m_outputSurfaces.pop(); - } -- m_config.vdpProcs.vdp_video_mixer_destroy(m_videoMixer); -+ m_config.context->GetProcs().vdp_video_mixer_destroy(m_videoMixer); - - delete [] m_BlackBar; - } -@@ -2498,7 +2510,7 @@ void CMixer::ProcessPicture() - destRect.y1 = m_config.outHeight; - - // start vdpau video mixer -- vdp_st = m_config.vdpProcs.vdp_video_mixer_render(m_videoMixer, -+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_render(m_videoMixer, - VDP_INVALID_HANDLE, - 0, - m_mixerfield, -@@ -2526,7 +2538,7 @@ void CMixer::ProcessPicture() - clipRect.y1 = clipRect.y0 + 2; - uint32_t *data[] = {m_BlackBar}; - uint32_t pitches[] = {destRect.x1}; -- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface, -+ vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface, - (void**)data, - pitches, - &clipRect); -@@ -2534,7 +2546,7 @@ void CMixer::ProcessPicture() - - clipRect = destRect; - clipRect.y0 = clipRect.y1 - 2; -- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface, -+ vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface, - (void**)data, - pitches, - &clipRect); -@@ -2547,7 +2559,7 @@ bool CMixer::CheckStatus(VdpStatus vdp_st, int line) - { - if (vdp_st != VDP_STATUS_OK) - { -- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); -+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); - m_vdpError = true; - return true; - } -@@ -3076,7 +3088,7 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() - pixmap->DVDPic = pic.DVDPic; - pixmap->id = i; - m_bufferPool.notVisiblePixmaps.push_back(i); -- m_config.vdpProcs.vdp_presentation_queue_display(pixmap->vdp_flip_queue, -+ m_config.context->GetProcs().vdp_presentation_queue_display(pixmap->vdp_flip_queue, - pixmap->surface,0,0,0); - } - if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) -@@ -3086,7 +3098,7 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture() - VdpPresentationQueueStatus status; - int idx = m_bufferPool.notVisiblePixmaps.front(); - VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[idx]; -- vdp_st = m_config.vdpProcs.vdp_presentation_queue_query_surface_status( -+ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_query_surface_status( - pixmap->vdp_flip_queue, pixmap->surface, &status, &time); - - if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE) -@@ -3289,7 +3301,7 @@ bool COutput::EnsureBufferPool() - VdpOutputSurface outputSurface; - for (int i = m_bufferPool.outputSurfaces.size(); i < m_bufferPool.numOutputSurfaces; i++) - { -- vdp_st = m_config.vdpProcs.vdp_output_surface_create(m_config.vdpDevice, -+ vdp_st = m_config.context->GetProcs().vdp_output_surface_create(m_config.context->GetDevice(), - VDP_RGBA_FORMAT_B8G8R8A8, - m_config.outWidth, - m_config.outHeight, -@@ -3318,13 +3330,13 @@ bool COutput::EnsureBufferPool() - pixmap.vdp_flip_target = VDP_INVALID_HANDLE; - MakePixmap(pixmap); - glXMakeCurrent(m_Display, None, NULL); -- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_create_x11(m_config.vdpDevice, -+ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_create_x11(m_config.context->GetDevice(), - pixmap.pixmap, //x_window, - &pixmap.vdp_flip_target); - - CheckStatus(vdp_st, __LINE__); - -- vdp_st = m_config.vdpProcs.vdp_presentation_queue_create(m_config.vdpDevice, -+ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_create(m_config.context->GetDevice(), - pixmap.vdp_flip_target, - &pixmap.vdp_flip_queue); - CheckStatus(vdp_st, __LINE__); -@@ -3352,12 +3364,12 @@ void COutput::ReleaseBufferPool() - { - if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE) - { -- vdp_st = m_config.vdpProcs.vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); -+ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); - CheckStatus(vdp_st, __LINE__); - } - if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE) - { -- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); -+ vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); - CheckStatus(vdp_st, __LINE__); - } - if (m_bufferPool.pixmaps[i].glPixmap) -@@ -3377,7 +3389,7 @@ void COutput::ReleaseBufferPool() - { - if (m_bufferPool.outputSurfaces[i] == VDP_INVALID_HANDLE) - continue; -- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); -+ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); - CheckStatus(vdp_st, __LINE__); - } - m_bufferPool.outputSurfaces.clear(); -@@ -3466,7 +3478,7 @@ void COutput::PreCleanup() - m_bufferPool.glOutputSurfaceMap.erase(it_map); - #endif - -- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); -+ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]); - CheckStatus(vdp_st, __LINE__); - - m_bufferPool.outputSurfaces[i] = VDP_INVALID_HANDLE; -@@ -3625,7 +3637,7 @@ bool COutput::GLInit() - if (!m_config.usePixmaps) - { - while (glGetError() != GL_NO_ERROR); -- glVDPAUInitNV(reinterpret_cast(m_config.vdpDevice), reinterpret_cast(m_config.vdpProcs.vdp_get_proc_address)); -+ glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); - if (glGetError() != GL_NO_ERROR) - { - CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); -@@ -3823,7 +3835,7 @@ bool COutput::CheckStatus(VdpStatus vdp_st, int line) - { - if (vdp_st != VDP_STATUS_OK) - { -- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); -+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line); - m_vdpError = true; - return true; - } -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -index c8e89dc..07a98a2 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -@@ -179,15 +179,11 @@ struct CVdpauConfig - int vidHeight; - int outWidth; - int outHeight; -- VDPAU_procs vdpProcs; -- VdpDevice vdpDevice; - VdpDecoder vdpDecoder; - VdpChromaType vdpChromaType; - CVdpauBufferStats *stats; - CDecoder *vdpau; -- int featureCount; - int upscale; -- VdpVideoMixerFeature vdpFeatures[14]; - CVideoSurfaces *videoSurfaces; - bool usePixmaps; - int numRenderBuffers; -@@ -546,22 +542,28 @@ class CVDPAUContext - public: - static bool EnsureContext(CVDPAUContext **ctx); - void Release(); -- void GetProcs(VDPAU_procs &procs); -+ VDPAU_procs& GetProcs(); - VdpDevice GetDevice(); -+ bool Supports(VdpVideoMixerFeature feature); -+ VdpVideoMixerFeature* GetFeatures(); -+ int GetFeatureCount(); - private: - CVDPAUContext(); - void Close(); - bool LoadSymbols(); - bool CreateContext(); - void DestroyContext(); -+ void QueryProcs(); -+ void SpewHardwareAvailable(); - static CVDPAUContext *m_context; - static CCriticalSection m_section; - static Display *m_display; - int m_refCount; -+ VdpVideoMixerFeature m_vdpFeatures[14]; -+ int m_featureCount; - static void *m_dlHandle; - VdpDevice m_vdpDevice; -- VdpGetProcAddress *m_vdp_get_proc_address; -- VdpDeviceDestroy *m_vdp_device_destroy; -+ VDPAU_procs m_vdpProcs; - VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address); - }; - -@@ -619,7 +621,6 @@ class CDecoder - protected: - void SetWidthHeight(int width, int height); - bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames); -- void SpewHardwareAvailable(); - bool CheckStatus(VdpStatus vdp_st, int line); - void FiniVDPAUOutput(); - void ReturnRenderPicture(CVdpauRenderPicture *renderPic); --- -1.8.4 - - -From eaad4ad62d588c9cc7d90af5dfded1b33bfe904e Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Mon, 30 Sep 2013 21:30:28 +0200 -Subject: [PATCH 87/89] vdpau: drop pixmap magic, it violates the spec - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 328 ++----------------------- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 31 --- - 2 files changed, 17 insertions(+), 342 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index 3b93eda..d844993 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -249,15 +249,6 @@ void CVDPAUContext::QueryProcs() - VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpProcs.vdp_decoder_destroy); - VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpProcs.vdp_decoder_render); - VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpProcs.vdp_decoder_query_caps); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpProcs.vdp_presentation_queue_target_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpProcs.vdp_presentation_queue_create); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpProcs.vdp_presentation_queue_destroy); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpProcs.vdp_presentation_queue_display); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpProcs.vdp_presentation_queue_block_until_surface_idle); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpProcs.vdp_presentation_queue_target_create_x11); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpProcs.vdp_presentation_queue_query_surface_status); -- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpProcs.vdp_presentation_queue_get_time); -- - #undef VDP_PROC - } - -@@ -757,11 +748,8 @@ bool CDecoder::Supports(EINTERLACEMETHOD method) - || method == VS_INTERLACEMETHOD_AUTO) - return true; - -- if (!m_vdpauConfig.usePixmaps) -- { -- if (method == VS_INTERLACEMETHOD_RENDER_BOB) -- return true; -- } -+ if (method == VS_INTERLACEMETHOD_RENDER_BOB) -+ return true; - - if (method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE) - return false; -@@ -897,15 +885,6 @@ bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames) - sizeof(m_vdpauConfig))) - { - bool success = reply->signal == COutputControlProtocol::ACC ? true : false; -- if (success) -- { -- CVdpauConfig *data; -- data = (CVdpauConfig*)reply->data; -- if (data) -- { -- m_vdpauConfig.usePixmaps = data->usePixmaps; -- } -- } - reply->Release(); - if (!success) - { -@@ -2961,7 +2940,6 @@ bool COutput::Uninit() - { - m_mixer.Dispose(); - GLUnmapSurfaces(); -- GLUnbindPixmaps(); - ReleaseBufferPool(); - DestroyGlxContext(); - return true; -@@ -3055,69 +3033,16 @@ void COutput::Flush() - - bool COutput::HasWork() - { -- if (m_config.usePixmaps) -- { -- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0) -- return true; -- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) -- return true; -- return false; -- } -- else -- { -- if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) -- return true; -- return false; -- } -+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) -+ return true; -+ return false; - } - - CVdpauRenderPicture* COutput::ProcessMixerPicture() - { - CVdpauRenderPicture *retPic = NULL; - -- if (m_config.usePixmaps) -- { -- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0) -- { -- unsigned int i = FindFreePixmap(); -- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[i]; -- pixmap->used = true; -- CVdpauProcessedPicture pic = m_bufferPool.processedPics.front(); -- m_bufferPool.processedPics.pop(); -- pixmap->surface = pic.outputSurface; -- pixmap->DVDPic = pic.DVDPic; -- pixmap->id = i; -- m_bufferPool.notVisiblePixmaps.push_back(i); -- m_config.context->GetProcs().vdp_presentation_queue_display(pixmap->vdp_flip_queue, -- pixmap->surface,0,0,0); -- } -- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty()) -- { -- VdpStatus vdp_st; -- VdpTime time; -- VdpPresentationQueueStatus status; -- int idx = m_bufferPool.notVisiblePixmaps.front(); -- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[idx]; -- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_query_surface_status( -- pixmap->vdp_flip_queue, pixmap->surface, &status, &time); -- -- if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE) -- { -- int idx = m_bufferPool.freeRenderPics.front(); -- retPic = m_bufferPool.allRenderPics[idx]; -- m_bufferPool.freeRenderPics.pop_front(); -- m_bufferPool.usedRenderPics.push_back(idx); -- retPic->sourceIdx = pixmap->id; -- retPic->DVDPic = pixmap->DVDPic; -- retPic->valid = true; -- retPic->texture[0] = pixmap->texture; -- retPic->crop = CRect(0,0,0,0); -- m_bufferPool.notVisiblePixmaps.pop_front(); -- m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &pixmap->surface, sizeof(pixmap->surface)); -- } -- } -- } // pixmap -- else if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) -+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty()) - { - int idx = m_bufferPool.freeRenderPics.front(); - retPic = m_bufferPool.allRenderPics[idx]; -@@ -3247,12 +3172,7 @@ bool COutput::ProcessSyncPicture() - - void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) - { -- if (m_config.usePixmaps) -- { -- m_bufferPool.pixmaps[pic->sourceIdx].used = false; -- return; -- } -- else if (pic->DVDPic.format == RENDER_FMT_VDPAU_420) -+ if (pic->DVDPic.format == RENDER_FMT_VDPAU_420) - { - std::map::iterator it; - it = m_bufferPool.glVideoSurfaceMap.find(pic->sourceIdx); -@@ -3278,21 +3198,6 @@ void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic) - } - } - --int COutput::FindFreePixmap() --{ -- // find free pixmap -- unsigned int i; -- for (i = 0; i < m_bufferPool.pixmaps.size(); ++i) -- { -- if (!m_bufferPool.pixmaps[i].used) -- break; -- } -- if (i == m_bufferPool.pixmaps.size()) -- return -1; -- else -- return i; --} -- - bool COutput::EnsureBufferPool() - { - VdpStatus vdp_st; -@@ -3315,40 +3220,6 @@ bool COutput::EnsureBufferPool() - sizeof(VdpOutputSurface)); - CLog::Log(LOGNOTICE, "VDPAU::COutput::InitBufferPool - Output Surface created"); - } -- -- -- if (m_config.usePixmaps && m_bufferPool.pixmaps.empty()) -- { -- // create pixmpas -- VdpauBufferPool::Pixmaps pixmap; -- unsigned int numPixmaps = NUM_RENDER_PICS; -- for (unsigned int i = 0; i < numPixmaps; i++) -- { -- pixmap.pixmap = None; -- pixmap.glPixmap = None; -- pixmap.vdp_flip_queue = VDP_INVALID_HANDLE; -- pixmap.vdp_flip_target = VDP_INVALID_HANDLE; -- MakePixmap(pixmap); -- glXMakeCurrent(m_Display, None, NULL); -- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_create_x11(m_config.context->GetDevice(), -- pixmap.pixmap, //x_window, -- &pixmap.vdp_flip_target); -- -- CheckStatus(vdp_st, __LINE__); -- -- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_create(m_config.context->GetDevice(), -- pixmap.vdp_flip_target, -- &pixmap.vdp_flip_queue); -- CheckStatus(vdp_st, __LINE__); -- glXMakeCurrent(m_Display, m_glPixmap, m_glContext); -- -- pixmap.id = i; -- pixmap.used = false; -- m_bufferPool.pixmaps.push_back(pixmap); -- } -- GLBindPixmaps(); -- } -- - return true; - } - -@@ -3358,32 +3229,6 @@ void COutput::ReleaseBufferPool() - - CSingleLock lock(m_bufferPool.renderPicSec); - -- if (m_config.usePixmaps) -- { -- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); ++i) -- { -- if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE) -- { -- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue); -- CheckStatus(vdp_st, __LINE__); -- } -- if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE) -- { -- vdp_st = m_config.context->GetProcs().vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target); -- CheckStatus(vdp_st, __LINE__); -- } -- if (m_bufferPool.pixmaps[i].glPixmap) -- { -- glXDestroyPixmap(m_Display, m_bufferPool.pixmaps[i].glPixmap); -- } -- if (m_bufferPool.pixmaps[i].pixmap) -- { -- XFreePixmap(m_Display, m_bufferPool.pixmaps[i].pixmap); -- } -- } -- m_bufferPool.pixmaps.clear(); -- } -- - // release all output surfaces - for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i) - { -@@ -3498,89 +3343,8 @@ void COutput::InitMixer() - } - } - --bool COutput::MakePixmap(VdpauBufferPool::Pixmaps &pixmap) --{ -- CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", m_config.outWidth, m_config.outHeight); -- -- // Get our window attribs. -- XWindowAttributes wndattribs; -- XGetWindowAttributes(m_Display, g_Windowing.GetWindow(), &wndattribs); -- -- pixmap.pixmap = XCreatePixmap(m_Display, -- g_Windowing.GetWindow(), -- m_config.outWidth, -- m_config.outHeight, -- wndattribs.depth); -- if (!pixmap.pixmap) -- { -- CLog::Log(LOGERROR, "VDPAU::COUtput::MakePixmap - GLX Error: MakePixmap: Unable to create XPixmap"); -- return false; -- } -- --// XGCValues values = {}; --// GC xgc; --// values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display)); --// xgc = XCreateGC(m_Display, pixmap.pixmap, GCForeground, &values); --// XFillRectangle(m_Display, pixmap.pixmap, xgc, 0, 0, m_config.outWidth, m_config.outHeight); --// XFreeGC(m_Display, xgc); -- -- if(!MakePixmapGL(pixmap)) -- return false; -- -- return true; --} -- --bool COutput::MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap) --{ -- int num=0; -- int fbConfigIndex = 0; -- -- int doubleVisAttributes[] = { -- GLX_RENDER_TYPE, GLX_RGBA_BIT, -- GLX_RED_SIZE, 8, -- GLX_GREEN_SIZE, 8, -- GLX_BLUE_SIZE, 8, -- GLX_ALPHA_SIZE, 8, -- GLX_DEPTH_SIZE, 8, -- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, -- GLX_BIND_TO_TEXTURE_RGBA_EXT, True, -- GLX_DOUBLEBUFFER, False, -- GLX_Y_INVERTED_EXT, True, -- GLX_X_RENDERABLE, True, -- None -- }; -- -- int pixmapAttribs[] = { -- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, -- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, -- None -- }; -- -- GLXFBConfig *fbConfigs; -- fbConfigs = glXChooseFBConfig(m_Display, g_Windowing.GetCurrentScreen(), doubleVisAttributes, &num); -- if (fbConfigs==NULL) -- { -- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - No compatible framebuffers found"); -- return false; -- } -- fbConfigIndex = 0; -- -- pixmap.glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], pixmap.pixmap, pixmapAttribs); -- -- if (!pixmap.glPixmap) -- { -- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - Could not create Pixmap"); -- XFree(fbConfigs); -- return false; -- } -- XFree(fbConfigs); -- return true; --} -- - bool COutput::GLInit() - { -- glXBindTexImageEXT = NULL; -- glXReleaseTexImageEXT = NULL; - #ifdef GL_NV_vdpau_interop - glVDPAUInitNV = NULL; - glVDPAUFiniNV = NULL; -@@ -3594,8 +3358,6 @@ bool COutput::GLInit() - glVDPAUGetSurfaceivNV = NULL; - #endif - -- m_config.usePixmaps = false; -- - #ifdef GL_NV_vdpau_interop - if (glewIsSupported("GL_NV_vdpau_interop")) - { -@@ -3625,27 +3387,21 @@ bool COutput::GLInit() - else - #endif - { -- m_config.usePixmaps = true; -- CSettings::Get().SetBool("videoplayer.usevdpaumixer",true); -+ // TODO should be detected before vdpau is opened, though very unlikely -+ // that this code is hit -+ CLog::Log(LOGERROR, "VDPAU::COutput driver does not support GL_NV_vdpau_interop"); - } -- if (!glXBindTexImageEXT) -- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT"); -- if (!glXReleaseTexImageEXT) -- glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT"); - - #ifdef GL_NV_vdpau_interop -- if (!m_config.usePixmaps) -+ while (glGetError() != GL_NO_ERROR); -+ glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); -+ if (glGetError() != GL_NO_ERROR) - { -- while (glGetError() != GL_NO_ERROR); -- glVDPAUInitNV(reinterpret_cast(m_config.context->GetDevice()), reinterpret_cast(m_config.context->GetProcs().vdp_get_proc_address)); -- if (glGetError() != GL_NO_ERROR) -- { -- CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); -- m_vdpError = true; -- return false; -- } -- CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized"); -+ CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed"); -+ m_vdpError = true; -+ return false; - } -+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized"); - #endif - - #ifdef GL_ARB_sync -@@ -3662,8 +3418,6 @@ bool COutput::GLInit() - void COutput::GLMapSurfaces() - { - #ifdef GL_NV_vdpau_interop -- if (m_config.usePixmaps) -- return; - - if (m_config.useInteropYuv) - { -@@ -3757,8 +3511,6 @@ void COutput::GLMapSurfaces() - void COutput::GLUnmapSurfaces() - { - #ifdef GL_NV_vdpau_interop -- if (m_config.usePixmaps) -- return; - - { - std::map::iterator it; -@@ -3785,52 +3537,6 @@ void COutput::GLUnmapSurfaces() - #endif - } - --void COutput::GLBindPixmaps() --{ -- if (!m_config.usePixmaps) -- return; -- -- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++) -- { -- // create texture -- glGenTextures(1, &m_bufferPool.pixmaps[i].texture); -- -- //bind texture -- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture); -- -- // bind pixmap -- glXBindTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT, NULL); -- -- glBindTexture(GL_TEXTURE_2D, 0); -- } -- -- CLog::Log(LOGNOTICE, "VDPAU::COutput: bound pixmaps"); --} -- --void COutput::GLUnbindPixmaps() --{ -- if (!m_config.usePixmaps) -- return; -- -- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++) -- { -- // create texture -- if (!glIsTexture(m_bufferPool.pixmaps[i].texture)) -- continue; -- -- //bind texture -- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture); -- -- // release pixmap -- glXReleaseTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT); -- -- glBindTexture(GL_TEXTURE_2D, 0); -- -- glDeleteTextures(1, &m_bufferPool.pixmaps[i].texture); -- } -- CLog::Log(LOGNOTICE, "VDPAU::COutput: unbound pixmaps"); --} -- - bool COutput::CheckStatus(VdpStatus vdp_st, int line) - { - if (vdp_st != VDP_STATUS_OK) -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -index 07a98a2..abe8da2 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h -@@ -103,15 +103,6 @@ struct VDPAU_procs - - VdpGenerateCSCMatrix * vdp_generate_csc_matrix; - -- VdpPresentationQueueTargetDestroy * vdp_presentation_queue_target_destroy; -- VdpPresentationQueueCreate * vdp_presentation_queue_create; -- VdpPresentationQueueDestroy * vdp_presentation_queue_destroy; -- VdpPresentationQueueDisplay * vdp_presentation_queue_display; -- VdpPresentationQueueBlockUntilSurfaceIdle * vdp_presentation_queue_block_until_surface_idle; -- VdpPresentationQueueTargetCreateX11 * vdp_presentation_queue_target_create_x11; -- VdpPresentationQueueQuerySurfaceStatus * vdp_presentation_queue_query_surface_status; -- VdpPresentationQueueGetTime * vdp_presentation_queue_get_time; -- - VdpGetErrorString * vdp_get_error_string; - - VdpDecoderCreate * vdp_decoder_create; -@@ -185,7 +176,6 @@ struct CVdpauConfig - CDecoder *vdpau; - int upscale; - CVideoSurfaces *videoSurfaces; -- bool usePixmaps; - int numRenderBuffers; - uint32_t maxReferences; - bool useInteropYuv; -@@ -363,18 +353,6 @@ struct VdpauBufferPool - { - VdpauBufferPool(); - virtual ~VdpauBufferPool(); -- struct Pixmaps -- { -- unsigned short id; -- bool used; -- DVDVideoPicture DVDPic; -- GLuint texture; -- Pixmap pixmap; -- GLXPixmap glPixmap; -- VdpPresentationQueueTarget vdp_flip_target; -- VdpPresentationQueue vdp_flip_queue; -- VdpOutputSurface surface; -- }; - struct GLVideoSurface - { - GLuint texture[4]; -@@ -386,9 +364,7 @@ struct VdpauBufferPool - }; - std::vector allRenderPics; - unsigned short numOutputSurfaces; -- std::vector pixmaps; - std::vector outputSurfaces; -- std::deque notVisiblePixmaps; - std::map glVideoSurfaceMap; - std::map glOutputSurfaceMap; - std::queue processedPics; -@@ -457,7 +433,6 @@ class COutput : private CThread - void QueueReturnPicture(CVdpauRenderPicture *pic); - void ProcessReturnPicture(CVdpauRenderPicture *pic); - bool ProcessSyncPicture(); -- int FindFreePixmap(); - bool Init(); - bool Uninit(); - void Flush(); -@@ -470,10 +445,6 @@ class COutput : private CThread - bool GLInit(); - void GLMapSurfaces(); - void GLUnmapSurfaces(); -- void GLBindPixmaps(); -- void GLUnbindPixmaps(); -- bool MakePixmap(VdpauBufferPool::Pixmaps &pixmap); -- bool MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap); - bool CheckStatus(VdpStatus vdp_st, int line); - CEvent m_outMsgEvent; - CEvent *m_inMsgEvent; -@@ -494,8 +465,6 @@ class COutput : private CThread - GLXPixmap m_glPixmap; - - // gl functions -- PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT; -- PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT; - #ifdef GL_NV_vdpau_interop - PFNGLVDPAUINITNVPROC glVDPAUInitNV; - PFNGLVDPAUFININVPROC glVDPAUFiniNV; --- -1.8.4 - - -From fa0004505a63f88470c0afc368668939b0ac08ed Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Tue, 1 Oct 2013 17:42:01 +0200 -Subject: [PATCH 88/89] vdpau: reduce number of render pics - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index d844993..f2d1c71 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -38,7 +38,7 @@ - #include "cores/VideoRenderers/RenderFlags.h" - - using namespace VDPAU; --#define NUM_RENDER_PICS 9 -+#define NUM_RENDER_PICS 7 - - #define ARSIZE(x) (sizeof(x) / sizeof((x)[0])) - --- -1.8.4 - - -From dc895960a515c0f5da6a722cde7598ce4559d831 Mon Sep 17 00:00:00 2001 -From: Rainer Hochecker -Date: Tue, 1 Oct 2013 17:51:02 +0200 -Subject: [PATCH 89/89] vdpau: cosmetics - ---- - xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 20 +++----------------- - 1 file changed, 3 insertions(+), 17 deletions(-) - -diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -index f2d1c71..d383c69 100644 ---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp -@@ -958,7 +958,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic) - - void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic) - { -- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__); - CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque; - CDecoder* vdp = (CDecoder*)ctx->GetHardware(); - -@@ -1292,7 +1291,7 @@ void CVdpauRenderPicture::Sync() - // Mixer - //----------------------------------------------------------------------------- - CMixer::CMixer(CEvent *inMsgEvent) : -- CThread("Vdpau Mixer Thread"), -+ CThread("Vdpau Mixer"), - m_controlPort("ControlPort", inMsgEvent, &m_outMsgEvent), - m_dataPort("DataPort", inMsgEvent, &m_outMsgEvent) - { -@@ -1456,11 +1455,6 @@ void CMixer::StateMachine(int signal, Protocol *port, Message *msg) - } - else - { --// if (m_extTimeout != 0) --// { --// SetPostProcFeatures(false); --// CLog::Log(LOGWARNING,"CVDPAU::Mixer timeout - decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size()); --// } - m_extTimeout = 100; - } - return; -@@ -1528,11 +1522,6 @@ void CMixer::StateMachine(int signal, Protocol *port, Message *msg) - } - else - { --// if (m_extTimeout != 0) --// { --// SetPostProcFeatures(false); --// CLog::Log(LOGNOTICE,"---mixer wait2 decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size()); --// } - m_extTimeout = 100; - } - return; -@@ -2210,7 +2199,6 @@ void CMixer::DisableHQScaling() - } - } - -- - void CMixer::Init() - { - m_Brightness = 0.0; -@@ -2276,10 +2264,9 @@ void CMixer::Flush() - void CMixer::InitCycle() - { - CheckFeatures(); -- uint64_t latency; - int flags; -+ uint64_t latency; - m_config.stats->GetParams(latency, flags); -- latency = (latency*1000)/CurrentHostFrequency(); - if (flags & DVP_FLAG_NO_POSTPROC) - SetPostProcFeatures(false); - else -@@ -2394,7 +2381,6 @@ void CMixer::FiniCycle() - m_config.videoSurfaces->ClearRender(tmp.videoSurface); - } - m_mixerInput.pop_back(); --// m_config.stats->DecDecoded(); - } - } - -@@ -2574,7 +2560,7 @@ bool CMixer::CheckStatus(VdpStatus vdp_st, int line) - // Output - //----------------------------------------------------------------------------- - COutput::COutput(CEvent *inMsgEvent) : -- CThread("Vdpau Output Thread"), -+ CThread("Vdpau Output"), - m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent), - m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent), - m_mixer(&m_outMsgEvent) --- -1.8.4 - diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-995.10-disable-alt-tab.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-995.10-disable-alt-tab.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-995.10-disable-alt-tab.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-995.10-disable-alt-tab.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-02-udev-mount-add-cdrom-support.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-02-udev-mount-add-cdrom-support.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-02-udev-mount-add-cdrom-support.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-02-udev-mount-add-cdrom-support.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-03-show-all-removable-disks-mounted-under-media.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-03-show-all-removable-disks-mounted-under-media.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-03-show-all-removable-disks-mounted-under-media.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-03-show-all-removable-disks-mounted-under-media.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-04-fixed-context-menu-remove-safely-selection.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-04-fixed-context-menu-remove-safely-selection.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-04-fixed-context-menu-remove-safely-selection.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-04-fixed-context-menu-remove-safely-selection.patch diff --git a/packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-05-use-udevil-to-umount.-escape-mountpath.patch b/packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-05-use-udevil-to-umount.-escape-mountpath.patch similarity index 100% rename from packages/mediacenter/xbmc/patches/13.alpha-710b1ee/xbmc-AML-XB9295c3f-05-use-udevil-to-umount.-escape-mountpath.patch rename to packages/mediacenter/xbmc/patches/13.alpha-9df3bc9/xbmc-AML-XB9295c3f-05-use-udevil-to-umount.-escape-mountpath.patch