Changeset View
Changeset View
Standalone View
Standalone View
src/bin/projectclip.cpp
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | |||||
133 | 133 | | |||
134 | ProjectClip::~ProjectClip() | 134 | ProjectClip::~ProjectClip() | ||
135 | { | 135 | { | ||
136 | // controller is deleted in bincontroller | 136 | // controller is deleted in bincontroller | ||
137 | m_thumbMutex.lock(); | 137 | m_thumbMutex.lock(); | ||
138 | m_requestedThumbs.clear(); | 138 | m_requestedThumbs.clear(); | ||
139 | m_thumbMutex.unlock(); | 139 | m_thumbMutex.unlock(); | ||
140 | m_thumbThread.waitForFinished(); | 140 | m_thumbThread.waitForFinished(); | ||
141 | delete m_thumbsProducer; | | |||
142 | audioFrameCache.clear(); | 141 | audioFrameCache.clear(); | ||
143 | // delete all timeline producers | 142 | // delete all timeline producers | ||
144 | std::map<int, std::shared_ptr<Mlt::Producer>>::iterator itr = m_timelineProducers.begin(); | 143 | std::map<int, std::shared_ptr<Mlt::Producer>>::iterator itr = m_timelineProducers.begin(); | ||
145 | while (itr != m_timelineProducers.end()) { | 144 | while (itr != m_timelineProducers.end()) { | ||
146 | itr = m_timelineProducers.erase(itr); | 145 | itr = m_timelineProducers.erase(itr); | ||
147 | } | 146 | } | ||
148 | } | 147 | } | ||
149 | 148 | | |||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Line(s) | 336 | { | |||
361 | if (auto ptr = m_model.lock()) { | 360 | if (auto ptr = m_model.lock()) { | ||
362 | std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this())); | 361 | std::static_pointer_cast<ProjectItemModel>(ptr)->onItemUpdated(std::static_pointer_cast<ProjectClip>(shared_from_this())); | ||
363 | } | 362 | } | ||
364 | // Make sure we have a hash for this clip | 363 | // Make sure we have a hash for this clip | ||
365 | getFileHash(); | 364 | getFileHash(); | ||
366 | return true; | 365 | return true; | ||
367 | } | 366 | } | ||
368 | 367 | | |||
369 | Mlt::Producer *ProjectClip::thumbProducer() | 368 | std::shared_ptr<Mlt::Producer> ProjectClip::thumbProducer() | ||
370 | { | 369 | { | ||
371 | QMutexLocker locker(&m_producerMutex); | 370 | QMutexLocker locker(&m_producerMutex); | ||
372 | if (m_thumbsProducer) { | 371 | if (m_thumbsProducer) { | ||
373 | return m_thumbsProducer; | 372 | return m_thumbsProducer; | ||
374 | } | 373 | } | ||
375 | if (clipType() == ClipType::Unknown) { | 374 | if (clipType() == ClipType::Unknown) { | ||
376 | return nullptr; | 375 | return nullptr; | ||
377 | } | 376 | } | ||
378 | std::shared_ptr<Mlt::Producer> prod = originalProducer(); | 377 | std::shared_ptr<Mlt::Producer> prod = originalProducer(); | ||
379 | if (!prod->is_valid()) { | 378 | if (!prod->is_valid()) { | ||
380 | return nullptr; | 379 | return nullptr; | ||
381 | } | 380 | } | ||
382 | Clip clip(*prod.get()); | 381 | Clip clip(*prod.get()); | ||
383 | if (KdenliveSettings::gpu_accel()) { | 382 | if (KdenliveSettings::gpu_accel()) { | ||
384 | m_thumbsProducer = clip.softClone(ClipController::getPassPropertiesList()); | 383 | m_thumbsProducer = std::make_shared<Mlt::Producer>(clip.softClone(ClipController::getPassPropertiesList())); | ||
385 | Mlt::Filter scaler(*prod->profile(), "swscale"); | 384 | Mlt::Filter scaler(*prod->profile(), "swscale"); | ||
386 | Mlt::Filter converter(*prod->profile(), "avcolor_space"); | 385 | Mlt::Filter converter(*prod->profile(), "avcolor_space"); | ||
387 | m_thumbsProducer->attach(scaler); | 386 | m_thumbsProducer->attach(scaler); | ||
388 | m_thumbsProducer->attach(converter); | 387 | m_thumbsProducer->attach(converter); | ||
389 | } else { | 388 | } else { | ||
390 | m_thumbsProducer = clip.clone(); | 389 | m_thumbsProducer = std::make_shared<Mlt::Producer>(clip.clone()); | ||
391 | } | 390 | } | ||
392 | return m_thumbsProducer; | 391 | return m_thumbsProducer; | ||
393 | } | 392 | } | ||
394 | 393 | | |||
395 | std::shared_ptr<Mlt::Producer> ProjectClip::timelineProducer(PlaylistState::ClipState state, int track) | 394 | std::shared_ptr<Mlt::Producer> ProjectClip::timelineProducer(PlaylistState::ClipState state, int track) | ||
396 | { | 395 | { | ||
397 | if (!m_service.startsWith(QLatin1String("avformat"))) { | 396 | if (!m_service.startsWith(QLatin1String("avformat"))) { | ||
398 | std::shared_ptr<Mlt::Producer>prod(originalProducer()->cut()); | 397 | std::shared_ptr<Mlt::Producer>prod(originalProducer()->cut()); | ||
▲ Show 20 Lines • Show All 328 Lines • ▼ Show 20 Line(s) | 718 | { | |||
727 | if (!m_thumbThread.isRunning()) { | 726 | if (!m_thumbThread.isRunning()) { | ||
728 | m_thumbThread = QtConcurrent::run(this, &ProjectClip::doExtractImage); | 727 | m_thumbThread = QtConcurrent::run(this, &ProjectClip::doExtractImage); | ||
729 | } | 728 | } | ||
730 | } | 729 | } | ||
731 | 730 | | |||
732 | void ProjectClip::doExtractImage() | 731 | void ProjectClip::doExtractImage() | ||
733 | { | 732 | { | ||
734 | // TODO refac: we can probably move that into a ThumbJob | 733 | // TODO refac: we can probably move that into a ThumbJob | ||
735 | Mlt::Producer *prod = thumbProducer(); | 734 | std::shared_ptr<Mlt::Producer> prod = thumbProducer(); | ||
736 | if (prod == nullptr || !prod->is_valid()) { | 735 | if (prod == nullptr || !prod->is_valid()) { | ||
737 | return; | 736 | return; | ||
738 | } | 737 | } | ||
739 | int frameWidth = 150 * prod->profile()->dar() + 0.5; | 738 | int frameWidth = 150 * prod->profile()->dar() + 0.5; | ||
740 | bool ok = false; | 739 | bool ok = false; | ||
741 | auto ptr = m_model.lock(); | 740 | auto ptr = m_model.lock(); | ||
742 | Q_ASSERT(ptr); | 741 | Q_ASSERT(ptr); | ||
743 | QDir thumbFolder = pCore->currentDoc()->getCacheDir(CacheThumbs, &ok); | 742 | QDir thumbFolder = pCore->currentDoc()->getCacheDir(CacheThumbs, &ok); | ||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |