From b458bfa54259efd2f02395749134504a9f216e88 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 4 May 2020 01:33:26 +1000 Subject: [PATCH] proxy: improved UI on proxy menu --- app/codec/ffmpeg/ffmpegdecoder.cpp | 11 ++++---- app/render/backend/videorenderframecache.cpp | 6 +++++ .../projectexplorer/projectexplorer.cpp | 26 ++++++++++++++++--- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/codec/ffmpeg/ffmpegdecoder.cpp b/app/codec/ffmpeg/ffmpegdecoder.cpp index 3c497adb5..1f5e4d422 100644 --- a/app/codec/ffmpeg/ffmpegdecoder.cpp +++ b/app/codec/ffmpeg/ffmpegdecoder.cpp @@ -760,6 +760,12 @@ bool FFmpegDecoder::ProxyVideo(const QAtomicInt *cancelled, int divider) futures.append(future); } + // Wait for all conversions to finish + for (int i=0;iset_proxy(divider, frame_index); } - // Wait for all conversions to finish - for (int i=0;i &VideoRenderFrameCache::time_hash_map() const QString VideoRenderFrameCache::GetFormatExtension(const PixelFormat::Format &f) { if (PixelFormat::FormatIsFloat(f)) { + // EXR is only fast with float buffers so we only use it for those return QStringLiteral(".exr"); } else { + // FIXME: Will probably need different codec here. JPEG is the fastest and smallest by far (much + // more so than TIFF or PNG) and we don't mind lossy for the offline cache, but JPEG + // doesn't support >8-bit or alpha channels. JPEG2000 does, but my OIIO wasn't compiled + // with it and I imagine it's not common in general. Still, this works well for now as a + // prototype. return QStringLiteral(".jpg"); } } diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index ae86d1092..d6c109834 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -310,6 +310,14 @@ void ProjectExplorer::ShowContextMenu() proxy_menu->addAction(tr("1/4"))->setData(4); proxy_menu->addAction(tr("1/8"))->setData(8); + foreach (QAction* a, proxy_menu->actions()) { + a->setCheckable(true); + + if (a->data() == video_stream->using_proxy()) { + a->setChecked(true); + } + } + connect(proxy_menu, &Menu::triggered, this, &ProjectExplorer::ContextMenuStartProxy); } @@ -395,9 +403,21 @@ void ProjectExplorer::ContextMenuStartProxy(QAction *a) return; } - if (video_stream->try_start_proxy()) { - ProxyTask* proxy_task = new ProxyTask(video_stream, a->data().toInt()); - TaskManager::instance()->AddTask(proxy_task); + int chosen_proxy_setting = a->data().toInt(); + + if (chosen_proxy_setting != video_stream->using_proxy()) { + if (!a->data().toInt()) { + + // 0 means disable the proxy + video_stream->set_proxy(0, QVector()); + + } else if (video_stream->try_start_proxy()) { + + // Start a background task for proxying + ProxyTask* proxy_task = new ProxyTask(video_stream, a->data().toInt()); + TaskManager::instance()->AddTask(proxy_task); + + } } }