streamlined viewable-based lengths

This commit is contained in:
itsmattkc
2021-04-08 09:46:31 +10:00
parent c023916d05
commit eef19ca0ff
11 changed files with 89 additions and 79 deletions
+6
View File
@@ -187,6 +187,12 @@ public:
return input_ids_;
}
virtual QVector<QString> inputs_for_output(const QString& output) const
{
Q_UNUSED(output)
return inputs();
}
const QVector<QString>& outputs() const
{
return outputs_;
+5
View File
@@ -191,6 +191,11 @@ public:
return ref;
}
bool IsValid() const
{
return type_ > kNone && type_ < kCount && index_ >= 0;
}
private:
Track::Type type_;
+34 -21
View File
@@ -92,35 +92,34 @@ QString ViewerOutput::Description() const
QString ViewerOutput::duration() const
{
// Try video first
rational using_timebase;
Timecode::Display using_display = Core::instance()->GetTimecodeDisplay();
// Get first enabled streams
VideoParams video = GetFirstEnabledVideoStream();
if (video.is_valid() && video.video_type() != VideoParams::kVideoTypeStill) {
rational frame_rate_timebase = video.frame_rate_as_time_base();
return Timecode::timestamp_to_timecode(Timecode::rescale_timestamp_ceil(video.duration(), video.time_base(), frame_rate_timebase),
frame_rate_timebase,
Core::instance()->GetTimecodeDisplay());
}
// Try audio second
AudioParams audio = GetFirstEnabledAudioStream();
if (audio.is_valid()) {
if (video.is_valid() && video.video_type() != VideoParams::kVideoTypeStill) {
// Prioritize video
using_timebase = video.frame_rate_as_time_base();
} else if (audio.is_valid()) {
// Use audio as a backup
// If we're showing in a timecode, we prefer showing audio in seconds instead
Timecode::Display display = Core::instance()->GetTimecodeDisplay();
if (display == Timecode::kTimecodeDropFrame
|| display == Timecode::kTimecodeNonDropFrame) {
display = Timecode::kTimecodeSeconds;
if (using_display == Timecode::kTimecodeDropFrame
|| using_display == Timecode::kTimecodeNonDropFrame) {
using_display = Timecode::kTimecodeSeconds;
}
return Timecode::timestamp_to_timecode(audio.duration(),
audio.time_base(),
display);
using_timebase = audio.sample_rate_as_time_base();
}
// Otherwise, return nothing
return QString();
if (using_timebase.isNull()) {
// No timebase, return null
return QString();
} else {
// Return time transformed to timecode
return Timecode::time_to_timecode(GetLength(), using_timebase, using_display);
}
}
QString ViewerOutput::rate() const
@@ -248,6 +247,20 @@ void ViewerOutput::InvalidateCache(const TimeRange& range, const QString& from,
super::InvalidateCache(range, from, element, job_time);
}
QVector<QString> ViewerOutput::inputs_for_output(const QString &output) const
{
QVector<QString> inputs;
Track::Type type = Track::Reference::TypeFromString(output);
if (type == Track::kVideo) {
inputs.append(kTextureInput);
} else if (type == Track::kAudio) {
inputs.append(kSamplesInput);
}
return inputs;
}
const rational& ViewerOutput::GetLength() const
{
return last_length_;
+2
View File
@@ -67,6 +67,8 @@ public:
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element, qint64 job_time) override;
virtual QVector<QString> inputs_for_output(const QString& output) const override;
VideoParams GetVideoParams(int index = 0) const
{
return GetStandardValue(kVideoParamsInput, index).value<VideoParams>();
+4 -3
View File
@@ -25,12 +25,13 @@
namespace olive {
NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRange &range)
NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const QString& output, const TimeRange &range)
{
NodeValueDatabase database;
// We need to insert tables into the database for each input
foreach (const QString& input, node->inputs()) {
auto inputs = node->inputs_for_output(output);
foreach (const QString& input, inputs) {
if (IsCancelled()) {
return NodeValueDatabase();
}
@@ -104,7 +105,7 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, const QString& output
// FIXME: Cache certain values here if we've already processed them before
// Generate database of input values of node
NodeValueDatabase database = GenerateDatabase(n, range);
NodeValueDatabase database = GenerateDatabase(n, output, range);
// By this point, the node should have all the inputs it needs to render correctly
NodeValueTable table = n->Value(output, database);
+1 -1
View File
@@ -42,7 +42,7 @@ public:
return GenerateTable(output.node(), output.output(), range);
}
NodeValueDatabase GenerateDatabase(const Node *node, const TimeRange &range);
NodeValueDatabase GenerateDatabase(const Node *node, const QString &output, const TimeRange &range);
protected:
NodeValueTable ProcessInput(const Node *node, const QString &input, const TimeRange &range);