Commit 504a5f2b authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix cache thumbs incorrectly using full res profile

parent f8ecc140
Pipeline #15895 passed with stage
in 13 minutes and 38 seconds
...@@ -499,7 +499,10 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl ...@@ -499,7 +499,10 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl
emit refreshPropertiesPanel(); emit refreshPropertiesPanel();
if (m_clipType == ClipType::AV || m_clipType == ClipType::Video || m_clipType == ClipType::Playlist) { if (m_clipType == ClipType::AV || m_clipType == ClipType::Video || m_clipType == ClipType::Playlist) {
QTimer::singleShot(1000, this, [this]() { QTimer::singleShot(1000, this, [this]() {
pCore->jobManager()->startJob<CacheJob>({m_binId}, -1, QString()); int loadjobId;
if (!pCore->jobManager()->hasPendingJob(m_binId, AbstractClipJob::CACHEJOB, &loadjobId)) {
pCore->jobManager()->startJob<CacheJob>({m_binId}, -1, QString());
}
}); });
} }
replaceInTimeline(); replaceInTimeline();
...@@ -1493,8 +1496,7 @@ void ProjectClip::getThumbFromPercent(int percent) ...@@ -1493,8 +1496,7 @@ void ProjectClip::getThumbFromPercent(int percent)
} else { } else {
// Generate percent thumbs // Generate percent thumbs
int id; int id;
if (pCore->jobManager()->hasPendingJob(m_binId, AbstractClipJob::CACHEJOB, &id)) { if (!pCore->jobManager()->hasPendingJob(m_binId, AbstractClipJob::CACHEJOB, &id)) {
} else {
pCore->jobManager()->startJob<CacheJob>({m_binId}, -1, QString(), 50); pCore->jobManager()->startJob<CacheJob>({m_binId}, -1, QString(), 50);
} }
} }
......
...@@ -205,8 +205,7 @@ void ProjectSubClip::getThumbFromPercent(int percent) ...@@ -205,8 +205,7 @@ void ProjectSubClip::getThumbFromPercent(int percent)
} else { } else {
// Generate percent thumbs // Generate percent thumbs
int id; int id;
if (pCore->jobManager()->hasPendingJob(m_parentClipId, AbstractClipJob::CACHEJOB, &id)) { if (!pCore->jobManager()->hasPendingJob(m_parentClipId, AbstractClipJob::CACHEJOB, &id)) {
} else {
pCore->jobManager()->startJob<CacheJob>({m_parentClipId}, -1, QString(), 25, m_inPoint, m_outPoint); pCore->jobManager()->startJob<CacheJob>({m_parentClipId}, -1, QString(), 25, m_inPoint, m_outPoint);
} }
} }
......
...@@ -756,13 +756,13 @@ Mlt::Profile *Core::thumbProfile() ...@@ -756,13 +756,13 @@ Mlt::Profile *Core::thumbProfile()
QMutexLocker lck(&m_thumbProfileMutex); QMutexLocker lck(&m_thumbProfileMutex);
if (!m_thumbProfile) { if (!m_thumbProfile) {
m_thumbProfile = std::make_unique<Mlt::Profile>(m_currentProfile.toStdString().c_str()); m_thumbProfile = std::make_unique<Mlt::Profile>(m_currentProfile.toStdString().c_str());
/*double factor = 144. / m_thumbProfile->height(); double factor = 144. / m_thumbProfile->height();
m_thumbProfile->set_height(144); m_thumbProfile->set_height(144);
int width = m_thumbProfile->width() * factor + 0.5; int width = m_thumbProfile->width() * factor + 0.5;
if (width % 2 > 0) { if (width % 2 > 0) {
width ++; width ++;
} }
m_thumbProfile->set_width(width);*/ m_thumbProfile->set_width(width);
} }
return m_thumbProfile.get(); return m_thumbProfile.get();
} }
......
...@@ -89,8 +89,11 @@ bool CacheJob::startJob() ...@@ -89,8 +89,11 @@ bool CacheJob::startJob()
m_thumbsCount = duration / 10; m_thumbsCount = duration / 10;
} }
std::set<int> frames; std::set<int> frames;
for (int i = 1; i <= m_thumbsCount; ++i) { double steps = qMax(pCore->getCurrentFps(), (double)duration / m_thumbsCount);
frames.insert(m_inPoint + (duration * i / m_thumbsCount)); int pos = m_inPoint;
for (int i = 1; i <= m_thumbsCount && pos <= duration; ++i) {
frames.insert(pos);
pos = m_inPoint + (steps * i);
} }
int size = (int)frames.size(); int size = (int)frames.size();
int count = 0; int count = 0;
......
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