13 double AspectRatio,
double RefreshRate)
14 : m_width(Resolution.width()),
15 m_height(Resolution.height()),
16 m_widthMM(PhysicalSize.width()),
17 m_heightMM(PhysicalSize.height())
24 double AspectRatio,
double RefreshRate)
130 return (
static_cast<uint64_t
>(Size.width()) << 34) |
131 (
static_cast<uint64_t
>(Size.height()) << 18) |
132 (
static_cast<uint64_t
>(Rate * 1000.0));
138 return qAbs(First - Second) < Precision;
144 double videorate =
Mode.RefreshRate();
149 if ((videorate > 24.5) && (videorate < 30.5))
156 for (
size_t i = 0; i < Modes.size(); ++i)
158 if (Modes[i].
Width() ==
Mode.Width() && Modes[i].Height() ==
Mode.Height())
160 auto rates = Modes[i].RefreshRates();
161 if (!rates.empty() && !qFuzzyCompare(videorate + 1.0, 1.0))
165 for (
double precision : { 0.001, 0.01, 0.1 })
167 for (
double rate : rates)
171 (qAbs(videorate - fmod(rate, videorate))
173 (fmod(rate,videorate) <= precision))
176 return static_cast<int>(i);
182 for (
double precision : { 0.01, 0.1, 1.0 })
184 double rounded = round(videorate);
185 for (
double rate : rates)
189 (qAbs(rounded - fmod(rate, rounded)) <= precision) ||
190 (fmod(rate,rounded) <= precision))
193 return static_cast<int>(i);
207 TargetRate = rates[rates.size() - 1];
209 else if (!rates.empty())
211 TargetRate = rates[rates.size() - 1];
213 return static_cast<int>(i);
219static void extract_key(uint64_t key,
double& rate,
int& height,
int& width)
221 rate = (key & ((1 << 18) - 1)) / 1000.0;
222 height = (key >> 18) & ((1 << 16) - 1);
223 width = (key >> 34) & ((1 << 16) - 1);
227 int Width,
int Height,
double Rate)
235 for (
const auto & it : Map)
245 for (
const auto & it : Map)
251 if (width ==
Width && height ==
Height && qFuzzyCompare(rate + 1.0, 1.0))
255 for (
const auto & it : Map)
261 if ((width == 0 && height ==
Height &&
262 (
CompareRates(Rate, rate, 0.01) || qFuzzyCompare(rate + 1.0, 1.0))) ||
263 (width == 0 && height == 0 &&
CompareRates(Rate, rate * 2.0, 0.01)) ||
264 (width == 0 && height == 0 &&
CompareRates(Rate, rate, 0.01)))
277 rates << QString::number(rate,
'f', 2);
278 return QObject::tr(
"%1x%2@%3Hz").arg(
m_width).arg(
m_height).arg(rates.join(
", "));
static bool CompareRates(double First, double Second, double Precision=0.01)
Determine whether two rates are considered equal with the given precision.
bool operator<(const MythDisplayMode &Other) const
static int FindBestMatch(const MythDisplayModes &Modes, const MythDisplayMode &Mode, double &TargetRate)
void SetRefreshRate(double Rate)
void AddRefreshRate(double Rate)
MythDisplayRates m_refreshRates
void SetAspectRatio(double AspectRatio)
double AspectRatio() const
double RefreshRate() const
static uint64_t FindBestScreen(const DisplayModeMap &Map, int Width, int Height, double Rate)
bool operator==(const MythDisplayMode &Other) const
const MythDisplayRates & RefreshRates() const
static uint64_t CalcKey(QSize Size, double Rate)
MythDisplayMode()=default
static void extract_key(uint64_t key, double &rate, int &height, int &width)
std::map< uint64_t, MythDisplayMode > DisplayModeMap
std::vector< MythDisplayMode > MythDisplayModes
std::vector< double > MythDisplayRates