added option to disable multithreading on images

This commit is contained in:
itsmattkc
2019-01-07 11:37:37 +11:00
parent 589c3e9df1
commit fee2c457f2
7 changed files with 230 additions and 201 deletions
+8 -4
View File
@@ -13,6 +13,7 @@
#include "panels/panels.h"
#include "panels/viewer.h"
#include "project/media.h"
#include "io/config.h"
#include "debug.h"
extern "C" {
@@ -458,7 +459,9 @@ void cache_video_worker(Clip* c, long playhead) {
if (c->multithreaded && c->cacher->interrupt) return; // abort
AVFrame* send_frame = c->frame;
// qint64 time = QDateTime::currentMSecsSinceEpoch();
read_ret = (c->use_existing_frame) ? 0 : retrieve_next_frame(c, send_frame);
// dout << QDateTime::currentMSecsSinceEpoch() - time;
c->use_existing_frame = false;
if (read_ret >= 0) {
bool send_it = true;
@@ -677,10 +680,11 @@ void open_clip_worker(Clip* clip) {
clip->opts = NULL;
// optimized decoding settings
if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_PSD) {
if ((clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF &&
clip->stream->codecpar->codec_id != AV_CODEC_ID_PSD)
|| !config.disable_multithreading_for_images) {
av_dict_set(&clip->opts, "threads", "auto", 0);
}
if (clip->stream->codecpar->codec_id == AV_CODEC_ID_H264) {
+6 -3
View File
@@ -48,7 +48,7 @@ void open_clip(Clip* clip, bool multithreaded) {
// maybe keep cacher instance in memory while clip exists for performance?
clip->cacher = new Cacher(clip);
QObject::connect(clip->cacher, SIGNAL(finished()), clip->cacher, SLOT(deleteLater()));
clip->cacher->start((clip->track < 0) ? QThread::NormalPriority : QThread::TimeCriticalPriority);
clip->cacher->start((clip->track < 0) ? QThread::HighPriority : QThread::TimeCriticalPriority);
}
} else {
clip->finished_opening = false;
@@ -83,7 +83,10 @@ void close_clip(Clip* clip, bool wait) {
if (clip->multithreaded) {
clip->cacher->caching = false;
clip->can_cache.wakeAll();
if (wait) clip->cacher->wait();
if (wait) {
clip->open_lock.lock();
clip->open_lock.unlock();
}
} else {
close_clip_worker(clip);
}
@@ -172,7 +175,7 @@ void get_clip_frame(Clip* c, long playhead) {
}
if (c->queue.at(i) != target_frame && ((c->queue.at(i)->pts > minimum_ts) == c->reverse)) {
//dout << "removed frame at" << i << "because its pts was" << c->queue.at(i)->pts << "compared to" << target_frame->pts;
av_frame_free(&c->queue[i]); // may be a little heavy for the UI thread?
av_frame_free(&c->queue[i]); // may be a little heavy for the main thread?
c->queue.removeAt(i);
i--;
}