}
}
-Render::Render(const QString & rendererName, int winid, int /* extid */, QWidget *parent) :
+Render::Render(const QString & rendererName, int winid, int /* extid */, QString profile, QWidget *parent) :
QObject(parent),
m_isBlocked(0),
m_name(rendererName),
, m_glWidget(0)
#endif
{
- kDebug() << "////////// USING PROFILE: " << (char*)KdenliveSettings::current_profile().toUtf8().data();
-
/*if (rendererName == "project") m_monitorId = 10000;
else m_monitorId = 10001;*/
/*m_osdTimer = new QTimer(this);
connect(m_osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()));*/
-
- buildConsumer();
+ if (profile.isEmpty()) profile = KdenliveSettings::current_profile();
+ buildConsumer(profile);
m_mltProducer = m_blackClip->cut(0, 50);
m_mltConsumer->connect(*m_mltProducer);
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
mlt_service nextservice = mlt_service_get_producer(service.get_service());
+ mlt_service nextservicetodisconnect;
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
QString resource = mlt_properties_get(properties, "mlt_service");
// Delete all transitions
while (mlt_type == "transition") {
- mlt_field_disconnect_service(field->get_field(), nextservice);
+ nextservicetodisconnect = nextservice;
+ nextservice = mlt_service_producer(nextservice);
+ mlt_field_disconnect_service(field->get_field(), nextservicetodisconnect);
nextservice = mlt_service_producer(nextservice);
if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
}
-void Render::buildConsumer()
+void Render::buildConsumer(const QString profileName)
{
char *tmp;
- m_activeProfile = KdenliveSettings::current_profile();
+ m_activeProfile = profileName;
tmp = decodedString(m_activeProfile);
setenv("MLT_PROFILE", tmp, 1);
delete m_blackClip;
}
-int Render::resetProfile()
+int Render::resetProfile(const QString profileName)
{
if (!m_mltConsumer) return 0;
- if (m_activeProfile == KdenliveSettings::current_profile()) {
+ if (m_activeProfile == profileName) {
kDebug() << "reset to same profile, nothing to do";
return 1;
}
- kDebug() << "// RESETTING PROFILE FROM: " << m_activeProfile << " TO: " << KdenliveSettings::current_profile();
+ kDebug() << "// RESETTING PROFILE FROM: " << m_activeProfile << " TO: " << profileName; //KdenliveSettings::current_profile();
if (m_isSplitView) slotSplitView(false);
if (!m_mltConsumer->is_stopped()) m_mltConsumer->stop();
m_mltConsumer->purge();
m_mltConsumer = NULL;
QString scene = sceneList();
int pos = 0;
-
+ double current_fps = m_mltProfile->fps();
delete m_blackClip;
m_blackClip = NULL;
}
m_mltProducer = NULL;
- buildConsumer();
-
+ buildConsumer(profileName);
+ double new_fps = m_mltProfile->fps();
+ if (current_fps != new_fps) {
+ // fps changed, we must update the scenelist positions
+ scene = updateSceneListFps(current_fps, new_fps, scene);
+ }
//kDebug() << "//RESET WITHSCENE: " << scene;
setSceneList(scene, pos);
-
+ // producers have changed (different profile), so reset them...
+ emit refreshDocumentProducers();
/*char *tmp = decodedString(scene);
Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "xml-string", tmp);
delete[] tmp;
return m_mltProfile->height();
}
-QPixmap Render::extractFrame(int frame_position, int width, int height)
+QImage Render::extractFrame(int frame_position, int width, int height)
{
if (width == -1) {
width = renderWidth();
height = renderHeight();
} else if (width % 2 == 1) width++;
- QPixmap pix(width, height);
+
if (!m_mltProducer) {
+ QImage pix(width, height, QImage::Format_RGB32);
pix.fill(Qt::black);
return pix;
}
producer->set("id", tmp);
delete[] tmp;
+ if (xml.hasAttribute("templatetext")) {
+ char *tmp = decodedString(xml.attribute("templatetext"));
+ producer->set("templatetext", tmp);
+ delete[] tmp;
+ }
+
if (!replaceProducer && xml.hasAttribute("file_hash")) {
// Clip already has all properties
emit replyGetFileProperties(clipId, producer, QMap < QString, QString >(), QMap < QString, QString >(), replaceProducer);
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
mlt_service nextservice = mlt_service_get_producer(service.get_service());
+ mlt_service nextservicetodisconnect;
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
QString resource = mlt_properties_get(properties, "mlt_service");
// Delete all transitions
while (mlt_type == "transition") {
- mlt_field_disconnect_service(field->get_field(), nextservice);
+ nextservicetodisconnect = nextservice;
nextservice = mlt_service_producer(nextservice);
+ mlt_field_disconnect_service(field->get_field(), nextservicetodisconnect);
if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_properties_get(properties, "mlt_type");
if (trackPlaylist.type() == playlist_type) trackPlaylist.clear();
trackNb--;
}
+ delete field;
}
mlt_service_unlock(service.get_service());
m_isBlocked = false;
blockSignals(false);
- emit refreshDocumentProducers();
+
return error;
//kDebug()<<"// SETSCN LST, POS: "<<position;
//if (position != 0) emit rendererPosition(position);
int dropFrames = 1;
if (show == false) dropFrames = 0;
m_mltConsumer->stop();
+#ifdef Q_WS_MAC
+ m_mltConsumer->set("real_time", dropFrames);
+#else
m_mltConsumer->set("play.real_time", dropFrames);
+#endif
if (m_mltConsumer->start() == -1) {
emit blockMonitors();
delete m_mltProducer;
kDebug() << "PLAYLIST NOT INITIALISED //////";
return -1;
}
+ if (prod == NULL) {
+ kDebug() << "Cannot insert clip without producer //////";
+ return -1;
+ }
Mlt::Producer parentProd(m_mltProducer->parent());
if (parentProd.get_producer() == NULL) {
kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
m_isBlocked = false;
}
-void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod)
+bool Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod)
{
// TODO: optimize
- mltRemoveClip(info.track, info.startPos);
- mltInsertClip(info, element, prod);
+ if (prod == NULL) {
+ kDebug() << "Cannot update clip with null producer //////";
+ return false;
+ }
+ Mlt::Service service(m_mltProducer->parent().get_service());
+ if (service.type() != tractor_type) {
+ kWarning() << "// TRACTOR PROBLEM";
+ return false;
+ }
+ Mlt::Tractor tractor(service);
+ Mlt::Producer trackProducer(tractor.track(info.track));
+ Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+ int startPos = info.startPos.frames(m_fps);
+ int clipIndex = trackPlaylist.get_clip_index_at(startPos);
+ Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
+
+ // keep effects
+ QList <Mlt::Filter *> filtersList;
+ Mlt::Service sourceService(clip->get_service());
+ int ct = 0;
+ Mlt::Filter *filter = sourceService.filter(ct);
+ while (filter) {
+ if (filter->get("kdenlive_ix") != 0) {
+ filtersList.append(filter);
+ }
+ ct++;
+ filter = sourceService.filter(ct);
+ }
+ if (!mltRemoveClip(info.track, info.startPos)) return false;
+ if (mltInsertClip(info, element, prod) == -1) return false;
+ if (!filtersList.isEmpty()) {
+ clipIndex = trackPlaylist.get_clip_index_at(startPos);
+ Mlt::Producer *destclip = trackPlaylist.get_clip(clipIndex);
+ Mlt::Service destService(destclip->get_service());
+ delete destclip;
+ for (int i = 0; i < filtersList.count(); i++)
+ destService.attach(*(filtersList.at(i)));
+ }
+ return true;
}
{
if (!m_mltProducer) {
kDebug() << "PLAYLIST NOT INITIALISED //////";
- return -1;
+ return 0;
}
Mlt::Producer parentProd(m_mltProducer->parent());
if (parentProd.get_producer() == NULL) {
kDebug() << "PLAYLIST BROKEN, CANNOT INSERT CLIP //////";
- return -1;
+ return 0;
}
Mlt::Service service(parentProd.get_service());
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
int clipIndex = trackPlaylist.get_clip_index_at(insertPos);
- if (!trackPlaylist.is_blank(clipIndex)) return -1;
+ if (clipIndex == trackPlaylist.count()) {
+ // We are after the end of the playlist
+ return -1;
+ }
+ if (!trackPlaylist.is_blank(clipIndex)) return 0;
if (fromBlankStart) return trackPlaylist.clip_length(clipIndex);
return trackPlaylist.clip_length(clipIndex) + trackPlaylist.clip_start(clipIndex) - insertPos;
}
void Render::mltPasteEffects(Mlt::Producer *source, Mlt::Producer *dest)
{
+ if (source == dest) return;
Mlt::Service sourceService(source->get_service());
Mlt::Service destService(dest->get_service());
}
}
-int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int strobe, Mlt::Producer *prod)
+int Render::mltChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, double speed, double oldspeed, int strobe, Mlt::Producer *prod)
{
m_isBlocked = true;
int newLength = 0;
int clipIndex = trackPlaylist.get_clip_index_at(startPos);
int clipLength = trackPlaylist.clip_length(clipIndex);
- Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
- if (clip == NULL) {
+ Mlt::Producer *original = trackPlaylist.get_clip(clipIndex);
+ if (original == NULL) {
return -1;
}
- if (!clip->is_valid() || clip->is_blank()) {
+ if (!original->is_valid() || original->is_blank()) {
// invalid clip
- delete clip;
+ delete original;
return -1;
}
- Mlt::Producer clipparent = clip->parent();
+ Mlt::Producer clipparent = original->parent();
if (!clipparent.is_valid() || clipparent.is_blank()) {
// invalid clip
- delete clip;
+ delete original;
return -1;
}
+ delete original;
QString serv = clipparent.get("mlt_service");
QString id = clipparent.get("id");
if (strobe > 1) url.append("&strobe=" + QString::number(strobe));
Mlt::Producer *slowprod = m_slowmotionProducers.value(url);
if (!slowprod || slowprod->get_producer() == NULL) {
- char *tmp = decodedString(url);
- slowprod = new Mlt::Producer(*m_mltProfile, "framebuffer", tmp);
+ char *tmp = decodedString("framebuffer:" + url);
+ slowprod = new Mlt::Producer(*m_mltProfile, 0, tmp);
if (strobe > 1) slowprod->set("strobe", strobe);
delete[] tmp;
QString producerid = "slowmotion:" + id + ':' + QString::number(speed);
}
Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
trackPlaylist.consolidate_blanks(0);
+
// Check that the blank space is long enough for our new duration
clipIndex = trackPlaylist.get_clip_index_at(startPos);
int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
Mlt::Producer *cut;
- GenTime oldDuration = GenTime(clipLength, m_fps);
- GenTime newDuration = oldDuration * oldspeed;
- if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + newDuration).frames(m_fps) > blankEnd) {
+ int originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps));
+ if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + speedIndependantInfo.cropDuration).frames(m_fps) > blankEnd) {
GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
- cut = prod->cut((int)(info.cropStart.frames(m_fps)), (int)(info.cropStart.frames(m_fps) + maxLength.frames(m_fps) - 1));
- } else cut = prod->cut((int)(info.cropStart.frames(m_fps)), (int)((info.cropStart + newDuration).frames(m_fps)) - 1);
+ cut = prod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - 1));
+ } else cut = prod->cut(originalStart, (int)(originalStart + speedIndependantInfo.cropDuration.frames(m_fps)) - 1);
// move all effects to the correct producer
mltPasteEffects(clip, cut);
if (strobe > 1) url.append("&strobe=" + QString::number(strobe));
Mlt::Producer *slowprod = m_slowmotionProducers.value(url);
if (!slowprod || slowprod->get_producer() == NULL) {
- char *tmp = decodedString(url);
- slowprod = new Mlt::Producer(*m_mltProfile, "framebuffer", tmp);
+ char *tmp = decodedString("framebuffer:" + url);
+ slowprod = new Mlt::Producer(*m_mltProfile, 0, tmp);
delete[] tmp;
slowprod->set("strobe", strobe);
QString producerid = "slowmotion:" + id.section(':', 1, 1) + ':' + QString::number(speed);
Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex);
trackPlaylist.consolidate_blanks(0);
- GenTime oldDuration = GenTime(clipLength, m_fps);
- GenTime newDuration = oldDuration * (oldspeed / speed);
+ GenTime duration = speedIndependantInfo.cropDuration / speed;
+ int originalStart = (int)(speedIndependantInfo.cropStart.frames(m_fps) / speed);
// Check that the blank space is long enough for our new duration
clipIndex = trackPlaylist.get_clip_index_at(startPos);
int blankEnd = trackPlaylist.clip_start(clipIndex) + trackPlaylist.clip_length(clipIndex);
Mlt::Producer *cut;
- if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + newDuration).frames(m_fps) > blankEnd) {
+ if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + duration).frames(m_fps) > blankEnd) {
GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
- cut = slowprod->cut((int)(info.cropStart.frames(m_fps) / speed), (int)(info.cropStart.frames(m_fps) / speed + maxLength.frames(m_fps) - 1));
- } else cut = slowprod->cut((int)(info.cropStart.frames(m_fps) / speed), (int)((info.cropStart / speed + newDuration).frames(m_fps) - 1));
+ cut = slowprod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - 1));
+ } else cut = slowprod->cut(originalStart, (int)(originalStart + duration.frames(m_fps)) - 1);
// move all effects to the correct producer
mltPasteEffects(clip, cut);
mlt_service_unlock(service.get_service());
}
- delete clip;
if (clipIndex + 1 == trackPlaylist.count()) mltCheckLength(&tractor);
m_isBlocked = false;
return newLength;
Mlt::Service clipService(clip->get_service());
m_isBlocked = true;
int duration = clip->get_playtime();
+ bool updateIndex = false;
delete clip;
- // temporarily remove all effects after insert point
- QList <Mlt::Filter *> filtersList;
+
const int filter_ix = params.paramValue("kdenlive_ix").toInt();
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() > filter_ix) {
+ if (QString(filter->get("kdenlive_ix")).toInt() == filter_ix) {
+ // A filter at that position already existed, so we will increase all indexes later
+ updateIndex = true;
+ break;
+ }
+ ct++;
+ filter = clipService.filter(ct);
+ }
+
+ if (params.paramValue("id") == "speed") {
+ // special case, speed effect is not really inserted, we just update the other effects index (kdenlive_ix)
+ ct = 0;
+ filter = clipService.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);
+ }
+ ct++;
+ filter = clipService.filter(ct);
+ }
+ m_isBlocked = false;
+ if (doRefresh) refresh();
+ return true;
+ }
+
+
+ // temporarily remove all effects after insert point
+ QList <Mlt::Filter *> filtersList;
+ ct = 0;
+ filter = clipService.filter(ct);
+ while (filter) {
+ if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) {
filtersList.append(filter);
clipService.detach(*filter);
} else ct++;
// re-add following filters
for (int i = 0; i < filtersList.count(); i++) {
- clipService.attach(*(filtersList.at(i)));
+ Mlt::Filter *filter = filtersList.at(i);
+ if (updateIndex)
+ filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
+ clipService.attach(*filter);
}
-
m_isBlocked = false;
if (doRefresh) refresh();
return true;
m_isBlocked = true;
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
+
+ /*
+ kDebug() << "EDITING FILTER: "<<index <<", "<<tag;
+ kDebug() << "EFFect stack: ++++++++++++++++++++++++++";
+ while (filter) {
+ kDebug() << "Filter: "<< filter->get("kdenlive_id") <<", IX: "<<filter->get("kdenlive_ix");
+ ct++;
+ filter = clipService.filter(ct);
+ }
+ kDebug() << "++++++++++++++++++++++++++";
+ */
+ ct = 0;
+ filter = clipService.filter(ct);
while (filter) {
if (filter->get("kdenlive_ix") == index) {
break;
}
if (!filter) {
- kDebug() << "WARINIG, FILTER FOR EDITING NOT FOUND, ADDING IT!!!!!";
+ 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...
- int ct = 0;
- filter = clipService.filter(ct);
- QList <Mlt::Filter *> filtersList;
- while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() > index.toInt()) {
- filtersList.append(filter);
- clipService.detach(*filter);
- } else ct++;
- filter = clipService.filter(ct);
- }
- bool success = mltAddEffect(track, position, params);
-
- for (int i = 0; i < filtersList.count(); i++) {
- clipService.attach(*(filtersList.at(i)));
- }
+ bool success = mltAddEffect(track, position, params);
m_isBlocked = false;
return success;
}
return true;
}
+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());
+ //int clipIndex = trackPlaylist.get_clip_index_at(position.frames(m_fps));
+ Mlt::Producer *clip = trackPlaylist.get_clip_at((int) position.frames(m_fps));
+ if (!clip) {
+ kDebug() << "WARINIG, CANNOT FIND CLIP ON track: " << track << ", AT POS: " << position.frames(m_fps);
+ return;
+ }
+ Mlt::Service clipService(clip->get_service());
+ delete clip;
+ m_isBlocked = true;
+ int ct = 0;
+ Mlt::Filter *filter = clipService.filter(ct);
+ while (filter) {
+ int pos = QString(filter->get("kdenlive_ix")).toInt();
+ if (pos == oldPos) {
+ filter->set("kdenlive_ix", newPos);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+
+ m_isBlocked = false;
+ refresh();
+}
+
void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
{
}
-void Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod)
+bool Render::mltUpdateClipProducer(int track, int pos, Mlt::Producer *prod)
{
if (prod == NULL || !prod->is_valid()) {
kDebug() << "// Warning, CLIP on track " << track << ", at: " << pos << " is invalid, cannot update it!!!";
- return;
+ return false;
}
kDebug() << "NEW PROD ID: " << prod->get("id");
m_isBlocked++;
Mlt::Service service(m_mltProducer->parent().get_service());
if (service.type() != tractor_type) {
kWarning() << "// TRACTOR PROBLEM";
- return;
+ return false;
}
mlt_service_lock(m_mltConsumer->get_service());
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
- int clipIndex = trackPlaylist.get_clip_index_at(pos + 1);
+ int clipIndex = trackPlaylist.get_clip_index_at(pos);
Mlt::Producer *clipProducer = trackPlaylist.replace_with_blank(clipIndex);
- if (clipProducer->is_blank()) {
+ if (clipProducer == NULL || clipProducer->is_blank()) {
kDebug() << "// ERROR UPDATING CLIP PROD";
delete clipProducer;
mlt_service_unlock(m_mltConsumer->get_service());
m_isBlocked--;
- return;
+ return false;
}
Mlt::Producer *clip = prod->cut(clipProducer->get_in(), clipProducer->get_out());
-
+ if (!clip) return false;
// move all effects to the correct producer
mltPasteEffects(clipProducer, clip);
trackPlaylist.insert_at(pos, clip, 1);
delete clipProducer;
mlt_service_unlock(m_mltConsumer->get_service());
m_isBlocked--;
+ return true;
}
bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEnd, Mlt::Producer *prod)
bool checkLength = false;
if (endTrack == startTrack) {
Mlt::Producer *clipProducer = trackPlaylist.replace_with_blank(clipIndex);
- if (!trackPlaylist.is_blank_at(moveEnd) || clipProducer->is_blank()) {
+ if (!trackPlaylist.is_blank_at(moveEnd) || !clipProducer || clipProducer->is_blank()) {
// error, destination is not empty
if (!trackPlaylist.is_blank_at(moveEnd)) trackPlaylist.insert_at(moveStart, clipProducer, 1);
- delete clipProducer;
+ if (clipProducer) delete clipProducer;
//int ix = trackPlaylist.get_clip_index_at(moveEnd);
kDebug() << "// ERROR MOVING CLIP TO : " << moveEnd;
mlt_service_unlock(service.get_service());
return false;
} else {
Mlt::Producer *clipProducer = trackPlaylist.replace_with_blank(clipIndex);
- if (clipProducer->is_blank()) {
+ if (!clipProducer || clipProducer->is_blank()) {
// error, destination is not empty
//int ix = trackPlaylist.get_clip_index_at(moveEnd);
- delete clipProducer;
+ if (clipProducer) delete clipProducer;
kDebug() << "// ERROR MOVING CLIP TO : " << moveEnd;
mlt_service_unlock(service.get_service());
m_isBlocked--;
mltPasteEffects(clipProducer, clip);
int newIndex = destTrackPlaylist.insert_at(moveEnd, clip, 1);
+
if (clip == clipProducer) {
delete clip;
clip = NULL;
setSceneList(scene, pos);
}
+
+QString Render::updateSceneListFps(double current_fps, double new_fps, QString scene)
+{
+ // Update all frame positions to the new fps value
+ //WARNING: there are probably some effects or other that hold a frame value
+ // as parameter and will also need to be updated here!
+ QDomDocument doc;
+ doc.setContent(scene);
+
+ double factor = new_fps / current_fps;
+ QDomNodeList producers = doc.elementsByTagName("producer");
+ for (int i = 0; i < producers.count(); i++) {
+ QDomElement prod = producers.at(i).toElement();
+ prod.removeAttribute("in");
+ prod.removeAttribute("out");
+
+ QDomNodeList props = prod.childNodes();
+ for (int j = 0; j < props.count(); j++) {
+ QDomElement param = props.at(j).toElement();
+ QString paramName = param.attribute("name");
+ if (paramName.startsWith("meta.") || paramName == "length") {
+ prod.removeChild(props.at(j));
+ j--;
+ }
+ }
+ }
+
+ QDomNodeList entries = doc.elementsByTagName("entry");
+ for (int i = 0; i < entries.count(); i++) {
+ QDomElement entry = entries.at(i).toElement();
+ int in = entry.attribute("in").toInt();
+ int out = entry.attribute("out").toInt();
+ in = factor * in + 0.5;
+ out = factor * out + 0.5;
+ entry.setAttribute("in", in);
+ entry.setAttribute("out", out);
+ }
+
+ QDomNodeList blanks = doc.elementsByTagName("blank");
+ for (int i = 0; i < blanks.count(); i++) {
+ QDomElement blank = blanks.at(i).toElement();
+ int length = blank.attribute("length").toInt();
+ length = factor * length + 0.5;
+ blank.setAttribute("length", QString::number(length));
+ }
+
+ QDomNodeList filters = doc.elementsByTagName("filter");
+ for (int i = 0; i < filters.count(); i++) {
+ QDomElement filter = filters.at(i).toElement();
+ int in = filter.attribute("in").toInt();
+ int out = filter.attribute("out").toInt();
+ in = factor * in + 0.5;
+ out = factor * out + 0.5;
+ filter.setAttribute("in", in);
+ filter.setAttribute("out", out);
+ }
+
+ QDomNodeList transitions = doc.elementsByTagName("transition");
+ for (int i = 0; i < transitions.count(); i++) {
+ QDomElement transition = transitions.at(i).toElement();
+ int in = transition.attribute("in").toInt();
+ int out = transition.attribute("out").toInt();
+ in = factor * in + 0.5;
+ out = factor * out + 0.5;
+ transition.setAttribute("in", in);
+ transition.setAttribute("out", out);
+ QDomNodeList props = transition.childNodes();
+ for (int j = 0; j < props.count(); j++) {
+ QDomElement param = props.at(j).toElement();
+ QString paramName = param.attribute("name");
+ if (paramName == "geometry") {
+ QString geom = param.firstChild().nodeValue();
+ QStringList keys = geom.split(';');
+ QStringList newKeys;
+ for (int k = 0; k < keys.size(); ++k) {
+ if (keys.at(k).contains('=')) {
+ int pos = keys.at(k).section('=', 0, 0).toInt();
+ pos = factor * pos + 0.5;
+ newKeys.append(QString::number(pos) + '=' + keys.at(k).section('=', 1));
+ } else newKeys.append(keys.at(k));
+ }
+ param.firstChild().setNodeValue(newKeys.join(";"));
+ }
+ }
+ }
+ QDomElement tractor = doc.elementsByTagName("tractor").at(0).toElement();
+ int out = tractor.attribute("out").toInt();
+ out = factor * out + 0.5;
+ tractor.setAttribute("out", out);
+ emit durationChanged(out);
+
+ //kDebug() << "///////////////////////////// " << out << " \n" << doc.toString() << "\n-------------------------";
+ return doc.toString();
+}
+
#include "renderer.moc"