commit f05b5b3ff8286f6252c2a3f3c8c367f8a5b821b5 Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 13:05:25 2022 -0700 final consistency modifications commit 4f27718d46de9660822eb197b0e900be947ec515 Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 11:40:58 2022 -0700 opengl: don't set texture options for null texture commit bb54cfcf4e219e1cbf1ecc6b5552cca75e6e1573 Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 11:40:29 2022 -0700 rename inputs commit e5ac8fffa2ac15f5549b6da5f42b05659c6d020f Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 10:37:23 2022 -0700 change alpha association formula commit dee09a88f17552e3f98be8940966822e45d6df4f Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 10:36:58 2022 -0700 glsl: use constants to improve readability commit aedc75ebee11b61198f29c464501a2ddb0506129 Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 10:36:26 2022 -0700 changed id capitalization commit 470b2bb85b51c4a57c109d3fb230088a81024277 Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 10:35:53 2022 -0700 node: update categories commit c78dacad82051dfbb3e40c92cfaf456dbff2de0d Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 09:22:57 2022 -0700 updated shaders to es 3 commit 1e7544be93e55916c94cd91629ec5eef728bfad8 Merge: 1bbb8d7f925d019609Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Tue Apr 12 09:02:32 2022 -0700 Merge branch 'master' into pr/1818 commit 1bbb8d7f9acd75cb4498733f105fbe0487c0db9c Author: brimson <40442071+brimson@users.noreply.github.com> Date: Tue Jan 18 18:36:24 2022 -0700 Simplify colordifferencekey.frag Avoiding extra MOV instruction commit c7cf1021ce5a3d090833e94e4bc212cc51a61a2a Author: brimson <40442071+brimson@users.noreply.github.com> Date: Tue Jan 18 11:43:02 2022 -0700 Revert switch-case changes Thanks Simran, MattKC, and Wilshaw for the clarifications commit 882ffeede01b81f0cb4dfd885ba05bf66119ac7e Author: brimson <40442071+brimson@users.noreply.github.com> Date: Tue Jan 18 00:06:31 2022 -0700 Optimize despill shader Turn previous averaging from (1 MAD + 1 MUL) to (1 DP2), reuse the result to prevent recalculation. commit 0c93f519977fa34840ab03d51addcf2456f931d8 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sat Jan 8 17:23:49 2022 +0000 Cleanup commit 222560ce1a4666899b1111854d4d549dd7ba1357 Merge: 96e21c2b4d3ffeaa35Author: ThomasWilshaw <thomaswilshaw@gmail.com> Date: Tue Jan 4 23:50:39 2022 +0000 Merge branch 'master' into color_key commit 96e21c2b43db3bf1051aca696970509292159548 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Tue Jan 4 23:45:26 2022 +0000 Rename and reoganise keying nodes commit 6d42ed23a69ebdb1f5b399957f0b37434d0519dd Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Tue Jan 4 23:04:50 2022 +0000 Move despill code to it's own node commit e97ab2e16fd1d4e2f2ff145b8c023ff0e1ee451e Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Mon Jan 3 21:39:48 2022 +0000 Add option for blue screens commit 2346f44e5af48bb9547c77c4c08ee7abfcb09393 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Mon Jan 3 21:14:55 2022 +0000 Optimise node slightly commit 446522edcf63525fafe7a97cf6d59b7ea0385460 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Mon Jan 3 21:10:03 2022 +0000 Fix GL ES compile error commit a765ce6c6f3e0c0e996f08e2a3ef1101818098e8 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 18:27:24 2022 +0000 Cleanup commit d268e0645df34aa306dc391d1dc10bf335524f94 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 18:03:26 2022 +0000 Fix core matte and change Darks start value commit 30b024dc5f59dd60ffc5012eee7a79201ed4f9c3 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 17:26:39 2022 +0000 Change matte controls and cleanup commit b742a9ba7ed651785a0781289a4c03fd4fb72e03 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 16:31:41 2022 +0000 Add a core and garbage matte commit f814d036b61b8de090df4c1f080c124b98b432d6 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 03:31:20 2022 +0000 Improve basic keyer commit 4995ec3b9b92c9b4cb0dc31a247d585b2a47e408 Author: Thomas Wilshaw <thomaswilshaw@gmail.com> Date: Sun Jan 2 00:23:18 2022 +0000 Start simple color key node
289 lines
7.4 KiB
C++
289 lines
7.4 KiB
C++
/***
|
|
|
|
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 "factory.h"
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include "audio/pan/pan.h"
|
|
#include "audio/volume/volume.h"
|
|
#include "block/clip/clip.h"
|
|
#include "block/gap/gap.h"
|
|
#include "block/subtitle/subtitle.h"
|
|
#include "block/transition/crossdissolve/crossdissolvetransition.h"
|
|
#include "block/transition/diptocolor/diptocolortransition.h"
|
|
#include "distort/cornerpin/cornerpindistortnode.h"
|
|
#include "distort/crop/cropdistortnode.h"
|
|
#include "distort/flip/flipdistortnode.h"
|
|
#include "distort/transform/transformdistortnode.h"
|
|
#include "effect/opacity/opacityeffect.h"
|
|
#include "generator/matrix/matrix.h"
|
|
#include "generator/noise/noise.h"
|
|
#include "generator/polygon/polygon.h"
|
|
#include "generator/shape/shapenode.h"
|
|
#include "generator/solid/solid.h"
|
|
#include "generator/text/textv1.h"
|
|
#include "generator/text/textv2.h"
|
|
#include "generator/text/textv3.h"
|
|
#include "filter/blur/blur.h"
|
|
#include "filter/mosaic/mosaicfilternode.h"
|
|
#include "filter/stroke/stroke.h"
|
|
#include "input/time/timeinput.h"
|
|
#include "input/value/valuenode.h"
|
|
#include "math/math/math.h"
|
|
#include "math/merge/merge.h"
|
|
#include "math/trigonometry/trigonometry.h"
|
|
#include "keying/colordifferencekey/colordifferencekey.h"
|
|
#include "keying/despill/despill.h"
|
|
#include "output/track/track.h"
|
|
#include "output/viewer/viewer.h"
|
|
#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 {
|
|
QList<Node*> NodeFactory::library_;
|
|
QVector<int> NodeFactory::hidden_;
|
|
|
|
void NodeFactory::Initialize()
|
|
{
|
|
Destroy();
|
|
|
|
// Add internal types
|
|
for (int i=0;i<kInternalNodeCount;i++) {
|
|
Node* created_node = CreateFromFactoryIndex(static_cast<InternalID>(i));
|
|
|
|
library_.append(created_node);
|
|
}
|
|
|
|
hidden_.append(kTextGeneratorV1);
|
|
hidden_.append(kTextGeneratorV2);
|
|
hidden_.append(kGroupNode);
|
|
}
|
|
|
|
void NodeFactory::Destroy()
|
|
{
|
|
qDeleteAll(library_);
|
|
library_.clear();
|
|
}
|
|
|
|
Menu *NodeFactory::CreateMenu(QWidget* parent, bool create_none_item, Node::CategoryID restrict_to)
|
|
{
|
|
Menu* menu = new Menu(parent);
|
|
menu->setToolTipsVisible(true);
|
|
|
|
for (int i=0;i<library_.size();i++) {
|
|
Node* n = library_.at(i);
|
|
|
|
if (restrict_to != Node::kCategoryUnknown && !n->Category().contains(restrict_to)) {
|
|
// Skip this node
|
|
continue;
|
|
}
|
|
|
|
if (hidden_.contains(i)) {
|
|
// Skip this node
|
|
continue;
|
|
}
|
|
|
|
// Make sure nodes are up-to-date with the current translation
|
|
n->Retranslate();
|
|
|
|
Menu* destination = nullptr;
|
|
|
|
QString category_name = Node::GetCategoryName(n->Category().isEmpty()
|
|
? Node::kCategoryUnknown
|
|
: n->Category().first());
|
|
|
|
// See if a menu with this category name already exists
|
|
QList<QAction*> menu_actions = menu->actions();
|
|
foreach (QAction* action, menu_actions) {
|
|
if (action->menu() && action->menu()->title() == category_name) {
|
|
destination = static_cast<Menu*>(action->menu());
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Create menu here if it doesn't exist
|
|
if (!destination) {
|
|
destination = new Menu(category_name, menu);
|
|
menu->InsertAlphabetically(destination);
|
|
}
|
|
|
|
// Add entry to menu
|
|
QAction* a = destination->InsertAlphabetically(n->Name());
|
|
a->setData(i);
|
|
a->setToolTip(n->Description());
|
|
}
|
|
|
|
if (create_none_item) {
|
|
|
|
QAction* none_item = new QAction(QCoreApplication::translate("NodeFactory", "None"),
|
|
menu);
|
|
|
|
none_item->setData(-1);
|
|
|
|
if (menu->actions().isEmpty()) {
|
|
menu->addAction(none_item);
|
|
} else {
|
|
QAction* separator = menu->insertSeparator(menu->actions().first());
|
|
menu->insertAction(separator, none_item);
|
|
}
|
|
}
|
|
|
|
return menu;
|
|
}
|
|
|
|
Node* NodeFactory::CreateFromMenuAction(QAction *action)
|
|
{
|
|
int index = action->data().toInt();
|
|
|
|
if (index == -1) {
|
|
return nullptr;
|
|
}
|
|
|
|
return library_.at(index)->copy();
|
|
}
|
|
|
|
QString NodeFactory::GetIDFromMenuAction(QAction *action)
|
|
{
|
|
int index = action->data().toInt();
|
|
|
|
if (index == -1) {
|
|
return QString();
|
|
}
|
|
|
|
return library_.at(action->data().toInt())->id();
|
|
}
|
|
|
|
QString NodeFactory::GetNameFromID(const QString &id)
|
|
{
|
|
if (!id.isEmpty()) {
|
|
foreach (Node* n, library_) {
|
|
if (n->id() == id) {
|
|
return n->Name();
|
|
}
|
|
}
|
|
}
|
|
|
|
return QString();
|
|
}
|
|
|
|
Node *NodeFactory::CreateFromID(const QString &id)
|
|
{
|
|
foreach (Node* n, library_) {
|
|
if (n->id() == id) {
|
|
return n->copy();
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
Node *NodeFactory::CreateFromFactoryIndex(const NodeFactory::InternalID &id)
|
|
{
|
|
switch (id) {
|
|
case kClipBlock:
|
|
return new ClipBlock();
|
|
case kGapBlock:
|
|
return new GapBlock();
|
|
case kPolygonGenerator:
|
|
return new PolygonGenerator();
|
|
case kMatrixGenerator:
|
|
return new MatrixGenerator();
|
|
case kTransformDistort:
|
|
return new TransformDistortNode();
|
|
case kTrackOutput:
|
|
return new Track();
|
|
case kViewerOutput:
|
|
return new ViewerOutput();
|
|
case kAudioVolume:
|
|
return new VolumeNode();
|
|
case kAudioPanning:
|
|
return new PanNode();
|
|
case kMath:
|
|
return new MathNode();
|
|
case kTrigonometry:
|
|
return new TrigonometryNode();
|
|
case kTime:
|
|
return new TimeInput();
|
|
case kBlurFilter:
|
|
return new BlurFilterNode();
|
|
case kSolidGenerator:
|
|
return new SolidGenerator();
|
|
case kMerge:
|
|
return new MergeNode();
|
|
case kStrokeFilter:
|
|
return new StrokeFilterNode();
|
|
case kTextGeneratorV1:
|
|
return new TextGeneratorV1();
|
|
case kTextGeneratorV2:
|
|
return new TextGeneratorV2();
|
|
case kTextGeneratorV3:
|
|
return new TextGeneratorV3();
|
|
case kCrossDissolveTransition:
|
|
return new CrossDissolveTransition();
|
|
case kDipToColorTransition:
|
|
return new DipToColorTransition();
|
|
case kMosaicFilter:
|
|
return new MosaicFilterNode();
|
|
case kCropDistort:
|
|
return new CropDistortNode();
|
|
case kProjectFootage:
|
|
return new Footage();
|
|
case kProjectFolder:
|
|
return new Folder();
|
|
case kProjectSequence:
|
|
return new Sequence();
|
|
case kValueNode:
|
|
return new ValueNode();
|
|
case kTimeRemapNode:
|
|
return new TimeRemapNode();
|
|
case kSubtitleBlock:
|
|
return new SubtitleBlock();
|
|
case kShapeGenerator:
|
|
return new ShapeNode();
|
|
case kColorDifferenceKeyKeying:
|
|
return new ColorDifferenceKeyNode();
|
|
case kDespillKeying:
|
|
return new DespillNode();
|
|
case kGroupNode:
|
|
return new NodeGroup();
|
|
case kOpacityEffect:
|
|
return new OpacityEffect();
|
|
case kFlipDistort:
|
|
return new FlipDistortNode();
|
|
case kNoiseGenerator:
|
|
return new NoiseGeneratorNode();
|
|
case kTimeOffsetNode:
|
|
return new TimeOffsetNode();
|
|
case kCornerPinDistort:
|
|
return new CornerPinDistortNode();
|
|
|
|
case kInternalNodeCount:
|
|
break;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
}
|