m_mltConsumer->set("resize", 1);
m_mltConsumer->set("window_id", m_winid);
m_mltConsumer->set("terminate_on_pause", 1);
+ m_mltConsumer->set("window_background", decodedString(KdenliveSettings::window_background().name()));
m_mltConsumer->listen("consumer-frame-show", this, (mlt_listener) consumer_frame_show);
m_mltConsumer->set("rescale", "nearest");
filter << "*." + fileType;
filter << "*." + fileType.toUpper();
more = dir.entryList(filter, QDir::Files);
- im.load(url.directory() + "/" + more.at(0));
+ im.load(url.directory() + '/' + more.at(0));
} else im.load(url.path());
//pixmap = im.scaled(width, height);
return pixmap;
more = dir.entryList( QDir::Files );
for ( it = more.begin() ; it != more.end() ; ++it ) {
if ((*it).endsWith("."+fileType, Qt::CaseInsensitive)) {
- if (!im.load(url.directory() + "/" + *it))
- kDebug()<<"++ ERROR LOADIN IMAGE: "<<url.directory() + "/" + *it;
+ if (!im.load(url.directory() + '/' + *it))
+ kDebug()<<"++ ERROR LOADIN IMAGE: "<<url.directory() + '/' + *it;
break;
}
}
}
}
-void Render::getFileProperties(const QDomElement &xml, const QString &clipId) {
+void Render::getFileProperties(const QDomElement &xml, const QString &clipId, bool replaceProducer) {
int height = 50;
int width = (int)(height * m_mltProfile->dar());
QMap < QString, QString > filePropertyMap;
KUrl url = KUrl(xml.attribute("resource", QString::null));
Mlt::Producer *producer = NULL;
if (xml.attribute("type").toInt() == TEXT && !QFile::exists(url.path())) {
- emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
+ emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
return;
}
if (xml.attribute("type").toInt() == COLOR) {
filePropertyMap["fps"] = producer->get("source_fps");
if (frame && frame->is_valid()) {
- filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + "x" + QString::number(frame->get_int("height"));
+ filePropertyMap["frame_size"] = QString::number(frame->get_int("width")) + 'x' + QString::number(frame->get_int("height"));
filePropertyMap["frequency"] = QString::number(frame->get_int("frequency"));
filePropertyMap["channels"] = QString::number(frame->get_int("channels"));
filePropertyMap["aspect_ratio"] = frame->get("aspect_ratio");
pix.fill(Qt::black);
mlt_pool_release(new_image);
- emit replyGetImage(clipId, 0, pix, width, height);
+ emit replyGetImage(clipId, pix);
} else if (frame->get_int("test_audio") == 0) {
QPixmap pixmap = KIcon("audio-x-generic").pixmap(QSize(width, height));
- emit replyGetImage(clipId, 0, pixmap, width, height);
+ emit replyGetImage(clipId, pixmap);
filePropertyMap["type"] = "audio";
}
}
metadataPropertyMap[ name.section(".", 0, -2)] = value;
}
- emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap);
+ emit replyGetFileProperties(clipId, producer, filePropertyMap, metadataPropertyMap, replaceProducer);
kDebug() << "REquested fuile info for: " << url.path();
if (frame) delete frame;
//if (producer) delete producer;
}
/** Create the producer from the Westley QDomDocument */
-QString Render::sceneList() {
+const QString Render::sceneList() {
QString playlist;
Mlt::Consumer westleyConsumer(*m_mltProfile , "westley:kdenlive_playlist");
m_mltProducer->optimise();
// We want a slowmotion producer
double speed = element.attribute("speed", "1.0").toDouble();
QString url = prod->get("resource");
- url.append("?" + QString::number(speed));
+ url.append('?' + QString::number(speed));
Mlt::Producer *slowprod = m_slowmotionProducers.value(url);
if (!slowprod || slowprod->get_producer() == NULL) {
char *tmp = decodedString(url);
delete[] tmp;
QString id = prod->get("id");
if (id.contains('_')) id = id.section('_', 0, 0);
- QString producerid = "slowmotion:" + id + ":" + QString::number(speed);
+ QString producerid = "slowmotion:" + id + ':' + QString::number(speed);
tmp = decodedString(producerid);
slowprod->set("id", tmp);
delete[] tmp;
int blankDuration = trackPlaylist.clip_length(i) - 1;
QString blk;
if (trackPlaylist.is_blank(i)) blk = "(blank)";
- kDebug()<<"CLIP "<<i<<": ("<<blankStart<<"x"<<blankStart + blankDuration<<")"<<blk;
+ kDebug()<<"CLIP "<<i<<": ("<<blankStart<<'x'<<blankStart + blankDuration<<")"<<blk;
}*/
int cutPos = (int) position.frames(m_fps);
int blankDuration = trackPlaylist.clip_length(i) - 1;
QString blk;
if (trackPlaylist.is_blank(i)) blk = "(blank)";
- kDebug()<<"CLIP "<<i<<": ("<<blankStart<<"x"<<blankStart + blankDuration<<")"<<blk;
+ kDebug()<<"CLIP "<<i<<": ("<<blankStart<<'x'<<blankStart + blankDuration<<")"<<blk;
}*/
m_isBlocked = false;
int blankDuration = trackPlaylist.clip_length(i) - 1;
QString blk;
if (trackPlaylist.is_blank(i)) blk = "(blank)";
- kDebug()<<"CLIP "<<i<<": ("<<blankStart<<"x"<<blankStart + blankDuration<<")"<<blk;
+ kDebug()<<"CLIP "<<i<<": ("<<blankStart<<'x'<<blankStart + blankDuration<<")"<<blk;
}*/
if (trackPlaylist.is_blank(clipIndex)) {
int blankDuration = trackPlaylist.clip_length(i) - 1;
QString blk;
if (trackPlaylist.is_blank(i)) blk = "(blank)";
- kDebug()<<"CLIP "<<i<<": ("<<blankStart<<"x"<<blankStart + blankDuration<<")"<<blk;
+ kDebug()<<"CLIP "<<i<<": ("<<blankStart<<'x'<<blankStart + blankDuration<<")"<<blk;
}*/
if (track != 0 && trackPlaylist.count() <= clipIndex) mltCheckLength();
int newLength = 0;
Mlt::Service service(m_mltProducer->parent().get_service());
if (service.type() != tractor_type) kWarning() << "// TRACTOR PROBLEM";
- kDebug() << "Changing clip speed, set in and out: " << info.cropStart.frames(m_fps) << " to " << (info.endPos - info.startPos).frames(m_fps) - 1;
+ //kDebug() << "Changing clip speed, set in and out: " << info.cropStart.frames(m_fps) << " to " << (info.endPos - info.startPos).frames(m_fps) - 1;
Mlt::Tractor tractor(service);
Mlt::Producer trackProducer(tractor.track(info.track));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
int clipLength = trackPlaylist.clip_length(clipIndex);
Mlt::Producer clip(trackPlaylist.get_clip(clipIndex));
- QString serv = clip.parent().get("mlt_service");
- QString id = clip.parent().get("id");
- kDebug() << "CLIP SERVICE: " << clip.parent().get("mlt_service");
+ if (!clip.is_valid() || clip.is_blank()) {
+ // invalid clip
+ return -1;
+ }
+ Mlt::Producer clipparent = clip.parent();
+ if (!clipparent.is_valid() || clipparent.is_blank()) {
+ // invalid clip
+ return -1;
+ }
+ QString serv = clipparent.get("mlt_service");
+ QString id = clipparent.get("id");
+ //kDebug() << "CLIP SERVICE: " << serv;
if (serv == "avformat" && speed != 1.0) {
mlt_service_lock(service.get_service());
- QString url = clip.parent().get("resource");
- url.append("?" + QString::number(speed));
+ QString url = clipparent.get("resource");
+ url.append('?' + QString::number(speed));
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);
delete[] tmp;
- QString producerid = "slowmotion:" + id + ":" + QString::number(speed);
+ QString producerid = "slowmotion:" + id + ':' + QString::number(speed);
tmp = decodedString(producerid);
slowprod->set("id", tmp);
delete[] tmp;
} else if (serv == "framebuffer") {
mlt_service_lock(service.get_service());
- QString url = clip.parent().get("resource");
- url = url.section("?", 0, 0);
- url.append("?" + QString::number(speed));
+ QString url = clipparent.get("resource");
+ url = url.section('?', 0, 0);
+ url.append('?' + QString::number(speed));
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);
delete[] tmp;
- QString producerid = "slowmotion:" + id.section(":", 1, 1) + ":" + QString::number(speed);
+ QString producerid = "slowmotion:" + id.section(':', 1, 1) + ':' + QString::number(speed);
tmp = decodedString(producerid);
slowprod->set("id", tmp);
delete[] tmp;
Mlt::Producer *cut;
if (clipIndex + 1 < trackPlaylist.count() && (info.startPos + newDuration).frames(m_fps) > blankEnd) {
GenTime maxLength = GenTime(blankEnd, m_fps) - info.startPos;
- cut = slowprod->cut((int)(info.cropStart.frames(m_fps)), (int)(info.cropStart.frames(m_fps) + maxLength.frames(m_fps) - 1));
+ 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));
trackPlaylist.insert_at(startPos, *cut, 1);
QString kfr = params.paramValue("keyframes");
if (!kfr.isEmpty()) {
- QStringList keyFrames = kfr.split(";", QString::SkipEmptyParts);
+ QStringList keyFrames = kfr.split(';', QString::SkipEmptyParts);
kDebug() << "// ADDING KEYFRAME EFFECT: " << params.paramValue("keyframes");
char *starttag = decodedString(params.paramValue("starttag", "start"));
char *endtag = decodedString(params.paramValue("endtag", "end"));
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();
+ 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++) {
int blankDuration = trackPlaylist.clip_length(i) - 1;
QString blk;
if (trackPlaylist.is_blank(i)) blk = "(blank)";
- kDebug()<<"CLIP "<<i<<": ("<<blankStart<<"x"<<blankStart + blankDuration<<")"<<blk;
+ kDebug()<<"CLIP "<<i<<": ("<<blankStart<<'x'<<blankStart + blankDuration<<")"<<blk;
}*/
if (trackPlaylist.is_blank_at((int) info.startPos.frames(m_fps))) {
int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
int newDuration = (int) clipDuration.frames(m_fps) - 1;
trackPlaylist.resize_clip(clipIndex, previousStart, newDuration + previousStart);
- //trackPlaylist.consolidate_blanks(0);
+ trackPlaylist.consolidate_blanks(0);
// skip to next clip
clipIndex++;
int diff = newDuration - previousDuration;
- kDebug() << "//////// RESIZE CLIP: " << clipIndex << "( pos: " << info.startPos.frames(25) << "), DIFF: " << diff << ", CURRENT DUR: " << previousDuration << ", NEW DUR: " << newDuration;
+ kDebug() << "//////// RESIZE CLIP: " << clipIndex << "( pos: " << info.startPos.frames(25) << "), DIFF: " << diff << ", CURRENT DUR: " << previousDuration << ", NEW DUR: " << newDuration << ", IX: " << clipIndex << ", MAX: " << trackPlaylist.count();
if (diff > 0) {
// clip was made longer, trim next blank if there is one.
- if (trackPlaylist.is_blank(clipIndex)) {
- int blankStart = trackPlaylist.clip_start(clipIndex);
- int blankDuration = trackPlaylist.clip_length(clipIndex) - 1;
- if (diff - blankDuration == 1) {
- trackPlaylist.remove(clipIndex);
- } else trackPlaylist.resize_clip(clipIndex, blankStart, blankStart + blankDuration - diff);
- } else {
- kDebug() << "/// RESIZE ERROR, NXT CLIP IS NOT BLK: " << clipIndex;
+ if (clipIndex < trackPlaylist.count()) {
+ // If this is not the last clip in playlist
+ if (trackPlaylist.is_blank(clipIndex)) {
+ int blankStart = trackPlaylist.clip_start(clipIndex);
+ int blankDuration = trackPlaylist.clip_length(clipIndex) - 1;
+ if (diff > blankDuration) kDebug() << "// ERROR blank clip is not large enough to get back required space!!!";
+ if (diff - blankDuration == 1) {
+ trackPlaylist.remove(clipIndex);
+ } else trackPlaylist.remove_region(blankStart, diff - 1);
+ } else {
+ kDebug() << "/// RESIZE ERROR, NXT CLIP IS NOT BLK: " << clipIndex;
+ }
}
} else trackPlaylist.insert_blank(clipIndex, 0 - diff - 1);
refresh();
}
+
+bool Render::mltResizeClipCrop(ItemInfo info, GenTime diff) {
+ Mlt::Service service(m_mltProducer->parent().get_service());
+ int frameOffset = (int) diff.frames(m_fps);
+ Mlt::Tractor tractor(service);
+ Mlt::Producer trackProducer(tractor.track(info.track));
+ Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+ if (trackPlaylist.is_blank_at(info.startPos.frames(m_fps))) {
+ kDebug() << "//////// ERROR RSIZING BLANK CLIP!!!!!!!!!!!";
+ return false;
+ }
+ mlt_service_lock(service.get_service());
+ int clipIndex = trackPlaylist.get_clip_index_at(info.startPos.frames(m_fps));
+ Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
+ if (clip == NULL) {
+ kDebug() << "//////// ERROR RSIZING NULL CLIP!!!!!!!!!!!";
+ mlt_service_unlock(service.get_service());
+ return false;
+ }
+ int previousStart = clip->get_in();
+ int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
+ m_isBlocked = true;
+ trackPlaylist.resize_clip(clipIndex, previousStart + frameOffset, previousStart + previousDuration + frameOffset);
+ m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
+ m_mltConsumer->set("refresh", 1);
+ return true;
+}
+
bool Render::mltResizeClipStart(ItemInfo info, GenTime diff) {
//kDebug() << "//////// RSIZING CLIP from: "<<info.startPos.frames(25)<<" to "<<diff.frames(25);
Mlt::Service service(m_mltProducer->parent().get_service());
}
mlt_service_lock(service.get_service());
int clipIndex = trackPlaylist.get_clip_index_at(info.startPos.frames(m_fps));
- /*int previousStart = trackPlaylist.clip_start(clipIndex);
- int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;*/
- //kDebug() << " ** RESIZING CLIP START:" << clipIndex << " on track:" << track << ", mid pos: " << pos.frames(25) << ", moving: " << moveFrame << ", in: " << in.frames(25) << ", out: " << out.frames(25);
Mlt::Producer *clip = trackPlaylist.get_clip(clipIndex);
if (clip == NULL) {
kDebug() << "//////// ERROR RSIZING NULL CLIP!!!!!!!!!!!";
mlt_service_unlock(service.get_service());
return false;
}
- //m_mltConsumer->set("refresh", 0);
int previousStart = clip->get_in();
int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
m_isBlocked = true;
void 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;
+ }
kDebug() << "NEW PROD ID: " << prod->get("id");
m_mltConsumer->set("refresh", 0);
kDebug() << "// TRYING TO UPDATE CLIP at: " << pos << ", TK: " << track;
if (resource == type && startTrack == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
mlt_transition_set_in_and_out(tr, new_in, new_out);
if (newTrack - startTrack != 0) {
- kDebug() << "///// TRANSITION CHANGE TRACK. CUrrent (b): " << currentTrack << "x" << mlt_transition_get_a_track(tr) << ", NEw: " << newTrack << "x" << newTransitionTrack;
+ kDebug() << "///// TRANSITION CHANGE TRACK. CUrrent (b): " << currentTrack << 'x' << mlt_transition_get_a_track(tr) << ", NEw: " << newTrack << 'x' << newTransitionTrack;
mlt_properties properties = MLT_TRANSITION_PROPERTIES(tr);
mlt_properties_set_int(properties, "a_track", newTransitionTrack);
mlt_properties_set_int(properties, "b_track", newTrack);
- //kDebug() << "set new start & end :" << new_in << new_out<< "TR OFFSET: "<<trackOffset<<", TRACKS: "<<mlt_transition_get_a_track(tr)<<"x"<<mlt_transition_get_b_track(tr);
+ //kDebug() << "set new start & end :" << new_in << new_out<< "TR OFFSET: "<<trackOffset<<", TRACKS: "<<mlt_transition_get_a_track(tr)<<'x'<<mlt_transition_get_b_track(tr);
}
break;
}
int currentIn = (int) mlt_transition_get_in(tr);
int currentOut = (int) mlt_transition_get_out(tr);
- // kDebug()<<"Looking for transition : " << currentIn <<"x"<<currentOut<< ", OLD oNE: "<<in_pos<<"x"<<out_pos;
+ // kDebug()<<"Looking for transition : " << currentIn <<'x'<<currentOut<< ", OLD oNE: "<<in_pos<<'x'<<out_pos;
if (resource == type && b_track == currentTrack && currentIn == in_pos && currentOut == out_pos) {
QMap<QString, QString> map = mltGetTransitionParamsFromXml(xml);
//map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
}
- if (e.attribute("namedesc").contains(";")) {
+ if (e.attribute("namedesc").contains(';')) {
QString format = e.attribute("format");
QStringList separators = format.split("%d", QString::SkipEmptyParts);
QStringList values = e.attribute("value").split(QRegExp("[,:;x]"));
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
QString resource = mlt_properties_get(properties, "mlt_service");
- kDebug() << "// resize transpar from: " << oldStart << ", TO: " << newStart << "x" << newEnd << ", " << track << ", " << id;
+ kDebug() << "// resize transpar from: " << oldStart << ", TO: " << newStart << 'x' << newEnd << ", " << track << ", " << id;
while (mlt_type == "transition") {
mlt_transition tr = (mlt_transition) nextservice;
int currentTrack = mlt_transition_get_b_track(tr);
int currentIn = (int) mlt_transition_get_in(tr);
//mlt_properties props = MLT_TRANSITION_PROPERTIES(tr);
int transitionId = QString(mlt_properties_get(properties, "transparency")).toInt();
- kDebug() << "// resize transpar current in: " << currentIn << ", Track: " << currentTrack << ", id: " << id << "x" << transitionId ;
+ kDebug() << "// resize transpar current in: " << currentIn << ", Track: " << currentTrack << ", id: " << id << 'x' << transitionId ;
if (resource == "composite" && track == currentTrack && currentIn == oldStart && transitionId == id) {
- kDebug() << " / / / / /RESIZE TRANS TO: " << newStart << "x" << newEnd;
+ kDebug() << " / / / / /RESIZE TRANS TO: " << newStart << 'x' << newEnd;
mlt_transition_set_in_and_out(tr, newStart, newEnd);
break;
}
int currentOut = (int) mlt_transition_get_out(tr);
//mlt_properties properties = MLT_TRANSITION_PROPERTIES(tr);
int transitionId = QString(mlt_properties_get(properties, "transparency")).toInt();
- //kDebug()<<" + TRANSITION "<<id<<" == "<<transitionId<<", START TMIE: "<<currentIn<<", LOOK FR: "<<startTime<<", TRACK: "<<currentTrack<<"x"<<startTrack;
+ //kDebug()<<" + TRANSITION "<<id<<" == "<<transitionId<<", START TMIE: "<<currentIn<<", LOOK FR: "<<startTime<<", TRACK: "<<currentTrack<<'x'<<startTrack;
if (resource == "composite" && transitionId == id && startTime == currentIn && startTrack == currentTrack) {
kDebug() << "//////MOVING";
mlt_transition_set_in_and_out(tr, endTime, endTime + currentOut - currentIn);
}
tractor.removeChild(track);
setSceneList(doc.toString(), m_framePosition);
+ mltCheckLength();
return;
blockSignals(true);