Skip to content

Commit

Permalink
[rbp] Fixes to handle zoom modes and anamorphic videos
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Sep 10, 2012
1 parent c25b3d2 commit 6c94a0b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 13 deletions.
24 changes: 20 additions & 4 deletions xbmc/cores/omxplayer/OMXPlayerVideo.cpp
Expand Up @@ -90,11 +90,11 @@ OMXPlayerVideo::OMXPlayerVideo(OMXClock *av_clock,
m_flags = 0;
m_bAllowFullscreen = false;
m_iCurrentPts = DVD_NOPTS_VALUE;
m_fFrameRate = 25.0f;
m_iVideoDelay = 0;
m_droptime = 0.0;
m_dropbase = 0.0;
m_autosync = 1;
m_fForcedAspectRatio = 0.0f;
m_messageQueue.SetMaxDataSize(10 * 1024 * 1024);
m_messageQueue.SetMaxTimeSize(8.0);

Expand Down Expand Up @@ -343,8 +343,14 @@ void OMXPlayerVideo::Output(int iGroupId, double pts, bool bDropPacket)
CLog::Log(LOGDEBUG,"%s - change configuration. %dx%d. framerate: %4.2f. format: BYPASS",
__FUNCTION__, m_width, m_height, m_fps);

if(!g_renderManager.Configure(m_video_width, m_video_height,
m_video_width, m_video_height, m_fps, flags, format, 0,
unsigned int iDisplayWidth = m_hints.width;
unsigned int iDisplayHeight = m_hints.height;
/* use forced aspect if any */
if( m_fForcedAspectRatio != 0.0f )
iDisplayWidth = (int) (iDisplayHeight * m_fForcedAspectRatio);

if(!g_renderManager.Configure(m_hints.width, m_hints.height,
iDisplayWidth, iDisplayHeight, m_fps, flags, format, 0,
m_hints.orientation))
{
CLog::Log(LOGERROR, "%s - failed to configure renderer", __FUNCTION__);
Expand Down Expand Up @@ -542,6 +548,11 @@ void OMXPlayerVideo::Process()
Sleep(1);
}
}
else if (pMsg->IsType(CDVDMsg::VIDEO_SET_ASPECT))
{
CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::VIDEO_SET_ASPECT");
m_fForcedAspectRatio = *((CDVDMsgDouble*)pMsg);
}
else if (pMsg->IsType(CDVDMsg::GENERAL_RESET))
{
CLog::Log(LOGDEBUG, "COMXPlayerVideo - CDVDMsg::GENERAL_RESET");
Expand Down Expand Up @@ -682,6 +693,11 @@ bool OMXPlayerVideo::OpenDecoder()
CLog::Log(LOGINFO, "OMXPlayerVideo::OpenDecoder : Invalid framerate %d, using forced 25fps and just trust timestamps\n", (int)m_fFrameRate);
m_fFrameRate = 25;
}
// use aspect in stream if available
if (m_hints.forced_aspect)
m_fForcedAspectRatio = m_hints.aspect;
else
m_fForcedAspectRatio = 0.0;

m_av_clock->Lock();
m_av_clock->OMXStop(false);
Expand Down Expand Up @@ -805,7 +821,7 @@ void OMXPlayerVideo::SetVideoRect(const CRect &SrcRect, const CRect &DestRect)
dst_rect.y2 *= yscale;
}

if(!(m_flags & CONF_FLAGS_FORMAT_SBS) && !!(m_flags & CONF_FLAGS_FORMAT_TB))
if(!(m_flags & CONF_FLAGS_FORMAT_SBS) && !(m_flags & CONF_FLAGS_FORMAT_TB))
m_omxVideo.SetVideoRect(SrcRect, m_dst_rect);
}

Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/omxplayer/OMXPlayerVideo.h
Expand Up @@ -69,6 +69,7 @@ class OMXPlayerVideo : public CThread
bool m_bRenderSubs;
bool m_bAllowFullscreen;

float m_fForcedAspectRatio;
unsigned int m_width;
unsigned int m_height;
unsigned int m_video_width;
Expand Down
35 changes: 26 additions & 9 deletions xbmc/cores/omxplayer/OMXVideo.cpp
Expand Up @@ -889,17 +889,34 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();
float sx1 = SrcRect.x1, sy1 = SrcRect.y1, sx2 = SrcRect.x2, sy2 = SrcRect.y2;
float dx1 = DestRect.x1, dy1 = DestRect.y1, dx2 = DestRect.x2, dy2 = DestRect.y2;
float sw = SrcRect.Width() / DestRect.Width();
float sh = SrcRect.Height() / DestRect.Height();

configDisplay.set = OMX_DISPLAY_SET_FULLSCREEN;
configDisplay.fullscreen = OMX_FALSE;

m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);
// doesn't like negative coordinates on dest_rect. So adjust by increasing src_rect
if (dx1 < 0.0f) {
sx1 -= dx1 * sw;
dx1 -= dx1;
}
if (dy1 < 0.0f) {
sy1 -= dy1 * sh;
dy1 -= dy1;
}

configDisplay.set = OMX_DISPLAY_SET_DEST_RECT;
configDisplay.dest_rect.x_offset = DestRect.x1;
configDisplay.dest_rect.y_offset = DestRect.y1;
configDisplay.dest_rect.width = DestRect.Width();
configDisplay.dest_rect.height = DestRect.Height();
configDisplay.fullscreen = OMX_FALSE;
configDisplay.noaspect = OMX_TRUE;

configDisplay.set = (OMX_DISPLAYSETTYPE)(OMX_DISPLAY_SET_DEST_RECT|OMX_DISPLAY_SET_SRC_RECT|OMX_DISPLAY_SET_FULLSCREEN|OMX_DISPLAY_SET_NOASPECT);
configDisplay.dest_rect.x_offset = (int)(dx1+0.5f);
configDisplay.dest_rect.y_offset = (int)(dy1+0.5f);
configDisplay.dest_rect.width = (int)(dx2-dx1+0.5f);
configDisplay.dest_rect.height = (int)(dy2-dy1+0.5f);

configDisplay.src_rect.x_offset = (int)(sx1+0.5f);
configDisplay.src_rect.y_offset = (int)(sy1+0.5f);
configDisplay.src_rect.width = (int)(sx2-sx1+0.5f);
configDisplay.src_rect.height = (int)(sy2-sy1+0.5f);

m_omx_render.SetConfig(OMX_IndexConfigDisplayRegion, &configDisplay);

Expand Down

0 comments on commit 6c94a0b

Please sign in to comment.