Merge branch 'master' into ocio_node
This commit is contained in:
@@ -33,6 +33,7 @@ const QString ClipBlock::kBufferIn = QStringLiteral("buffer_in");
|
||||
const QString ClipBlock::kMediaInInput = QStringLiteral("media_in_in");
|
||||
const QString ClipBlock::kSpeedInput = QStringLiteral("speed_in");
|
||||
const QString ClipBlock::kReverseInput = QStringLiteral("reverse_in");
|
||||
const QString ClipBlock::kMaintainAudioPitchInput = QStringLiteral("maintain_audio_pitch_in");
|
||||
|
||||
ClipBlock::ClipBlock() :
|
||||
in_transition_(nullptr),
|
||||
@@ -52,6 +53,8 @@ ClipBlock::ClipBlock() :
|
||||
AddInput(kReverseInput, NodeValue::kBoolean, false, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
IgnoreHashingFrom(kReverseInput);
|
||||
|
||||
AddInput(kMaintainAudioPitchInput, NodeValue::kBoolean, false, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
|
||||
PrependInput(kBufferIn, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
SetValueHintForInput(kBufferIn, ValueHint(NodeValue::kBuffer));
|
||||
}
|
||||
|
||||
@@ -71,6 +71,21 @@ public:
|
||||
return GetStandardValue(kReverseInput).toBool();
|
||||
}
|
||||
|
||||
void set_reverse(bool e)
|
||||
{
|
||||
SetStandardValue(kReverseInput, e);
|
||||
}
|
||||
|
||||
bool maintain_audio_pitch() const
|
||||
{
|
||||
return GetStandardValue(kMaintainAudioPitchInput).toBool();
|
||||
}
|
||||
|
||||
void set_maintain_audio_pitch(bool e)
|
||||
{
|
||||
SetStandardValue(kMaintainAudioPitchInput, e);
|
||||
}
|
||||
|
||||
TransitionBlock* in_transition()
|
||||
{
|
||||
return in_transition_;
|
||||
@@ -110,6 +125,7 @@ public:
|
||||
static const QString kMediaInInput;
|
||||
static const QString kSpeedInput;
|
||||
static const QString kReverseInput;
|
||||
static const QString kMaintainAudioPitchInput;
|
||||
|
||||
protected:
|
||||
virtual void LinkChangeEvent() override;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(cornerpin)
|
||||
add_subdirectory(crop)
|
||||
add_subdirectory(flip)
|
||||
add_subdirectory(transform)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2021 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/cornerpin/cornerpindistortnode.cpp
|
||||
node/distort/cornerpin/cornerpindistortnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,226 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "cornerpindistortnode.h"
|
||||
|
||||
#include "common/lerp.h"
|
||||
#include "core.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString CornerPinDistortNode::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString CornerPinDistortNode::kTopLeftInput = QStringLiteral("top_left_in");
|
||||
const QString CornerPinDistortNode::kTopRightInput = QStringLiteral("top_right_in");
|
||||
const QString CornerPinDistortNode::kBottomRightInput = QStringLiteral("bottom_right_in");
|
||||
const QString CornerPinDistortNode::kBottomLeftInput = QStringLiteral("bottom_left_in");
|
||||
const QString CornerPinDistortNode::kPerspectiveInput = QStringLiteral("perspective_in");
|
||||
|
||||
CornerPinDistortNode::CornerPinDistortNode()
|
||||
{
|
||||
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kPerspectiveInput, NodeValue::kBoolean, true);
|
||||
AddInput(kTopLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kTopRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomRightInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
AddInput(kBottomLeftInput, NodeValue::kVec2, QVector2D(0.0, 0.0));
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Retranslate()
|
||||
{
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
SetInputName(kPerspectiveInput, tr("Perspective"));
|
||||
SetInputName(kTopLeftInput, tr("Top Left"));
|
||||
SetInputName(kTopRightInput, tr("Top Right"));
|
||||
SetInputName(kBottomRightInput, tr("Bottom Right"));
|
||||
SetInputName(kBottomLeftInput, tr("Bottom Left"));
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
ShaderJob job;
|
||||
job.InsertValue(value);
|
||||
job.SetAlphaChannelRequired(GenerateJob::kAlphaForceOn);
|
||||
job.InsertValue(QStringLiteral("resolution_in"), NodeValue(NodeValue::kVec2, globals.resolution(), this));
|
||||
|
||||
// Convert slider values to their pixel values and then convert to clip space (-1.0 ... 1.0) for overriding the
|
||||
// vertex coordinates.
|
||||
const QVector2D &resolution = globals.resolution();
|
||||
QVector2D half_resolution = resolution * 0.5;
|
||||
QVector2D top_left = QVector2D(ValueToPixel(0, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D top_right = QVector2D(ValueToPixel(1, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_right = QVector2D(ValueToPixel(2, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
QVector2D bottom_left = QVector2D(ValueToPixel(3, value, resolution)) / half_resolution - QVector2D(1.0, 1.0);
|
||||
|
||||
// Override default vertex coordinates.
|
||||
QVector<float> adjusted_vertices = {top_left.x(), top_left.y(), 0.0f,
|
||||
top_right.x(), top_right.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f,
|
||||
|
||||
top_left.x(), top_left.y(), 0.0f,
|
||||
bottom_left.x(), bottom_left.y(), 0.0f,
|
||||
bottom_right.x(), bottom_right.y(), 0.0f};
|
||||
job.SetVertexCoordinates(adjusted_vertices);
|
||||
|
||||
// If no texture do nothing
|
||||
if (!job.GetValue(kTextureInput).data().isNull()) {
|
||||
// In the special case that all sliders are in their default position just
|
||||
// push the texture.
|
||||
if (!(job.GetValue(kTopLeftInput).data().value<QVector2D>().isNull()
|
||||
&& job.GetValue(kTopRightInput).data().value<QVector2D>().isNull() &&
|
||||
job.GetValue(kBottomRightInput).data().value<QVector2D>().isNull() &&
|
||||
job.GetValue(kBottomLeftInput).data().value<QVector2D>().isNull())) {
|
||||
table->Push(NodeValue::kShaderJob, QVariant::fromValue(job), this);
|
||||
} else {
|
||||
table->Push(NodeValue::kTexture, job.GetValue(kTextureInput).data(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShaderCode CornerPinDistortNode::GetShaderCode(const QString &shader_id) const
|
||||
{
|
||||
Q_UNUSED(shader_id)
|
||||
QString frag = FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/cornerpin.frag"));
|
||||
QString vert = FileFunctions::ReadFileAsString(QStringLiteral(":/shaders/cornerpin.vert"));
|
||||
|
||||
// HACK: No good, very bad hack
|
||||
#ifndef Q_OS_MAC
|
||||
frag.prepend(QStringLiteral("#version 130\n\n"));
|
||||
vert.prepend(QStringLiteral("#version 130\n\n"));
|
||||
#else
|
||||
vert.prepend(QStringLiteral("#extension GL_EXT_gpu_shader4 : require\n\n"));
|
||||
#endif
|
||||
|
||||
return ShaderCode(frag, vert);
|
||||
}
|
||||
|
||||
QPointF CornerPinDistortNode::ValueToPixel(int value, const NodeValueRow& row, const QVector2D &resolution) const
|
||||
{
|
||||
Q_ASSERT(value >= 0 && value <= 3);
|
||||
switch (value) {
|
||||
case 0: // Top left
|
||||
return QPointF(row[kTopLeftInput].data().value<QVector2D>().x(),
|
||||
row[kTopLeftInput].data().value<QVector2D>().y());
|
||||
break;
|
||||
case 1: // Top right
|
||||
return QPointF(resolution.x() + row[kTopRightInput].data().value<QVector2D>().x(),
|
||||
row[kTopRightInput].data().value<QVector2D>().y());
|
||||
break;
|
||||
case 2: // Bottom right
|
||||
return QPointF(resolution.x() + row[kBottomRightInput].data().value<QVector2D>().x(),
|
||||
resolution.y() + row[kBottomRightInput].data().value<QVector2D>().y());
|
||||
break;
|
||||
case 3: //Bottom left
|
||||
return QPointF(row[kBottomLeftInput].data().value<QVector2D>().x(),
|
||||
row[kBottomLeftInput].data().value<QVector2D>().y() + resolution.y());
|
||||
break;
|
||||
default: // We should never get here
|
||||
return QPointF();
|
||||
}
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::DrawGizmos(const NodeValueRow &row, const NodeGlobals &globals, QPainter *p)
|
||||
{
|
||||
const QVector2D &resolution = globals.resolution();
|
||||
|
||||
const double handle_radius = GetGizmoHandleRadius(p->transform());
|
||||
|
||||
p->setPen(QPen(Qt::white, 0));
|
||||
|
||||
QPointF top_left = ValueToPixel(0, row, resolution);
|
||||
QPointF top_right = ValueToPixel(1, row, resolution);
|
||||
QPointF bottom_right = ValueToPixel(2, row, resolution);
|
||||
QPointF bottom_left = ValueToPixel(3, row, resolution);
|
||||
|
||||
// Add the correct offset to each slider
|
||||
SetInputProperty(kTopLeftInput, QStringLiteral("offset"), QVector2D(0.0, 0.0));
|
||||
SetInputProperty(kTopRightInput, QStringLiteral("offset"), QVector2D(resolution.x() , 0.0));
|
||||
SetInputProperty(kBottomRightInput, QStringLiteral("offset"), resolution);
|
||||
SetInputProperty(kBottomLeftInput, QStringLiteral("offset"), QVector2D(0.0, resolution.y()));
|
||||
|
||||
// Draw bounding box
|
||||
p->drawLine(QLineF(top_left, top_right));
|
||||
p->drawLine(QLineF(top_right, bottom_right));
|
||||
p->drawLine(QLineF(bottom_right, bottom_left));
|
||||
p->drawLine(QLineF(bottom_left, top_left));
|
||||
|
||||
// Create handles
|
||||
gizmo_resize_handle_[0] = CreateGizmoHandleRect(top_left, handle_radius);
|
||||
gizmo_resize_handle_[1] = CreateGizmoHandleRect(top_right, handle_radius);
|
||||
gizmo_resize_handle_[2] = CreateGizmoHandleRect(bottom_right, handle_radius);
|
||||
gizmo_resize_handle_[3] = CreateGizmoHandleRect(bottom_left, handle_radius);
|
||||
|
||||
// Draw handles
|
||||
DrawAndExpandGizmoHandles(p, handle_radius, gizmo_resize_handle_, kGizmoCornerCount);
|
||||
}
|
||||
|
||||
bool CornerPinDistortNode::GizmoPress(const NodeValueRow &row, const NodeGlobals &globals, const QPointF &p)
|
||||
{
|
||||
bool gizmo_active[kGizmoCornerCount] = {false};
|
||||
|
||||
for (int i = 0; i < kGizmoCornerCount; i++) {
|
||||
gizmo_active[i] = gizmo_resize_handle_[i].contains(p);
|
||||
|
||||
if (gizmo_active[i]) {
|
||||
gizmo_drag_start_ = p;
|
||||
gizmo_res_ = globals.resolution();
|
||||
gizmo_drag_ = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers)
|
||||
{
|
||||
if (gizmo_dragger_.isEmpty()) {
|
||||
gizmo_dragger_.resize(2);
|
||||
if (gizmo_drag_ == 0) {
|
||||
gizmo_dragger_[0].Start(NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 0), time);
|
||||
gizmo_dragger_[1].Start(NodeKeyframeTrackReference(NodeInput(this, kTopLeftInput), 1), time);
|
||||
}
|
||||
if (gizmo_drag_ == 1) {
|
||||
gizmo_dragger_[0].Start(NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 0), time);
|
||||
gizmo_dragger_[1].Start(NodeKeyframeTrackReference(NodeInput(this, kTopRightInput), 1), time);
|
||||
}
|
||||
if (gizmo_drag_ == 2) {
|
||||
gizmo_dragger_[0].Start(NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 0), time);
|
||||
gizmo_dragger_[1].Start(NodeKeyframeTrackReference(NodeInput(this, kBottomRightInput), 1), time);
|
||||
}
|
||||
if (gizmo_drag_ == 3) {
|
||||
gizmo_dragger_[0].Start(NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 0), time);
|
||||
gizmo_dragger_[1].Start(NodeKeyframeTrackReference(NodeInput(this, kBottomLeftInput), 1), time);
|
||||
}
|
||||
}
|
||||
|
||||
QPointF diff = p - gizmo_drag_start_;
|
||||
gizmo_dragger_[0].Drag(gizmo_dragger_[0].GetStartValue().toDouble() + diff.x());
|
||||
gizmo_dragger_[1].Drag(gizmo_dragger_[1].GetStartValue().toDouble() + diff.y());
|
||||
}
|
||||
|
||||
void CornerPinDistortNode::GizmoRelease(MultiUndoCommand *command) {
|
||||
for (NodeInputDragger &i : gizmo_dragger_) {
|
||||
i.End(command);
|
||||
}
|
||||
gizmo_dragger_.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CORNERPINDISTORTNODE_H
|
||||
#define CORNERPINDISTORTNODE_H
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
#include "node/inputdragger.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
class CornerPinDistortNode : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CornerPinDistortNode();
|
||||
|
||||
NODE_DEFAULT_DESTRUCTOR(CornerPinDistortNode)
|
||||
|
||||
virtual Node* copy() const override
|
||||
{
|
||||
return new CornerPinDistortNode();
|
||||
}
|
||||
|
||||
virtual QString Name() const override
|
||||
{
|
||||
return tr("Corner Pin");
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.cornerpin");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
{
|
||||
return {kCategoryDistort};
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
{
|
||||
return tr("Distort the image by dragging the corners.");
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
virtual ShaderCode GetShaderCode(const QString &shader_id) const override;
|
||||
|
||||
virtual bool HasGizmos() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void DrawGizmos(const NodeValueRow& row, const NodeGlobals &globals, QPainter *p) override;
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease(MultiUndoCommand *command) override;
|
||||
|
||||
/**
|
||||
* @brief Convenience function - converts the 2D slider values from being
|
||||
* an offset to the actual pixel value.
|
||||
*/
|
||||
QPointF ValueToPixel(int value, const NodeValueRow &row, const QVector2D &resolution) const;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kPerspectiveInput;
|
||||
static const QString kTopLeftInput;
|
||||
static const QString kTopRightInput;
|
||||
static const QString kBottomRightInput;
|
||||
static const QString kBottomLeftInput;
|
||||
|
||||
private:
|
||||
// Gizmo variables
|
||||
static const int kGizmoCornerCount = 4;
|
||||
QRectF gizmo_resize_handle_[kGizmoCornerCount];
|
||||
QRectF gizmo_whole_rect_;
|
||||
|
||||
int gizmo_drag_;
|
||||
QVector<NodeInputDragger> gizmo_dragger_;
|
||||
QPointF gizmo_drag_start_;
|
||||
QVector2D gizmo_res_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // CORNERPINDISTORTNODE_H
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "block/transition/crossdissolve/crossdissolvetransition.h"
|
||||
#include "block/transition/diptocolor/diptocolortransition.h"
|
||||
#include "color/displaytransform/displaytransform.h"
|
||||
#include "distort/cornerpin/cornerpindistortnode.h"
|
||||
#include "distort/crop/cropdistortnode.h"
|
||||
#include "distort/flip/flipdistortnode.h"
|
||||
#include "distort/transform/transformdistortnode.h"
|
||||
@@ -54,6 +55,7 @@
|
||||
#include "project/folder/folder.h"
|
||||
#include "project/footage/footage.h"
|
||||
#include "project/sequence/sequence.h"
|
||||
#include "time/timeoffset/timeoffsetnode.h"
|
||||
#include "time/timeremap/timeremap.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -262,6 +264,10 @@ Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
|
||||
return new FlipDistortNode();
|
||||
case kNoiseGenerator:
|
||||
return new NoiseGeneratorNode();
|
||||
case kTimeOffsetNode:
|
||||
return new TimeOffsetNode();
|
||||
case kCornerPinDistort:
|
||||
return new CornerPinDistortNode();
|
||||
case kDisplayTransform:
|
||||
return new DisplayTransformNode();
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
kOpacityEffect,
|
||||
kFlipDistort,
|
||||
kNoiseGenerator,
|
||||
kTimeOffsetNode,
|
||||
kCornerPinDistort,
|
||||
kDisplayTransform,
|
||||
|
||||
// Count value
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(timeoffset)
|
||||
add_subdirectory(timeremap)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2021 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/time/timeoffset/timeoffsetnode.cpp
|
||||
node/time/timeoffset/timeoffsetnode.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,91 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "timeoffsetnode.h"
|
||||
|
||||
#include "widget/slider/rationalslider.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
const QString TimeOffsetNode::kTimeInput = QStringLiteral("time_in");
|
||||
const QString TimeOffsetNode::kInputInput = QStringLiteral("input_in");
|
||||
|
||||
#define super Node
|
||||
|
||||
TimeOffsetNode::TimeOffsetNode()
|
||||
{
|
||||
AddInput(kTimeInput, NodeValue::kRational, QVariant::fromValue(rational(0)), InputFlags(kInputFlagNotConnectable));
|
||||
SetInputProperty(kTimeInput, QStringLiteral("view"), RationalSlider::kTime);
|
||||
SetInputProperty(kTimeInput, QStringLiteral("viewlock"), true);
|
||||
IgnoreHashingFrom(kTimeInput);
|
||||
|
||||
AddInput(kInputInput, NodeValue::kNone, InputFlags(kInputFlagNotKeyframable));
|
||||
}
|
||||
|
||||
void TimeOffsetNode::Retranslate()
|
||||
{
|
||||
SetInputName(kTimeInput, QStringLiteral("Time"));
|
||||
SetInputName(kInputInput, QStringLiteral("Input"));
|
||||
}
|
||||
|
||||
TimeRange TimeOffsetNode::InputTimeAdjustment(const QString &input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
if (input == kInputInput) {
|
||||
return TimeRange(GetRemappedTime(input_time.in()), GetRemappedTime(input_time.out()));
|
||||
} else {
|
||||
return super::InputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange TimeOffsetNode::OutputTimeAdjustment(const QString &input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
/*if (input == kInputInput) {
|
||||
rational target_time = GetValueAtTime(kTimeInput, input_time.in()).value<rational>();
|
||||
|
||||
return TimeRange(target_time, target_time + input_time.length());
|
||||
} else {
|
||||
return super::OutputTimeAdjustment(input, element, input_time);
|
||||
}*/
|
||||
return super::OutputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
void TimeOffsetNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
table->Push(value[kInputInput]);
|
||||
}
|
||||
|
||||
void TimeOffsetNode::Hash(QCryptographicHash &hash, const NodeGlobals &globals, const VideoParams &video_params) const
|
||||
{
|
||||
// Don't hash anything of our own, just pass-through to the connected node at the remapped tmie
|
||||
if (IsInputConnected(kInputInput)) {
|
||||
Node *out = GetConnectedOutput(kInputInput);
|
||||
|
||||
NodeGlobals new_globals = globals;
|
||||
new_globals.set_time(TimeRange(GetRemappedTime(globals.time().in()), GetRemappedTime(globals.time().out())));
|
||||
Node::Hash(out, GetValueHintForInput(kInputInput), hash, new_globals, video_params);
|
||||
}
|
||||
}
|
||||
|
||||
rational TimeOffsetNode::GetRemappedTime(const rational &input) const
|
||||
{
|
||||
return input + GetValueAtTime(kTimeInput, input).value<rational>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMEOFFSETNODE_H
|
||||
#define TIMEOFFSETNODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class TimeOffsetNode : public Node
|
||||
{
|
||||
public:
|
||||
TimeOffsetNode();
|
||||
|
||||
NODE_DEFAULT_DESTRUCTOR(TimeOffsetNode)
|
||||
NODE_COPY_FUNCTION(TimeOffsetNode)
|
||||
|
||||
virtual QString Name() const override
|
||||
{
|
||||
return tr("Time Offset");
|
||||
}
|
||||
|
||||
virtual QString id() const override
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.timeoffset");
|
||||
}
|
||||
|
||||
virtual QVector<CategoryID> Category() const override
|
||||
{
|
||||
return {kCategoryGeneral};
|
||||
}
|
||||
|
||||
virtual QString Description() const override
|
||||
{
|
||||
return tr("Offset time passing through the graph.");
|
||||
}
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override;
|
||||
virtual TimeRange OutputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
|
||||
static const QString kTimeInput;
|
||||
static const QString kInputInput;
|
||||
|
||||
protected:
|
||||
virtual void Hash(QCryptographicHash &hash, const NodeGlobals &globals, const VideoParams& video_params) const override;
|
||||
|
||||
private:
|
||||
rational GetRemappedTime(const rational& input) const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMEOFFSETNODE_H
|
||||
Reference in New Issue
Block a user