Skip to content

Commit

Permalink
squash: Move renderinfo into a structure
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 6, 2015
1 parent 8e6ed05 commit 7aa2225
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 80 deletions.
7 changes: 2 additions & 5 deletions xbmc/cores/VideoRenderers/BaseRenderer.h
Expand Up @@ -95,18 +95,15 @@ class CBaseRenderer
/**
* Returns number of references a single buffer can retain when rendering a single frame
*/
virtual unsigned int GetOptimalBufferSize() { return 0; }
virtual unsigned int GetMaxBufferSize() { return 0; }
virtual void *GetOpaquePointer() { return NULL; }
virtual void SetBufferSize(int numBuffers) { }
virtual void ReleaseBuffer(int idx) { }
virtual bool NeedBufferForRef(int idx) { return false; }
virtual bool IsGuiLayer() { return true; }

virtual bool Supports(ERENDERFEATURE feature) { return false; }

// Supported pixel formats, can be called before configure
std::vector<ERenderFormat> SupportedFormats() { return std::vector<ERenderFormat>(); }
// Render info, can be called before configure
virtual CRenderInfo GetRenderInfo() { return CRenderInfo(); }

virtual void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
virtual void RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn);
Expand Down
12 changes: 8 additions & 4 deletions xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
Expand Up @@ -3456,17 +3456,21 @@ void CLinuxRendererGL::UnBindPbo(YUVBUFFER& buff)
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
}

unsigned int CLinuxRendererGL::GetOptimalBufferSize()
CRenderInfo CLinuxRendererGL::GetRenderInfo()
{
CRenderInfo info;
info.formats = m_formats;
info.max_buffer_size = NUM_BUFFERS;
if(m_format == RENDER_FMT_CVBREF)
return 2;
info.optimal_buffer_size = 2;
else if (m_format == RENDER_FMT_VAAPI ||
m_format == RENDER_FMT_VAAPINV12 ||
m_format == RENDER_FMT_VDPAU ||
m_format == RENDER_FMT_VDPAU_420)
return 5;
info.optimal_buffer_size = 5;
else
return 3;
info.optimal_buffer_size = 3;
return info;
}

#ifdef HAVE_LIBVDPAU
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/VideoRenderers/LinuxRendererGL.h
Expand Up @@ -134,8 +134,6 @@ class CLinuxRendererGL : public CBaseRenderer
virtual void Flush();
virtual void ReleaseBuffer(int idx);
virtual void SetBufferSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
virtual unsigned int GetMaxBufferSize() { return NUM_BUFFERS; }
virtual unsigned int GetOptimalBufferSize();

#ifdef HAVE_LIBVDPAU
virtual void AddProcessor(VDPAU::CVdpauRenderPicture* vdpau, int index);
Expand All @@ -158,7 +156,7 @@ class CLinuxRendererGL : public CBaseRenderer

virtual EINTERLACEMETHOD AutoInterlaceMethod();

virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
virtual CRenderInfo GetRenderInfo();

protected:
virtual void Render(DWORD flags, int renderBuffer);
Expand Down
15 changes: 10 additions & 5 deletions xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
Expand Up @@ -2980,18 +2980,23 @@ EINTERLACEMETHOD CLinuxRendererGLES::AutoInterlaceMethod()
#endif
}

unsigned int CLinuxRendererGLES::GetOptimalBufferSize()
CRenderInfo CLinuxRendererGLES::GetRenderInfo()
{
CRenderInfo info;
info.formats = m_formats;
info.max_buffer_size = NUM_BUFFERS;
if(m_format == RENDER_FMT_OMXEGL ||
m_format == RENDER_FMT_CVBREF ||
m_format == RENDER_FMT_EGLIMG ||
m_format == RENDER_FMT_MEDIACODEC)
return 2;
else if(m_format == RENDER_FMT_IMXMAP)
info.optimal_buffer_size = 2;
else if(m_format == RENDER_FMT_IMXMAP) {
// Let the codec control the buffer size
return GetMaxBufferSize();
info.optimal_buffer_size = info.max_buffer_size;
}
else
return 3;
info.optimal_buffer_size = 3;
return info;
}

#ifdef HAVE_LIBOPENMAX
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/VideoRenderers/LinuxRendererGLES.h
Expand Up @@ -145,8 +145,6 @@ class CLinuxRendererGLES : public CBaseRenderer
virtual void ReorderDrawPoints();
virtual void ReleaseBuffer(int idx);
virtual void SetBufferSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
virtual unsigned int GetMaxBufferSize() { return NUM_BUFFERS; }
virtual unsigned int GetOptimalBufferSize();
virtual bool IsGuiLayer();

virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
Expand All @@ -160,7 +158,7 @@ class CLinuxRendererGLES : public CBaseRenderer

virtual EINTERLACEMETHOD AutoInterlaceMethod();

virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
virtual CRenderInfo GetRenderInfo();

#ifdef HAVE_LIBOPENMAX
virtual void AddProcessor(COpenMax* openMax, DVDVideoPicture *picture, int index);
Expand Down
9 changes: 7 additions & 2 deletions xbmc/cores/VideoRenderers/MMALRenderer.cpp
Expand Up @@ -39,9 +39,10 @@
#define MMAL_DEBUG_VERBOSE
#endif

void *CMMALRenderer::GetOpaquePointer()
CRenderInfo CMMALRenderer::GetRenderInfo()
{
CSingleLock lock(m_sharedSection);
CRenderInfo info;

// we'll assume that video is accelerated (RENDER_FMT_MMAL) for now
// we can reconfigure renderer later if necessary
Expand All @@ -52,7 +53,11 @@ void *CMMALRenderer::GetOpaquePointer()
CLog::Log(LOGDEBUG, "%s::%s cookie:%p", CLASSNAME, __func__, (void *)m_vout_input_pool);
#endif

return (void *)m_vout_input_pool;
info.max_buffer_size = NUM_BUFFERS;
info.optimal_buffer_size = NUM_BUFFERS;
info.opaque_pointer = (void *)m_vout_input_pool;
info.formats = m_formats;
return info;
}

static void vout_control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
Expand Down
5 changes: 1 addition & 4 deletions xbmc/cores/VideoRenderers/MMALRenderer.h
Expand Up @@ -70,7 +70,7 @@ class CMMALRenderer : public CBaseRenderer
virtual void Flush();
virtual bool IsConfigured() { return m_bConfigured; }
virtual void AddProcessor(CMMALVideoBuffer *buffer, int index);
virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
virtual CRenderInfo GetRenderInfo();

virtual bool Supports(ERENDERFEATURE feature);
virtual bool Supports(EDEINTERLACEMODE mode);
Expand All @@ -82,13 +82,10 @@ class CMMALRenderer : public CBaseRenderer
void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);

virtual void SetBufferSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
virtual unsigned int GetMaxBufferSize() { return NUM_BUFFERS; }
virtual unsigned int GetOptimalBufferSize() { return NUM_BUFFERS; }
virtual void SetVideoRect(const CRect& SrcRect, const CRect& DestRect);
virtual bool IsGuiLayer() { return false; }

void vout_input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
virtual void *GetOpaquePointer();
protected:
int m_iYV12RenderBuffer;
int m_NumYV12Buffers;
Expand Down
17 changes: 17 additions & 0 deletions xbmc/cores/VideoRenderers/RenderFormats.h
Expand Up @@ -42,4 +42,21 @@ enum ERenderFormat {
RENDER_FMT_MMAL,
};

struct CRenderInfo
{
CRenderInfo()
{
optimal_buffer_size = 0;
max_buffer_size = 0;
formats.clear();

This comment has been minimized.

Copy link
@FernetMenta

FernetMenta May 6, 2015

no need to initialise a vector with clear(). or did I miss something?

This comment has been minimized.

Copy link
@popcornmix

popcornmix May 6, 2015

Author Owner

I'm sure you're right - will remove.

opaque_pointer = NULL;
}
unsigned int optimal_buffer_size;
unsigned int max_buffer_size;
// Supported pixel formats, can be called before configure
std::vector<ERenderFormat> formats;
// Can be used for initialising video codec with information from renderer (e.g. a shared image pool)
void *opaque_pointer;
};

#endif
35 changes: 9 additions & 26 deletions xbmc/cores/VideoRenderers/RenderManager.cpp
Expand Up @@ -273,11 +273,13 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
lock2.Enter();
m_format = format;

int renderbuffers = m_pRenderer->GetOptimalBufferSize();
CRenderInfo info = m_pRenderer->GetRenderInfo();
int renderbuffers = info.optimal_buffer_size;
m_QueueSize = renderbuffers;
if (buffers > 0)
m_QueueSize = std::min(buffers, renderbuffers);
m_QueueSize = std::min(m_QueueSize, (int)m_pRenderer->GetMaxBufferSize());

m_QueueSize = std::min(m_QueueSize, (int)info.max_buffer_size);
m_QueueSize = std::min(m_QueueSize, NUM_BUFFERS);
if(m_QueueSize < 2)
{
Expand Down Expand Up @@ -936,36 +938,17 @@ void CXBMCRenderManager::UpdateResolution()
}
}


unsigned int CXBMCRenderManager::GetOptimalBufferSize()
// Get renderer info, can be called before configure
CRenderInfo CXBMCRenderManager::GetRenderInfo()
{
CSharedLock lock(m_sharedSection);
CRenderInfo info;
if (!m_pRenderer)
{
CLog::Log(LOGERROR, "%s - renderer is NULL", __FUNCTION__);
return 0;
return CRenderInfo();
}
return m_pRenderer->GetMaxBufferSize();
}

void *CXBMCRenderManager::GetOpaquePointer()
{
CSharedLock lock(m_sharedSection);
if (!m_pRenderer)
{
CLog::Log(LOGERROR, "%s - renderer is NULL", __FUNCTION__);
return 0;
}
return m_pRenderer->GetOpaquePointer();
}

// Supported pixel formats, can be called before configure
std::vector<ERenderFormat> CXBMCRenderManager::SupportedFormats()
{
CSharedLock lock(m_sharedSection);
if (m_pRenderer)
return m_pRenderer->SupportedFormats();
return std::vector<ERenderFormat>();
return m_pRenderer->GetRenderInfo();
}

int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic)
Expand Down
9 changes: 2 additions & 7 deletions xbmc/cores/VideoRenderers/RenderManager.h
Expand Up @@ -162,13 +162,8 @@ class CXBMCRenderManager
CLinuxRenderer *m_pRenderer;
#endif

unsigned int GetOptimalBufferSize();

// Supported pixel formats, can be called before configure
std::vector<ERenderFormat> SupportedFormats();

// Can we used for initialising video codec with information from renderer (e.g. a shared image pool)
void *GetOpaquePointer();
// Get renderer info, can be called before configure
CRenderInfo GetRenderInfo();

void Recover(); // called after resolution switch if something special is needed

Expand Down
10 changes: 7 additions & 3 deletions xbmc/cores/VideoRenderers/WinRenderer.cpp
Expand Up @@ -1331,12 +1331,16 @@ EINTERLACEMETHOD CWinRenderer::AutoInterlaceMethod()
return VS_INTERLACEMETHOD_DEINTERLACE_HALF;
}

unsigned int CWinRenderer::GetOptimalBufferSize()
CRenderInfo CWinRenderer::GetRenderInfo()
{
CRenderInfo info;
info.formats = m_formats;
info.max_buffer_size = NUM_BUFFERS;
if (m_format == RENDER_FMT_DXVA && m_processor)
return m_processor->Size();
info.optimal_buffer_size = m_processor->Size();
else
return 3;
info.optimal_buffer_size = 3;
return info;
}

void CWinRenderer::ReleaseBuffer(int idx)
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/VideoRenderers/WinRenderer.h
Expand Up @@ -157,7 +157,7 @@ class CWinRenderer : public CBaseRenderer
virtual bool IsConfigured() { return m_bConfigured; }
virtual void Flush();

virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
virtual CRenderInfo GetRenderInfo();

virtual bool Supports(ERENDERFEATURE feature);
virtual bool Supports(EDEINTERLACEMODE mode);
Expand All @@ -168,9 +168,7 @@ class CWinRenderer : public CBaseRenderer

void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);

virtual unsigned int GetOptimalBufferSize();
virtual void SetBufferSize(int numBuffers) { m_neededBuffers = numBuffers; }
virtual unsigned int GetMaxBufferSize() { return NUM_BUFFERS; }
virtual void ReleaseBuffer(int idx);
virtual bool NeedBufferForRef(int idx);

Expand Down
10 changes: 5 additions & 5 deletions xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
Expand Up @@ -134,17 +134,17 @@ CDVDOverlayCodec* CDVDFactoryCodec::OpenCodec(CDVDOverlayCodec* pCodec, CDVDStre
}


CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigned int surfaces, const std::vector<ERenderFormat>& formats, const void *opaque_pointer)
CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CRenderInfo info)
{
CDVDVideoCodec* pCodec = NULL;
CDVDCodecOptions options;

if(formats.empty())
if(info.formats.empty())
options.m_formats.push_back(RENDER_FMT_YUV420P);
else
options.m_formats = formats;
options.m_formats = info.formats;

options.m_opaque_pointer = opaque_pointer;
options.m_opaque_pointer = info.opaque_pointer;

//when support for a hardware decoder is not compiled in
//only print it if it's actually available on the platform
Expand Down Expand Up @@ -340,7 +340,7 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, unsigne
}
#endif

std::string value = StringUtils::Format("%d", surfaces);
std::string value = StringUtils::Format("%d", info.optimal_buffer_size);
options.m_keys.push_back(CDVDCodecOption("surfaces", value));
if( (pCodec = OpenCodec(new CDVDVideoCodecFFmpeg(), hint, options)) ) return pCodec;

Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.h
Expand Up @@ -22,6 +22,7 @@

#include <vector>
#include "cores/VideoRenderers/RenderFormats.h"
#include "cores/VideoRenderers/BaseRenderer.h"

class CDVDVideoCodec;
class CDVDAudioCodec;
Expand All @@ -35,7 +36,7 @@ class CDVDCodecOptions;
class CDVDFactoryCodec
{
public:
static CDVDVideoCodec* CreateVideoCodec(CDVDStreamInfo &hint, unsigned int surfaces = 0, const std::vector<ERenderFormat>& formats = std::vector<ERenderFormat>(), const void *opaque_pointer = NULL);
static CDVDVideoCodec* CreateVideoCodec(CDVDStreamInfo &hint, CRenderInfo info = CRenderInfo());
static CDVDAudioCodec* CreateAudioCodec(CDVDStreamInfo &hint );
static CDVDOverlayCodec* CreateOverlayCodec(CDVDStreamInfo &hint );

Expand Down
14 changes: 5 additions & 9 deletions xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
Expand Up @@ -179,21 +179,17 @@ double CDVDPlayerVideo::GetOutputDelay()

bool CDVDPlayerVideo::OpenStream( CDVDStreamInfo &hint )
{
unsigned int surfaces = 0;
std::vector<ERenderFormat> formats;
void *opaque_pointer = NULL;
#ifdef HAS_VIDEO_PLAYBACK
surfaces = g_renderManager.GetOptimalBufferSize();
formats = g_renderManager.SupportedFormats();
opaque_pointer = g_renderManager.GetOpaquePointer();
#endif
CRenderInfo info;
#ifdef HAS_VIDEO_PLAYBACK
info = g_renderManager.GetRenderInfo();
#endif

m_pullupCorrection.ResetVFRDetection();
if(hint.flags & AV_DISPOSITION_ATTACHED_PIC)
return false;

CLog::Log(LOGNOTICE, "Creating video codec with codec id: %i", hint.codec);
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, surfaces, formats, opaque_pointer);
CDVDVideoCodec* codec = CDVDFactoryCodec::CreateVideoCodec(hint, info);
if(!codec)
{
CLog::Log(LOGERROR, "Unsupported video codec");
Expand Down

0 comments on commit 7aa2225

Please sign in to comment.