X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Frenderer.cpp;h=904e94308da12ff2ba10d66c7eb64315d88f5abb;hb=e0706c69456a64eea5cb22b3909ff9299142b685;hp=733224cc8628c98c3f6bc2ddbd23ac523b58572f;hpb=2b1c40908368fff4b20912551c266e45c89f6607;p=kdenlive diff --git a/src/renderer.cpp b/src/renderer.cpp index 733224cc..904e9430 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -67,7 +67,7 @@ static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr } } -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), @@ -84,14 +84,12 @@ Render::Render(const QString & rendererName, int winid, int /* extid */, QWidget , 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); @@ -151,10 +149,10 @@ void Render::closeMlt() } -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; @@ -232,14 +230,14 @@ void Render::buildConsumer() } -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(); @@ -270,7 +268,7 @@ int Render::resetProfile() } 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 @@ -958,7 +956,7 @@ int Render::setSceneList(QString playlist, int position) if (trackPlaylist.type() == playlist_type) trackPlaylist.clear(); trackNb--; } - delete field; + delete field; } mlt_service_unlock(service.get_service()); @@ -1710,7 +1708,7 @@ void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *pr } ct++; filter = sourceService.filter(ct); - } + } mltRemoveClip(info.track, info.startPos); mltInsertClip(info, element, prod); if (!filtersList.isEmpty()) { @@ -2067,7 +2065,7 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int Mlt::Producer *cut; GenTime duration = info.cropDuration; - int originalStart = (int)(info.originalcropStart.frames(m_fps)); + int originalStart = (int)(info.originalcropStart.frames(m_fps)); if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + info.cropDuration).frames(m_fps) > blankEnd) { GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos; cut = prod->cut(originalStart, (int)(originalStart + maxLength.frames(m_fps) - 1)); @@ -2104,9 +2102,9 @@ int Render::mltChangeClipSpeed(ItemInfo info, double speed, double oldspeed, int } Mlt::Producer *clip = trackPlaylist.replace_with_blank(clipIndex); trackPlaylist.consolidate_blanks(0); - - GenTime duration = info.cropDuration / speed; - int originalStart = (int)(info.originalcropStart.frames(m_fps) / speed); + + GenTime duration = info.cropDuration / speed; + int originalStart = (int)(info.originalcropStart.frames(m_fps) / speed); // Check that the blank space is long enough for our new duration clipIndex = trackPlaylist.get_clip_index_at(startPos); @@ -2187,15 +2185,45 @@ bool Render::mltAddEffect(int track, GenTime position, EffectsParameterList para 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 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) { + // 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 filtersList; + ct = 0; + filter = clipService.filter(ct); while (filter) { if (QString(filter->get("kdenlive_ix")).toInt() >= filter_ix) { - filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1); filtersList.append(filter); clipService.detach(*filter); } else ct++; @@ -2302,7 +2330,10 @@ bool Render::mltAddEffect(int track, GenTime position, EffectsParameterList para // 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(); @@ -2338,6 +2369,19 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par m_isBlocked = true; int ct = 0; Mlt::Filter *filter = clipService.filter(ct); + + /* + kDebug() << "EDITING FILTER: "<get("kdenlive_id") <<", IX: "<get("kdenlive_ix"); + ct++; + filter = clipService.filter(ct); + } + kDebug() << "++++++++++++++++++++++++++"; + */ + ct = 0; + filter = clipService.filter(ct); while (filter) { if (filter->get("kdenlive_ix") == index) { break; @@ -2347,24 +2391,10 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par } 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 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; } @@ -2383,6 +2413,38 @@ bool Render::mltEditEffect(int track, GenTime position, EffectsParameterList par 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) { @@ -2764,9 +2826,9 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn // move all effects to the correct producer mltPasteEffects(clipProducer, clip); - + int newIndex = destTrackPlaylist.insert_at(moveEnd, clip, 1); - + if (clip == clipProducer) { delete clip; clip = NULL;