Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
--- libs/libmythtv/NuppelVideoPlayer.cpp	(revision 18204)
+++ libs/libmythtv/NuppelVideoPlayer.cpp	(working copy)
@@ -633,7 +633,8 @@
             GetDecoder()->GetVideoCodecID(),
             GetDecoder()->GetVideoCodecPrivate(),
             video_disp_dim, video_aspect,
-            widget->winId(), display_rect, 0 /*embedid*/);
+            widget->winId(), display_rect, (video_frame_rate * play_speed), 
+	    0 /*embedid*/);
 
         if (!videoOutput)
         {
@@ -648,7 +649,7 @@
         videoOutput->SetVideoScalingAllowed(db_scale);
 
         // We need to tell it this for automatic deinterlacer settings
-        videoOutput->SetVideoFrameRate(video_frame_rate * play_speed);
+	videoOutput->SetVideoFrameRate(video_frame_rate * play_speed);
 
         if (videoOutput->hasMCAcceleration() && !decode_extra_audio)
         {
Index: libs/libmythtv/videoout_d3d.cpp
===================================================================
--- libs/libmythtv/videoout_d3d.cpp	(revision 18204)
+++ libs/libmythtv/videoout_d3d.cpp	(working copy)
@@ -451,7 +451,7 @@
 
 bool VideoOutputD3D::Init(int width, int height, float aspect,
                           WId winid, int winx, int winy, int winw,
-                          int winh, WId embedid)
+                          int winh, float video_prate, WId embedid)
 {
     VERBOSE(VB_PLAYBACK, LOC +
             "Init w=" << width << " h=" << height);
@@ -462,8 +462,8 @@
                   kPrebufferFramesNormal, kPrebufferFramesSmall,
                   kKeepPrebuffer);
 
-    VideoOutput::Init(width, height, aspect, winid,
-                      winx, winy, winw, winh, embedid);
+    VideoOutput::Init(width, height, aspect, winid, winx, 
+		      winy, winw, winh, video_prate, embedid);
 
     m_hWnd = winid;
 
Index: libs/libmythtv/videoout_quartz.cpp
===================================================================
--- libs/libmythtv/videoout_quartz.cpp	(revision 18204)
+++ libs/libmythtv/videoout_quartz.cpp	(working copy)
@@ -1333,8 +1333,8 @@
 }
 
 bool VideoOutputQuartz::Init(int width, int height, float aspect,
-                             WId winid, int winx, int winy,
-                             int winw, int winh, WId embedid)
+                             WId winid, int winx, int winy, int winw,
+			     int winh, float video_prate, WId embedid)
 {
     VERBOSE(VB_PLAYBACK, LOC +
             QString("Init(WxH %1x%2, aspect=%3, winid=%4\n\t\t\t"
@@ -1356,8 +1356,8 @@
     vbuffers.Init(kNumBuffers, true, kNeedFreeFrames, 
                   kPrebufferFramesNormal, kPrebufferFramesSmall, 
                   kKeepPrebuffer);
-    VideoOutput::Init(width, height, aspect, winid,
-                      winx, winy, winw, winh, embedid);
+    VideoOutput::Init(width, height, aspect, winid, winx, 
+		      winy, winw, winh, video_prate, embedid);
 
     data->srcWidth  = video_dim.width();
     data->srcHeight = video_dim.height();
@@ -1508,6 +1508,7 @@
 
 void VideoOutputQuartz::SetVideoFrameRate(float playback_fps)
 {
+    video_prate = playback_fps;
     VERBOSE(VB_PLAYBACK, "SetVideoFrameRate("<<playback_fps<<")");
 }
 
Index: libs/libmythtv/videoout_dx.h
===================================================================
--- libs/libmythtv/videoout_dx.h	(revision 18204)
+++ libs/libmythtv/videoout_dx.h	(working copy)
@@ -21,7 +21,8 @@
    ~VideoOutputDX();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh, 
+	      float video_prate, WId embedid = 0);
     void PrepareFrame(VideoFrame *buffer, FrameScanType);
     void Show(FrameScanType );
 
Index: libs/libmythtv/videoout_directfb.cpp
===================================================================
--- libs/libmythtv/videoout_directfb.cpp	(revision 18204)
+++ libs/libmythtv/videoout_directfb.cpp	(working copy)
@@ -353,7 +353,7 @@
 
 bool VideoOutputDirectfb::Init(int width, int height, float aspect, WId winid,
                                int winx, int winy, int winw, int winh,
-                               WId embedid)
+                               float video_prate, WId embedid)
 {
     // Hack to avoid embedded video output...
     if ((winw < 320) || (winh < 240))
@@ -646,7 +646,7 @@
                            display_visible_rect.y(),
                            display_visible_rect.width(),
                            display_visible_rect.height(),
-                           embedid))
+                           video_prate, embedid))
     {
         return false;
     }
Index: libs/libmythtv/videoout_d3d.h
===================================================================
--- libs/libmythtv/videoout_d3d.h	(revision 18204)
+++ libs/libmythtv/videoout_d3d.h	(working copy)
@@ -20,7 +20,8 @@
    ~VideoOutputD3D();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh, 
+	      float video_prate, WId embedid = 0);
 
     bool InitD3D();
     void UnInitD3D();
Index: libs/libmythtv/videoout_ivtv.h
===================================================================
--- libs/libmythtv/videoout_ivtv.h	(revision 18204)
+++ libs/libmythtv/videoout_ivtv.h	(working copy)
@@ -16,7 +16,8 @@
    ~VideoOutputIvtv();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh,
+	      float video_prate, WId embedid = 0);
     void PrepareFrame(VideoFrame *buffer, FrameScanType);
     void Show(FrameScanType );
 
Index: libs/libmythtv/videoout_null.cpp
===================================================================
--- libs/libmythtv/videoout_null.cpp	(revision 18204)
+++ libs/libmythtv/videoout_null.cpp	(working copy)
@@ -115,15 +115,15 @@
 
 bool VideoOutputNull::Init(int width, int height, float aspect,
                            WId winid, int winx, int winy, int winw, 
-                           int winh, WId embedid)
+                           int winh, float video_prate, WId embedid)
 {
     if ((width <= 0) || (height <= 0))
         return false;
 
     QMutexLocker locker(&global_lock);
 
-    VideoOutput::Init(width, height, aspect, winid,
-                      winx, winy, winw, winh, embedid);
+    VideoOutput::Init(width, height, aspect, winid, winx, 
+		      winy, winw, winh, video_prate, embedid);
 
     vbuffers.Init(kNumBuffers, true, kNeedFreeFrames, 
                   kPrebufferFramesNormal, kPrebufferFramesSmall, 
Index: libs/libmythtv/videooutbase.cpp
===================================================================
--- libs/libmythtv/videooutbase.cpp	(revision 18204)
+++ libs/libmythtv/videooutbase.cpp	(working copy)
@@ -67,7 +67,7 @@
         void          *codec_priv,
         const QSize   &video_dim, float        video_aspect,
         WId            win_id,    const QRect &display_rect,
-        WId            embed_id)
+	float video_prate,        WId            embed_id)
 {
     (void) codec_priv;
 
@@ -166,10 +166,12 @@
 
         if (vo)
         {
+	    vo->video_prate = video_prate;
             if (vo->Init(
                     video_dim.width(), video_dim.height(), video_aspect,
                     win_id, display_rect.x(), display_rect.y(),
-                    display_rect.width(), display_rect.height(), embed_id))
+                    display_rect.width(), display_rect.height(),
+		    video_prate, embed_id))
             {
                 return vo;
             }
@@ -181,6 +183,8 @@
         renderer = VideoDisplayProfile::GetBestVideoRenderer(renderers);
     }
 
+
+
     VERBOSE(VB_IMPORTANT, LOC_ERR +
             "Not compiled with any useable video output method.");
 
@@ -363,7 +367,8 @@
  * \return true if successful, false otherwise.
  */
 bool VideoOutput::Init(int width, int height, float aspect, WId winid,
-                       int winx, int winy, int winw, int winh, WId embedid)
+                       int winx, int winy, int winw, int winh,
+		       float video_prate, WId embedid)
 {
     (void)winid;
     (void)embedid;
@@ -405,6 +410,7 @@
 
 void VideoOutput::SetVideoFrameRate(float playback_fps)
 {
+    video_prate = playback_fps;
     db_vdisp_profile->SetOutput(playback_fps);
 }
 
Index: libs/libmythtv/videoout_directfb.h
===================================================================
--- libs/libmythtv/videoout_directfb.h	(revision 18204)
+++ libs/libmythtv/videoout_directfb.h	(working copy)
@@ -14,7 +14,8 @@
     ~VideoOutputDirectfb();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh, 
+	      float video_prate, WId embedid = 0);
 
     void ProcessFrame(VideoFrame *frame, OSD *osd,
                       FilterChain *filterList,
Index: libs/libmythtv/videoout_xv.h
===================================================================
--- libs/libmythtv/videoout_xv.h	(revision 18204)
+++ libs/libmythtv/videoout_xv.h	(working copy)
@@ -60,7 +60,8 @@
    ~VideoOutputXv();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh, 
+	      float video_prate, WId embedid = 0);
 
     bool SetDeinterlacingEnabled(bool);
     bool SetupDeinterlace(bool interlaced, const QString& ovrf="");
Index: libs/libmythtv/videoout_xv.cpp
===================================================================
--- libs/libmythtv/videoout_xv.cpp	(revision 18204)
+++ libs/libmythtv/videoout_xv.cpp	(working copy)
@@ -405,8 +405,9 @@
     if ((width == 1920 || width == 1440) && height == 1088)
         height = 1080; // ATSC 1920x1080
 
-    if (display_res && display_res->SwitchToVideo(width, height))
-    {
+    if (display_res && display_res->SwitchToVideo(width, height, 
+						  (short) roundf(video_prate)))
+	{
         // Switching to custom display resolution succeeded
         // Make a note of the new size
         display_dim = QSize(display_res->GetPhysicalWidth(),
@@ -1568,14 +1569,14 @@
 }
 
 /**
- * \fn VideoOutputXv::Init(int,int,float,WId,int,int,int,int,WId)
+ * \fn VideoOutputXv::Init(int,int,float,WId,int,int,int,int,float,WId)
  * Initializes class for video output.
  *
  * \return success or failure.
  */
 bool VideoOutputXv::Init(
-    int width, int height, float aspect,
-    WId winid, int winx, int winy, int winw, int winh, WId embedid)
+    int width, int height, float aspect, WId winid, int winx, 
+    int winy, int winw, int winh, float video_prate, WId embedid)
 {
     needrepaint = true;
 
@@ -1609,7 +1610,7 @@
     // Basic setup
     VideoOutput::Init(width, height, aspect,
                       winid, winx, winy, winw, winh,
-                      embedid);
+                      video_prate, embedid);
 
     // Set resolution/measurements (check XRandR, Xinerama, config settings)
     InitDisplayMeasurements(width, height);
Index: libs/libmythtv/videooutbase.h
===================================================================
--- libs/libmythtv/videooutbase.h	(revision 18204)
+++ libs/libmythtv/videooutbase.h	(working copy)
@@ -36,14 +36,14 @@
         void          *codec_priv,
         const QSize   &video_dim, float        video_aspect,
         WId            win_id,    const QRect &display_rect,
-        WId            embed_id);
+        float video_prate,        WId            embed_id);
 
     VideoOutput();
     virtual ~VideoOutput();
 
     virtual bool Init(int width, int height, float aspect,
                       WId winid, int winx, int winy, int winw, 
-                      int winh, WId embedid = 0);
+                      int winh, float video_prate, WId embedid = 0);
     virtual void InitOSD(OSD *osd);
     virtual void SetVideoFrameRate(float);
 
@@ -276,6 +276,7 @@
     QSize   video_dim;        ///< Pixel dimensions of video buffer
     QSize   video_disp_dim;   ///< Pixel dimensions of video display area
     float   video_aspect;     ///< Physical aspect ratio of video
+    float   video_prate;  ///< Playback frame rate of video
 
     /// Normally this is the same as videoAspect, but may not be
     /// if the user has toggled the aspect override mode.
Index: libs/libmythtv/videoout_ivtv.cpp
===================================================================
--- libs/libmythtv/videoout_ivtv.cpp	(revision 18204)
+++ libs/libmythtv/videoout_ivtv.cpp	(working copy)
@@ -405,7 +405,7 @@
 
 bool VideoOutputIvtv::Init(int width, int height, float aspect, 
                            WId winid, int winx, int winy, int winw, 
-                           int winh, WId embedid)
+                           int winh, float video_prate, WId embedid)
 {
     VERBOSE(VB_PLAYBACK, LOC + "Init() -- begin");
 
@@ -416,7 +416,7 @@
     videoDevice = gContext->GetSetting("PVR350VideoDev");
 
     VideoOutput::Init(width, height, aspect, winid, winx, winy, winw, winh, 
-                      embedid);
+                      video_prate, embedid);
 
     osdbufsize = video_dim.width() * video_dim.height() * 4;
 
Index: libs/libmythtv/videoout_quartz.h
===================================================================
--- libs/libmythtv/videoout_quartz.h	(revision 18204)
+++ libs/libmythtv/videoout_quartz.h	(working copy)
@@ -13,7 +13,8 @@
    ~VideoOutputQuartz();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh, 
+	      float video_prate, WId embedid = 0);
     void SetVideoFrameRate(float playback_fps);
     void PrepareFrame(VideoFrame *buffer, FrameScanType t);
     void Show(FrameScanType);
Index: libs/libmythtv/videoout_dx.cpp
===================================================================
--- libs/libmythtv/videoout_dx.cpp	(revision 18204)
+++ libs/libmythtv/videoout_dx.cpp	(working copy)
@@ -158,16 +158,16 @@
 }
 
 bool VideoOutputDX::Init(int width, int height, float aspect,
-                           WId winid, int winx, int winy, int winw, 
-                           int winh, WId embedid)
+                         WId winid, int winx, int winy, int winw, 
+			 int winh, float video_prate, WId embedid)
 {
     db_vdisp_profile->SetVideoRenderer("directx");
 
     vbuffers.Init(kNumBuffers, true, kNeedFreeFrames, 
                   kPrebufferFramesNormal, kPrebufferFramesSmall, 
                   kKeepPrebuffer);
-    VideoOutput::Init(width, height, aspect, winid,
-                      winx, winy, winw, winh, embedid);
+    VideoOutput::Init(width, height, aspect, winid, winx, 
+		      winy, winw, winh, video_prate, embedid);
 
     wnd = winid;
 
Index: libs/libmythtv/videoout_null.h
===================================================================
--- libs/libmythtv/videoout_null.h	(revision 18204)
+++ libs/libmythtv/videoout_null.h	(working copy)
@@ -12,7 +12,8 @@
    ~VideoOutputNull();
 
     bool Init(int width, int height, float aspect, WId winid,
-              int winx, int winy, int winw, int winh, WId embedid = 0);
+              int winx, int winy, int winw, int winh,
+	      float video_prate, WId embedid = 0);
 
     bool SetupDeinterlace(bool, const QString &ovrf = "")
         { (void)ovrf; return false; } // we don't deinterlace in null output..
Index: libs/libmyth/DisplayRes.cpp
===================================================================
--- libs/libmyth/DisplayRes.cpp	(revision 18204)
+++ libs/libmyth/DisplayRes.cpp	(working copy)
@@ -37,10 +37,10 @@
     // Initialize GUI mode
     mode[GUI].Init();
     tW = tH = 0;
-    gContext->GetResolutionSetting("GuiVidMode", tW, tH);
+    gContext->GetResolutionSetting("GuiVidMode", tW, tH, tAspect, tRate);
     GetDisplaySize(tW_mm, tH_mm);
     gContext->GetResolutionSetting("DisplaySize", tW_mm, tH_mm);
-    mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, 0);
+    mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, tRate);
 
 
     // Initialize default VIDEO mode
@@ -87,6 +87,10 @@
     tmode next_mode = VIDEO; // default VIDEO mode
     DisplayResScreen next = mode[next_mode];
 
+    // If requested refresh rate is 0, attempt to match video fps
+    if (next.RefreshRate() == 0)
+	next.AddRefreshRate(irate);
+
     // try to find video override mode
     uint key = DisplayResScreen::CalcKey(iwidth, iheight, irate);
     DisplayResMapCIt it = in_size_to_output_mode.find(key);
@@ -130,7 +134,8 @@
     // need to change video mode?
     short target_rate = 0;
     DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate);
-    bool chg = !(next == last) || !(last.RefreshRate() == target_rate);
+    // If GuiVidModeRefreshRate is 0, assume any refresh rate is good enough.
+    bool chg = !(next == last) || (next.RefreshRate() !=0 && !(last.RefreshRate() == target_rate)); 
 
     VERBOSE(VB_PLAYBACK, QString("Trying %1x%2 %3 Hz")
             .arg(next.Width()).arg(next.Height()).arg(target_rate));
Index: libs/libmyth/DisplayResScreen.cpp
===================================================================
--- libs/libmyth/DisplayResScreen.cpp	(revision 18204)
+++ libs/libmyth/DisplayResScreen.cpp	(working copy)
@@ -89,13 +89,20 @@
         if (dsr[i].Width()==d.Width() && dsr[i].Height()==d.Height())
         {
             const vector<short>& rates = dsr[i].RefreshRates();
-            if (rates.size())
+            if (rates.size() && d.RefreshRate() != 0)
             {
-                vector<short>::const_iterator it =
-                    find(rates.begin(), rates.end(), d.RefreshRate());
-                target_rate = (it == rates.end()) ? *(--rates.end()) : *it;
-                return i;
+		for (uint j=0; j < rates.size(); ++j)
+		{
+		    // Multiple of target_rate will do
+		    if (rates[j] % d.RefreshRate() == 0)
+		    {
+			target_rate = rates[j];
+			return i;
+		    }
+		}
+                target_rate = rates[rates.size() - 1];
             }
+	    return i;
         }
     }
     return -1;

