Ticket #5643: adjust_rate4-trunk20764.patch
File adjust_rate4-trunk20764.patch, 29.0 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
old new 737 737 GetDecoder()->GetVideoCodecPrivate(), 738 738 pipState, 739 739 video_disp_dim, video_aspect, 740 widget->winId(), display_rect, 0 /*embedid*/); 740 widget->winId(), display_rect, (video_frame_rate * play_speed), 741 0 /*embedid*/); 741 742 742 743 if (!videoOutput) 743 744 { -
mythtv/libs/libmythtv/videooutbase.cpp
old new 73 73 PIPState pipState, 74 74 const QSize &video_dim, float video_aspect, 75 75 WId win_id, const QRect &display_rect, 76 WIdembed_id)76 float video_prate, WId embed_id) 77 77 { 78 78 (void) codec_priv; 79 79 … … 194 194 if (vo) 195 195 { 196 196 vo->SetPIPState(pipState); 197 vo->video_prate = video_prate; 197 198 if (vo->Init( 198 199 video_dim.width(), video_dim.height(), video_aspect, 199 200 win_id, display_rect.x(), display_rect.y(), … … 419 420 420 421 void VideoOutput::SetVideoFrameRate(float playback_fps) 421 422 { 423 video_prate = playback_fps; 422 424 if (db_vdisp_profile) 423 425 db_vdisp_profile->SetOutput(playback_fps); 424 426 } … … 1513 1515 if ((width == 1920 || width == 1440) && height == 1088) 1514 1516 height = 1080; // ATSC 1920x1080 1515 1517 1516 if (display_res && display_res->SwitchToVideo(width, height ))1518 if (display_res && display_res->SwitchToVideo(width, height, video_prate)) 1517 1519 { 1518 1520 // Switching to custom display resolution succeeded 1519 1521 // Make a note of the new size -
mythtv/libs/libmythtv/videooutbase.h
old new 49 49 PIPState pipState, 50 50 const QSize &video_dim, float video_aspect, 51 51 WId win_id, const QRect &display_rect, 52 WIdembed_id);52 float video_prate, WId embed_id); 53 53 54 54 VideoOutput(); 55 55 virtual ~VideoOutput(); … … 297 297 bool db_use_picture_controls; 298 298 299 299 VideoDisplayProfile *db_vdisp_profile; 300 float video_prate; ///< Playback frame rate of video 300 301 301 302 // Picture-in-Picture 302 303 QSize pip_desired_display_size; -
mythtv/libs/libmythui/DisplayRes.cpp
old new 10 10 #include "DisplayResOSX.h" 11 11 #endif 12 12 13 #include <cmath> 14 13 15 DisplayRes * DisplayRes::instance = NULL; 14 16 bool DisplayRes::locked = false; 15 17 … … 56 58 // Initialise DESKTOP mode 57 59 GetDisplayInfo(tW, tH, tW_mm, tH_mm, tRate); 58 60 mode[DESKTOP].Init(); 59 mode[DESKTOP] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, tRate);61 mode[DESKTOP] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, (float) tRate); 60 62 VERBOSE(VB_GENERAL, QString("Desktop video mode: %1x%2 %3 Hz") 61 63 .arg(tW).arg(tH).arg(tRate)); 62 64 63 65 // Initialize GUI mode 64 66 mode[GUI].Init(); 65 67 tW = tH = 0; 66 GetMythDB()->GetResolutionSetting("GuiVidMode", tW, tH );68 GetMythDB()->GetResolutionSetting("GuiVidMode", tW, tH, tAspect, tRate); 67 69 GetMythDB()->GetResolutionSetting("DisplaySize", tW_mm, tH_mm); 68 mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, tRate);70 mode[GUI] = DisplayResScreen(tW, tH, tW_mm, tH_mm, -1.0, (float) tRate); 69 71 70 72 71 73 // Initialize default VIDEO mode 72 74 tW = tH = 0; 73 75 GetMythDB()->GetResolutionSetting("TVVidMode", tW, tH, tAspect, tRate); 74 mode[VIDEO] = DisplayResScreen(tW, tH, tW_mm, tH_mm, tAspect, tRate);76 mode[VIDEO] = DisplayResScreen(tW, tH, tW_mm, tH_mm, tAspect, (float) tRate); 75 77 76 78 77 79 // Initialize video override mode … … 89 91 break; 90 92 91 93 uint key = DisplayResScreen::CalcKey(iw, ih, irate); 92 DisplayResScreen scr(ow, oh, tW_mm, tH_mm, oaspect, orate);94 DisplayResScreen scr(ow, oh, tW_mm, tH_mm, oaspect, (float)orate); 93 95 in_size_to_output_mode[key] = scr; 94 96 } 95 97 … … 107 109 return true; 108 110 } 109 111 110 bool DisplayRes::SwitchToVideo(int iwidth, int iheight, short irate)112 bool DisplayRes::SwitchToVideo(int iwidth, int iheight, float frate) 111 113 { 112 114 tmode next_mode = VIDEO; // default VIDEO mode 113 115 DisplayResScreen next = mode[next_mode]; 114 116 117 // If requested refresh rate is 0, attempt to match video fps 118 if (next.RefreshRate() == 0) 119 { 120 VERBOSE(VB_PLAYBACK, QString("*** Trying to match best resolution %1Hz") .arg(frate)); 121 next.AddRefreshRate(frate); 122 } 123 115 124 // try to find video override mode 116 uint key = DisplayResScreen::CalcKey(iwidth, iheight, irate);125 uint key = DisplayResScreen::CalcKey(iwidth, iheight, (short) roundf(frate)); 117 126 DisplayResMapCIt it = in_size_to_output_mode.find(key); 118 127 if (it != in_size_to_output_mode.end()) 119 128 mode[next_mode = CUSTOM_VIDEO] = next = it->second; 120 129 121 130 // need to change video mode? 122 short target_rate =0;131 float target_rate = 0.0; 123 132 DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate); 124 bool chg = !(next == last) || !( last.RefreshRate() == target_rate);133 bool chg = !(next == last) || !(DisplayResScreen::compare_rates(last.RefreshRate(),target_rate)); 125 134 126 135 VERBOSE(VB_PLAYBACK, QString("Trying %1x%2 %3 Hz") 127 136 .arg(next.Width()).arg(next.Height()).arg(target_rate)); … … 153 162 DisplayResScreen next = mode[next_mode]; 154 163 155 164 // need to change video mode? 156 short target_rate = next.RefreshRate();165 float target_rate = next.RefreshRate(); 157 166 DisplayResScreen::FindBestMatch(GetVideoModes(), next, target_rate); 158 bool chg = !(next == last) || !(last.RefreshRate() == target_rate); 167 // If GuiVidModeRefreshRate is 0, assume any refresh rate is good enough. 168 bool chg = (!(next == last) || (next.RefreshRate() !=0 169 && !(DisplayResScreen::compare_rates(last.RefreshRate(), target_rate)))); 159 170 160 171 VERBOSE(VB_GENERAL, QString("Trying %1x%2 %3 Hz") 161 172 .arg(next.Width()).arg(next.Height()).arg(target_rate)); … … 180 191 bool DisplayRes::SwitchToCustomGUI(int width, int height, short rate) 181 192 { 182 193 mode[CUSTOM_GUI] = DisplayResScreen(width, height, mode[GUI].Width_mm(), 183 mode[GUI].Height_mm(), -1.0, rate);194 mode[GUI].Height_mm(), -1.0, (float)rate); 184 195 return SwitchToGUI(CUSTOM_GUI); 185 196 } 186 197 187 const std::vector<short> DisplayRes::GetRefreshRates(int width, 188 int height) const { 189 short tr; 190 std::vector<short> empty; 198 const std::vector<short> DisplayRes::GetRefreshRates(int width, int height) const { 199 std::vector<short> srates; 200 std::vector<float> rates = GetRefreshRatesFloat(width, height); 201 202 for (int i=0; i<rates.size(); i++) 203 srates.push_back((short) rates[i]); 204 return srates; 205 } 206 const std::vector<float> DisplayRes::GetRefreshRatesFloat(int width, int height) const { 207 float tr; 208 std::vector<float> empty; 191 209 192 const DisplayResScreen drs(width, height, 0, 0, -1.0, 0 );210 const DisplayResScreen drs(width, height, 0, 0, -1.0, 0.0); 193 211 const DisplayResVector& drv = GetVideoModes(); 194 212 int t = DisplayResScreen::FindBestMatch(drv, drs, tr); 195 213 if (t < 0) -
mythtv/libs/libmythui/DisplayRes.h
old new 59 59 * @{ 60 60 */ 61 61 62 /** \fn SwitchToVideo(int iwidth, int iheight, short irate = 0)62 /** \fn SwitchToVideo(int iwidth, int iheight, float frate = 0) 63 63 * \brief Switches to the resolution and refresh rate defined in the 64 64 * database for the specified video resolution and frame rate. 65 65 */ 66 bool SwitchToVideo(int iwidth, int iheight, short irate =0);66 bool SwitchToVideo(int iwidth, int iheight, float frate = 0.0); 67 67 /** \brief Switches to the GUI resolution specified. 68 68 * 69 69 * If which_gui is GUI then this switches to the resolution … … 127 127 /// \brief Returns all video modes supported by the display. 128 128 virtual const std::vector<DisplayResScreen>& GetVideoModes() const = 0; 129 129 /// \brief Returns refresh rates available at a specific screen resolution. 130 const std::vector<float> GetRefreshRatesFloat(int width, int height) const; 130 131 const std::vector<short> GetRefreshRates(int width, int height) const; 131 132 /** @} */ 132 133 … … 138 139 // These methods are implemented by the subclasses 139 140 virtual bool GetDisplayInfo(int &w_pix, int &h_pix, int &w_mm, 140 141 int &h_mm, short &rate) const = 0; 141 virtual bool SwitchToVideoMode(int width, int height, short framerate) = 0;142 virtual bool SwitchToVideoMode(int width, int height, float framerate) = 0; 142 143 143 144 private: 144 145 DisplayRes(const DisplayRes & rhs); // disable copy constructor; -
mythtv/libs/libmythui/DisplayResOSX.cpp
old new 70 70 return d; 71 71 } 72 72 73 bool DisplayResOSX::SwitchToVideoMode(int width, int height, short refreshrate)73 bool DisplayResOSX::SwitchToVideoMode(int width, int height, float refreshrate) 74 74 { 75 75 CGDirectDisplayID d = mythtv_display(); 76 76 CFDictionaryRef dispMode = NULL; … … 79 79 // find mode that matches the desired size 80 80 if (refreshrate) 81 81 dispMode = CGDisplayBestModeForParametersAndRefreshRate( 82 d, 32, width, height, (CGRefreshRate)( refreshrate), &match);82 d, 32, width, height, (CGRefreshRate)((short)refreshrate), &match); 83 83 84 84 if (!match) 85 85 dispMode = … … 126 126 127 127 if (screen_map.find(key)==screen_map.end()) 128 128 screen_map[key] = DisplayResScreen(width, height, 129 0, 0, -1.0, refresh);129 0, 0, -1.0, (float) refresh); 130 130 else 131 131 screen_map[key].AddRefreshRate(refresh); 132 132 } -
mythtv/libs/libmythui/DisplayResOSX.h
old new 13 13 protected: 14 14 bool GetDisplayInfo(int &w_pix, int &h_pix, int &w_mm, 15 15 int &h_mm, short &rate) const; 16 bool SwitchToVideoMode(int width, int height, short framerate);16 bool SwitchToVideoMode(int width, int height, float framerate); 17 17 18 18 private: 19 19 mutable std::vector<DisplayResScreen> m_video_modes; -
mythtv/libs/libmythui/DisplayResScreen.cpp
old new 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 std::vector<float>& rr, const std::map<float, short>& rr2) 24 : width(w), height(h), width_mm(mw), height_mm(mh), refreshRates(rr), realRates(rr2), custom(true) 25 { 26 SetAspectRatio(-1.0); 27 } 28 29 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 30 const float* rr, uint rr_length) 31 : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) 24 32 { 25 33 SetAspectRatio(-1.0); 26 34 for (uint i = 0; i < rr_length; ++i) … … 29 37 std::sort(refreshRates.begin(), refreshRates.end()); 30 38 } 31 39 40 DisplayResScreen::DisplayResScreen(int w, int h, int mw, int mh, 41 const short* rr, uint rr_length) 42 : width(w), height(h), width_mm(mw), height_mm(mh), custom(false) 43 { 44 SetAspectRatio(-1.0); 45 for (uint i = 0; i < rr_length; ++i) 46 { 47 refreshRates.push_back((float)rr[i]); 48 } 49 std::sort(refreshRates.begin(), refreshRates.end()); 50 } 51 32 52 DisplayResScreen::DisplayResScreen(const QString &str) 33 : width(0), height(0), width_mm(0), height_mm(0), aspect(-1.0) 53 : width(0), height(0), width_mm(0), height_mm(0), aspect(-1.0), custom(false) 34 54 { 35 55 refreshRates.clear(); 36 56 QStringList slist = str.split(":"); … … 44 64 height_mm = slist[3].toInt(); 45 65 aspect = slist[4].toDouble(); 46 66 for (int i = 5; i<slist.size(); ++i) 47 refreshRates.push_back(slist[i].to Short());67 refreshRates.push_back(slist[i].toFloat()); 48 68 } 49 69 } 50 70 … … 81 101 return dsr; 82 102 } 83 103 104 //compares if the float f1 is equal with f2 and returns 1 if true and 0 if false 105 bool DisplayResScreen::compare_rates(float f1, float f2) 106 { 107 float precision = 0.01; 108 if (((f1 - precision) < f2) && 109 ((f1 + precision) > f2)) 110 { 111 return true; 112 } 113 else 114 { 115 return false; 116 } 117 } 118 84 119 int DisplayResScreen::FindBestMatch(const std::vector<DisplayResScreen>& dsr, 85 120 const DisplayResScreen& d, 86 121 short& target_rate) 87 122 { 123 float target; 124 int i = FindBestMatch(dsr, d, target); 125 target_rate = target; 126 return i; 127 } 128 129 int DisplayResScreen::FindBestMatch(const std::vector<DisplayResScreen>& dsr, 130 const DisplayResScreen& d, 131 float& target_rate) 132 { 133 // Amend vector with custom list 88 134 for (uint i=0; i<dsr.size(); ++i) 89 135 { 90 136 if (dsr[i].Width()==d.Width() && dsr[i].Height()==d.Height()) 91 137 { 92 const std::vector< short>& rates = dsr[i].RefreshRates();93 if (rates.size() )138 const std::vector<float>& rates = dsr[i].RefreshRates(); 139 if (rates.size() && d.RefreshRate() != 0) 94 140 { 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; 141 for (uint j=0; j < rates.size(); ++j) 142 { 143 // Multiple of target_rate will do 144 if (compare_rates(d.RefreshRate(),rates[j]) || (fmod(rates[j],d.RefreshRate()) <= 0.01)) 145 { 146 target_rate = rates[j]; 147 return i; 148 } 149 } 150 // Can't find exact frame rate, so try rounding to the nearest integer, so 23.97Hz will work with 24Hz etc 151 for (uint j=0; j < rates.size(); ++j) 152 { 153 float rounded = (float) ((int) (rates[j] + 0.5)); 154 // Multiple of target_rate will do 155 if (compare_rates(d.RefreshRate(),rounded) || (fmod(rounded,d.RefreshRate()) <= 0.01)) 156 { 157 target_rate = rounded; 158 return i; 159 } 160 } 161 target_rate = rates[rates.size() - 1]; 99 162 } 163 return i; 100 164 } 101 165 } 102 166 return -1; -
mythtv/libs/libmythui/DisplayResScreen.h
old new 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 DisplayResScreen(int w, int h, int mw, int mh, 23 const std::vector<float>& refreshRates, const std::map<float, short>& realrates); 24 DisplayResScreen(int w, int h, int mw, int mh, 25 const float* refreshRates, uint rr_length); 22 26 DisplayResScreen(int w, int h, int mw, int mh, 23 27 const short* refreshRates, uint rr_length); 24 28 DisplayResScreen(const QString &str); … … 29 33 int Height() const { return height; } 30 34 int Width_mm() const { return width_mm; } 31 35 int Height_mm() const { return height_mm; } 36 bool Custom() const { return custom; } 37 32 38 inline double AspectRatio() const; 33 inline short RefreshRate() const;34 const std::vector< short>& RefreshRates() const { return refreshRates; }39 inline float RefreshRate() const; 40 const std::vector<float>& RefreshRates() const { return refreshRates; } 35 41 36 42 // Sets, adds 37 43 void SetAspectRatio(double a); 38 void AddRefreshRate( short rr) {44 void AddRefreshRate(float rr) { 39 45 refreshRates.push_back(rr); 40 46 std::sort(refreshRates.begin(), refreshRates.end()); 41 47 } 48 void ClearRefreshRates(void) { 49 refreshRates.clear(); 50 } 51 void SetCustom(bool b) { 52 custom = b; 53 } 54 55 // Map for matching real rates and xrandr rate; 56 std::map<float, short> realRates; 57 std::map<short, float> xrandrRates; 42 58 43 59 // Converters & comparitors 44 60 QString toString() const; … … 50 66 static std::vector<DisplayResScreen> Convert(const QStringList& slist); 51 67 static int FindBestMatch(const std::vector<DisplayResScreen>& dsr, 52 68 const DisplayResScreen& d, 69 float& target_rate); 70 static int FindBestMatch(const std::vector<DisplayResScreen>& dsr, 71 const DisplayResScreen& d, 53 72 short& target_rate); 54 73 static inline int CalcKey(int w, int h, int rate); 74 static bool compare_rates(float f1, float f2); 55 75 56 76 private: 57 77 int width, height; // size in pixels 58 78 int width_mm, height_mm; // physical size in millimeters 59 79 double aspect; // aspect ratio, calculated or set 60 std::vector<short> refreshRates; 80 std::vector<float> refreshRates; 81 bool custom; // Set if resolution was defined manually 61 82 }; 62 83 63 84 typedef std::vector<DisplayResScreen> DisplayResVector; … … 85 106 return aspect; 86 107 } 87 108 88 inline short DisplayResScreen::RefreshRate() const109 inline float DisplayResScreen::RefreshRate() const 89 110 { 90 111 if (refreshRates.size() >= 1) 91 112 return refreshRates[0]; 92 else return 0 ;113 else return 0.0; 93 114 } 94 115 95 116 inline bool DisplayResScreen::operator < (const DisplayResScreen& b) const -
mythtv/libs/libmythui/DisplayResX.cpp
old new 1 1 #include <iostream> 2 2 3 #include "config.h" 4 #include "DisplayResX.h" 5 #include "mythverbose.h" 6 #include "mythdb.h" 7 3 8 #include "mythxdisplay.h" 4 9 5 #include <X11/extensions/Xrandr.h> // this has to be after util-x11.h (Qt bug) 10 #include <QRegExp> 11 #include <QIODevice> 12 #include <QFileInfo> 6 13 7 #include "DisplayResX.h"14 #include <X11/extensions/Xrandr.h> // this has to be after util-x11.h (Qt bug) 8 15 9 16 using std::cerr; 10 17 using std::endl; … … 47 54 return success; 48 55 } 49 56 50 bool DisplayResX::SwitchToVideoMode(int width, int height, short desired_rate)57 bool DisplayResX::SwitchToVideoMode(int width, int height, float desired_rate) 51 58 { 52 short rate; 59 float rate; 60 short finalrate; 53 61 DisplayResScreen desired_screen(width, height, 0, 0, -1.0, desired_rate); 54 62 int idx = DisplayResScreen::FindBestMatch(m_video_modes_unsorted, 55 63 desired_screen, rate); … … 63 71 Rotation rot; 64 72 XRRConfigCurrentConfiguration(cfg, &rot); 65 73 74 // Search real xrandr rate for desired_rate 75 finalrate = (short) rate; 76 for (uint i=0; i < m_video_modes.size(); i++) { 77 if ((m_video_modes[i].Width() == width) && (m_video_modes[i].Height() == height)) 78 { 79 if (m_video_modes[i].Custom()) 80 { 81 finalrate = m_video_modes[i].realRates[rate]; 82 VERBOSE(VB_PLAYBACK, QString("CustomRate Found, set %1Hz as %2") .arg(rate) .arg(finalrate)); 83 } 84 break; 85 } 86 } 87 66 88 Window root = display->GetRoot(); 67 89 Status status = XRRSetScreenConfigAndRate(display->GetDisplay(), cfg, 68 root, idx, rot, rate,90 root, idx, rot, finalrate, 69 91 CurrentTime); 70 92 71 93 XRRFreeScreenConfigInfo(cfg); … … 102 124 rates, num_rates); 103 125 m_video_modes.push_back(scr); 104 126 } 127 128 QString customscreen = GetMythDB()->GetSetting("CustomScreenRate"); 129 if (GetMythDB()->GetNumSetting("UseVideoModes", 0) && customscreen.size()); 130 { 131 std::map<uint, DisplayResScreen> customscr; 132 133 QFileInfo fi(customscreen); 134 QFile file(customscreen); 135 136 if (!fi.exists() || !fi.isFile()) 137 { 138 VERBOSE(VB_PLAYBACK, QString("CustomScreenRate: \"%1\" failed: does not exist or isn't a file") 139 .arg(customscreen)); 140 } 141 else if ( file.open(QIODevice::ReadOnly) ) { 142 QRegExp regexp = QRegExp("^\\s*(\\d+),(\\d+),(\\d+\\.?\\d*),(\\d+)\\s*$"); 143 QTextStream stream( &file ); 144 QString line; 145 int pos; 146 while ( !stream.atEnd() ) 147 { 148 pos = regexp.indexIn(stream.readLine()); 149 if (pos > -1) 150 { 151 int w = regexp.cap(1).toInt(); 152 int h = regexp.cap(2).toInt(); 153 float hz = regexp.cap(3).toFloat(); 154 int xrandrhz = regexp.cap(4).toShort(); 155 uint key = DisplayResScreen::CalcKey(w, h, 0); 156 // Check if that resolution has already been defined, and if not create a new screen 157 if (customscr.find(key) == customscr.end()) 158 { 159 customscr[key] = DisplayResScreen(w, h, 0, 0, 0, hz); 160 } 161 else 162 { 163 customscr[key].AddRefreshRate(hz); 164 } 165 customscr[key].realRates[hz] = xrandrhz; 166 customscr[key].xrandrRates[xrandrhz] = hz; 167 } 168 } 169 file.close(); 170 171 // Update existing DisplayResScreen vector, and update it with new frequencies 172 for (uint i=0; i < m_video_modes.size(); i++) 173 { 174 DisplayResScreen scr = m_video_modes[i]; 175 int w = scr.Width(); 176 int h = scr.Height(); 177 int mw = scr.Width_mm(); 178 int mh = scr.Height_mm(); 179 uint key = DisplayResScreen::CalcKey(w, h, 0); 180 if (customscr.find(key) != customscr.end()) 181 { 182 // Found custom information for that resolution 183 // Replace xrandr refresh rate, with real one 184 std::vector<float> newrates; 185 std::map<float, short> realRates; 186 const std::vector<float>& rates = scr.RefreshRates(); 187 bool found = false; 188 for (std::vector<float>::const_iterator it = rates.begin() ; it != rates.end(); it++) 189 { 190 if (customscr[key].xrandrRates.find(*it) != customscr[key].xrandrRates.end()) 191 { 192 // Defined in custom rate, use it 193 newrates.push_back(customscr[key].xrandrRates[*it]); 194 realRates[customscr[key].xrandrRates[*it]] = *it; 195 found = true; 196 VERBOSE(VB_PLAYBACK, QString("CustomRate Found, set %1 as %2Hz") .arg(*it) .arg(customscr[key].xrandrRates[*it])); 197 } 198 } 199 if (found) 200 { 201 m_video_modes.erase(m_video_modes.begin() + i); 202 std::sort(newrates.begin(), newrates.end()); 203 m_video_modes.insert(m_video_modes.begin() + i, DisplayResScreen(w, h, mw, mh, newrates, realRates)); 204 } 205 } 206 } 207 } 208 } 209 105 210 m_video_modes_unsorted = m_video_modes; 106 211 std::sort(m_video_modes.begin(), m_video_modes.end()); 107 212 XRRFreeScreenConfigInfo(cfg); -
mythtv/programs/mythfrontend/globalsettings.cpp
old new 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); 2697 2711 settings->addChild(defaultsettings); 2698 2712 settings->addChild(overrides); 2713 settings->addChild(customscreensettings); 2699 2714 2700 2715 addTarget("1", settings); 2701 2716 addTarget("0", new VerticalConfigurationGroup(true)); -
mythtv/libs/libmythui/DisplayResX.h
old new 13 13 protected: 14 14 bool GetDisplayInfo(int &w_pix, int &h_pix, int &w_mm, 15 15 int &h_mm, short &rate) const; 16 bool SwitchToVideoMode(int width, int height, short framerate);16 bool SwitchToVideoMode(int width, int height, float framerate); 17 17 18 18 private: 19 19 mutable std::vector<DisplayResScreen> m_video_modes;