Commit 591c44a1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Cleanup, fix timeline thumbnails for images/titles

parent 34495ee8
......@@ -257,6 +257,11 @@ void ProjectClip::setThumbnail(QImage img)
bin()->emitItemUpdated(this);
}
QPixmap ProjectClip::thumbnail(int width, int height)
{
return m_thumbnail.pixmap(width, height);
}
void ProjectClip::setProducer(ClipController *controller, bool replaceProducer)
{
if (!replaceProducer && m_controller) {
......
......@@ -127,6 +127,7 @@ public:
/** @brief Sets thumbnail for this clip. */
void setThumbnail(QImage);
QPixmap thumbnail(int width, int height);
/** @brief Sets the MLT producer associated with this clip
* @param producer The producer
......
......@@ -107,7 +107,6 @@ Render::Render(Kdenlive::MonitorId rendererName, BinController *binController, G
connect(m_binController, SIGNAL(createThumb(QDomElement,QString,int)), this, SLOT(getFileProperties(QDomElement,QString,int)));
connect(m_binController, SIGNAL(setDocumentNotes(QString)), this, SIGNAL(setDocumentNotes(QString)));
}
//connect(this, SIGNAL(mltFrameReceived(Mlt::Frame*)), this, SLOT(showFrame(Mlt::Frame*)), Qt::UniqueConnection);
}
Render::~Render()
......@@ -1264,39 +1263,6 @@ int Render::setSceneList(QString playlist, int position)
if (m_mltProducer) {
m_mltProducer->set_speed(0);
/*Mlt::Service service(m_mltProducer->parent().get_service());
service.lock();
if (service.type() == tractor_type) {
Mlt::Tractor tractor(service);
Mlt::Field *field = tractor.field();
mlt_service nextservice = mlt_service_get_producer(service.get_service());
mlt_service nextservicetodisconnect;
mlt_properties properties = MLT_SERVICE_PROPERTIES(nextservice);
QString mlt_type = mlt_properties_get(properties, "mlt_type");
QString resource = mlt_properties_get(properties, "mlt_service");
// Delete all transitions
while (mlt_type == "transition") {
nextservicetodisconnect = nextservice;
nextservice = mlt_service_producer(nextservice);
mlt_field_disconnect_service(field->get_field(), nextservicetodisconnect);
if (nextservice == NULL) break;
properties = MLT_SERVICE_PROPERTIES(nextservice);
mlt_type = mlt_properties_get(properties, "mlt_type");
resource = mlt_properties_get(properties, "mlt_service");
}
for (int trackNb = tractor.count() - 1; trackNb >= 0; --trackNb) {
Mlt::Producer trackProducer(tractor.track(trackNb));
Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
if (trackPlaylist.type() == playlist_type) trackPlaylist.clear();
}
delete field;
}
service.unlock();*/
qDeleteAll(m_slowmotionProducers.values());
m_slowmotionProducers.clear();
......@@ -1333,7 +1299,6 @@ int Render::setSceneList(QString playlist, int position)
}
blockSignals(false);
Mlt::Tractor tractor(service);
qDebug()<<"****************************** BUILDING PLAYLIST ***********************";
Mlt::Properties retainList((mlt_properties) tractor.get_data("xml_retain"));
if (retainList.is_valid() && retainList.get_data(m_binController->binPlaylistId().toUtf8().constData())) {
Mlt::Playlist playlist((mlt_playlist) retainList.get_data(m_binController->binPlaylistId().toUtf8().constData()));
......@@ -1371,15 +1336,14 @@ int Render::setSceneList(QString playlist, int position)
// pass basic info, the others (folder, etc) will be taken from the producer itself
info.clipId = id;
info.replaceProducer = true;
qDebug()<<" // / PRODUCER READY FOR: "<<id;
emit gotFileProperties(info, m_binController->getController(id));
}
//delete original;
}
return error;
////qDebug()<<"// SETSCN LST, POS: "<<position;
//if (position != 0) emit rendererPosition(position);
if (position != 0) emit rendererPosition(position);
return error;
}
......@@ -1903,29 +1867,6 @@ void Render::checkFrameNumber(int pos)
}
}
void Render::showFrame(Mlt::Frame* frame)
{
int currentPos = m_mltConsumer->position();
if (currentPos == requestedSeekPosition) requestedSeekPosition = SEEK_INACTIVE;
emit rendererPosition(currentPos);
if (frame->is_valid()) {
mlt_image_format format = mlt_image_rgb24;
int width = 0;
int height = 0;
const uchar* image = frame->get_image(format, width, height);
QImage qimage(width, height, QImage::Format_RGB888); //Format_ARGB32_Premultiplied);
memcpy(qimage.scanLine(0), image, width * height * 3);
if (analyseAudio) showAudio(*frame);
delete frame;
emit showImageSignal(qimage);
if (sendFrameForAnalysis) {
emit frameUpdated(qimage);
}
} else delete frame;
showFrameSemaphore.release();
emit checkSeeking();
}
void Render::emitFrameUpdated(QImage img)
{
emit frameUpdated(img);
......
......@@ -400,7 +400,6 @@ private slots:
void processFileProperties();
/** @brief A clip with multiple video streams was found, ask what to do. */
void slotMultiStreamProducerFound(const QString &path, QList<int> audio_list, QList<int> video_list, stringMap data);
void showFrame(Mlt::Frame *);
void slotCheckSeeking();
signals:
......
......@@ -62,7 +62,7 @@ ClipItem::ClipItem(ProjectClip *clip, const ItemInfo& info, double fps, double s
setZValue(2);
m_effectList = EffectsList(true);
FRAME_SIZE = frame_width;
qDebug()<<" + + +LOADING CLP on TK: "<<info.track<<" / THEIGHT; "<<KdenliveSettings::trackheight();
//qDebug()<<" + + +LOADING CLP on TK: "<<info.track<<" / THEIGHT; "<<KdenliveSettings::trackheight();
setRect(0, 0, (info.endPos - info.startPos).frames(m_fps) - 0.02, (double) itemHeight());
setPos(info.startPos.frames(m_fps), (double)(info.track * KdenliveSettings::trackheight()) + 1 + itemOffset());
// set speed independent info
......@@ -108,6 +108,7 @@ ClipItem::ClipItem(ProjectClip *clip, const ItemInfo& info, double fps, double s
m_baseColor = m_binClip->getProducerColorProperty("resource");
} else if (m_clipType == Image || m_clipType == Text) {
m_baseColor = QColor(141, 166, 215);
m_startPix = m_binClip->thumbnail(rect().height(), frame_width);
//connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int,QImage)), this, SLOT(slotThumbReady(int,QImage)));
} else if (m_clipType == Audio) {
m_baseColor = QColor(141, 215, 166);
......@@ -2053,7 +2054,6 @@ void ClipItem::slotRefreshClip()
bool ClipItem::needsDuplicate() const
{
qDebug()<<"// NEEDS DUP: "<<m_clipType;
if (m_clipType != AV && m_clipType != Audio && m_clipType != Playlist) {
return false;
}
......
......@@ -166,6 +166,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, Timeline *timeline, CustomTra
connect(m_document->renderer(), SIGNAL(replaceTimelineProducer(QString)), this, SLOT(slotReplaceTimelineProducer(QString)));
connect(m_document->renderer(), SIGNAL(updateTimelineProducer(QString)), this, SLOT(slotUpdateTimelineProducer(QString)));
connect(m_document->renderer(), SIGNAL(rendererPosition(int)), this, SLOT(setCursorPos(int)));
scale(1, 1);
setAlignment(Qt::AlignLeft | Qt::AlignTop);
......@@ -6116,14 +6117,14 @@ void CustomTrackView::slotUpdateAllThumbs()
if (item && item->isEnabled() && item->clipType() != Color && item->clipType() != Audio) {
// Check if we have a cached thumbnail
if (item->clipType() == Image || item->clipType() == Text) {
QString thumb = thumbBase + item->getBinHash() + "_0.png";
QString thumb = thumbBase + item->getBinHash() + "#0.png";
if (QFile::exists(thumb)) {
QPixmap pix(thumb);
if (pix.isNull()) QFile::remove(thumb);
item->slotSetStartThumb(pix);
}
} else {
QString startThumb = thumbBase + item->getBinHash() + '_';
QString startThumb = thumbBase + item->getBinHash() + '#';
QString endThumb = startThumb;
startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
......
......@@ -123,6 +123,8 @@ Timeline::Timeline(KdenliveDoc *doc, const QList<QAction *> &actions, bool *ok,
connect(m_trackview->horizontalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(slotUpdateVerticalScroll(int,int)));
connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
connect(m_trackview, SIGNAL(doTrackLock(int,bool)), this, SLOT(slotChangeTrackLock(int,bool)));
m_trackview->slotUpdateAllThumbs();
slotChangeZoom(m_doc->zoom().x(), m_doc->zoom().y());
slotSetZone(m_doc->zone(), false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment