architecture: move loop modes to clips

This commit is contained in:
itsmattkc
2022-07-17 15:22:36 -07:00
parent 4c71a33b7b
commit 0d9727b6d2
13 changed files with 179 additions and 79 deletions
+7 -19
View File
@@ -37,7 +37,6 @@
namespace olive {
const QString Footage::kFilenameInput = QStringLiteral("file_in");
const QString Footage::kLoopModeInput = QStringLiteral("loop_in");
#define super ViewerOutput
@@ -49,8 +48,6 @@ Footage::Footage(const QString &filename) :
{
SetCacheTextures(true);
PrependInput(kLoopModeInput, NodeValue::kCombo, 0, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
PrependInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
Clear();
@@ -70,8 +67,6 @@ void Footage::Retranslate()
super::Retranslate();
SetInputName(kFilenameInput, tr("Filename"));
SetInputName(kLoopModeInput, tr("Loop Mode"));
SetComboBoxStrings(kLoopModeInput, {tr("None"), tr("Loop"), tr("Clamp")});
}
void Footage::InputValueChangedEvent(const QString &input, int element)
@@ -139,11 +134,6 @@ void Footage::SetValid()
valid_ = true;
}
Footage::LoopMode Footage::loop_mode() const
{
return static_cast<LoopMode>(GetStandardValue(kLoopModeInput).toInt());
}
QString Footage::filename() const
{
return GetStandardValue(kFilenameInput).toString();
@@ -263,17 +253,15 @@ void Footage::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeV
// Pop filename from table
QString file = value[kFilenameInput].toString();
LoopMode loop_mode = static_cast<LoopMode>(value[kLoopModeInput].toInt());
// If the file exists and the reference is valid, push a footage job to the renderer
if (QFileInfo(file).exists()) {
if (QFileInfo::exists(file)) {
// Push length
table->Push(NodeValue::kRational, QVariant::fromValue(GetLength()), this, false, QStringLiteral("length"));
table->Push(NodeValue::kRational, QVariant::fromValue(GetLength()), this, QStringLiteral("length"));
// Push each stream as a footage job
for (int i=0; i<GetTotalStreamCount(); i++) {
Track::Reference ref = GetReferenceFromRealIndex(i);
FootageJob job(decoder_, filename(), ref.type(), GetLength(), loop_mode);
FootageJob job(decoder_, filename(), ref.type(), GetLength());
NodeValue::Type type;
@@ -339,7 +327,7 @@ bool TimeIsOutOfBounds(const rational& time, const rational& length)
return time < 0 || time >= length;
}
rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mode, const rational &length, VideoParams::Type type, const rational& timebase)
rational Footage::AdjustTimeByLoopMode(rational time, Decoder::LoopMode loop_mode, const rational &length, VideoParams::Type type, const rational& timebase)
{
if (type == VideoParams::kVideoTypeStill) {
// No looping for still images
@@ -348,15 +336,15 @@ rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mod
if (TimeIsOutOfBounds(time, length)) {
switch (loop_mode) {
case kLoopModeOff:
case Decoder::kLoopModeOff:
// Return no time to indicate no frame should be shown here
time = rational::NaN;
break;
case kLoopModeClamp:
case Decoder::kLoopModeClamp:
// Clamp footage time to length
time = clamp(time, rational(0), length - timebase);
break;
case kLoopModeLoop:
case Decoder::kLoopModeLoop:
// Loop footage time around job length
do {
if (time >= length) {
+2 -13
View File
@@ -24,6 +24,7 @@
#include <QList>
#include <QDateTime>
#include "codec/decoder.h"
#include "common/rational.h"
#include "footagedescription.h"
#include "node/output/viewer/viewer.h"
@@ -44,12 +45,6 @@ class Footage : public ViewerOutput
{
Q_OBJECT
public:
enum LoopMode {
kLoopModeOff,
kLoopModeLoop,
kLoopModeClamp
};
/**
* @brief Footage Constructor
*/
@@ -101,11 +96,6 @@ public:
*/
void SetValid();
/**
* @brief Get currently set loop mode
*/
LoopMode loop_mode() const;
/**
* @brief Return the current filename of this Footage object
*/
@@ -183,7 +173,7 @@ public:
virtual Node *GetConnectedSampleOutput() override;
static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type, const rational &timebase);
static rational AdjustTimeByLoopMode(rational time, Decoder::LoopMode loop_mode, const rational& length, VideoParams::Type type, const rational &timebase);
virtual void LoadFinishedEvent() override;
@@ -191,7 +181,6 @@ public:
virtual qint64 mod_time() const override;
static const QString kFilenameInput;
static const QString kLoopModeInput;
protected:
virtual void InputValueChangedEvent(const QString &input, int element) override;