summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-10-09 20:09:35 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-10-09 20:09:35 (GMT)
commitdece85bd3d6d7b4d612dd86a1b3db353fb62ccb9 (patch)
tree6a011af055cf09244fd42c24bb6752758480baab
parent4e5cd2a0da759b4787f72e7e553ba336693af864 (diff)
Add tripod parameter to vidstab
BUG: 370360
-rw-r--r--src/project/clipstabilize.cpp21
-rw-r--r--src/project/clipstabilize.h5
-rw-r--r--src/project/jobs/filterjob.cpp8
3 files changed, 25 insertions, 9 deletions
diff --git a/src/project/clipstabilize.cpp b/src/project/clipstabilize.cpp
index 84cc080..449ba0a 100644
--- a/src/project/clipstabilize.cpp
+++ b/src/project/clipstabilize.cpp
@@ -22,6 +22,7 @@
#include "clipstabilize.h"
#include "effectstack/widgets/doubleparameterwidget.h"
#include "effectstack/effectstackview2.h"
+#include "effectstack/positionedit.h"
#include <QDebug>
#include <mlt++/Mlt.h>
@@ -30,7 +31,7 @@
#include <KMessageBox>
#include <klocalizedstring.h>
-ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,QWidget * parent) :
+ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName, int out, QWidget * parent) :
QDialog(parent),
m_filtername(filterName),
m_urls(urls),
@@ -71,7 +72,8 @@ ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,
<< QStringLiteral("crop,type,bool,value,0,min,0,max,1,tooltip,0 = keep border 1 = black background")
<< QStringLiteral("zoom,type,int,value,0,min,-500,max,500,tooltip,additional zoom during transform")
<< QStringLiteral("optzoom,type,bool,value,1,min,0,max,1,tooltip,use optimal zoom (calulated from transforms)")
- << QStringLiteral("sharpen,type,double,value,0.8,min,0,max,1,decimals,1,tooltip,sharpen transformed image"));
+ << QStringLiteral("sharpen,type,double,value,0.8,min,0,max,1,decimals,1,tooltip,sharpen transformed image")
+ << QStringLiteral("tripod,type,position,value,0,min,0,max,100000,tooltip,reference frame"));
} else if (m_filtername==QLatin1String("videostab")) {
fillParameters(QStringList(QStringLiteral("shutterangle,type,int,value,0,min,0,max,180,tooltip,Angle that Images could be maximum rotated")));
}
@@ -80,6 +82,7 @@ ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,
vbox=new QVBoxLayout(optionsbox);
QHashIterator<QString,QHash<QString,QString> > hi(m_ui_params);
+ m_tc.setFormat(KdenliveSettings::project_fps());
while(hi.hasNext()){
hi.next();
QHash<QString,QString> val=hi.value();
@@ -106,7 +109,12 @@ ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,
connect(ch, &QCheckBox::stateChanged, this, &ClipStabilize::slotUpdateParams);
ch->setToolTip(val[QStringLiteral("tooltip")]);
vbox->addWidget(ch);
-
+ } else if (val[QStringLiteral("type")]==QLatin1String("position")){
+ PositionEdit *posedit = new PositionEdit(hi.key(), 0, 0, out, m_tc, this);
+ posedit->setToolTip(val[QStringLiteral("tooltip")]);
+ posedit->setObjectName(hi.key());
+ vbox->addWidget(posedit);
+ connect(posedit, &PositionEdit::parameterChanged, this, &ClipStabilize::slotUpdateParams);
}
}
adjustSize();
@@ -129,7 +137,7 @@ QMap <QString, QString> ClipStabilize::filterParams()
{
QMap <QString, QString> params;
params.insert(QStringLiteral("filter"), m_filtername);
-
+
QMapIterator<QString, QString> i(m_fixedParams);
while (i.hasNext()) {
i.next();
@@ -177,9 +185,12 @@ void ClipStabilize::slotUpdateParams()
if (m_ui_params[name][QStringLiteral("type")]==QLatin1String("int") || m_ui_params[name][QStringLiteral("type")]==QLatin1String("double")){
DoubleParameterWidget *dbl=static_cast<DoubleParameterWidget*>(w);
m_ui_params[name][QStringLiteral("value")]=QString::number((double)(dbl->getValue()));
- }else if (m_ui_params[name][QStringLiteral("type")]==QLatin1String("bool")){
+ } else if (m_ui_params[name][QStringLiteral("type")]==QLatin1String("bool")){
QCheckBox *ch=(QCheckBox*)w;
m_ui_params[name][QStringLiteral("value")]= ch->checkState() == Qt::Checked ? "1" : "0" ;
+ } else if (m_ui_params[name][QStringLiteral("type")]==QLatin1String("position")){
+ PositionEdit *pos=(PositionEdit *)w;
+ m_ui_params[name][QStringLiteral("value")]= QString::number(pos->getPosition());
}
}
}
diff --git a/src/project/clipstabilize.h b/src/project/clipstabilize.h
index af462ac..981b510 100644
--- a/src/project/clipstabilize.h
+++ b/src/project/clipstabilize.h
@@ -24,7 +24,7 @@
#include "ui_clipstabilize_ui.h"
-
+#include "timecode.h"
#include <QUrl>
class ClipStabilize : public QDialog, public Ui::ClipStabilize_UI
@@ -32,7 +32,7 @@ class ClipStabilize : public QDialog, public Ui::ClipStabilize_UI
Q_OBJECT
public:
- explicit ClipStabilize(const QStringList &urls, const QString &filterName,QWidget * parent = 0);
+ explicit ClipStabilize(const QStringList &urls, const QString &filterName, int out, QWidget * parent = 0);
~ClipStabilize();
/** @brief Should the generated clip be added to current project. */
bool autoAddClip() const;
@@ -59,6 +59,7 @@ private:
QVBoxLayout *vbox;
void fillParameters(QStringList);
QMap <QString, QString> m_fixedParams;
+ Timecode m_tc;
signals:
void addClip(const QUrl &url);
diff --git a/src/project/jobs/filterjob.cpp b/src/project/jobs/filterjob.cpp
index 9d7540d..f354beb 100644
--- a/src/project/jobs/filterjob.cpp
+++ b/src/project/jobs/filterjob.cpp
@@ -197,8 +197,12 @@ QHash <ProjectClip *, AbstractClipJob *> FilterJob::prepareJob(QList <ProjectCli
}
return jobs;
} else if (filterName == QLatin1String("vidstab") || filterName == QLatin1String("videostab2") || filterName == QLatin1String("videostab")) {
- // vidstab
- QPointer<ClipStabilize> d = new ClipStabilize(sources, filterName);
+ // vidstab
+ int out = 100000;
+ if (clips.count() == 1) {
+ out = clips.first()->duration().frames(KdenliveSettings::project_fps());
+ }
+ QPointer<ClipStabilize> d = new ClipStabilize(sources, filterName, out);
if (d->exec() == QDialog::Accepted) {
QMap <QString, QString> producerParams = d->producerParams();
QMap <QString, QString> filterParams = d->filterParams();