delete[] tmp;
}
+ int volume = KdenliveSettings::volume();
+ m_mltConsumer->set("volume", (float)volume / 100);
m_mltConsumer->set("progressive", 1);
m_mltConsumer->set("audio_buffer", 1024);
QString videoDriver = KdenliveSettings::videodrivername();
QString currentDriver = m_mltConsumer->get("video_driver");
if (getenv("SDL_VIDEO_YUV_HWACCEL") != NULL && currentDriver == "x11") currentDriver = "x11_noaccel";
- if (m_activeProfile == profileName && currentDriver == videoDriver) {
+ QString background = KdenliveSettings::window_background().name();
+ QString currentBackground = m_mltConsumer->get("window_background");
+ int volume = KdenliveSettings::volume();
+ int currentVolume = (int)(QString(m_mltConsumer->get("volume")).toDouble() * 100.0);
+ if (m_activeProfile == profileName && currentDriver == videoDriver && volume == currentVolume && background == currentBackground) {
kDebug() << "reset to same profile, nothing to do";
return 1;
}
int frame_height = imageHeight;
uint8_t *data = frame->get_image(format, frame_width, frame_height, 0);
QImage image((uchar *)data, frame_width, frame_height, QImage::Format_ARGB32);
- QPixmap pix(frame_width, frame_height);
+ QPixmap pix;
if (!image.isNull()) {
- pix = QPixmap::fromImage(image.rgbSwapped());
+ if (frame_width > (2 * width)) {
+ // there was a scaling problem, do it manually
+ QImage scaled = image.scaled(width, imageHeight);
+ pix = QPixmap::fromImage(scaled.rgbSwapped());
+ } else pix = QPixmap::fromImage(image.rgbSwapped());
} else
pix.fill(Qt::black);
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));
+
+ int clipIndex = trackPlaylist.get_clip_index_at((int) position.frames(m_fps));
+ Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
if (!clip) {
kDebug() << "WARINIG, CANNOT FIND CLIP ON track: " << track << ", AT POS: " << position.frames(m_fps);
return;
}
+
Mlt::Service clipService(clip->get_service());
+ int duration = clip->get_playtime();
+ bool doRefresh = true;
+ // Check if clip is visible in monitor
+ int diff = trackPlaylist.clip_start(clipIndex) + duration - m_mltProducer->position();
+ if (diff < 0 || diff > duration) doRefresh = false;
delete clip;
+
m_isBlocked = true;
int ct = 0;
Mlt::Filter *filter = clipService.filter(ct);
}
m_isBlocked = false;
- refresh();
+ if (doRefresh) refresh();
}
void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos)
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));
+
+ int clipIndex = trackPlaylist.get_clip_index_at((int) position.frames(m_fps));
+ Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
if (!clip) {
kDebug() << "WARINIG, CANNOT FIND CLIP ON track: " << track << ", AT POS: " << position.frames(m_fps);
return;
}
+
Mlt::Service clipService(clip->get_service());
+ int duration = clip->get_playtime();
+ bool doRefresh = true;
+ // Check if clip is visible in monitor
+ int diff = trackPlaylist.clip_start(clipIndex) + duration - m_mltProducer->position();
+ if (diff < 0 || diff > duration) doRefresh = false;
delete clip;
+
m_isBlocked = true;
int ct = 0;
QList <Mlt::Filter *> filtersList;
}
m_isBlocked = false;
- refresh();
+ if (doRefresh) refresh();
}
bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration)
int new_in = (int)newIn.frames(m_fps);
int new_out = (int)newOut.frames(m_fps) - 1;
if (new_in >= new_out) return false;
+ int old_in = (int)oldIn.frames(m_fps);
+ int old_out = (int)oldOut.frames(m_fps) - 1;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
+ bool doRefresh = true;
+ // Check if clip is visible in monitor
+ int diff = old_out - m_mltProducer->position();
+ if (diff < 0 || diff > old_out - old_in) doRefresh = false;
+ if (doRefresh) {
+ diff = new_out - m_mltProducer->position();
+ if (diff < 0 || diff > new_out - new_in) doRefresh = false;
+ }
+
m_isBlocked++;
mlt_service_lock(service.get_service());
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
QString resource = mlt_properties_get(properties, "mlt_service");
- int old_pos = (int)(oldIn.frames(m_fps) + oldOut.frames(m_fps)) / 2;
+ int old_pos = (int)(old_in + old_out) / 2;
bool found = false;
while (mlt_type == "transition") {
}
mlt_service_unlock(service.get_service());
m_isBlocked--;
- refresh();
+ if (doRefresh) refresh();
//if (m_isBlocked == 0) m_mltConsumer->set("refresh", 1);
return found;
}
mltDeleteTransition(oldTag, a_track, b_track, in, out, xml, false);
mltAddTransition(tag, a_track, b_track, in, out, xml, false);
}
- refresh();
- //mltSavePlaylist();
+
+ if (m_mltProducer->position() > in.frames(m_fps) && m_mltProducer->position() < out.frames(m_fps)) refresh();
}
void Render::mltUpdateTransitionParams(QString type, int a_track, int b_track, GenTime in, GenTime out, QDomElement xml)
QMap<QString, QString>::Iterator it;
QString key;
mlt_properties transproperties = MLT_TRANSITION_PROPERTIES(tr);
+
+ QString currentId = mlt_properties_get(transproperties, "kdenlive_id");
+ if (currentId != xml.attribute("id")) {
+ // The transition ID is not the same, so reset all properties
+ char *tmp = decodedString(xml.attribute("id"));
+ mlt_properties_set(transproperties, "kdenlive_id", tmp);
+ delete[] tmp;
+ // Cleanup previous properties
+ QStringList permanentProps;
+ permanentProps << "factory" << "kdenlive_id" << "mlt_service" << "mlt_type" << "in";
+ permanentProps << "out" << "a_track" << "b_track";
+ for (int i = 0; i < mlt_properties_count(transproperties); i++) {
+ QString propName = mlt_properties_get_name(transproperties, i);
+ if (!propName.startsWith('_') && ! permanentProps.contains(propName)) {
+ tmp = decodedString(propName);
+ mlt_properties_set(transproperties, tmp, "");
+ delete[] tmp;
+ }
+ }
+ }
+
mlt_properties_set_int(transproperties, "force_track", xml.attribute("force_track").toInt());
mlt_properties_set_int(transproperties, "automatic", xml.attribute("automatic", "0").toInt());
- // update the transition id in case it uses the same MLT service but different Kdenlive id
- char *tmp = decodedString(xml.attribute("id"));
- mlt_properties_set(transproperties, "kdenlive_id", tmp);
- delete[] tmp;
+
if (currentBTrack != a_track) {
- mlt_properties_set_int(properties, "a_track", a_track);
+ mlt_properties_set_int(transproperties, "a_track", a_track);
}
for (it = map.begin(); it != map.end(); ++it) {
key = it.key();
Mlt::Transition *transition = new Mlt::Transition(*m_mltProfile, transId);
if (out != GenTime())
transition->set_in_and_out((int) in.frames(m_fps), (int) out.frames(m_fps) - 1);
+
+ if (do_refresh && (m_mltProducer->position() < in.frames(m_fps) || m_mltProducer->position() > out.frames(m_fps))) do_refresh = false;
QMap<QString, QString>::Iterator it;
QString key;
if (xml.attribute("automatic") == "1") transition->set("automatic", 1);