Ticket #5643: adjust_rate3-trunk.patch
File adjust_rate3-trunk.patch, 37.5 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
741 741 GetDecoder()->GetVideoCodecPrivate(), 742 742 pipState, 743 743 video_disp_dim, video_aspect, 744 widget->winId(), display_rect, 0 /*embedid*/); 744 widget->winId(), display_rect, (video_frame_rate * play_speed), 745 0 /*embedid*/); 745 746 746 747 if (!videoOutput) 747 748 { -
mythtv/libs/libmythtv/videoout_d3d.cpp
453 453 454 454 bool VideoOutputD3D::Init(int width, int height, float aspect, 455 455 WId winid, int winx, int winy, int winw, 456 int winh, WId embedid)456 int winh, float video_prate, WId embedid) 457 457 { 458 458 VERBOSE(VB_PLAYBACK, LOC + 459 459 "Init w=" << width << " h=" << height); … … 464 464 kPrebufferFramesNormal, kPrebufferFramesSmall, 465 465 kKeepPrebuffer); 466 466 467 VideoOutput::Init(width, height, aspect, winid, 468 win x, winy, winw, winh, embedid);467 VideoOutput::Init(width, height, aspect, winid, winx, 468 winy, winw, winh, video_prate, embedid); 469 469 470 470 m_hWnd = winid; 471 471 -
mythtv/libs/libmythtv/videoout_quartz.cpp
1216 1216 } 1217 1217 1218 1218 bool VideoOutputQuartz::Init(int width, int height, float aspect, 1219 WId winid, int winx, int winy, 1220 int win w, int winh, WId embedid)1219 WId winid, int winx, int winy, int winw, 1220 int winh, float video_prate, WId embedid) 1221 1221 { 1222 1222 VERBOSE(VB_PLAYBACK, LOC + 1223 1223 QString("Init(WxH %1x%2, aspect=%3, winid=%4\n\t\t\t" … … 1240 1240 kPrebufferFramesNormal, kPrebufferFramesSmall, 1241 1241 kKeepPrebuffer); 1242 1242 VideoOutput::Init(width, height, aspect, winid, 1243 winx, winy, winw, winh, embedid); 1243 winx, winy, winw, winh, video_prate, 1244 embedid); 1244 1245 1245 1246 const QSize video_dim = windows[0].GetVideoDim(); 1246 1247 data->srcWidth = video_dim.width(); … … 1407 1408 1408 1409 void VideoOutputQuartz::SetVideoFrameRate(float playback_fps) 1409 1410 { 1411 video_prate = playback_fps; 1410 1412 VERBOSE(VB_PLAYBACK, "SetVideoFrameRate("<<playback_fps<<")"); 1411 1413 } 1412 1414 -
mythtv/libs/libmythtv/videoout_dx.h
21 21 ~VideoOutputDX(); 22 22 23 23 bool Init(int width, int height, float aspect, WId winid, 24 int winx, int winy, int winw, int winh, WId embedid = 0); 24 int winx, int winy, int winw, int winh, 25 float video_prate, WId embedid = 0); 25 26 26 27 void ProcessFrame(VideoFrame *frame, OSD *osd, 27 28 FilterChain *filterList, -
mythtv/libs/libmythtv/videoout_directfb.cpp
354 354 355 355 bool VideoOutputDirectfb::Init(int width, int height, float aspect, WId winid, 356 356 int winx, int winy, int winw, int winh, 357 WId embedid)357 float video_prate, WId embedid) 358 358 { 359 359 // Hack to avoid embedded video output... 360 360 if ((winw < 320) || (winh < 240)) … … 652 652 display_visible_rect.y(), 653 653 display_visible_rect.width(), 654 654 display_visible_rect.height(), 655 embedid))655 video_prate, embedid)) 656 656 { 657 657 return false; 658 658 } -
mythtv/libs/libmythtv/videoout_d3d.h
20 20 ~VideoOutputD3D(); 21 21 22 22 bool Init(int width, int height, float aspect, WId winid, 23 int winx, int winy, int winw, int winh, WId embedid = 0); 23 int winx, int winy, int winw, int winh, 24 float video_prate, WId embedid = 0); 24 25 25 26 bool InitD3D(); 26 27 void UnInitD3D(); -
mythtv/libs/libmythtv/videoout_ivtv.h
16 16 ~VideoOutputIvtv(); 17 17 18 18 bool Init(int width, int height, float aspect, WId winid, 19 int winx, int winy, int winw, int winh, WId embedid = 0); 19 int winx, int winy, int winw, int winh, 20 float video_prate, WId embedid = 0); 20 21 void PrepareFrame(VideoFrame *buffer, FrameScanType); 21 22 void Show(FrameScanType ); 22 23 -
mythtv/libs/libmythtv/videoout_null.cpp
118 118 119 119 bool VideoOutputNull::Init(int width, int height, float aspect, 120 120 WId winid, int winx, int winy, int winw, 121 int winh, WId embedid)121 int winh, float video_prate, WId embedid) 122 122 { 123 123 if ((width <= 0) || (height <= 0)) 124 124 return false; 125 125 126 126 QMutexLocker locker(&global_lock); 127 127 128 VideoOutput::Init(width, height, aspect, winid, 129 win x, winy, winw, winh, embedid);128 VideoOutput::Init(width, height, aspect, winid, winx, 129 winy, winw, winh, video_prate, embedid); 130 130 131 131 vbuffers.Init(kNumBuffers, true, kNeedFreeFrames, 132 132 kPrebufferFramesNormal, kPrebufferFramesSmall, -
mythtv/libs/libmythtv/videooutbase.cpp
66 66 PIPState pipState, 67 67 const QSize &video_dim, float video_aspect, 68 68 WId win_id, const QRect &display_rect, 69 WIdembed_id)69 float video_prate, WId embed_id) 70 70 { 71 71 (void) codec_priv; 72 72 … … 178 178 if (vo) 179 179 { 180 180 vo->SetPIPState(pipState); 181 vo->video_prate = video_prate; 181 182 if (vo->Init( 182 183 video_dim.width(), video_dim.height(), video_aspect, 183 184 win_id, display_rect.x(), display_rect.y(), 184 display_rect.width(), display_rect.height(), embed_id)) 185 display_rect.width(), display_rect.height(), 186 video_prate, embed_id)) 185 187 { 186 188 return vo; 187 189 } … … 351 353 * \return true if successful, false otherwise. 352 354 */ 353 355 bool VideoOutput::Init(int width, int height, float aspect, WId winid, 354 int winx, int winy, int winw, int winh, WId embedid) 356 int winx, int winy, int winw, int winh, 357 float video_prate, WId embedid) 355 358 { 356 359 (void)winid; 357 360 (void)embedid; … … 382 385 383 386 void VideoOutput::SetVideoFrameRate(float playback_fps) 384 387 { 388 video_prate = playback_fps; 385 389 if (db_vdisp_profile) 386 390 db_vdisp_profile->SetOutput(playback_fps); 387 391 } -
mythtv/libs/libmythtv/videoout_directfb.h
14 14 ~VideoOutputDirectfb(); 15 15 16 16 bool Init(int width, int height, float aspect, WId winid, 17 int winx, int winy, int winw, int winh, WId embedid = 0); 17 int winx, int winy, int winw, int winh, 18 float video_prate, WId embedid = 0); 18 19 19 20 void ProcessFrame(VideoFrame *frame, OSD *osd, 20 21 FilterChain *filterList, -
mythtv/libs/libmythtv/videoout_xv.h
57 57 ~VideoOutputXv(); 58 58 59 59 bool Init(int width, int height, float aspect, WId winid, 60 int winx, int winy, int winw, int winh, WId embedid = 0); 60 int winx, int winy, int winw, int winh, 61 float video_prate, WId embedid = 0); 61 62 62 63 bool SetDeinterlacingEnabled(bool); 63 64 bool SetupDeinterlace(bool interlaced, const QString& ovrf=""); -
mythtv/libs/libmythtv/videoout_xv.cpp
387 387 if ((width == 1920 || width == 1440) && height == 1088) 388 388 height = 1080; // ATSC 1920x1080 389 389 390 if (display_res && display_res->SwitchToVideo(width, height)) 390 if (display_res && display_res->SwitchToVideo(width, height, 391 (short) roundf(video_prate), 392 video_prate)) 391 393 { 392 394 // Switching to custom display resolution succeeded 393 395 // Make a note of the new size … … 1599 1601 } 1600 1602 1601 1603 /** 1602 * \fn VideoOutputXv::Init(int,int,float,WId,int,int,int,int, WId)1604 * \fn VideoOutputXv::Init(int,int,float,WId,int,int,int,int,float,WId) 1603 1605 * Initializes class for video output. 1604 1606 * 1605 1607 * \return success or failure. 1606 1608 */ 1607 1609 bool VideoOutputXv::Init( 1608 int width, int height, float aspect, 1609 WId winid, int winx, int winy, int winw, int winh, WId embedid)1610 int width, int height, float aspect, WId winid, int winx, 1611 int winy, int winw, int winh, float video_prate, WId embedid) 1610 1612 { 1611 1613 windows[0].SetNeedRepaint(true); 1612 1614 … … 1663 1665 // Basic setup 1664 1666 VideoOutput::Init(width, height, aspect, 1665 1667 winid, winx, winy, winw, winh, 1666 embedid);1668 video_prate, embedid); 1667 1669 1668 1670 // Set resolution/measurements (check XRandR, Xinerama, config settings) 1669 1671 InitDisplayMeasurements(width, height); -
mythtv/libs/libmythtv/videooutbase.h
48 48 PIPState pipState, 49 49 const QSize &video_dim, float video_aspect, 50 50 WId win_id, const QRect &display_rect, 51 WIdembed_id);51 float video_prate, WId embed_id); 52 52 53 53 VideoOutput(); 54 54 virtual ~VideoOutput(); 55 55 56 56 virtual bool Init(int width, int height, float aspect, 57 57 WId winid, int winx, int winy, int winw, 58 int winh, WId embedid = 0);58 int winh, float video_prate, WId embedid = 0); 59 59 virtual void InitOSD(OSD *osd); 60 60 virtual void SetVideoFrameRate(float); 61 61 … … 297 297 298 298 VideoDisplayProfile *db_vdisp_profile; 299 299 300 float video_prate; ///< Playback frame rate of video 301 300 302 // Picture-in-Picture 301 303 QSize pip_desired_display_size; 302 304 QSize pip_display_size; -
mythtv/libs/libmythtv/videoout_ivtv.cpp
406 406 407 407 bool VideoOutputIvtv::Init(int width, int height, float aspect, 408 408 WId winid, int winx, int winy, int winw, 409 int winh, WId embedid)409 int winh, float video_prate, WId embedid) 410 410 { 411 411 VERBOSE(VB_PLAYBACK, LOC + "Init() -- begin"); 412 412 … … 415 415 videoDevice = gContext->GetSetting("PVR350VideoDev"); 416 416 417 417 VideoOutput::Init(width, height, aspect, winid, winx, winy, winw, winh, 418 embedid);418 video_prate, embedid); 419 419 420 420 windows[0].SetAllowPreviewEPG(true); 421 421 -
mythtv/libs/libmythtv/videoout_quartz.h
13 13 ~VideoOutputQuartz(); 14 14 15 15 bool Init(int width, int height, float aspect, WId winid, 16 int winx, int winy, int winw, int winh, WId embedid = 0); 16 int winx, int winy, int winw, int winh, 17 float video_prate, WId embedid = 0); 17 18 18 19 void ProcessFrame(VideoFrame *frame, OSD *osd, 19 20 FilterChain *filterList, -
mythtv/libs/libmythtv/videoout_dx.cpp
160 160 } 161 161 162 162 bool VideoOutputDX::Init(int width, int height, float aspect, 163 164 int winh, WId embedid)163 WId winid, int winx, int winy, int winw, 164 int winh, float video_prate, WId embedid) 165 165 { 166 166 db_vdisp_profile->SetVideoRenderer("directx"); 167 167 168 168 vbuffers.Init(kNumBuffers, true, kNeedFreeFrames, 169 169 kPrebufferFramesNormal, kPrebufferFramesSmall, 170 170 kKeepPrebuffer); 171 VideoOutput::Init(width, height, aspect, winid, 172 win x, winy, winw, winh, embedid);171 VideoOutput::Init(width, height, aspect, winid, winx, 172 winy, winw, winh, video_prate, embedid); 173 173 174 174 wnd = winid; 175 175 -
mythtv/libs/libmythtv/videoout_null.h
12 12 ~VideoOutputNull(); 13 13 14 14 bool Init(int width, int height, float aspect, WId winid, 15 int winx, int winy, int winw, int winh, WId embedid = 0); 15 int winx, int winy, int winw, int winh, 16 float video_prate, WId embedid = 0); 16 17 17 18 bool SetupDeinterlace(bool, const QString &ovrf = "") 18 19 { (void)ovrf; return false; } // we don't deinterlace in null output.. -
mythtv/libs/libmythui/DisplayResOSX.h
12 12 13 13 protected: 14 14 bool GetDisplaySize(int &width_mm, int &height_mm) const; 15 bool SwitchToVideoMode(int width, int height, short framerate);15 bool SwitchToVideoMode(int width, int height, float framerate); 16 16 17 17 private: 18 18 mutable std::vector<DisplayResScreen> m_video_modes; -
mythtv/libs/libmythui/DisplayRes.cpp
38 38 // Initialize GUI mode 39 39 mode[GUI].Init(); 40 40 tW = tH = 0; 41 GetMythDB()->GetResolutionSetting("GuiVidMode", tW, tH );41 GetMythDB()->GetResolutionSetting("GuiVidMode", tW, tH, tAspect, tRate); 42 42 GetDisplaySize(tW_mm, tH_mm); 43 43 GetMythDB()->GetResolutionSetting("DisplaySize", tW_mm, tH_mm); 44 mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, 0);44 mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, (float)tRate); 45 45 46 46 47 47 // Initialize default VIDEO mode 48 48 tW = tH = 0; 49 49 GetMythDB()->GetResolutionSetting("TVVidMode", tW, tH, tAspect, tRate); 50 mode[VIDEO] = DisplayResScreen(tW, tH, tW_mm, tH_mm, tAspect, tRate);50 mode[VIDEO] = DisplayResScreen(tW, tH, tW_mm, tH_mm, tAspect, (float)tRate); 51 51 52 52 53 53 // Initialize video override mode … … 65 65 break; 66 66 67 67 uint key = DisplayResScreen::CalcKey(iw, ih, irate); 68 DisplayResScreen scr(ow, oh, tW_mm, tH_mm, oaspect, orate);68 DisplayResScreen scr(ow, oh, tW_mm, tH_mm, oaspect, (float)orate); 69 69 in_size_to_output_mode[key] = scr; 70 70 } 71 71 … … 83 83 return true; 84 84 } 85 85 86 bool DisplayRes::SwitchToVideo(int iwidth, int iheight, short irate )86 bool DisplayRes::SwitchToVideo(int iwidth, int iheight, short irate, float frate) 87 87 { 88 88 tmode next_mode = VIDEO; // default VIDEO mode 89 89 DisplayResScreen next = mode[next_mode]; 90 90 91 // If requested refresh rate is 0, attempt to match video fps 92 if (next.RefreshRate() == 0) 93 { 94 VERBOSE(VB_PLAYBACK, QString("*** Trying to match best resolution %1Hz") .arg(frate)); 95 next.AddRefreshRate(frate); 96 } 97 91 98 // try to find video override mode 92 99 uint key = DisplayResScreen::CalcKey(iwidth, iheight, irate); 93 100 DisplayResMapCIt it = in_size_to_output_mode.find(key); … … 95 102 mode[next_mode = CUSTOM_VIDEO] = next = it->second; 96 103 97 104 // need to change video mode? 98 short target_rate =0;105 float target_rate = 0.0; 99 106 DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate); 100 bool chg = !(next == last) || !( last.RefreshRate() == target_rate);107 bool chg = !(next == last) || !(DisplayResScreen::compare_rates(last.RefreshRate(),target_rate)); 101 108 102 109 VERBOSE(VB_PLAYBACK, QString("Trying %1x%2 %3 Hz") 103 110 .arg(next.Width()).arg(next.Height()).arg(target_rate)); … … 129 136 DisplayResScreen next = mode[next_mode]; 130 137 131 138 // need to change video mode? 132 short target_rate =0;139 float target_rate = 0.0; 133 140 DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate); 134 bool chg = !(next == last) || !(last.RefreshRate() == target_rate); 141 // If GuiVidModeRefreshRate is 0, assume any refresh rate is good enough. 142 bool chg = (!(next == last) || (next.RefreshRate() !=0 143 && !(DisplayResScreen::compare_rates(last.RefreshRate(), target_rate)))); 135 144 136 145 VERBOSE(VB_PLAYBACK, QString("Trying %1x%2 %3 Hz") 137 146 .arg(next.Width()).arg(next.Height()).arg(target_rate)); … … 155 164 bool DisplayRes::SwitchToCustomGUI(int width, int height, short rate) 156 165 { 157 166 mode[CUSTOM_GUI] = DisplayResScreen(width, height, mode[GUI].Width_mm(), 158 mode[GUI].Height_mm(), -1.0, rate);167 mode[GUI].Height_mm(), -1.0, (float)rate); 159 168 return SwitchToGUI(CUSTOM_GUI); 160 169 } 161 170 162 const std::vector<short> DisplayRes::GetRefreshRates(int width, 163 int height) const { 164 short tr; 165 std::vector<short> empty; 171 const std::vector<short> DisplayRes::GetRefreshRates(int width, int height) const { 172 std::vector<short> srates; 173 std::vector<float> rates = GetRefreshRatesFloat(width, height); 166 174 167 const DisplayResScreen drs(width, height, 0, 0, -1.0, 0); 175 for (int i=0; i<rates.size(); i++) 176 srates.push_back((short) rates[i]); 177 return srates; 178 } 179 const std::vector<float> DisplayRes::GetRefreshRatesFloat(int width, int height) const { 180 float tr; 181 std::vector<float> empty; 182 183 const DisplayResScreen drs(width, height, 0, 0, -1.0, 0.0); 168 184 const DisplayResVector& drv = GetVideoModes(); 169 185 int t = DisplayResScreen::FindBestMatch(drv, drs, tr); 170 186 if (t < 0) -
mythtv/libs/libmythui/DisplayResOSX.cpp
64 64 return d; 65 65 } 66 66 67 bool DisplayResOSX::SwitchToVideoMode(int width, int height, short refreshrate)67 bool DisplayResOSX::SwitchToVideoMode(int width, int height, float refreshrate) 68 68 { 69 69 CGDirectDisplayID d = mythtv_display(); 70 70 CFDictionaryRef dispMode = NULL; … … 73 73 // find mode that matches the desired size 74 74 if (refreshrate) 75 75 dispMode = CGDisplayBestModeForParametersAndRefreshRate( 76 d, 32, width, height, (CGRefreshRate)( refreshrate), &match);76 d, 32, width, height, (CGRefreshRate)((short)refreshrate), &match); 77 77 78 78 if (!match) 79 79 dispMode = … … 120 120 121 121 if (screen_map.find(key)==screen_map.end()) 122 122 screen_map[key] = DisplayResScreen(width, height, 123 0, 0, -1.0, refresh);123 0, 0, -1.0, (float) refresh); 124 124 else 125 125 screen_map[key].AddRefreshRate(refresh); 126 126 } -
mythtv/libs/libmythui/DisplayResX.h
12 12 13 13 protected: 14 14 bool GetDisplaySize(int &width_mm, int &height_mm) const; 15 bool SwitchToVideoMode(int width, int height, short framerate);15 bool SwitchToVideoMode(int width, int height, float framerate); 16 16 17 17 private: 18 18 mutable std::vector<DisplayResScreen> m_video_modes; -
mythtv/libs/libmythui/DisplayResScreen.h
14 14 public: 15 15 // Constructors, initializers 16 16 DisplayResScreen() 17 : width(0), height(0), width_mm(0), height_mm(0), aspect(-1.0) {;}17 : width(0), height(0), width_mm(0), height_mm(0), aspect(-1.0), custom(false) {;} 18 18 DisplayResScreen(int w, int h, int mw, int mh, 19 double aspectRatio/* = -1.0*/, short refreshRate/* = 0*/);19 double aspectRatio/* = -1.0*/, float refreshRate/* = 0*/); 20 20 DisplayResScreen(int w, int h, int mw, int mh, 21 const std::vector< short>& refreshRates);21 const std::vector<float>& refreshRates); 22 22 DisplayResScreen(int w, int h, int mw, int mh, 23 const float* refreshRates, uint rr_length); 24 DisplayResScreen(int w, int h, int mw, int mh, 23 25 const short* refreshRates, uint rr_length); 24 26 DisplayResScreen(const QString &str); 25 27 inline void Init(); … … 29 31 int Height() const { return height; } 30 32 int Width_mm() const { return width_mm; } 31 33 int Height_mm() const { return height_mm; } 34 bool Custom() const { return custom; } 35 32 36 inline double AspectRatio() const; 33 inline short RefreshRate() const;34 const std::vector< short>& RefreshRates() const { return refreshRates; }37 inline float RefreshRate() const; 38 const std::vector<float>& RefreshRates() const { return refreshRates; } 35 39 36 40 // Sets, adds 37 41 void SetAspectRatio(double a); 38 void AddRefreshRate( short rr) {42 void AddRefreshRate(float rr) { 39 43 refreshRates.push_back(rr); 40 44 std::sort(refreshRates.begin(), refreshRates.end()); 41 45 } 46 void ClearRefreshRates(void) { 47 refreshRates.clear(); 48 } 49 void SetCustom(bool b) { 50 custom = b; 51 } 52 53 // Map for matching real rates and xrandr rate; 54 std::map<float, short> realRates; 42 55 43 56 // Converters & comparitors 44 57 QString toString() const; … … 50 63 static std::vector<DisplayResScreen> Convert(const QStringList& slist); 51 64 static int FindBestMatch(const std::vector<DisplayResScreen>& dsr, 52 65 const DisplayResScreen& d, 66 float& target_rate); 67 static int FindBestMatch(const std::vector<DisplayResScreen>& dsr, 68 const DisplayResScreen& d, 53 69 short& target_rate); 54 70 static inline int CalcKey(int w, int h, int rate); 71 static bool compare_rates(float f1, float f2); 55 72 56 73 private: 57 74 int width, height; // size in pixels 58 75 int width_mm, height_mm; // physical size in millimeters 59 76 double aspect; // aspect ratio, calculated or set 60 std::vector<short> refreshRates; 77 std::vector<float> refreshRates; 78 bool custom; // Set if resolution was defined manually 61 79 }; 62 80 63 81 typedef std::vector<DisplayResScreen> DisplayResVector; … … 85 103 return aspect; 86 104 } 87 105 88 inline short DisplayResScreen::RefreshRate() const106 inline float DisplayResScreen::RefreshRate() const 89 107 { 90 108 if (refreshRates.size() >= 1) 91 109 return refreshRates[0]; 92 else return 0 ;110 else return 0.0; 93 111 } 94 112 95 113 inline bool DisplayResScreen::operator < (const DisplayResScreen& b) const -
mythtv/libs/libmythui/DisplayResX.cpp
1 1 #include <iostream> 2 2 3 #include "util-x11.h" 4 5 #include <X11/extensions/Xrandr.h> // this has to be after util-x11.h (Qt bug) 6 3 #include "config.h" 7 4 #include "DisplayResX.h" 5 #include "mythverbose.h" 6 #include "mythdb.h" 8 7 9 8 using std::cerr; 10 9 using std::endl; 11 10 11 #include <QRegExp> 12 #include <QIODevice> 13 #include <QFileInfo> 14 15 #include "util-x11.h" 16 17 #include <X11/extensions/Xrandr.h> // this has to be after util-x11.h (Qt bug) 18 12 19 static XRRScreenConfiguration *GetScreenConfig(Display*& display); 13 20 14 21 DisplayResX::DisplayResX(void) … … 33 40 return false; 34 41 } 35 42 36 bool DisplayResX::SwitchToVideoMode(int width, int height, short desired_rate)43 bool DisplayResX::SwitchToVideoMode(int width, int height, float desired_rate) 37 44 { 38 short rate; 45 float rate; 46 short finalrate; 47 39 48 DisplayResScreen desired_screen(width, height, 0, 0, -1.0, desired_rate); 40 49 int idx = DisplayResScreen::FindBestMatch(m_video_modes_unsorted, 41 50 desired_screen, rate); … … 50 59 Rotation rot; 51 60 XRRConfigCurrentConfiguration(cfg, &rot); 52 61 62 // Search real xrandr rate for desired_rate 63 finalrate = (short) rate; 64 for (uint i=0; i < m_video_modes.size(); i++) { 65 if ((m_video_modes[i].Width() == width) && (m_video_modes[i].Height() == height)) 66 { 67 if (m_video_modes[i].Custom()) 68 { 69 finalrate = m_video_modes[i].realRates[rate]; 70 VERBOSE(VB_PLAYBACK, QString("CustomRate Found, set %1Hz as %2") .arg(rate) .arg(finalrate)); 71 } 72 break; 73 } 74 } 75 53 76 Window root = DefaultRootWindow(display); 54 77 Status status = XRRSetScreenConfigAndRate(display, cfg, root, idx, 55 rot, rate, CurrentTime);78 rot, finalrate, CurrentTime); 56 79 57 80 XRRFreeScreenConfigInfo(cfg); 58 81 XCloseDisplay(display); … … 88 111 rates, num_rates); 89 112 m_video_modes.push_back(scr); 90 113 } 114 115 QString customscreen = GetMythDB()->GetSetting("CustomScreenRate"); 116 if (GetMythDB()->GetNumSetting("UseVideoModes", 0) && !customscreen.size()); 117 { 118 QFileInfo fi(customscreen); 119 QFile file(customscreen); 120 121 if (!fi.exists() || !fi.isFile()) 122 { 123 VERBOSE(VB_PLAYBACK, QString("CustomScreenRate: \"%1\" failed: does not exist or isn't a file") 124 .arg(customscreen)); 125 } 126 else if ( file.open(QIODevice::ReadOnly) ) { 127 QRegExp regexp = QRegExp("^\\s*(\\d+),(\\d+),(\\d+\\.?\\d*),(\\d+)\\s*$"); 128 QTextStream stream( &file ); 129 QString line; 130 int pos; 131 while ( !stream.atEnd() ) { 132 pos = regexp.indexIn(stream.readLine()); 133 if (pos > -1) { 134 int w = regexp.cap(1).toInt(); 135 int h = regexp.cap(2).toInt(); 136 float hz = regexp.cap(3).toFloat(); 137 int xrandrhz = regexp.cap(4).toShort(); 138 int found = -1; 139 VERBOSE(VB_PLAYBACK, QString("Found definition for %1x%2 @ %3Hz (xrandr: %4)") 140 .arg(w) .arg(h) .arg(hz) .arg(xrandrhz)); 141 // find if video mode already exist, and remove refresh rates for custom one 142 for (int i=0; i < m_video_modes.size(); i++) { 143 if ((m_video_modes[i].Width() == w) && (m_video_modes[i].Height() == h)) 144 { 145 found = i; 146 if (!m_video_modes[i].Custom()) 147 { 148 m_video_modes[i].ClearRefreshRates(); 149 m_video_modes[i].SetCustom(true); 150 } 151 m_video_modes[i].AddRefreshRate(hz); 152 m_video_modes[i].realRates[hz] = xrandrhz; 153 break; 154 } 155 } 156 if (found < 0) 157 { 158 DisplayResScreen scr(w, h, 0, 0, -1.0, hz); 159 scr.SetCustom(true); 160 m_video_modes.push_back(scr); 161 } 162 } 163 } 164 file.close(); 165 } 166 } 167 91 168 m_video_modes_unsorted = m_video_modes; 92 169 std::sort(m_video_modes.begin(), m_video_modes.end()); 93 170 -
mythtv/libs/libmythui/DisplayResScreen.cpp
1 1 #include <QStringList> 2 2 3 3 #include "DisplayResScreen.h" 4 #include <cmath> 4 5 5 6 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 6 double aspectRatio, short refreshRate)7 : width(w), height(h), width_mm(mw), height_mm(mh) 7 double aspectRatio, float refreshRate) 8 : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) 8 9 { 9 10 SetAspectRatio(aspectRatio); 10 11 if (refreshRate > 0) … … 12 13 } 13 14 14 15 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 15 const std::vector< short>& rr)16 : width(w), height(h), width_mm(mw), height_mm(mh), refreshRates(rr) 16 const std::vector<float>& rr) 17 : width(w), height(h), width_mm(mw), height_mm(mh), refreshRates(rr), custom(false) 17 18 { 18 19 SetAspectRatio(-1.0); 19 20 } 20 21 21 22 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 22 const short* rr, uint rr_length)23 : width(w), height(h), width_mm(mw), height_mm(mh) 23 const float* rr, uint rr_length) 24 : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) 24 25 { 25 26 SetAspectRatio(-1.0); 26 27 for (uint i = 0; i < rr_length; ++i) … … 29 30 std::sort(refreshRates.begin(), refreshRates.end()); 30 31 } 31 32 33 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 34 const short* rr, uint rr_length) 35 : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) 36 { 37 SetAspectRatio(-1.0); 38 for (uint i = 0; i < rr_length; ++i) 39 refreshRates.push_back((float)rr[i]); 40 41 std::sort(refreshRates.begin(), refreshRates.end()); 42 } 43 32 44 DisplayResScreen::DisplayResScreen(const QString &str) 33 45 : width(0), height(0), width_mm(0), height_mm(0), aspect(-1.0) 34 46 { … … 44 56 height_mm = slist[3].toInt(); 45 57 aspect = slist[4].toDouble(); 46 58 for (int i = 5; i<slist.size(); ++i) 47 refreshRates.push_back(slist[i].to Short());59 refreshRates.push_back(slist[i].toFloat()); 48 60 } 49 61 } 50 62 … … 81 93 return dsr; 82 94 } 83 95 96 //compares if the float f1 is equal with f2 and returns 1 if true and 0 if false 97 bool DisplayResScreen::compare_rates(float f1, float f2) 98 { 99 float precision = 0.01; 100 if (((f1 - precision) < f2) && 101 ((f1 + precision) > f2)) 102 { 103 return true; 104 } 105 else 106 { 107 return false; 108 } 109 } 110 84 111 int DisplayResScreen::FindBestMatch(const std::vector<DisplayResScreen>& dsr, 85 112 const DisplayResScreen& d, 86 113 short& target_rate) 87 114 { 115 float target; 116 int i = FindBestMatch(dsr, d, target); 117 target_rate = target; 118 return i; 119 } 120 121 int DisplayResScreen::FindBestMatch(const std::vector<DisplayResScreen>& dsr, 122 const DisplayResScreen& d, 123 float& target_rate) 124 { 125 // Amend vector with custom list 88 126 for (uint i=0; i<dsr.size(); ++i) 89 127 { 90 128 if (dsr[i].Width()==d.Width() && dsr[i].Height()==d.Height()) 91 129 { 92 const std::vector< short>& rates = dsr[i].RefreshRates();93 if (rates.size() )130 const std::vector<float>& rates = dsr[i].RefreshRates(); 131 if (rates.size() && d.RefreshRate() != 0) 94 132 { 95 std::vector<short>::const_iterator it = 96 find(rates.begin(), rates.end(), d.RefreshRate()); 97 target_rate = (it == rates.end()) ? *(--rates.end()) : *it; 98 return i; 99 } 133 for (uint j=0; j < rates.size(); ++j) 134 { 135 // Multiple of target_rate will do 136 if (compare_rates(d.RefreshRate(),rates[j]) || (fmod(rates[j],d.RefreshRate()) <= 0.01)) 137 { 138 target_rate = rates[j]; 139 return i; 140 } 141 } 142 // Can't find exact frame rate, so try rounding to the nearest integer, so 23.97Hz will work with 24Hz etc 143 for (uint j=0; j < rates.size(); ++j) 144 { 145 float rounded = (float) ((int) (rates[j] + 0.5)); 146 // Multiple of target_rate will do 147 if (compare_rates(d.RefreshRate(),rounded) || (fmod(rounded,d.RefreshRate()) <= 0.01)) 148 { 149 target_rate = rounded; 150 return i; 151 } 152 } 153 target_rate = rates[rates.size() - 1]; 154 } 155 return i; 100 156 } 101 157 } 102 158 return -1; -
mythtv/libs/libmythui/DisplayRes.h
40 40 * \brief Switches to the resolution and refresh rate defined in the 41 41 * database for the specified video resolution and frame rate. 42 42 */ 43 bool SwitchToVideo(int iwidth, int iheight, short irate = 0 );43 bool SwitchToVideo(int iwidth, int iheight, short irate = 0, float frate = 0.0); 44 44 /** \brief Switches to the GUI resolution specified. 45 45 * 46 46 * If which_gui is GUI then this switches to the resolution … … 104 104 /// \brief Returns all video modes supported by the display. 105 105 virtual const std::vector<DisplayResScreen>& GetVideoModes() const = 0; 106 106 /// \brief Returns refresh rates available at a specific screen resolution. 107 const std::vector<short> GetRefreshRates(int width, int height) const; 107 const std::vector<float> GetRefreshRatesFloat(int width, int height) const; 108 const std::vector<short> GetRefreshRates(int width, int height) const; 108 109 /** @} */ 109 110 110 111 protected: … … 114 115 115 116 // These methods are implemented by the subclasses 116 117 virtual bool GetDisplaySize(int &width_mm, int &height_mm) const = 0; 117 virtual bool SwitchToVideoMode(int width, int height, short framerate) = 0;118 virtual bool SwitchToVideoMode(int width, int height, float framerate) = 0; 118 119 119 120 private: 120 121 DisplayRes(const DisplayRes & rhs); // disable copy constructor; -
mythtv/programs/mythfrontend/globalsettings.cpp
2525 2525 return gc; 2526 2526 } 2527 2527 2528 static HostLineEdit *CustomScreenConfig() 2529 { 2530 HostLineEdit *gedit = new HostLineEdit("CustomScreenRate"); 2531 gedit->setLabel(QObject::tr("Custom screen rate definition file")); 2532 gedit->setHelpText(QObject::tr("Custom screen resolution configuration " 2533 "for matching xrandr value.")); 2534 return gedit; 2535 } 2536 2528 2537 static HostSpinBox *VidModeWidth(int idx) 2529 2538 { 2530 2539 HostSpinBox *gs = new HostSpinBox(QString("VidModeWidth%1").arg(idx), … … 2693 2702 rate, SLOT(ChangeResolution(const QString&))); 2694 2703 } 2695 2704 2705 ConfigurationGroup* customscreensettings = 2706 new HorizontalConfigurationGroup(false, false); 2707 2708 customscreensettings->addChild(CustomScreenConfig()); 2709 2696 2710 ConfigurationGroup* settings = new VerticalConfigurationGroup(false); 2711 2697 2712 settings->addChild(defaultsettings); 2698 2713 settings->addChild(overrides); 2714 settings->addChild(customscreensettings); 2699 2715 2700 2716 addTarget("1", settings); 2701 2717 addTarget("0", new VerticalConfigurationGroup(true));