timecode functions: added convenience function and improved error reporting
Added a convenience function for converting rational time to a timecode and timecode converters now return error messages if something goes wrong.
This commit is contained in:
@@ -34,7 +34,7 @@ QString Timecode::timestamp_to_timecode(const int64_t ×tamp,
|
||||
bool show_plus_if_positive)
|
||||
{
|
||||
if (timebase.isNull()) {
|
||||
return QString();
|
||||
return QStringLiteral("INVALID TIMEBASE");
|
||||
}
|
||||
|
||||
double timestamp_dbl = (rational(timestamp) * timebase).toDouble();
|
||||
@@ -126,7 +126,7 @@ QString Timecode::timestamp_to_timecode(const int64_t ×tamp,
|
||||
return QString::number(qRound(timestamp_dbl * 1000));
|
||||
}
|
||||
|
||||
return QString();
|
||||
return QStringLiteral("INVALID TIMECODE MODE");
|
||||
}
|
||||
|
||||
int64_t Timecode::timecode_to_timestamp(const QString &timecode, const rational &timebase, const Display &display, bool* ok)
|
||||
@@ -244,6 +244,11 @@ rational Timecode::timestamp_to_time(const int64_t ×tamp, const rational &t
|
||||
return rational(timestamp) * timebase;
|
||||
}
|
||||
|
||||
QString Timecode::time_to_timecode(const rational &time, const rational &timebase, const Timecode::Display &display, bool show_plus_if_positive)
|
||||
{
|
||||
return timestamp_to_timecode(time_to_timestamp(time, timebase), timebase, display, show_plus_if_positive);
|
||||
}
|
||||
|
||||
bool Timecode::TimebaseIsDropFrame(const rational &timebase)
|
||||
{
|
||||
return (timebase.numerator() == 1001);
|
||||
|
||||
Reference in New Issue
Block a user