info.endPos = m_dragItem->endPos();
info.startPos = info.endPos - GenTime(2.5);
info.track = m_dragItem->track();
- int transitiontrack = info.track - 1;
+ int transitiontrack = getPreviousVideoTrack(info.track);
slotAddTransition((ClipItem *) m_dragItem, info, transitiontrack);
}
updateSnapPoints(m_dragItem);
}
}
emit clipItemSelected((m_dragItem && m_dragItem->type() == AVWIDGET) ? (ClipItem*) m_dragItem : NULL);
- emit transitionItemSelected((m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) ? (Transition*) m_dragItem : NULL);
if (!collision) {
kDebug() << "//////// NO ITEM FOUND ON CLICK";
void CustomTrackView::updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition) {
Transition *item = getTransitionItemAt((int)pos.frames(m_document->fps()) + 1, track);
+ if (!item) {
+ kWarning() << "Unable to find transition at pos :" << pos.frames(m_document->fps()) << ", ON track: " << track;
+ return;
+ }
m_document->renderer()->mltUpdateTransition(oldTransition.attribute("tag"), transition.attribute("tag"), transition.attribute("transition_btrack").toInt(), m_tracksList.count() - transition.attribute("transition_atrack").toInt(), item->startPos(), item->endPos(), transition);
repaint();
m_document->setModified(true);
m_commandStack->push(command);
//kDebug()<<"/// MOVING TRS FROM: "<<(int)(m_tracksList.count() - m_startPos.y())<<", OFFSET: "<<(int) (m_dragItem->track() - m_startPos.y());
Transition *transition = (Transition *) m_dragItem;
- m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_dragItemInfo.track - m_dragItem->track()), m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
+ m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItem->track()), getPreviousVideoTrack(m_dragItem->track()), m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
}
} else if (m_operationMode == RESIZESTART) {
MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false);
m_commandStack->push(command);
Transition *transition = (Transition *) m_dragItem;
- m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), 0, m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
+ m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItemInfo.track), 0, m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
}
- m_document->renderer()->doRefresh();
+ //m_document->renderer()->doRefresh();
} else if (m_operationMode == RESIZEEND) {
// resize end
if (m_dragItem->type() == AVWIDGET) {
MoveTransitionCommand *command = new MoveTransitionCommand(this, m_dragItemInfo, info, false);
m_commandStack->push(command);
Transition *transition = (Transition *) m_dragItem;
- m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), 0, m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
+ m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_tracksList.count() - m_dragItemInfo.track), (int)(m_tracksList.count() - m_dragItemInfo.track), 0, m_dragItemInfo.startPos, m_dragItemInfo.endPos, info.startPos, info.endPos);
}
- m_document->renderer()->doRefresh();
+ //m_document->renderer()->doRefresh();
}
+ emit transitionItemSelected((m_dragItem && m_dragItem->type() == TRANSITIONWIDGET) ? (Transition*) m_dragItem : NULL);
m_document->setModified(true);
m_operationMode = NONE;
m_dragItem = NULL;
item->resizeEnd((int) end.endPos.frames(m_document->fps()), m_scale);
}
//item->moveTransition(GenTime((int) (endPos.x() - startPos.x()), m_document->fps()));
- m_document->renderer()->mltMoveTransition(item->transitionTag(), m_tracksList.count() - start.track, start.track - end.track, start.startPos, start.endPos, end.startPos, end.endPos);
+ m_document->renderer()->mltMoveTransition(item->transitionTag(), m_tracksList.count() - start.track, m_tracksList.count() - end.track, getPreviousVideoTrack(end.track), start.startPos, start.endPos, end.startPos, end.endPos);
}
void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end) {
#include <mlt++/Mlt.h>
#if LIBAVCODEC_VERSION_MAJOR > 51 || (LIBAVCODEC_VERSION_MAJOR > 50 && LIBAVCODEC_VERSION_MINOR > 54)
- // long_name was added in FFmpeg avcodec version 51.55
- #define ENABLE_FFMPEG_CODEC_DESCRIPTION 1
+// long_name was added in FFmpeg avcodec version 51.55
+#define ENABLE_FFMPEG_CODEC_DESCRIPTION 1
#endif
static void consumer_frame_show(mlt_consumer, Render * self, mlt_frame frame_ptr) {
else
filePropertyMap["type"] = "video";
- QPixmap pix(width, height);
- mlt_image_format format = mlt_image_rgb24a;
- const uint8_t *thumb = frame->get_image(format, width, height);
- QImage image(thumb, width, height, QImage::Format_ARGB32 );
- if (!image.isNull()) {
- pix = pix.fromImage(image);
- } else pix.fill(Qt::black);
+ QPixmap pix(width, height);
+ mlt_image_format format = mlt_image_rgb24a;
+ const uint8_t *thumb = frame->get_image(format, width, height);
+ QImage image(thumb, width, height, QImage::Format_ARGB32);
+ if (!image.isNull()) {
+ pix = pix.fromImage(image);
+ } else pix.fill(Qt::black);
emit replyGetImage(clipId, 0, pix, width, height);
} else if (frame->get_int("test_audio") == 0) {
#if ENABLE_FFMPEG_CODEC_DESCRIPTION
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->long_name;
- else
+ else
#endif
- if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
- filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
+ filePropertyMap["videocodec"] = context->streams[ index ]->codec->codec->name;
}
context = (AVFormatContext *) mlt_properties_get_data(properties, "audio_context", NULL);
if (context != NULL) {
#if ENABLE_FFMPEG_CODEC_DESCRIPTION
if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->long_name)
filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->long_name;
- else
+ else
#endif
- if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
- filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
+ if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name)
+ filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name;
}
#endif
// metadata
if (!filter) {
kDebug() << "WARINIG, FILTER FOR EDITING NOT FOUND, ADDING IT!!!!!";
- // 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);
- }
+ // 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);
+ }
mltAddEffect(track, position, args);
- for (int i = 0; i < filtersList.count(); i++) {
- clipService.attach(*(filtersList.at(i)));
- }
+ for (int i = 0; i < filtersList.count(); i++) {
+ clipService.attach(*(filtersList.at(i)));
+ }
m_isBlocked = false;
return;
void Render::mltMoveEffect(int track, GenTime position, int oldPos, int newPos) {
- kDebug() << "MOVING EFFECT FROM " << oldPos<< ", TO: " << newPos;
+ kDebug() << "MOVING EFFECT FROM " << oldPos << ", TO: " << newPos;
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Filter *filter = clipService.filter(ct);
bool found = false;
if (newPos > oldPos) {
- while (filter) {
- if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
- filter->set("kdenlive_ix", newPos);
- filtersList.append(filter);
- clipService.detach(*filter);
- filter = clipService.filter(ct);
- while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
- filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
- ct++;
- filter = clipService.filter(ct);
- }
- found = true;
- }
- if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
- filtersList.append(filter);
- clipService.detach(*filter);
- } else ct++;
- filter = clipService.filter(ct);
- }
- }
- else {
- while (filter) {
- if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
- filter->set("kdenlive_ix", newPos);
- filtersList.append(filter);
- clipService.detach(*filter);
- } else ct++;
- filter = clipService.filter(ct);
- }
-
- ct = 0;
- filter = clipService.filter(ct);
- while (filter) {
- int pos = QString(filter->get("kdenlive_ix")).toInt();
- if (pos >= newPos) {
- if (pos < oldPos) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
- filtersList.append(filter);
- clipService.detach(*filter);
- } else ct++;
- filter = clipService.filter(ct);
- }
+ while (filter) {
+ if (!found && QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ filter->set("kdenlive_ix", newPos);
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ filter = clipService.filter(ct);
+ while (filter && QString(filter->get("kdenlive_ix")).toInt() <= newPos) {
+ filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() - 1);
+ ct++;
+ filter = clipService.filter(ct);
+ }
+ found = true;
+ }
+ if (filter && QString(filter->get("kdenlive_ix")).toInt() > newPos) {
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+ } else {
+ while (filter) {
+ if (QString(filter->get("kdenlive_ix")).toInt() == oldPos) {
+ filter->set("kdenlive_ix", newPos);
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
+
+ ct = 0;
+ filter = clipService.filter(ct);
+ while (filter) {
+ int pos = QString(filter->get("kdenlive_ix")).toInt();
+ if (pos >= newPos) {
+ if (pos < oldPos) filter->set("kdenlive_ix", QString(filter->get("kdenlive_ix")).toInt() + 1);
+ filtersList.append(filter);
+ clipService.detach(*filter);
+ } else ct++;
+ filter = clipService.filter(ct);
+ }
}
-
+
for (int i = 0; i < filtersList.count(); i++) {
- clipService.attach(*(filtersList.at(i)));
+ clipService.attach(*(filtersList.at(i)));
}
m_isBlocked = false;
//mlt_events_unblock( MLT_PRODUCER_PROPERTIES(clipProducer.get_producer()), NULL );
}
-void Render::mltMoveTransition(QString type, int startTrack, int trackOffset, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut) {
- m_isBlocked = true;
+void Render::mltMoveTransition(QString type, int startTrack, int newTrack, int newTransitionTrack, GenTime oldIn, GenTime oldOut, GenTime newIn, GenTime newOut) {
+
Mlt::Service service(m_mltProducer->parent().get_service());
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
+ mlt_service_lock(service.get_service());
m_mltConsumer->set("refresh", 0);
- mlt_service serv = m_mltProducer->parent().get_service();
+ m_isBlocked = true;
+ mlt_service serv = m_mltProducer->parent().get_service();
mlt_service nextservice = mlt_service_get_producer(serv);
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
if (resource == type && startTrack == currentTrack && currentIn <= old_pos && currentOut >= old_pos) {
mlt_transition_set_in_and_out(tr, new_in, new_out);
- if (trackOffset != 0) {
+ if (newTrack - startTrack != 0) {
+ 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", mlt_transition_get_a_track(tr) + trackOffset);
- mlt_properties_set_int(properties, "b_track", mlt_transition_get_b_track(tr) + trackOffset);
+ 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);
}
-
break;
}
nextservice = mlt_service_producer(nextservice);
+ if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_properties_get(properties, "mlt_type");
resource = mlt_properties_get(properties, "mlt_service");
}
m_isBlocked = false;
+ mlt_service_unlock(service.get_service());
m_mltConsumer->set("refresh", 1);
}
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);
break;
}
nextservice = mlt_service_producer(nextservice);
+ if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_properties_get(properties, "mlt_type");
resource = mlt_properties_get(properties, "mlt_service");
break;
}
nextservice = mlt_service_producer(nextservice);
+ if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_properties_get(properties, "mlt_type");
resource = mlt_properties_get(properties, "mlt_service");