summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2013-03-10 10:55:51 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2013-03-10 10:55:51 (GMT)
commitf8b94e4037e9eea645fabfddc2e373ace81dafed (patch)
tree31e8cf15239d783f3b31bd72b690cd33a332bc5f
parent4af6675294267a037dfbd0598062b8cfbfdcbb5b (diff)
Implement deinterlacer and rescale options for MLT consumer
-rw-r--r--src/kdenlivesettings.kcfg10
-rw-r--r--src/monitor.cpp69
-rw-r--r--src/monitor.h2
-rw-r--r--src/monitormanager.cpp6
-rw-r--r--src/monitormanager.h2
-rw-r--r--src/renderer.cpp27
-rw-r--r--src/renderer.h2
7 files changed, 108 insertions, 10 deletions
diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg
index b00e591..40c0909 100644
--- a/src/kdenlivesettings.kcfg
+++ b/src/kdenlivesettings.kcfg
@@ -795,6 +795,16 @@
<label>Default category for newly created clip markers.</label>
<default>0</default>
</entry>
+
+ <entry name="mltdeinterlacer" type="String">
+ <label>Name of the chosen deinterlacer.</label>
+ <default>onefield</default>
+ </entry>
+
+ <entry name="mltinterpolation" type="String">
+ <label>Name of the chosen interpol method.</label>
+ <default>nearest</default>
+ </entry>
</group>
diff --git a/src/monitor.cpp b/src/monitor.cpp
index 511f8ea..4c3fd13 100644
--- a/src/monitor.cpp
+++ b/src/monitor.cpp
@@ -31,6 +31,7 @@
#include <KFileDialog>
#include <KApplication>
#include <KMessageBox>
+#include <KSelectAction>
#include <QMouseEvent>
#include <QStylePainter>
@@ -289,14 +290,38 @@ void Monitor::setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMe
showTips->setCheckable(true);
connect(showTips, SIGNAL(toggled(bool)), this, SLOT(slotSwitchMonitorInfo(bool)));
showTips->setChecked(KdenliveSettings::displayMonitorInfo());
+
+ KSelectAction *interlace = new KSelectAction(i18n("Deinterlacer"), this);
+ interlace->addAction(i18n("One Field (fast)"));
+ interlace->addAction(i18n("Linear Blend (fast)"));
+ interlace->addAction(i18n("YADIF - temporal only (good)"));
+ interlace->addAction(i18n("YADIF - temporal + spacial (best)"));
+ if (KdenliveSettings::mltdeinterlacer() == "linearblend") interlace->setCurrentItem(1);
+ else if (KdenliveSettings::mltdeinterlacer() == "yadif-temporal") interlace->setCurrentItem(2);
+ else if (KdenliveSettings::mltdeinterlacer() == "yadif") interlace->setCurrentItem(3);
+ else interlace->setCurrentItem(0);
+ connect(interlace, SIGNAL(triggered(int)), this, SLOT(slotSetDeinterlacer(int)));
+
+ KSelectAction *interpol = new KSelectAction(i18n("Interpolation"), this);
+ interpol->addAction(i18n("Nearest Neighbor (fast)"));
+ interpol->addAction(i18n("Bilinear (good)"));
+ interpol->addAction(i18n("Bicubic (better)"));
+ interpol->addAction(i18n("Hyper/Lanczos (best)"));
+ if (KdenliveSettings::mltinterpolation() == "bilinear") interpol->setCurrentItem(1);
+ else if (KdenliveSettings::mltinterpolation() == "bicubic") interpol->setCurrentItem(2);
+ else if (KdenliveSettings::mltinterpolation() == "hyper") interpol->setCurrentItem(3);
+ else interpol->setCurrentItem(0);
+ connect(interpol, SIGNAL(triggered(int)), this, SLOT(slotSetInterpolation(int)));
QAction *dropFrames = m_contextMenu->addAction(KIcon(), i18n("Real time (drop frames)"));
dropFrames->setCheckable(true);
dropFrames->setChecked(true);
connect(dropFrames, SIGNAL(toggled(bool)), this, SLOT(slotSwitchDropFrames(bool)));
-
+
m_configMenu->addAction(showTips);
m_configMenu->addAction(dropFrames);
+ m_configMenu->addAction(interlace);
+ m_configMenu->addAction(interpol);
}
@@ -981,6 +1006,48 @@ void Monitor::slotSwitchDropFrames(bool show)
render->setDropFrames(show);
}
+void Monitor::slotSetDeinterlacer(int ix)
+{
+ QString value;
+ switch (ix) {
+
+ case 1:
+ value = "linearblend";
+ break;
+ case 2:
+ value = "yadif-nospatial";
+ break;
+ case 3:
+ value = "yadif";
+ break;
+ default:
+ value = "onefield";
+ }
+ KdenliveSettings::setMltdeinterlacer(value);
+ m_monitorManager->setConsumerProperty("deinterlace_method", value);
+}
+
+void Monitor::slotSetInterpolation(int ix)
+{
+ QString value;
+ switch (ix) {
+ case 1:
+ value = "bilinear";
+ break;
+ case 2:
+ value = "bicubic";
+ break;
+ case 3:
+ value = "hyper";
+ break;
+ default:
+ value = "nearest";
+ }
+ KdenliveSettings::setMltinterpolation(value);
+ m_monitorManager->setConsumerProperty("rescale", value);
+}
+
+
void Monitor::slotSwitchMonitorInfo(bool show)
{
KdenliveSettings::setDisplayMonitorInfo(show);
diff --git a/src/monitor.h b/src/monitor.h
index c782127..1de74ff 100644
--- a/src/monitor.h
+++ b/src/monitor.h
@@ -170,6 +170,8 @@ private slots:
void setClipZone(QPoint pos);
void slotSwitchMonitorInfo(bool show);
void slotSwitchDropFrames(bool show);
+ void slotSetDeinterlacer(int ix);
+ void slotSetInterpolation(int ix);
void slotGoToMarker(QAction *action);
void slotSetVolume(int volume);
void slotShowVolume();
diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp
index ca23d9a..e848666 100644
--- a/src/monitormanager.cpp
+++ b/src/monitormanager.cpp
@@ -84,6 +84,12 @@ AbstractMonitor* MonitorManager::monitor(Kdenlive::MONITORID monitorName)
return monitor;
}
+void MonitorManager::setConsumerProperty(const QString &name, const QString &value)
+{
+ if (m_clipMonitor) m_clipMonitor->render->setConsumerProperty(name, value);
+ if (m_projectMonitor) m_projectMonitor->render->setConsumerProperty(name, value);
+}
+
bool MonitorManager::activateMonitor(Kdenlive::MONITORID name, bool forceRefresh)
{
if (m_clipMonitor == NULL || m_projectMonitor == NULL)
diff --git a/src/monitormanager.h b/src/monitormanager.h
index 91ba702..8d12134 100644
--- a/src/monitormanager.h
+++ b/src/monitormanager.h
@@ -50,6 +50,8 @@ public:
QString getProjectFolder() const;
/** @brief Sets current document for later reference. */
void setDocument(KdenliveDoc *doc);
+ /** @brief Change an MLT consumer property for both monitors. */
+ void setConsumerProperty(const QString &name, const QString &value);
public slots:
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 512afae..816d19a 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -239,8 +239,8 @@ void Render::buildConsumer(const QString &profileName)
if (m_mltConsumer->is_valid()) {
externalConsumer = true;
m_mltConsumer->set("terminate_on_pause", 0);
- m_mltConsumer->set("deinterlace_method", "onefield");
- m_mltConsumer->set("rescale", "nearest");
+ m_mltConsumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData());
+ m_mltConsumer->set("rescale", KdenliveSettings::mltinterpolation().toUtf8().constData());
m_mltConsumer->set("buffer", "1");
m_mltConsumer->set("real_time", KdenliveSettings::mltthreads());
}
@@ -274,7 +274,7 @@ void Render::buildConsumer(const QString &profileName)
// Set defaults for decklink consumer
if (m_mltConsumer) {
m_mltConsumer->set("terminate_on_pause", 0);
- m_mltConsumer->set("deinterlace_method", "onefield");
+ m_mltConsumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData());
externalConsumer = true;
}
}
@@ -300,7 +300,7 @@ void Render::buildConsumer(const QString &profileName)
}
//m_mltConsumer->set("resize", 1);
m_mltConsumer->set("window_background", KdenliveSettings::window_background().name().toUtf8().constData());
- m_mltConsumer->set("rescale", "nearest");
+ m_mltConsumer->set("rescale", KdenliveSettings::mltinterpolation().toUtf8().constData());
mlt_log_set_callback(kdenlive_callback);
QString audioDevice = KdenliveSettings::audiodevicename();
@@ -1757,11 +1757,7 @@ void Render::setDropFrames(bool show)
int dropFrames = KdenliveSettings::mltthreads();
if (show == false) dropFrames = -dropFrames;
m_mltConsumer->stop();
- if (m_winid == 0)
- m_mltConsumer->set("real_time", dropFrames);
- else
- m_mltConsumer->set("play.real_time", dropFrames);
-
+ m_mltConsumer->set("real_time", dropFrames);
if (m_mltConsumer->start() == -1) {
kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
}
@@ -1769,6 +1765,19 @@ void Render::setDropFrames(bool show)
}
}
+void Render::setConsumerProperty(const QString &name, const QString &value)
+{
+ QMutexLocker locker(&m_mutex);
+ if (m_mltConsumer) {
+ m_mltConsumer->stop();
+ m_mltConsumer->set(name.toUtf8().constData(), value.toUtf8().constData());
+ if (m_isActive && m_mltConsumer->start() == -1) {
+ kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
+ }
+
+ }
+}
+
bool Render::isPlaying() const
{
if (!m_mltConsumer || m_mltConsumer->is_stopped()) return false;
diff --git a/src/renderer.h b/src/renderer.h
index c65d2cb..d725c81 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -294,6 +294,8 @@ Q_OBJECT public:
const QList <Mlt::Producer *> producersList();
void updatePreviewSettings();
void setDropFrames(bool show);
+ /** @brief Sets an MLT consumer property. */
+ void setConsumerProperty(const QString &name, const QString &value);
QString updateSceneListFps(double current_fps, double new_fps, QString scene);
void showAudio(Mlt::Frame&);