]> git.sesse.net Git - kdenlive/commitdiff
Implement deinterlacer and rescale options for MLT consumer
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Mar 2013 10:55:51 +0000 (11:55 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 10 Mar 2013 10:55:51 +0000 (11:55 +0100)
src/kdenlivesettings.kcfg
src/monitor.cpp
src/monitor.h
src/monitormanager.cpp
src/monitormanager.h
src/renderer.cpp
src/renderer.h

index b00e5914a69bc4942c46d7d20431ebb648085584..40c0909d6b74e3c7d70cbdc73011a1bab9cf32e3 100644 (file)
       <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>
 
index 511f8ea9405490fff3c411552d3cb90bf4791448..4c3fd13ebfd96cda7d0c2a5cc505142722f11bf7 100644 (file)
@@ -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);
index c7821273f87f231cf22a1f95cf91395ca933bfff..1de74ffa0cb2d7bcce33f1d6a58c9ed025bd0b27 100644 (file)
@@ -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();
index ca23d9a31eef1de787dd8f1cb7bce9b27babee99..e8486663b67da2659a8224e30ed1e8e5a2638f56 100644 (file)
@@ -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)
index 91ba702145abd01d0ca021de748d979d77a73972..8d12134023effd85d85d60ea2f3ae8e099c9053c 100644 (file)
@@ -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:
 
index 512afae1c6b29923b57314528874e326bcea2543..816d19ae42f5276931bc04393b07b8f0af499bf2 100644 (file)
@@ -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;
index c65d2cb67201a01875ec2448e8722e92c9b6d2a6..d725c81bd928648f565a61108808692bc2f3108c 100644 (file)
@@ -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&);