X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fdocclipbase.cpp;h=38c8cbfdfec97d064afeb43f519ce5fa080d222d;hb=c6032c1c3f29018ee84aa3078f8d2b7e858497ae;hp=41eb8c5e34c35bcb57fe841d6fdaa81d00db02e8;hpb=25a95ff4dba48d6a94c5c1d0d653617b1c327b90;p=kdenlive diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 41eb8c5e..38c8cbfd 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -28,6 +28,7 @@ #include "kdenlivesettings.h" #include "kthumb.h" #include "clipmanager.h" +#include "slideshowclip.h" #include #include @@ -57,7 +58,10 @@ 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")) { @@ -574,7 +578,6 @@ 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_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()); @@ -648,6 +651,48 @@ void DocClipBase::slotRefreshProducer() 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"; @@ -663,8 +708,8 @@ 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()); + filter->set("cycle", getProperty("ttl").toInt()); + filter->set("duration", getProperty("luma_duration").toInt()); QString resource = getProperty("luma_file"); char *tmp = (char *) qstrdup(resource.toUtf8().data()); filter->set("luma.resource", tmp); @@ -676,8 +721,8 @@ 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()); + filter->set("cycle", getProperty("ttl").toInt()); + filter->set("duration", getProperty("luma_duration").toInt()); QString resource = getProperty("luma_file"); char *tmp = (char *) qstrdup(resource.toUtf8().data()); filter->set("luma.resource", tmp); @@ -700,6 +745,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); + } + } } } @@ -710,7 +785,7 @@ void DocClipBase::setProperties(QMap properties) QMapIterator 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()); @@ -721,7 +796,15 @@ void DocClipBase::setProperties(QMap properties) void DocClipBase::setMetadata(QMap properties) { - m_metadata = properties; + QMapIterator 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 DocClipBase::metadata() const @@ -871,7 +954,7 @@ QMap 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;