Commit f8b94e40 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Implement deinterlacer and rescale options for MLT consumer

parent 4af66752
......@@ -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>
......
......@@ -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);
......
......@@ -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();
......
......@@ -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)
......
......@@ -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:
......
......@@ -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;
......
......@@ -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&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment