Skip to content

Commit

Permalink
vdpau: add gui setting for opengl interop
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Jan 9, 2012
1 parent a2ec819 commit 76fbaa8
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 38 deletions.
3 changes: 2 additions & 1 deletion language/Dutch/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,8 @@
<string id="13430">Hardwareversnelling inschakelen (OpenMax)</string>
<string id="13431">Pixelshaders</string>
<string id="13432">Hardware acceleratie toestaan (VideoToolbox)</string>

<string id="13433">Vdpau OpenGL interop RGB inschakelen</string>
<string id="13434">Vdpau OpenGL interop YUV inschakelen</string>
<string id="13500">A/V-synchronisatiemethode</string>
<string id="13501">Audiosignaal</string>
<string id="13502">Videosignaal (Drop/Dupe audio)</string>
Expand Down
2 changes: 2 additions & 0 deletions language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,8 @@
<string id="13430">Allow hardware acceleration (OpenMax)</string>
<string id="13431">Pixel Shaders</string>
<string id="13432">Allow hardware acceleration (VideoToolbox)</string>
<string id="13433">Allow Vdpau OpenGL interop RGB</string>
<string id="13434">Allow Vdpau OpenGL interop YUV</string>

<string id="13500">A/V sync method</string>
<string id="13501">Audio clock</string>
Expand Down
2 changes: 2 additions & 0 deletions language/German/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@
<string id="13430">Hardwarebeschleunigung erlauben (OpenMax)</string>
<string id="13431">Pixel Shaders</string>
<string id="13432">Hardwarebeschleunigung erlauben (VideoToolbox)</string>
<string id="13433">Vdpau OpenGL interop RGB erlauben</string>
<string id="13434">Vdpau OpenGL interop YUV erlauben</string>

<string id="13500">A/V Sync Methode</string>
<string id="13501">Audio Takt</string>
Expand Down
71 changes: 35 additions & 36 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*
*/

// switch to turn on GL_NV_vdpau_interop
#define VDPAU_GL_INTEROP

#include "system.h"
#ifdef HAVE_LIBVDPAU
#include <dlfcn.h>
Expand Down Expand Up @@ -118,42 +115,43 @@ CVDPAU::CVDPAU() : CThread("CVDPAU")
if (!glXReleaseTexImageEXT)
glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");

hasVdpauGlInterop = false;
m_GlInteropStatus = OUTPUT_NONE;
m_renderThread = NULL;
m_presentPicture = m_flipBuffer[0] = m_flipBuffer[1] = m_flipBuffer[2] = NULL;
m_flipBufferIdx = 0;

#ifdef VDPAU_GL_INTEROP
#ifdef GL_NV_vdpau_interop
if (!glVDPAUInitNV)
glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUInitNV");
if (!glVDPAUFiniNV)
glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glXGetProcAddress((GLubyte *) "glVDPAUFiniNV");
if (!glVDPAURegisterOutputSurfaceNV)
glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterOutputSurfaceNV");
if (!glVDPAURegisterVideoSurfaceNV)
glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterVideoSurfaceNV");
if (!glVDPAUIsSurfaceNV)
glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUIsSurfaceNV");
if (!glVDPAUUnregisterSurfaceNV)
glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnregisterSurfaceNV");
if (!glVDPAUSurfaceAccessNV)
glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUSurfaceAccessNV");
if (!glVDPAUMapSurfacesNV)
glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUMapSurfacesNV");
if (!glVDPAUUnmapSurfacesNV)
glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnmapSurfacesNV");
if (!glVDPAUGetSurfaceivNV)
glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUGetSurfaceivNV");

hasVdpauGlInterop = glewIsSupported("GL_NV_vdpau_interop");
if (hasVdpauGlInterop)
{
CLog::Log(LOGNOTICE, "CVDPAU::CVDPAU GL interop supported and being used");
if (glewIsSupported("GL_NV_vdpau_interop"))
{
if (!glVDPAUInitNV)
glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUInitNV");
if (!glVDPAUFiniNV)
glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glXGetProcAddress((GLubyte *) "glVDPAUFiniNV");
if (!glVDPAURegisterOutputSurfaceNV)
glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterOutputSurfaceNV");
if (!glVDPAURegisterVideoSurfaceNV)
glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterVideoSurfaceNV");
if (!glVDPAUIsSurfaceNV)
glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUIsSurfaceNV");
if (!glVDPAUUnregisterSurfaceNV)
glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnregisterSurfaceNV");
if (!glVDPAUSurfaceAccessNV)
glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUSurfaceAccessNV");
if (!glVDPAUMapSurfacesNV)
glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUMapSurfacesNV");
if (!glVDPAUUnmapSurfacesNV)
glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnmapSurfacesNV");
if (!glVDPAUGetSurfaceivNV)
glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUGetSurfaceivNV");

CLog::Log(LOGNOTICE, "CVDPAU::CVDPAU GL interop supported");
}
else
#endif
#endif
{
g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
}

totalAvailableOutputSurfaces = 0;
presentSurface = VDP_INVALID_HANDLE;
Expand Down Expand Up @@ -647,7 +645,7 @@ bool CVDPAU::Supports(EINTERLACEMETHOD method)
|| method == VS_INTERLACEMETHOD_AUTO)
return true;

if (hasVdpauGlInterop)
if (g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
{
if (method == VS_INTERLACEMETHOD_RENDER_BOB)
return true;
Expand Down Expand Up @@ -1167,7 +1165,8 @@ bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)
}
}

if (!m_bVdpauDeinterlacing && hasVdpauGlInterop)
if (!m_bVdpauDeinterlacing &&
g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
{
if (m_vdpauOutputMethod == OUTPUT_GL_INTEROP_YUV)
return true;
Expand Down Expand Up @@ -1200,7 +1199,7 @@ bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)
totalAvailableOutputSurfaces = 0;

int tmpMaxOutputSurfaces = NUM_OUTPUT_SURFACES;
if (!hasVdpauGlInterop)
if (!g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb"))
tmpMaxOutputSurfaces = 4;

// Creation of outputSurfaces
Expand Down Expand Up @@ -1228,7 +1227,7 @@ bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)

for (int i = 0; i < NUM_OUTPUT_SURFACES; i++)
{
if (hasVdpauGlInterop)
if (g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb"))
m_allOutPic[i].outputSurface = outputSurfaces[i];

m_allOutPic[i].render = NULL;
Expand All @@ -1237,7 +1236,7 @@ bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)

m_mixerCmd = 0;

if (hasVdpauGlInterop)
if (g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb"))
m_vdpauOutputMethod = OUTPUT_GL_INTEROP_RGB;
else
{
Expand Down
1 change: 0 additions & 1 deletion xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ class CVDPAU
bool m_bVdpauDeinterlacing;
bool m_binterlacedFrame;
int m_dropCount;
bool hasVdpauGlInterop;
volatile bool glInteropFinish;
bool m_bsurfaceMapped;
bool m_dropState;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/settings/GUISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ void CGUISettings::Initialize()

#ifdef HAVE_LIBVDPAU
AddBool(vp, "videoplayer.usevdpau", 13425, true);
AddBool(vp, "videoplayer.usevdpauinteroprgb", 13433, true);
AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
#endif
#ifdef HAVE_LIBVA
AddBool(vp, "videoplayer.usevaapi", 13426, true);
Expand Down
34 changes: 34 additions & 0 deletions xbmc/settings/GUIWindowSettingsCategory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,40 @@ void CGUIWindowSettingsCategory::UpdateSettings()
pControl->SetEnabled(true);
}
}
else if (strSetting.Equals("videoplayer.usevdpauinteropyuv"))
{
bool hasInterop = false;
#ifdef GL_NV_vdpau_interop
hasInterop = true;
#endif
CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
{
pControl->SetEnabled(true);
}
else
{
pControl->SetEnabled(false);
g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
}
}
else if (strSetting.Equals("videoplayer.usevdpauinteroprgb"))
{
bool hasInterop = false;
#ifdef GL_NV_vdpau_interop
hasInterop = true;
#endif
CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
{
pControl->SetEnabled(true);
}
else
{
pControl->SetEnabled(false);
g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
}
}
else
#endif
if (strSetting.Equals("videoscreen.resolution"))
Expand Down

0 comments on commit 76fbaa8

Please sign in to comment.