]> git.sesse.net Git - kdenlive/blobdiff - src/docclipbase.cpp
Get rid of buggy "drop B frame" speedup feature
[kdenlive] / src / docclipbase.cpp
index 8b83045f76d6faf3c0b9acf77022084835ef239b..214693c6eef5df9667a995cf160b6e024b5bc9fc 100644 (file)
 #include "kdenlivesettings.h"
 #include "kthumb.h"
 #include "clipmanager.h"
+#include "slideshowclip.h"
 
 #include <KIO/NetAccess>
 #include <KDebug>
 
 #include <QCryptographicHash>
 
+#include <cstdio>
+
 DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QString &id) :
         QObject(),
         m_audioFrameCache(),
@@ -41,7 +44,7 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
         m_baseTrackProducers(),
         m_audioTrackProducers(),
         m_videoOnlyProducer(NULL),
-        m_snapMarkers(),
+        m_snapMarkers(QList < CommentedTime >()),
         m_duration(),
         m_audioTimer(NULL),
         m_thumbProd(NULL),
@@ -55,14 +58,17 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, const QStrin
     if (m_placeHolder) xml.removeAttribute("placeholder");
     QDomNamedNodeMap attributes = xml.attributes();
     for (int i = 0; i < attributes.count(); i++) {
-        m_properties.insert(attributes.item(i).nodeName(), attributes.item(i).nodeValue());
+        QString name = attributes.item(i).nodeName();
+        if (name.startsWith("meta.attr.")) {
+            m_metadata.insert(name.section('.', 2, 3), attributes.item(i).nodeValue());
+        } else m_properties.insert(name, attributes.item(i).nodeValue());
     }
 
     if (xml.hasAttribute("cutzones")) {
         QStringList cuts = xml.attribute("cutzones").split(";", QString::SkipEmptyParts);
         for (int i = 0; i < cuts.count(); i++) {
             QString z = cuts.at(i);
-            addCutZone(z.section('-', 0, 0).toInt(), z.section('-', 1, 1).toInt());
+            addCutZone(z.section('-', 0, 0).toInt(), z.section('-', 1, 1).toInt(), z.section('-', 2, 2));
         }
     }
 
@@ -124,23 +130,20 @@ void DocClipBase::setZone(QPoint zone)
 
 QPoint DocClipBase::zone() const
 {
-    QPoint zone;
-    zone.setX(m_properties.value("zone_in").toInt());
-    zone.setY(m_properties.value("zone_out", "50").toInt());
+    QPoint zone(m_properties.value("zone_in", "0").toInt(), m_properties.value("zone_out", "50").toInt());
     return zone;
 }
 
 void DocClipBase::slotCreateAudioTimer()
 {
     connect(m_thumbProd, SIGNAL(audioThumbReady(QMap <int, QMap <int, QByteArray> >)), this , SLOT(updateAudioThumbnail(QMap <int, QMap <int, QByteArray> >)));
-    connect(this, SIGNAL(getAudioThumbs()), this , SLOT(slotGetAudioThumbs()));
     m_audioTimer = new QTimer(this);
     connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs()));
 }
 
 void DocClipBase::askForAudioThumbs()
 {
-    if (m_thumbProd && m_audioTimer) slotGetAudioThumbs();
+    if (m_thumbProd && m_audioTimer) m_thumbProd->askForAudioThumbs(getId());
 }
 
 void DocClipBase::slotClearAudioCache()
@@ -273,7 +276,8 @@ QDomElement DocClipBase::toXML() const
     if (!m_cutZones.isEmpty()) {
         QStringList cuts;
         for (int i = 0; i < m_cutZones.size(); i++) {
-            cuts << QString::number(m_cutZones.at(i).x()) + "-" + QString::number(m_cutZones.at(i).y());
+            CutZoneInfo info = m_cutZones.at(i);
+            cuts << QString::number(info.zone.x()) + "-" + QString::number(info.zone.y()) + "-" + info.description;
         }
         clip.setAttribute("cutzones", cuts.join(";"));
     }
@@ -300,7 +304,7 @@ const QPixmap & DocClipBase::thumbnail() const
 
 void DocClipBase::updateAudioThumbnail(QMap<int, QMap<int, QByteArray> > data)
 {
-    //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
+    //kDebug() << "CLIPBASE RECIEDVED AUDIO DATA*********************************************";
     m_audioFrameCache = data;
     m_audioThumbCreated = true;
     emit gotAudioData();
@@ -322,10 +326,6 @@ QList < CommentedTime > DocClipBase::commentedSnapMarkers() const
     return m_snapMarkers;
 }
 
-void DocClipBase::setSnapMarkers(QList < CommentedTime > markers)
-{
-    m_snapMarkers = markers;
-}
 
 void DocClipBase::addSnapMarker(const GenTime & time, QString comment)
 {
@@ -432,10 +432,10 @@ void DocClipBase::clearProducers()
     m_baseTrackProducers.clear();
 }
 
-void DocClipBase::deleteProducers()
+void DocClipBase::deleteProducers(bool clearThumbCreator)
 {
     kDebug() << "// CLIP KILL PRODS ct: " << m_baseTrackProducers.count();
-    if (m_thumbProd) m_thumbProd->clearProducer();
+    if (clearThumbCreator && m_thumbProd) m_thumbProd->clearProducer();
     /*kDebug()<<"// CLIP KILL PRODS ct: "<<m_baseTrackProducers.count();
     int max = m_baseTrackProducers.count();
     for (int i = 0; i < max; i++) {
@@ -457,13 +457,19 @@ void DocClipBase::deleteProducers()
     m_audioTrackProducers.clear();
 }
 
+void DocClipBase::setValid()
+{
+    m_placeHolder = false;
+}
+
 void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
 {
-    if (producer == NULL) return;
+    if (producer == NULL || (m_placeHolder && !reset)) return;
+    if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer);
     if (reset) {
         // Clear all previous producers
         kDebug() << "/+++++++++++++++   DELETE ALL PRODS " << producer->get("id");
-        deleteProducers();
+        deleteProducers(false);
     }
     QString id = producer->get("id");
     if (id.contains('_')) {
@@ -495,7 +501,17 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset)
     }
     //m_clipProducer = producer;
     //m_clipProducer->set("transparency", m_properties.value("transparency").toInt());
-    if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer);
+}
+
+static double getPixelAspect(QMap<QString, QString>& props) {
+    int width = props.value("frame_size").section('x', 0, 0).toInt();
+    int height = props.value("frame_size").section('x', 1, 1).toInt();
+    int aspectNumerator = props.value("force_aspect_num").toInt();
+    int aspectDenominator = props.value("force_aspect_den").toInt();
+    if (aspectDenominator != 0 && width != 0)
+        return double(height) * aspectNumerator / aspectDenominator / width;    
+    else
+        return 1.0;
 }
 
 Mlt::Producer *DocClipBase::audioProducer(int track)
@@ -508,13 +524,17 @@ Mlt::Producer *DocClipBase::audioProducer(int track)
     if (m_audioTrackProducers.at(track) == NULL) {
         Mlt::Producer *base = producer();
         m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource"));
-        if (m_properties.contains("force_aspect_ratio")) m_audioTrackProducers.at(track)->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_aspect_num") && m_properties.contains("force_aspect_den") && m_properties.contains("frame_size"))
+            m_audioTrackProducers.at(track)->set("force_aspect_ratio", getPixelAspect(m_properties));
+        if (m_properties.contains("force_fps")) m_audioTrackProducers.at(track)->set("force_fps", m_properties.value("force_fps").toDouble());
+        if (m_properties.contains("force_progressive")) m_audioTrackProducers.at(track)->set("force_progressive", m_properties.value("force_progressive").toInt());
+        if (m_properties.contains("force_tff")) m_audioTrackProducers.at(track)->set("force_tff", m_properties.value("force_tff").toInt());
         if (m_properties.contains("threads")) m_audioTrackProducers.at(track)->set("threads", m_properties.value("threads").toInt());
         m_audioTrackProducers.at(track)->set("video_index", -1);
         if (m_properties.contains("audio_index")) m_audioTrackProducers.at(track)->set("audio_index", m_properties.value("audio_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
-        m_audioTrackProducers.at(track)->set("id", tmp);
-        delete[] tmp;
+        m_audioTrackProducers.at(track)->set("id", QString(getId() + '_' + QString::number(track) + "_audio").toUtf8().data());
+        if (m_properties.contains("force_colorspace")) m_audioTrackProducers.at(track)->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_audioTrackProducers.at(track)->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_audioTrackProducers.at(track);
 }
@@ -527,13 +547,17 @@ Mlt::Producer *DocClipBase::videoProducer()
             if (m_baseTrackProducers.at(i) != NULL) break;
         if (i >= m_baseTrackProducers.count()) return NULL;
         m_videoOnlyProducer = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
-        if (m_properties.contains("force_aspect_ratio")) m_videoOnlyProducer->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_aspect_num") && m_properties.contains("force_aspect_den") && m_properties.contains("frame_size"))
+            m_videoOnlyProducer->set("force_aspect_ratio", getPixelAspect(m_properties));
+        if (m_properties.contains("force_fps")) m_videoOnlyProducer->set("force_fps", m_properties.value("force_fps").toDouble());
+        if (m_properties.contains("force_progressive")) m_videoOnlyProducer->set("force_progressive", m_properties.value("force_progressive").toInt());
+        if (m_properties.contains("force_tff")) m_videoOnlyProducer->set("force_tff", m_properties.value("force_tff").toInt());
         if (m_properties.contains("threads")) m_videoOnlyProducer->set("threads", m_properties.value("threads").toInt());
         m_videoOnlyProducer->set("audio_index", -1);
         if (m_properties.contains("video_index")) m_videoOnlyProducer->set("video_index", m_properties.value("video_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + "_video").toUtf8().data());
-        m_videoOnlyProducer->set("id", tmp);
-        delete[] tmp;
+        m_videoOnlyProducer->set("id", QString(getId() + "_video").toUtf8().data());
+        if (m_properties.contains("force_colorspace")) m_videoOnlyProducer->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_videoOnlyProducer->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_videoOnlyProducer;
 }
@@ -569,18 +593,18 @@ Mlt::Producer *DocClipBase::producer(int track)
             m_baseTrackProducers[track] = NULL;
             return NULL;
         }
-
-        if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
+        if (m_properties.contains("force_aspect_num") && m_properties.contains("force_aspect_den") && m_properties.contains("frame_size"))
+            m_baseTrackProducers[track]->set("force_aspect_raio", getPixelAspect(m_properties));
+        if (m_properties.contains("force_fps")) m_baseTrackProducers[track]->set("force_fps", m_properties.value("force_fps").toDouble());
+        if (m_properties.contains("force_progressive")) m_baseTrackProducers[track]->set("force_progressive", m_properties.value("force_progressive").toInt());
+        if (m_properties.contains("force_tff")) m_baseTrackProducers[track]->set("force_tff", m_properties.value("force_tff").toInt());
         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
         if (m_properties.contains("audio_index")) m_baseTrackProducers[track]->set("audio_index", m_properties.value("audio_index").toInt());
-        char *tmp = (char *) qstrdup(QString(getId() + '_' + QString::number(track)).toUtf8().data());
-        m_baseTrackProducers[track]->set("id", tmp);
-        delete[] tmp;
-        if (KdenliveSettings::dropbframes() && m_baseTrackProducers.at(i)->get("skip_loop_filter") && strcmp(m_baseTrackProducers.at(i)->get("skip_loop_filter"), "all") == 0) {
-            m_baseTrackProducers[track]->set("skip_loop_filter", "all");
-            m_baseTrackProducers[track]->set("skip_frame", "bidir");
-        }
+        m_baseTrackProducers[track]->set("id", QString(getId() + '_' + QString::number(track)).toUtf8().data());
+
+        if (m_properties.contains("force_colorspace")) m_baseTrackProducers[track]->set("force_colorspace", m_properties.value("force_colorspace").toInt());
+        if (m_properties.contains("full_luma")) m_baseTrackProducers[track]->set("set.force_full_luma", m_properties.value("full_luma").toInt());
     }
     return m_baseTrackProducers.at(track);
 }
@@ -609,6 +633,14 @@ void DocClipBase::setProducerProperty(const char *name, const char *data)
     }
 }
 
+void DocClipBase::resetProducerProperty(const char *name)
+{
+    for (int i = 0; i < m_baseTrackProducers.count(); i++) {
+        if (m_baseTrackProducers.at(i) != NULL)
+            m_baseTrackProducers[i]->set(name, (const char*) NULL);
+    }
+}
+
 const char *DocClipBase::producerProperty(const char *name) const
 {
     for (int i = 0; i < m_baseTrackProducers.count(); i++) {
@@ -625,14 +657,54 @@ void DocClipBase::slotRefreshProducer()
     if (m_baseTrackProducers.count() == 0) return;
     kDebug() << "////////////   REFRESH CLIP !!!!!!!!!!!!!!!!";
     if (m_clipType == SLIDESHOW) {
-        /*char *tmp = (char *) qstrdup(getProperty("resource").toUtf8().data());
-               Mlt::Producer producer(*(m_clipProducer->profile()), tmp);
-               delete[] tmp;
+        /*Mlt::Producer producer(*(m_clipProducer->profile()), getProperty("resource").toUtf8().data());
         delete m_clipProducer;
         m_clipProducer = new Mlt::Producer(producer.get_producer());
         if (!getProperty("out").isEmpty()) m_clipProducer->set_in_and_out(getProperty("in").toInt(), getProperty("out").toInt());*/
         setProducerProperty("ttl", getProperty("ttl").toInt());
         //m_clipProducer->set("id", getProperty("id"));
+        if (!getProperty("animation").isEmpty()) {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(ct);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "affine") == 0) {
+                    break;
+                } else if (strcmp(filter->get("mlt_service"), "boxblur") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+
+            if (!filter || strcmp(filter->get("mlt_service"), "affine")) {
+                // filter does not exist, create it.
+                Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "affine");
+                if (filter && filter->is_valid()) {
+                    int cycle = getProperty("ttl").toInt();
+                    QString geometry = SlideshowClip::animationToGeometry(getProperty("animation"), cycle);
+                    if (!geometry.isEmpty()) {
+                        if (getProperty("animation").contains("low-pass")) {
+                            Mlt::Filter *blur = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "boxblur");
+                            if (blur && blur->is_valid())
+                                clipService.attach(*blur);
+                        }
+                        filter->set("transition.geometry", geometry.toUtf8().data());
+                        filter->set("transition.cycle", cycle);
+                        clipService.attach(*filter);
+                    }
+                }
+            }
+        } else {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(0);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "affine") == 0 || strcmp(filter->get("mlt_service"), "boxblur") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+        }
         if (getProperty("fade") == "1") {
             // we want a fade filter effect
             kDebug() << "////////////   FADE WANTED";
@@ -648,12 +720,9 @@ void DocClipBase::slotRefreshProducer()
             }
 
             if (filter && strcmp(filter->get("mlt_service"), "luma") == 0) {
-                filter->set("period", getProperty("ttl").toInt() - 1);
-                filter->set("luma.out", getProperty("luma_duration").toInt());
-                QString resource = getProperty("luma_file");
-                char *tmp = (char *) qstrdup(resource.toUtf8().data());
-                filter->set("luma.resource", tmp);
-                delete[] tmp;
+                filter->set("cycle", getProperty("ttl").toInt());
+                filter->set("duration", getProperty("luma_duration").toInt());
+                filter->set("luma.resource", getProperty("luma_file").toUtf8().data());
                 if (!getProperty("softness").isEmpty()) {
                     int soft = getProperty("softness").toInt();
                     filter->set("luma.softness", (double) soft / 100.0);
@@ -661,12 +730,9 @@ void DocClipBase::slotRefreshProducer()
             } else {
                 // filter does not exist, create it...
                 Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "luma");
-                filter->set("period", getProperty("ttl").toInt() - 1);
-                filter->set("luma.out", getProperty("luma_duration").toInt());
-                QString resource = getProperty("luma_file");
-                char *tmp = (char *) qstrdup(resource.toUtf8().data());
-                filter->set("luma.resource", tmp);
-                delete[] tmp;
+                filter->set("cycle", getProperty("ttl").toInt());
+                filter->set("duration", getProperty("luma_duration").toInt());
+                filter->set("luma.resource", getProperty("luma_file").toUtf8().data());
                 if (!getProperty("softness").isEmpty()) {
                     int soft = getProperty("softness").toInt();
                     filter->set("luma.softness", (double) soft / 100.0);
@@ -685,6 +751,36 @@ void DocClipBase::slotRefreshProducer()
                 filter = clipService.filter(ct);
             }
         }
+        if (getProperty("crop") == "1") {
+            // we want a center crop filter effect
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(ct);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "crop") == 0) {
+                    break;
+                }
+                ct++;
+                filter = clipService.filter(ct);
+            }
+
+            if (!filter || strcmp(filter->get("mlt_service"), "crop")) {
+                // filter does not exist, create it...
+                Mlt::Filter *filter = new Mlt::Filter(*(m_baseTrackProducers.at(0)->profile()), "crop");
+                filter->set("center", 1);
+                clipService.attach(*filter);
+            }
+        } else {
+            Mlt::Service clipService(m_baseTrackProducers.at(0)->get_service());
+            int ct = 0;
+            Mlt::Filter *filter = clipService.filter(0);
+            while (filter) {
+                if (strcmp(filter->get("mlt_service"), "crop") == 0) {
+                    clipService.detach(*filter);
+                } else ct++;
+                filter = clipService.filter(ct);
+            }
+        }
     }
 }
 
@@ -695,7 +791,7 @@ void DocClipBase::setProperties(QMap <QString, QString> properties)
     QMapIterator<QString, QString> i(properties);
     bool refreshProducer = false;
     QStringList keys;
-    keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness";
+    keys << "luma_duration" << "luma_file" << "fade" << "ttl" << "softness" << "crop" << "animation";
     while (i.hasNext()) {
         i.next();
         setProperty(i.key(), i.value());
@@ -706,7 +802,15 @@ void DocClipBase::setProperties(QMap <QString, QString> properties)
 
 void DocClipBase::setMetadata(QMap <QString, QString> properties)
 {
-    m_metadata = properties;
+    QMapIterator<QString, QString> i(properties);
+    while (i.hasNext()) {
+        i.next();
+        if (i.value().isEmpty() && m_metadata.contains(i.key())) {
+            m_metadata.remove(i.key());
+        } else {
+            m_metadata.insert(i.key(), i.value());
+        }
+    }
 }
 
 QMap <QString, QString> DocClipBase::metadata() const
@@ -744,6 +848,13 @@ void DocClipBase::getFileHash(const QString url)
     }
 }
 
+bool DocClipBase::checkHash() const
+{
+    KUrl url = fileURL();
+    if (!url.isEmpty() && getClipHash() != getHash(url.path())) return false;
+    return true;
+}
+
 QString DocClipBase::getClipHash() const
 {
     QString hash;
@@ -754,6 +865,11 @@ QString DocClipBase::getClipHash() const
     return hash;
 }
 
+void DocClipBase::setPlaceHolder(bool place)
+{
+    m_placeHolder = place;
+}
+
 // static
 QString DocClipBase::getHash(const QString &path)
 {
@@ -791,25 +907,38 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
     } else if (key == "out") setDuration(GenTime(value.toInt(), KdenliveSettings::project_fps()));
     //else if (key == "transparency") m_clipProducer->set("transparency", value.toInt());
     else if (key == "colour") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("colour", tmp);
-        delete[] tmp;
+        setProducerProperty("colour", value.toUtf8().data());
     } else if (key == "templatetext") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("templatetext", tmp);
-        delete[] tmp;
+        setProducerProperty("templatetext", value.toUtf8().data());
         setProducerProperty("force_reload", 1);
     } else if (key == "xmldata") {
-        char *tmp = (char *) qstrdup(value.toUtf8().data());
-        setProducerProperty("xmldata", tmp);
-        delete[] tmp;
+        setProducerProperty("xmldata", value.toUtf8().data());
         setProducerProperty("force_reload", 1);
-    } else if (key == "force_aspect_ratio") {
+    } else if (key == "force_aspect_num") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_aspect_num");
+            resetProducerProperty("force_aspect_ratio");
+        } else setProducerProperty("force_aspect_ratio", getPixelAspect(m_properties));
+    } else if (key == "force_aspect_den") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_aspect_den");
+            resetProducerProperty("force_aspect_ratio");
+        } else setProducerProperty("force_aspect_ratio", getPixelAspect(m_properties));
+    } else if (key == "force_fps") {
         if (value.isEmpty()) {
-            m_properties.remove("force_aspect_ratio");
-            //TODO: find a was to remove the "force_aspect_ratio" property from producer, currently does not work
-            setProducerProperty("force_aspect_ratio", 0);
-        } else setProducerProperty("force_aspect_ratio", value.toDouble());
+            m_properties.remove("force_fps");
+            resetProducerProperty("force_fps");
+        } else setProducerProperty("force_fps", value.toDouble());
+    } else if (key == "force_progressive") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_progressive");
+            resetProducerProperty("force_progressive");
+        } else setProducerProperty("force_progressive", value.toInt());
+    } else if (key == "force_tff") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_tff");
+            resetProducerProperty("force_tff");
+        } else setProducerProperty("force_tff", value.toInt());
     } else if (key == "threads") {
         if (value.isEmpty()) {
             m_properties.remove("threads");
@@ -825,6 +954,16 @@ void DocClipBase::setProperty(const QString &key, const QString &value)
             m_properties.remove("audio_index");
             setProducerProperty("audio_index", m_properties.value("default_audio").toInt());
         } else setProducerProperty("audio_index", value.toInt());
+    } else if (key == "force_colorspace") {
+        if (value.isEmpty()) {
+            m_properties.remove("force_colorspace");
+            resetProducerProperty("force_colorspace");
+        } else setProducerProperty("force_colorspace", value.toInt());
+    } else if (key == "full_luma") {
+        if (value.isEmpty()) {
+            m_properties.remove("full_luma");
+            resetProducerProperty("set.force_full_luma");
+        } else setProducerProperty("set.force_full_luma", value.toInt());
     }
 }
 
@@ -835,7 +974,7 @@ QMap <QString, QString> DocClipBase::properties() const
 
 bool DocClipBase::slotGetAudioThumbs()
 {
-    if (m_thumbProd == NULL) return false;
+    if (m_thumbProd == NULL || isPlaceHolder()) return false;
     if (!KdenliveSettings::audiothumbnails() || m_audioTimer == NULL) {
         if (m_audioTimer != NULL) m_audioTimer->stop();
         return false;
@@ -855,37 +994,88 @@ bool DocClipBase::isPlaceHolder() const
     return m_placeHolder;
 }
 
-void DocClipBase::addCutZone(int in, int out)
+void DocClipBase::addCutZone(int in, int out, QString desc)
 {
-    if (!m_cutZones.contains(QPoint(in, out))) {
-        m_cutZones.append(QPoint(in, out));
-    }
+    CutZoneInfo info;
+    info.zone = QPoint(in, out);
+    info.description = desc;
+    for (int i = 0; i < m_cutZones.count(); i++)
+        if (m_cutZones.at(i).zone == info.zone) {
+            return;
+        }
+    m_cutZones.append(info);
 }
 
 bool DocClipBase::hasCutZone(QPoint p) const
 {
-    return m_cutZones.contains(p);
+    for (int i = 0; i < m_cutZones.count(); i++)
+        if (m_cutZones.at(i).zone == p) return true;
+    return false;
 }
 
 
 void DocClipBase::removeCutZone(int in, int out)
 {
-    m_cutZones.removeAll(QPoint(in, out));
+    QPoint p(in, out);
+    for (int i = 0; i < m_cutZones.count(); i++) {
+        if (m_cutZones.at(i).zone == p) {
+            m_cutZones.removeAt(i);
+            i--;
+        }
+    }
 }
 
-void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out)
+void DocClipBase::updateCutZone(int oldin, int oldout, int in, int out, QString desc)
 {
     QPoint old(oldin, oldout);
     for (int i = 0; i < m_cutZones.size(); ++i) {
-        if (m_cutZones.at(i) == old) {
-            m_cutZones.replace(i, QPoint(in, out));
+        if (m_cutZones.at(i).zone == old) {
+            CutZoneInfo info;
+            info.zone = QPoint(in, out);
+            info.description = desc;
+            m_cutZones.replace(i, info);
             break;
         }
     }
 }
 
-QList <QPoint> DocClipBase::cutZones() const
+QList <CutZoneInfo> DocClipBase::cutZones() const
 {
     return m_cutZones;
 }
 
+bool DocClipBase::hasVideoCodec(const QString &codec) const
+{
+    Mlt::Producer *prod = NULL;
+    if (m_baseTrackProducers.count() == 0) return false;
+    for (int i = 0; i < m_baseTrackProducers.count(); i++) {
+        if (m_baseTrackProducers.at(i) != NULL) {
+            prod = m_baseTrackProducers.at(i);
+            break;
+        }
+    }
+
+    if (!prod) return false;
+    int default_video = prod->get_int("video_index");
+    char property[200];
+    snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video);
+    return prod->get(property) == codec;
+}
+
+bool DocClipBase::hasAudioCodec(const QString &codec) const
+{
+    Mlt::Producer *prod = NULL;
+    if (m_baseTrackProducers.count() == 0) return false;
+    for (int i = 0; i < m_baseTrackProducers.count(); i++) {
+        if (m_baseTrackProducers.at(i) != NULL) {
+            prod = m_baseTrackProducers.at(i);
+            break;
+        }
+    }
+    if (!prod) return false;
+    int default_video = prod->get_int("audio_index");
+    char property[200];
+    snprintf(property, sizeof(property), "meta.media.%d.codec.name", default_video);
+    return prod->get(property) == codec;
+}
+