rational: implement NaN mode
Also clarify code where 0 is used as a rational.
This commit is contained in:
@@ -40,6 +40,9 @@ const QString Track::kMutedInput = QStringLiteral("muted_in");
|
||||
|
||||
Track::Track() :
|
||||
track_type_(Track::kNone),
|
||||
track_length_(0),
|
||||
midop_track_length_(0),
|
||||
preop_track_length_(0),
|
||||
index_(-1),
|
||||
locked_(false)
|
||||
{
|
||||
@@ -276,7 +279,7 @@ void Track::InputDisconnectedEvent(const QString &input, int element, const Node
|
||||
if (next) {
|
||||
UpdateInOutFrom(blocks_.indexOf(next));
|
||||
} else if (blocks_.isEmpty()) {
|
||||
SetLengthInternal(rational());
|
||||
SetLengthInternal(0);
|
||||
} else {
|
||||
SetLengthInternal(blocks_.last()->out());
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace olive {
|
||||
TrackList::TrackList(Sequence *parent, const Track::Type &type, const QString &track_input) :
|
||||
QObject(parent),
|
||||
track_input_(track_input),
|
||||
total_length_(0),
|
||||
type_(type)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight
|
||||
#define super Node
|
||||
|
||||
ViewerOutput::ViewerOutput(bool create_default_streams) :
|
||||
last_length_(0),
|
||||
video_length_(0),
|
||||
audio_length_(0),
|
||||
video_frame_cache_(this),
|
||||
audio_playback_cache_(this),
|
||||
video_cache_enabled_(true),
|
||||
@@ -226,7 +229,7 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
|
||||
|
||||
if ((video_cache_enabled_ && (from == kTextureInput || from == kVideoParamsInput))
|
||||
|| (audio_cache_enabled_ && (from == kSamplesInput || from == kAudioParamsInput))) {
|
||||
TimeRange invalidated_range(qMax(rational(), range.in()),
|
||||
TimeRange invalidated_range(qMax(rational(0), range.in()),
|
||||
qMin(GetLength(), range.out()));
|
||||
|
||||
if (invalidated_range.in() != invalidated_range.out()) {
|
||||
@@ -297,8 +300,6 @@ void ViewerOutput::Retranslate()
|
||||
|
||||
void ViewerOutput::VerifyLength()
|
||||
{
|
||||
rational subtitle_length;
|
||||
|
||||
video_length_ = VerifyLengthInternal(Track::kVideo);
|
||||
if (video_cache_enabled_) {
|
||||
video_frame_cache_.SetLength(video_length_);
|
||||
@@ -309,7 +310,7 @@ void ViewerOutput::VerifyLength()
|
||||
audio_playback_cache_.SetLength(audio_length_);
|
||||
}
|
||||
|
||||
subtitle_length = VerifyLengthInternal(Track::kSubtitle);
|
||||
rational subtitle_length = VerifyLengthInternal(Track::kSubtitle);
|
||||
|
||||
rational real_length = qMax(subtitle_length, qMax(video_length_, audio_length_));
|
||||
|
||||
@@ -345,14 +346,19 @@ rational ViewerOutput::VerifyLengthInternal(Track::Type type) const
|
||||
case Track::kVideo:
|
||||
if (IsInputConnected(kTextureInput)) {
|
||||
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kTextureInput), TimeRange(0, 0));
|
||||
qDebug() << "Got video length:" << t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
|
||||
return t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
|
||||
rational r = t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
|
||||
if (!r.isNaN()) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Track::kAudio:
|
||||
if (IsInputConnected(kSamplesInput)) {
|
||||
NodeValueTable t = traverser.GenerateTable(GetConnectedOutput(kSamplesInput), TimeRange(0, 0));
|
||||
return t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();
|
||||
rational r = t.Get(NodeValue::kRational, QStringLiteral("length")).value<rational>();;
|
||||
if (!r.isNaN()) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Track::kNone:
|
||||
@@ -361,7 +367,7 @@ rational ViewerOutput::VerifyLengthInternal(Track::Type type) const
|
||||
break;
|
||||
}
|
||||
|
||||
return rational();
|
||||
return 0;
|
||||
}
|
||||
|
||||
NodeOutput ViewerOutput::GetConnectedTextureOutput()
|
||||
|
||||
@@ -196,7 +196,7 @@ rational Footage::VerifyLengthInternal(Track::Type type) const
|
||||
}
|
||||
}
|
||||
|
||||
return super::VerifyLengthInternal(type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString Footage::GetColorspaceToUse(const VideoParams ¶ms) const
|
||||
|
||||
@@ -123,7 +123,7 @@ rational Sequence::VerifyLengthInternal(Track::Type type) const
|
||||
}
|
||||
}
|
||||
|
||||
return rational();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sequence::InputConnectedEvent(const QString &input, int element, const NodeOutput &output)
|
||||
|
||||
Reference in New Issue
Block a user