Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[rbp] Fix non-square pixel display apect ratio and 3D TAB modes corre…
…ctly
  • Loading branch information
popcornmix authored and davilla committed Jan 22, 2013
1 parent 865be19 commit d486cf4
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 168 deletions.
18 changes: 13 additions & 5 deletions xbmc/cores/VideoRenderers/BaseRenderer.cpp
Expand Up @@ -214,6 +214,16 @@ RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RES
*
*/

// work out current non-3D resolution (in case we are currently in 3D mode)
if (curr.dwFlags & D3DPRESENTFLAG_MODE3DSBS)
{
iScreenWidth *= 2;
}
else if (curr.dwFlags & D3DPRESENTFLAG_MODE3DTB)
{
iScreenHeight *= 2;
}
// work out resolution if we switch to 3D mode
if(m_iFlags & CONF_FLAGS_FORMAT_SBS)
{
iScreenWidth /= 2;
Expand Down Expand Up @@ -500,11 +510,6 @@ void CBaseRenderer::CalcNormalDisplayRect(float offsetX, float offsetY, float sc
//***************************************************************************************
void CBaseRenderer::CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height)
{
if(m_iFlags & CONF_FLAGS_FORMAT_SBS)
desired_width /= 2;
else if(m_iFlags & CONF_FLAGS_FORMAT_TB)
desired_height /= 2;

m_sourceFrameRatio = (float)desired_width / desired_height;

// Check whether mplayer has decided that the size of the video file should be changed
Expand Down Expand Up @@ -577,6 +582,9 @@ void CBaseRenderer::SetViewMode(int viewMode)
if (viewMode < VIEW_MODE_NORMAL || viewMode > VIEW_MODE_CUSTOM)
viewMode = VIEW_MODE_NORMAL;

if (m_iFlags & (CONF_FLAGS_FORMAT_SBS | CONF_FLAGS_FORMAT_TB))
viewMode = VIEW_MODE_NORMAL;

g_settings.m_currentVideoSettings.m_ViewMode = viewMode;

// get our calibrated full screen resolution
Expand Down
Empty file.
4 changes: 3 additions & 1 deletion xbmc/cores/omxplayer/OMXPlayer.cpp
Expand Up @@ -2958,8 +2958,10 @@ bool COMXPlayer::OpenVideoStream(int iStream, int source, bool reset)
m_player_video.SendMessage(new CDVDMsg(CDVDMsg::GENERAL_RESET));

unsigned flags = 0;
if(m_filename.find("3DSBS") != string::npos)
if(m_filename.find("3DSBS") != string::npos || m_filename.find("HSBS") != string::npos)
flags = CONF_FLAGS_FORMAT_SBS;
else if(m_filename.find("3DTAB") != string::npos || m_filename.find("HTAB") != string::npos)
flags = CONF_FLAGS_FORMAT_TB;
m_player_video.SetFlags(flags);

/* store information about stream */
Expand Down
28 changes: 19 additions & 9 deletions xbmc/cores/omxplayer/OMXPlayerVideo.cpp
Expand Up @@ -99,8 +99,8 @@ OMXPlayerVideo::OMXPlayerVideo(OMXClock *av_clock,
m_messageQueue.SetMaxTimeSize(8.0);

RESOLUTION res = g_graphicsContext.GetVideoResolution();
m_video_width = g_settings.m_ResInfo[res].iWidth;
m_video_height = g_settings.m_ResInfo[res].iHeight;
m_video_width = g_settings.m_ResInfo[res].iScreenWidth;
m_video_height = g_settings.m_ResInfo[res].iScreenHeight;

m_dst_rect.SetRect(0, 0, 0, 0);

Expand Down Expand Up @@ -337,16 +337,25 @@ void OMXPlayerVideo::Output(int iGroupId, double pts, bool bDropPacket)
flags |= CONF_FLAGS_FORMAT_SBS;
}
}

CLog::Log(LOGDEBUG,"%s - change configuration. %dx%d. framerate: %4.2f. format: BYPASS",
__FUNCTION__, m_width, m_height, m_fps);
else if(m_flags & CONF_FLAGS_FORMAT_TB)
{
if(g_Windowing.Support3D(m_video_width, m_video_height, D3DPRESENTFLAG_MODE3DTB))
{
CLog::Log(LOGNOTICE, "3DTB movie found");
flags |= CONF_FLAGS_FORMAT_TB;
}
}

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);

CLog::Log(LOGDEBUG,"%s - change configuration. %dx%d. framerate: %4.2f. %dx%x format: BYPASS",
__FUNCTION__, m_width, m_height, m_fps, iDisplayWidth, iDisplayHeight);

if(!g_renderManager.Configure(m_hints.width, m_hints.height,
iDisplayWidth, iDisplayHeight, m_fps, flags, format, 0,
m_hints.orientation))
Expand Down Expand Up @@ -813,21 +822,22 @@ void OMXPlayerVideo::SetVideoRect(const CRect &SrcRect, const CRect &DestRect)
CRect gui, display, dst_rect;
RESOLUTION res = g_graphicsContext.GetVideoResolution();
gui.SetRect(0, 0, g_settings.m_ResInfo[res].iWidth, g_settings.m_ResInfo[res].iHeight);
display.SetRect(0, 0, g_settings.m_ResInfo[res].iWidth, g_settings.m_ResInfo[res].iHeight);
display.SetRect(0, 0, g_settings.m_ResInfo[res].iScreenWidth, g_settings.m_ResInfo[res].iScreenHeight);

dst_rect = m_dst_rect;
if (gui != display)
{
float xscale = display.Width() / gui.Width();
float yscale = display.Height() / gui.Height();
// video is displayed in absolute coordinates (bypassing half width or height GUI mode)
if (m_flags & CONF_FLAGS_FORMAT_SBS) xscale *= 2.0f;
if (m_flags & CONF_FLAGS_FORMAT_TB) yscale *= 2.0f;
dst_rect.x1 *= xscale;
dst_rect.x2 *= xscale;
dst_rect.y1 *= yscale;
dst_rect.y2 *= yscale;
}

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

void OMXPlayerVideo::RenderUpdateCallBack(const void *ctx, const CRect &SrcRect, const CRect &DestRect)
Expand Down
10 changes: 3 additions & 7 deletions xbmc/cores/omxplayer/OMXVideo.cpp
Expand Up @@ -940,14 +940,8 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
return;

OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();
RESOLUTION res = g_graphicsContext.GetVideoResolution();
// DestRect is in GUI coordinates, rather than display coordinates, so we have to scale
float xscale = (float)g_settings.m_ResInfo[res].iScreenWidth / (float)g_settings.m_ResInfo[res].iWidth;
float yscale = (float)g_settings.m_ResInfo[res].iScreenHeight / (float)g_settings.m_ResInfo[res].iHeight;
float sx1 = SrcRect.x1, sy1 = SrcRect.y1, sx2 = SrcRect.x2, sy2 = SrcRect.y2;
float dx1 = DestRect.x1*xscale, dy1 = DestRect.y1*yscale, dx2 = DestRect.x2*xscale, dy2 = DestRect.y2*yscale;
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();

Expand All @@ -961,6 +955,8 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
dy1 -= dy1;
}

OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();
configDisplay.fullscreen = OMX_FALSE;
configDisplay.noaspect = OMX_TRUE;

Expand Down
35 changes: 20 additions & 15 deletions xbmc/linux/DllBCM.h
Expand Up @@ -53,11 +53,12 @@ class DllBcmHostInterface
virtual int vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_rate,
HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags) = 0;

virtual int vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_T group, TV_SUPPORTED_MODE_T *supported_modes,
virtual int vc_tv_hdmi_get_supported_modes_new(HDMI_RES_GROUP_T group, TV_SUPPORTED_MODE_NEW_T *supported_modes,
uint32_t max_supported_modes, HDMI_RES_GROUP_T *preferred_group,
uint32_t *preferred_mode) = 0;
virtual int vc_tv_hdmi_power_on_explicit(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code) = 0;
virtual int vc_tv_get_state(TV_GET_STATE_RESP_T *tvstate) = 0;
virtual int vc_tv_hdmi_power_on_explicit_new(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code) = 0;
virtual int vc_tv_hdmi_set_property(const HDMI_PROPERTY_PARAM_T *property) = 0;
virtual int vc_tv_get_display_state(TV_DISPLAY_STATE_T *tvstate) = 0;
virtual int vc_tv_show_info(uint32_t show) = 0;
virtual int vc_gencmd(char *response, int maxlen, const char *string) = 0;
virtual void vc_tv_register_callback(TVSERVICE_CALLBACK_T callback, void *callback_data) = 0;
Expand Down Expand Up @@ -97,14 +98,16 @@ class DllBcmHost : public DllDynamic, DllBcmHostInterface
virtual int vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_rate,
HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags)
{ return ::vc_tv_hdmi_power_on_best_3d(width, height, frame_rate, scan_mode, match_flags); };
virtual int vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_T group, TV_SUPPORTED_MODE_T *supported_modes,
virtual int vc_tv_hdmi_get_supported_modes_new(HDMI_RES_GROUP_T group, TV_SUPPORTED_MODE_NEW_T *supported_modes,
uint32_t max_supported_modes, HDMI_RES_GROUP_T *preferred_group,
uint32_t *preferred_mode)
{ return ::vc_tv_hdmi_get_supported_modes(group, supported_modes, max_supported_modes, preferred_group, preferred_mode); };
virtual int vc_tv_hdmi_power_on_explicit(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code)
{ return ::vc_tv_hdmi_power_on_explicit(mode, group, code); };
virtual int vc_tv_get_state(TV_GET_STATE_RESP_T *tvstate)
{ return ::vc_tv_get_state(tvstate); };
{ return ::vc_tv_hdmi_get_supported_modes_new(group, supported_modes, max_supported_modes, preferred_group, preferred_mode); };
virtual int vc_tv_hdmi_power_on_explicit_new(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code)
{ return ::vc_tv_hdmi_power_on_explicit_new(mode, group, code); };
virtual int vc_tv_hdmi_set_property(const HDMI_PROPERTY_PARAM_T *property)
{ return ::vc_tv_hdmi_set_property(property); };
virtual int vc_tv_get_display_state(TV_DISPLAY_STATE_T *tvstate)
{ return ::vc_tv_get_display_state(tvstate); };
virtual int vc_tv_show_info(uint32_t show)
{ return ::vc_tv_show_info(show); };
virtual int vc_gencmd(char *response, int maxlen, const char *string)
Expand Down Expand Up @@ -162,10 +165,11 @@ class DllBcmHost : public DllDynamic, DllBcmHostInterface
HDMI_INTERLACED_T p4, EDID_MODE_MATCH_FLAG_T p5))
DEFINE_METHOD5(int, vc_tv_hdmi_power_on_best_3d, (uint32_t p1, uint32_t p2, uint32_t p3,
HDMI_INTERLACED_T p4, EDID_MODE_MATCH_FLAG_T p5))
DEFINE_METHOD5(int, vc_tv_hdmi_get_supported_modes, (HDMI_RES_GROUP_T p1, TV_SUPPORTED_MODE_T *p2,
DEFINE_METHOD5(int, vc_tv_hdmi_get_supported_modes_new, (HDMI_RES_GROUP_T p1, TV_SUPPORTED_MODE_NEW_T *p2,
uint32_t p3, HDMI_RES_GROUP_T *p4, uint32_t *p5))
DEFINE_METHOD3(int, vc_tv_hdmi_power_on_explicit, (HDMI_MODE_T p1, HDMI_RES_GROUP_T p2, uint32_t p3))
DEFINE_METHOD1(int, vc_tv_get_state, (TV_GET_STATE_RESP_T *p1))
DEFINE_METHOD3(int, vc_tv_hdmi_power_on_explicit_new, (HDMI_MODE_T p1, HDMI_RES_GROUP_T p2, uint32_t p3))
DEFINE_METHOD1(int, vc_tv_hdmi_set_property, (const HDMI_PROPERTY_PARAM_T *property))
DEFINE_METHOD1(int, vc_tv_get_display_state, (TV_DISPLAY_STATE_T *p1))
DEFINE_METHOD1(int, vc_tv_show_info, (uint32_t p1))
DEFINE_METHOD3(int, vc_gencmd, (char *p1, int p2, const char *p3))

Expand Down Expand Up @@ -195,9 +199,10 @@ class DllBcmHost : public DllDynamic, DllBcmHostInterface
RESOLVE_METHOD(graphics_get_display_size)
RESOLVE_METHOD(vc_tv_hdmi_power_on_best)
RESOLVE_METHOD(vc_tv_hdmi_power_on_best_3d)
RESOLVE_METHOD(vc_tv_hdmi_get_supported_modes)
RESOLVE_METHOD(vc_tv_hdmi_power_on_explicit)
RESOLVE_METHOD(vc_tv_get_state)
RESOLVE_METHOD(vc_tv_hdmi_get_supported_modes_new)
RESOLVE_METHOD(vc_tv_hdmi_power_on_explicit_new)
RESOLVE_METHOD(vc_tv_hdmi_set_property)
RESOLVE_METHOD(vc_tv_get_display_state)
RESOLVE_METHOD(vc_tv_show_info)
RESOLVE_METHOD(vc_gencmd)
RESOLVE_METHOD(vc_tv_register_callback)
Expand Down

0 comments on commit d486cf4

Please sign in to comment.