Merge pull request #4706 from popcornmix/portrait_aspect
authorMartijn Kaijser <machine.sanctum@gmail.com>
Wed, 21 May 2014 17:16:41 +0000 (19:16 +0200)
committerMartijn Kaijser <machine.sanctum@gmail.com>
Wed, 21 May 2014 17:16:41 +0000 (19:16 +0200)
[omxplayer] Fix for aspect ratio of portrait videos

1  2 
xbmc/cores/omxplayer/OMXPlayerVideo.cpp

@@@ -641,31 -644,50 +641,41 @@@ int OMXPlayerVideo::GetFreeSpace(
  
  void OMXPlayerVideo::SetVideoRect(const CRect &InSrcRect, const CRect &InDestRect)
  {
 -  CRect SrcRect = InSrcRect, DestRect = InDestRect;
 +  // we get called twice a frame for left/right. Can ignore the rights.
 +  if (g_graphicsContext.GetStereoView() == RENDER_STEREO_VIEW_RIGHT)
 +    return;
  
 -  // in 3d modes skip this - we get called as the gui switches from left eye to right eye
 +  CRect SrcRect = InSrcRect, DestRect = InDestRect;
    unsigned flags = GetStereoModeFlags(GetStereoMode());
 -
 -  if (CONF_FLAGS_STEREO_MODE_MASK(flags))
 -  {
 -    if (g_graphicsContext.GetStereoMode() == RENDER_STEREO_MODE_MONO)
 -    {
 -       if (GetStereoMode() == "left_right")
 -         SrcRect.SetRect(0, 0, m_hints.width>>1, m_hints.height);
 -       else if (GetStereoMode() == "right_left")
 -         SrcRect.SetRect(m_hints.width>>1, 0, m_hints.width, m_hints.height);
 -       else if (GetStereoMode() == "top_bottom")
 -         SrcRect.SetRect(0, 0, m_hints.width, m_hints.height>>1);
 -       else if (GetStereoMode() == "bottom_top")
 -         SrcRect.SetRect(0, m_hints.height>>1, m_hints.width, m_hints.height);
 -    }
 -    else
 -      SrcRect.SetRect(0, 0, m_hints.width, m_hints.height);
 -    // interpreted as fullscreen
 -    DestRect.SetRect(0, 0, 0, 0);
 -  }
 +  RENDER_STEREO_MODE video_stereo_mode = (flags & CONF_FLAGS_STEREO_MODE_SBS) ? RENDER_STEREO_MODE_SPLIT_VERTICAL :
 +                                         (flags & CONF_FLAGS_STEREO_MODE_TAB) ? RENDER_STEREO_MODE_SPLIT_HORIZONTAL : RENDER_STEREO_MODE_OFF;
 +  bool stereo_invert                   = (flags & CONF_FLAGS_STEREO_CADANCE_RIGHT_LEFT) ? true : false;
 +  RENDER_STEREO_MODE display_stereo_mode = g_graphicsContext.GetStereoMode();
  
+   // fix up transposed video
+   if (m_hints.orientation == 90 || m_hints.orientation == 270)
+   {
+     float diff = (DestRect.Height() - DestRect.Width()) * 0.5f;
+     DestRect.x1 -= diff;
+     DestRect.x2 += diff;
+     DestRect.y1 += diff;
+     DestRect.y2 -= diff;
+   }
    // check if destination rect or video view mode has changed
 -  if (m_dst_rect != DestRect || m_src_rect != SrcRect)
 -  {
 -    m_src_rect  = SrcRect;
 -    m_dst_rect  = DestRect;
 -  }
 -  else
 -  {
 +  if (!(m_dst_rect != DestRect) && !(m_src_rect != SrcRect) && m_video_stereo_mode == video_stereo_mode && m_display_stereo_mode == display_stereo_mode && m_StereoInvert == stereo_invert)
      return;
 -  }
 +
 +  CLog::Log(LOGDEBUG, "OMXPlayerVideo::%s %d,%d,%d,%d -> %d,%d,%d,%d (%d,%d,%d,%d,%s)", __func__,
 +      (int)SrcRect.x1, (int)SrcRect.y1, (int)SrcRect.x2, (int)SrcRect.y2,
 +      (int)DestRect.x1, (int)DestRect.y1, (int)DestRect.x2, (int)DestRect.y2,
 +      video_stereo_mode, display_stereo_mode, CMediaSettings::Get().GetCurrentVideoSettings().m_StereoInvert, g_graphicsContext.GetStereoView(), OMXPlayerVideo::GetStereoMode().c_str());
 +
 +  m_src_rect = SrcRect;
 +  m_dst_rect = DestRect;
 +  m_video_stereo_mode = video_stereo_mode;
 +  m_display_stereo_mode = display_stereo_mode;
 +  m_StereoInvert = stereo_invert;
  
    // might need to scale up m_dst_rect to display size as video decodes
    // to separate video plane that is at display size.