}
}
-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);
}
-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_mltProducer = NULL;
- buildConsumer();
+ buildConsumer(profileName);
double new_fps = m_mltProfile->fps();
if (current_fps != new_fps) {
// fps changed, we must update the scenelist positions
}
//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;
}
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);
void Render::mltUpdateClip(ItemInfo info, QDomElement element, Mlt::Producer *prod)
{
// TODO: optimize
+ Mlt::Service service(m_mltProducer->parent().get_service());
+ if (service.type() != tractor_type) {
+ kWarning() << "// TRACTOR PROBLEM";
+ return;
+ }
+ 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);
+ }
mltRemoveClip(info.track, info.startPos);
mltInsertClip(info, element, prod);
+ 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)));
+ }
}
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 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) {
+ GenTime duration = info.cropDuration;
+ 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((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 + info.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 = 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);
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;
for (int i = 0; i < filtersList.count(); i++) {
clipService.attach(*(filtersList.at(i)));
}
-
m_isBlocked = false;
if (doRefresh) refresh();
return true;
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());
mltPasteEffects(clipProducer, clip);
int newIndex = destTrackPlaylist.insert_at(moveEnd, clip, 1);
+
if (clip == clipProducer) {
delete clip;
clip = NULL;
tractor.setAttribute("out", out);
emit durationChanged(out);
- kDebug() << "///////////////////////////// " << out << " \n" << doc.toString() << "\n-------------------------";
+ //kDebug() << "///////////////////////////// " << out << " \n" << doc.toString() << "\n-------------------------";
return doc.toString();
}