Commit 251f545c authored by Gustavo Pichorim Boiko's avatar Gustavo Pichorim Boiko
Browse files

Use the thumb producer form project clip in ThumbJob

Summary:
Update the ProjectClip::thumbProducer to be a std::shared_ptr and use it in the
ThumbJob.

Using the originalProducer() causes crashes when using movit acceleration.

Test Plan:
- Enable movit
- Run kdenlive
- Add a JPEG image to the project bin

Reviewers: alcinos, mardelle

Reviewed By: alcinos, mardelle

Differential Revision: https://phabricator.kde.org/D8808
parent dd4128b4
......@@ -138,7 +138,6 @@ ProjectClip::~ProjectClip()
m_requestedThumbs.clear();
m_thumbMutex.unlock();
m_thumbThread.waitForFinished();
delete m_thumbsProducer;
audioFrameCache.clear();
// delete all timeline producers
std::map<int, std::shared_ptr<Mlt::Producer>>::iterator itr = m_timelineProducers.begin();
......@@ -366,7 +365,7 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl
return true;
}
Mlt::Producer *ProjectClip::thumbProducer()
std::shared_ptr<Mlt::Producer> ProjectClip::thumbProducer()
{
QMutexLocker locker(&m_producerMutex);
if (m_thumbsProducer) {
......@@ -381,13 +380,13 @@ Mlt::Producer *ProjectClip::thumbProducer()
}
Clip clip(*prod.get());
if (KdenliveSettings::gpu_accel()) {
m_thumbsProducer = clip.softClone(ClipController::getPassPropertiesList());
m_thumbsProducer = std::make_shared<Mlt::Producer>(clip.softClone(ClipController::getPassPropertiesList()));
Mlt::Filter scaler(*prod->profile(), "swscale");
Mlt::Filter converter(*prod->profile(), "avcolor_space");
m_thumbsProducer->attach(scaler);
m_thumbsProducer->attach(converter);
} else {
m_thumbsProducer = clip.clone();
m_thumbsProducer = std::make_shared<Mlt::Producer>(clip.clone());
}
return m_thumbsProducer;
}
......@@ -732,7 +731,7 @@ void ProjectClip::slotExtractImage(const QList<int> &frames)
void ProjectClip::doExtractImage()
{
// TODO refac: we can probably move that into a ThumbJob
Mlt::Producer *prod = thumbProducer();
std::shared_ptr<Mlt::Producer> prod = thumbProducer();
if (prod == nullptr || !prod->is_valid()) {
return;
}
......
......@@ -140,7 +140,7 @@ public:
bool isReady() const;
/** @brief Returns this clip's producer. */
Mlt::Producer *thumbProducer();
std::shared_ptr< Mlt::Producer > thumbProducer();
/** @brief Recursively disable/enable bin effects. */
void setBinEffectsEnabled(bool enabled) override;
......@@ -223,7 +223,7 @@ private:
const QString getFileHash();
/** @brief Store clip url temporarily while the clip controller has not been created. */
QString m_temporaryUrl;
Mlt::Producer *m_thumbsProducer;
std::shared_ptr<Mlt::Producer> m_thumbsProducer;
QMutex m_producerMutex;
QMutex m_thumbMutex;
QFuture<void> m_thumbThread;
......
......@@ -72,7 +72,7 @@ bool ThumbJob::startJob()
// Don't create thumbnail for audio clips
return true;
}
m_prod = m_binClip->originalProducer();
m_prod = m_binClip->thumbProducer();
if ((m_prod == nullptr) || !m_prod->is_valid()) {
return 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