decklink: Fix truncation warnings

Also simplify DeckLinkDeviceMode::IsEqualFrameRate using cross-multiply.
This commit is contained in:
jpark37
2021-07-23 20:32:53 -07:00
committed by Jim
parent 8440a53da3
commit 31c488f0d0
2 changed files with 8 additions and 13 deletions

View File

@@ -68,20 +68,16 @@ const std::string &DeckLinkDeviceMode::GetName(void) const
bool DeckLinkDeviceMode::IsEqualFrameRate(int64_t num, int64_t den)
{
if (!mode)
return false;
bool equal = false;
BMDTimeValue timeValue;
BMDTimeScale timeScale;
if (mode->GetFrameRate(&timeValue, &timeScale) != S_OK)
return false;
if (mode) {
BMDTimeValue frameDuration;
BMDTimeScale timeScale;
if (SUCCEEDED(mode->GetFrameRate(&frameDuration, &timeScale)))
equal = timeScale * den == frameDuration * num;
}
// Calculate greatest common divisor of both values to properly compare framerates
int decklinkGcd = std::gcd(timeScale, timeValue);
int inputGcd = std::gcd(num, den);
return ((timeScale / decklinkGcd) == (num / inputGcd) &&
(timeValue / decklinkGcd) == (den / inputGcd));
return equal;
}
void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)

View File

@@ -3,7 +3,6 @@
#include "platform.hpp"
#include <string>
#include <numeric>
#define MODE_ID_AUTO -1