// setup length here as otherwise default length (currently 15000 frames in MLT) will be taken although outpoint is larger
if (xml.attribute("type").toInt() == COLOR || xml.attribute("type").toInt() == TEXT
- || xml.attribute("type").toInt() == IMAGE || xml.attribute("type").toInt() == SLIDESHOW)
+ || xml.attribute("type").toInt() == IMAGE || xml.attribute("type").toInt() == SLIDESHOW)
producer->set("length", xml.attribute("out").toInt() - xml.attribute("in").toInt() + 1);
if (xml.hasAttribute("out")) producer->set_in_and_out(xml.attribute("in").toInt(), xml.attribute("out").toInt());
clipService.attach(*filter);
}
}
+ if (xml.attribute("crop") == "1") {
+ // user wants to center crop the slides
+ Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, "crop");
+ if (filter && filter->is_valid()) {
+ filter->set("center", 1);
+ producer->attach(*filter);
+ }
+ }
}
return newLength;
}
+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::Producer trackProducer(tractor.track(track));
+ Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+ Mlt::Service clipService(trackPlaylist.get_service());
+
+ m_isBlocked = true;
+ 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 (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);
+ ct++;
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ m_isBlocked = false;
+ refresh();
+ return success;
+}
+
bool Render::mltRemoveEffect(int track, GenTime position, QString index, bool updateIndex, bool doRefresh)
{
+ if (position < GenTime()) {
+ // Remove track effect
+ return mltRemoveTrackEffect(track, index, updateIndex);
+ }
Mlt::Service service(m_mltProducer->parent().get_service());
bool success = false;
Mlt::Tractor tractor(service);
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
- Mlt::Service trackService(trackPlaylist.get_service());
+ Mlt::Service trackService(trackProducer.get_service()); //trackPlaylist
return mltAddEffect(trackService, params, 15000, true);
}
delete clip;
return mltAddEffect(clipService, params, duration, doRefresh);
}
-
+
bool Render::mltAddEffect(Mlt::Service service, EffectsParameterList params, int duration, bool doRefresh)
{
bool updateIndex = false;
params.removeParam("max");
params.removeParam("factor");
int offset = 0;
- for (int i = 0; i < keyFrames.size() - 1; ++i) {
+ // Special case, only one keyframe, means we want a constant value
+ if (keyFrames.count() == 1) {
Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterTag);
if (filter && filter->is_valid()) {
filter->set("kdenlive_id", filterId);
- int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset;
- double y1 = keyFrames.at(i).section(':', 1, 1).toDouble();
- int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt();
- double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble();
- if (x2 == -1) x2 = duration;
-
+ int x1 = keyFrames.at(0).section(':', 0, 0).toInt();
+ double y1 = keyFrames.at(0).section(':', 1, 1).toDouble();
for (int j = 0; j < params.count(); j++) {
char *name = decodedString(params.at(j).name());
char *value = decodedString(params.at(j).value());
delete[] name;
delete[] value;
}
-
filter->set("in", x1);
- filter->set("out", x2);
//kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
filter->set(starttag, QString::number((min + y1) / factor).toUtf8().data());
- filter->set(endtag, QString::number((min + y2) / factor).toUtf8().data());
service.attach(*filter);
- offset = 1;
}
- }
+ } else for (int i = 0; i < keyFrames.size() - 1; ++i) {
+ Mlt::Filter *filter = new Mlt::Filter(*m_mltProfile, filterTag);
+ if (filter && filter->is_valid()) {
+ filter->set("kdenlive_id", filterId);
+ int x1 = keyFrames.at(i).section(':', 0, 0).toInt() + offset;
+ double y1 = keyFrames.at(i).section(':', 1, 1).toDouble();
+ int x2 = keyFrames.at(i + 1).section(':', 0, 0).toInt();
+ double y2 = keyFrames.at(i + 1).section(':', 1, 1).toDouble();
+ if (x2 == -1) x2 = duration;
+
+ for (int j = 0; j < params.count(); j++) {
+ char *name = decodedString(params.at(j).name());
+ char *value = decodedString(params.at(j).value());
+ filter->set(name, value);
+ delete[] name;
+ delete[] value;
+ }
+
+ filter->set("in", x1);
+ filter->set("out", x2);
+ //kDebug() << "// ADDING KEYFRAME vals: " << min<<" / "<<max<<", "<<y1<<", factor: "<<factor;
+ filter->set(starttag, QString::number((min + y1) / factor).toUtf8().data());
+ filter->set(endtag, QString::number((min + y2) / factor).toUtf8().data());
+ service.attach(*filter);
+ offset = 1;
+ }
+ }
delete[] starttag;
delete[] endtag;
} else {
delete[] value;
}
+ if (params.paramValue("id") == "pan_zoom") {
+ filter->set_in_and_out(service.get_int("in"), service.get_int("out") + 1);
+ }
// attach filter to the clip
service.attach(*filter);
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::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+ Mlt::Service clipService(trackPlaylist.get_service());
+ m_isBlocked = true;
+ int ct = 0;
+ QString index = params.paramValue("kdenlive_ix");
+ QString tag = params.paramValue("tag");
+
+ Mlt::Filter *filter = clipService.filter(ct);
+ while (filter) {
+ if (filter->get("kdenlive_ix") == index) {
+ break;
+ }
+ ct++;
+ filter = clipService.filter(ct);
+ }
+
+ if (!filter) {
+ kDebug() << "WARINIG, FILTER FOR EDITING NOT FOUND, ADDING IT! " << index << ", " << tag;
+ // filter was not found, it was probably a disabled filter, so add it to the correct place...
+
+ bool success = false;//mltAddTrackEffect(track, params);
+ m_isBlocked = false;
+ return success;
+ }
+ QString prefix;
+ QString ser = filter->get("mlt_service");
+ if (ser == "region") prefix = "filter0.";
+ mlt_service_lock(service.get_service());
+ for (int j = 0; j < params.count(); j++) {
+ char *name = decodedString(prefix + params.at(j).name());
+ char *value = decodedString(params.at(j).value());
+ filter->set(name, value);
+ delete[] name;
+ delete[] value;
+ }
+ mlt_service_unlock(service.get_service());
+
+ m_isBlocked = false;
+ refresh();
+ return true;
+
+}
+
bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList params)
{
QString index = params.paramValue("kdenlive_ix");
bool success = mltAddEffect(track, position, params);
return success;
}
-
+ if (position < GenTime()) {
+ return mltEditTrackEffect(track, params);
+ }
// find filter
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
void Render::mltUpdateEffectPosition(int track, GenTime position, int oldPos, int newPos)
{
-
- kDebug() << "MOVING EFFECT FROM " << oldPos << ", TO: " << newPos;
Mlt::Service service(m_mltProducer->parent().get_service());
-
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
{
-
- kDebug() << "MOVING EFFECT FROM " << oldPos << ", TO: " << newPos;
+ if (position < GenTime()) {
+ mltMoveTrackEffect(track, oldPos, newPos);
+ return;
+ }
Mlt::Service service(m_mltProducer->parent().get_service());
-
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
if (doRefresh) refresh();
}
+void Render::mltMoveTrackEffect(int track, int oldPos, int newPos)
+{
+ Mlt::Service service(m_mltProducer->parent().get_service());
+ Mlt::Tractor tractor(service);
+ Mlt::Producer trackProducer(tractor.track(track));
+ Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+
+ Mlt::Service clipService(trackPlaylist.get_service());
+
+ m_isBlocked = true;
+ int ct = 0;
+ QList <Mlt::Filter *> filtersList;
+ Mlt::Filter *filter = clipService.filter(ct);
+ bool found = false;
+ if (newPos > oldPos) {
+ while (filter) {
+ if (!found && QString(filter->get("kdenlive_ix")).toInt() == 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);
+ ct++;
+ filter = clipService.filter(ct);
+ }
+ found = true;
+ }
+ if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ } else {
+ while (filter) {
+ if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ filter->set("kdenlive_ix", newPos);
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+
+ ct = 0;
+ filter = clipService.filter(ct);
+ while (filter) {
+ int pos = QString(filter->get("kdenlive_ix")).toInt();
+ if (pos >= newPos) {
+ if (pos < oldPos) filter->set("kdenlive_ix", pos + 1);
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ }
+
+ for (int i = 0; i < filtersList.count(); i++) {
+ clipService.attach(*(filtersList.at(i)));
+ }
+ m_isBlocked = false;
+ refresh();
+}
+
bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration)
{
m_isBlocked = true;
Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
int previousStart = clip->get_in();
int newDuration = (int) clipDuration.frames(m_fps) - 1;
+ int currentOut = (int)(info.cropStart + info.cropDuration).frames(m_fps) - 1;
int diff = newDuration - (trackPlaylist.clip_length(clipIndex) - 1);
- if (newDuration > clip->get_length()) {
- clip->parent().set("length", newDuration + 1);
- clip->parent().set("out", newDuration);
- clip->set("length", newDuration + 1);
+ if (currentOut > clip->get_length()) {
+ clip->parent().set("length", currentOut + 1);
+ clip->parent().set("out", currentOut);
+ clip->set("length", currentOut + 1);
}
- if (newDuration > clip->get_out()) {
+ /*if (newDuration > clip->get_out()) {
clip->parent().set_in_and_out(0, newDuration + 1);
clip->set_in_and_out(0, newDuration + 1);
- }
+ }*/
delete clip;
trackPlaylist.resize_clip(clipIndex, previousStart, newDuration + previousStart);
trackPlaylist.consolidate_blanks(0);