#include "kdenlivesettings.h"
#include "kthumb.h"
#include "definitions.h"
+#include "slideshowclip.h"
#include <mlt++/Mlt.h>
#endif
self->emitFrameNumber(mlt_frame_get_position(frame_ptr));
- if (frame_ptr->convert_image)
+ if (self->sendFrameForAnalysis && frame_ptr->convert_image) {
self->emitFrameUpdated(frame);
+ }
if (frame.get_double("_speed") == 0.0) {
self->emitConsumerStopped();
} else if (frame.get_double("_speed") < 0.0 && mlt_frame_get_position(frame_ptr) <= 0) {
Render::Render(const QString & rendererName, int winid, int /* extid */, QString profile, QWidget *parent) :
QObject(parent),
m_isBlocked(0),
+ sendFrameForAnalysis(false),
m_name(rendererName),
m_mltConsumer(NULL),
m_mltProducer(NULL),
Mlt::Frame *frame = producer->get_frame();
if (xml.attribute("type").toInt() == SLIDESHOW) {
- if (xml.hasAttribute("ttl")) producer->set("ttl", xml.attribute("ttl").toInt());
+ int ttl = xml.hasAttribute("ttl") ? xml.attribute("ttl").toInt() : 0;
+ if (ttl) producer->set("ttl", ttl);
+ if (!xml.attribute("animation").isEmpty()) {
+ Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "affine");
+ if (filter && filter->is_valid()) {
+ int cycle = ttl;
+ QString geometry = SlideshowClip::animationToGeometry(xml.attribute("animation"), cycle);
+ if (!geometry.isEmpty()) {
+ if (xml.attribute("animation").contains("low-pass")) {
+ Mlt::Filter *blur = new Mlt::Filter(*m_mltProfile, "boxblur");
+ if (blur && blur->is_valid())
+ producer->attach(*blur);
+ }
+ filter->set("transition.geometry", geometry.toUtf8().data());
+ filter->set("transition.cycle", cycle);
+ producer->attach(*filter);
+ }
+ }
+ }
if (xml.attribute("fade") == "1") {
// user wants a fade effect to slideshow
Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "luma");
if (filter && filter->is_valid()) {
- if (xml.hasAttribute("ttl")) filter->set("period", xml.attribute("ttl").toInt() - 1);
- if (xml.hasAttribute("luma_duration") && !xml.attribute("luma_duration").isEmpty()) filter->set("luma.out", xml.attribute("luma_duration").toInt());
+ if (ttl) filter->set("cycle", ttl);
+ if (xml.hasAttribute("luma_duration") && !xml.attribute("luma_duration").isEmpty()) filter->set("duration", xml.attribute("luma_duration").toInt());
if (xml.hasAttribute("luma_file") && !xml.attribute("luma_file").isEmpty()) {
char *tmp = decodedString(xml.attribute("luma_file"));
filter->set("luma.resource", tmp);
filter->set("luma.softness", (double) soft / 100.0);
}
}
- Mlt::Service clipService(producer->get_service());
- clipService.attach(*filter);
+ producer->attach(*filter);
}
}
if (xml.attribute("crop") == "1") {
}
#endif
+
/*
* MLT playlist direct manipulation.
*/
int ct = 0;
Mlt::Filter *filter = sourceService.filter(ct);
while (filter) {
- if (filter->get("kdenlive_ix") != 0) {
+ if (filter->get_int("kdenlive_ix") != 0) {
filtersList.append(filter);
}
ct++;
int ct = 0;
Mlt::Filter *filter = sourceService.filter(ct);
while (filter) {
- if (filter->get("kdenlive_ix") != 0) {
+ if (filter->get_int("kdenlive_ix") != 0) {
sourceService.detach(*filter);
destService.attach(*filter);
} else ct++;
bool Render::mltRemoveTrackEffect(int track, QString index, bool updateIndex)
{
- kDebug() << "REMOVE TK EFF: " << track << ", IX: " << index;
Mlt::Service service(m_mltProducer->parent().get_service());
bool success = false;
Mlt::Tractor tractor(service);
Mlt::Service clipService(trackPlaylist.get_service());
m_isBlocked = true;
+ mlt_service_lock(service.get_service());
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get("kdenlive_ix") == index) {
+ if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get_int("kdenlive_ix") == index.toInt()) {
if (clipService.detach(*filter) == 0) success = true;
} else if (updateIndex) {
// Adjust the other effects index
- if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
+ if (filter->get_int("kdenlive_ix") > index.toInt()) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
} else ct++;
filter = clipService.filter(ct);
}
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
refresh();
return success;
}
// if (tag.startsWith("ladspa")) tag = "ladspa";
m_isBlocked = true;
+ mlt_service_lock(service.get_service());
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get("kdenlive_ix") == index) {// && filter->get("kdenlive_id") == id) {
+ if ((index == "-1" && strcmp(filter->get("kdenlive_id"), "")) || filter->get_int("kdenlive_ix") == index.toInt()) {// && filter->get("kdenlive_id") == id) {
if (clipService.detach(*filter) == 0) success = true;
//kDebug()<<"Deleted filter id:"<<filter->get("kdenlive_id")<<", ix:"<<filter->get("kdenlive_ix")<<", SERVICE:"<<filter->get("mlt_service");
} else if (updateIndex) {
// Adjust the other effects index
- if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
+ if (filter->get_int("kdenlive_ix") > index.toInt()) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
} else ct++;
filter = clipService.filter(ct);
}
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
if (doRefresh) refresh();
return success;
}
}
Mlt::Service clipService(clip->get_service());
- m_isBlocked = true;
int duration = clip->get_playtime();
if (doRefresh) {
// Check if clip is visible in monitor
const int filter_ix = params.paramValue("kdenlive_ix").toInt();
const QString region = params.paramValue("region");
int ct = 0;
+ m_isBlocked = true;
+ mlt_service_lock(service.get_service());
+
Mlt::Filter *filter = service.filter(ct);
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() == filter_ix) {
+ if (filter->get_int("kdenlive_ix") == filter_ix) {
// A filter at that position already existed, so we will increase all indexes later
updateIndex = true;
break;
ct = 0;
filter = service.filter(ct);
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) {
- if (updateIndex) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
+ if (filter->get_int("kdenlive_ix") >= filter_ix) {
+ if (updateIndex) filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") + 1);
}
ct++;
filter = service.filter(ct);
}
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
if (doRefresh) refresh();
return true;
}
ct = 0;
filter = service.filter(ct);
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) {
+ if (filter->get_int("kdenlive_ix") >= filter_ix) {
filtersList.append(filter);
service.detach(*filter);
} else ct++;
} else {
kDebug() << "filter is NULL";
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
return false;
}
params.removeParam("kdenlive_id");
for (int i = 0; i < filtersList.count(); i++) {
Mlt::Filter *filter = filtersList.at(i);
if (updateIndex)
- filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
+ filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") + 1);
service.attach(*filter);
}
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
if (doRefresh) refresh();
return true;
}
bool Render::mltEditTrackEffect(int track, EffectsParameterList params)
{
- kDebug() << "EDIT TK, FILTER: " << track;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- if (filter->get("kdenlive_ix") == index) {
+ if (filter->get_int("kdenlive_ix") == index.toInt()) {
break;
}
ct++;
if (!params.paramValue("keyframes").isEmpty() || /*it.key().startsWith("#") || */tag.startsWith("ladspa") || tag == "sox" || tag == "autotrack_rectangle" || params.hasParam("region")) {
// This is a keyframe effect, to edit it, we remove it and re-add it.
- mltRemoveEffect(track, position, index, false);
- bool success = mltAddEffect(track, position, params);
+ bool success = mltRemoveEffect(track, position, index, false);
+ if (!success) kDebug() << "// ERROR Removing effect : " << index;
+ if (position < GenTime()) success = mltAddTrackEffect(track, params);
+ else success = mltAddEffect(track, position, params);
+ if (!success) kDebug() << "// ERROR Adding effect : " << index;
return success;
}
if (position < GenTime()) {
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- if (filter->get("kdenlive_ix") == index) {
+ if (filter->get_int("kdenlive_ix") == index.toInt()) {
break;
}
ct++;
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- int pos = QString(filter->get("kdenlive_ix")).toInt();
+ int pos = filter->get_int("kdenlive_ix");
if (pos == oldPos) {
filter->set("kdenlive_ix", newPos);
} else ct++;
bool found = false;
if (newPos > oldPos) {
while (filter) {
- if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ if (!found && filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
filter = clipService.filter(ct);
- while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
- filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
+ while (filter && filter->get_int("kdenlive_ix") <= newPos) {
+ filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
filter = clipService.filter(ct);
}
found = true;
}
- if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
+ if (filter && filter->get_int("kdenlive_ix") > newPos) {
filtersList.append(filter);
clipService.detach(*filter);
} else ct++;
}
} else {
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ if (filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
ct = 0;
filter = clipService.filter(ct);
while (filter) {
- int pos = QString(filter->get("kdenlive_ix")).toInt();
+ int pos = filter->get_int("kdenlive_ix");
if (pos >= newPos) {
if (pos < oldPos) filter->set("kdenlive_ix", pos + 1);
filtersList.append(filter);
bool found = false;
if (newPos > oldPos) {
while (filter) {
- if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ if (!found && filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
filter = clipService.filter(ct);
- while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
- filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
+ while (filter && filter->get_int("kdenlive_ix") <= newPos) {
+ filter->set("kdenlive_ix", filter->get_int("kdenlive_ix") - 1);
ct++;
filter = clipService.filter(ct);
}
found = true;
}
- if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
+ if (filter && filter->get_int("kdenlive_ix") > newPos) {
filtersList.append(filter);
clipService.detach(*filter);
} else ct++;
}
} else {
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ if (filter->get_int("kdenlive_ix") == oldPos) {
filter->set("kdenlive_ix", newPos);
filtersList.append(filter);
clipService.detach(*filter);
ct = 0;
filter = clipService.filter(ct);
while (filter) {
- int pos = QString(filter->get("kdenlive_ix")).toInt();
+ int pos = filter->get_int("kdenlive_ix");
if (pos >= newPos) {
if (pos < oldPos) filter->set("kdenlive_ix", pos + 1);
filtersList.append(filter);
return doc.toString();
}
+
+void Render::sendFrameUpdate()
+{
+ if (m_mltProducer) {
+ Mlt::Frame * frame = m_mltProducer->get_frame();
+ emitFrameUpdated(*frame);
+ delete frame;
+ }
+}
+
+
#include "renderer.moc"