From 9636ec202dc7aa4334b05aa2541bf8a1d0595474 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Thu, 28 Jul 2022 08:57:18 -0700 Subject: [PATCH] render: allow forcing channel count --- app/render/rendermanager.cpp | 3 +++ app/render/rendermanager.h | 1 + app/render/renderprocessor.cpp | 7 ++++++- app/task/export/export.cpp | 2 +- app/task/render/render.cpp | 13 +++++++------ app/task/render/render.h | 4 ++-- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/render/rendermanager.cpp b/app/render/rendermanager.cpp index 1df5590b3..bf7dc449b 100644 --- a/app/render/rendermanager.cpp +++ b/app/render/rendermanager.cpp @@ -100,6 +100,7 @@ RenderTicketPtr RenderManager::RenderFrame(Node *node, const VideoParams &vparam QSize(0, 0), QMatrix4x4(), VideoParams::kFormatInvalid, + 0, nullptr, cache, return_type); @@ -110,6 +111,7 @@ RenderTicketPtr RenderManager::RenderFrame(Node *node, ColorManager* color_manag const VideoParams &video_params, const AudioParams &audio_params, const QSize& force_size, const QMatrix4x4& force_matrix, VideoParams::Format force_format, + int force_channel_count, ColorProcessorPtr force_color_output, FrameHashCache* cache, ReturnType return_type) { @@ -121,6 +123,7 @@ RenderTicketPtr RenderManager::RenderFrame(Node *node, ColorManager* color_manag ticket->setProperty("size", force_size); ticket->setProperty("matrix", force_matrix); ticket->setProperty("format", force_format); + ticket->setProperty("channelcount", force_channel_count); ticket->setProperty("mode", mode); ticket->setProperty("type", kTypeVideo); ticket->setProperty("colormanager", Node::PtrToValue(color_manager)); diff --git a/app/render/rendermanager.h b/app/render/rendermanager.h index 891e2fffc..6eed0a5bc 100644 --- a/app/render/rendermanager.h +++ b/app/render/rendermanager.h @@ -119,6 +119,7 @@ public: const VideoParams& video_params, const AudioParams& audio_params, const QSize& force_size, const QMatrix4x4& force_matrix, VideoParams::Format force_format, + int force_channel_count, ColorProcessorPtr force_color_output, FrameHashCache* cache = nullptr, ReturnType return_type = kFrame); diff --git a/app/render/renderprocessor.cpp b/app/render/renderprocessor.cpp index 0a6d78078..da419eef7 100644 --- a/app/render/renderprocessor.cpp +++ b/app/render/renderprocessor.cpp @@ -75,7 +75,12 @@ FramePtr RenderProcessor::GenerateFrame(TexturePtr texture, const rational& time frame_params.set_format(frame_format); } - frame_params.set_channel_count(texture ? texture->channel_count() : VideoParams::kRGBChannelCount); + int force_channel_count = ticket_->property("channelcount").toInt(); + if (force_channel_count != 0) { + frame_params.set_channel_count(force_channel_count); + } else { + frame_params.set_channel_count(texture ? texture->channel_count() : VideoParams::kRGBAChannelCount); + } FramePtr frame = Frame::Create(); frame->set_timestamp(time); diff --git a/app/task/export/export.cpp b/app/task/export/export.cpp index 3df5f1240..7688860d7 100644 --- a/app/task/export/export.cpp +++ b/app/task/export/export.cpp @@ -162,7 +162,7 @@ bool ExportTask::Run() Render(color_manager_, video_range, audio_range, subtitle_range, RenderMode::kOnline, nullptr, video_force_size, video_force_matrix, encoder_->GetDesiredPixelFormat(), - color_processor_); + VideoParams::kRGBAChannelCount, color_processor_); bool success = true; diff --git a/app/task/render/render.cpp b/app/task/render/render.cpp index d427b9608..1bb764022 100644 --- a/app/task/render/render.cpp +++ b/app/task/render/render.cpp @@ -42,7 +42,7 @@ bool RenderTask::Render(ColorManager* manager, RenderMode::Mode mode, FrameHashCache* cache, const QSize &force_size, const QMatrix4x4 &force_matrix, VideoParams::Format force_format, - ColorProcessorPtr force_color_output) + int force_channel_count, ColorProcessorPtr force_color_output) { QMetaObject::invokeMethod(RenderManager::instance(), "SetAggressiveGarbageCollection", Q_ARG(bool, true)); @@ -88,7 +88,7 @@ bool RenderTask::Render(ColorManager* manager, rational next_frame; for (int i=0; isetProperty("time", QVariant::fromValue(time)); @@ -291,8 +292,8 @@ void RenderTask::StartTicket(QThread* watcher_thread, ColorManager* manager, watcher->SetTicket(RenderManager::instance()->RenderFrame(viewer_->GetConnectedTextureOutput(), manager, time, mode, video_params_, audio_params_, force_size, force_matrix, - force_format, force_color_output, - cache)); + force_format, force_channel_count, + force_color_output, cache)); } void RenderTask::TicketDone(RenderTicketWatcher* watcher) diff --git a/app/task/render/render.h b/app/task/render/render.h index 2609bc3d9..a9313e738 100644 --- a/app/task/render/render.h +++ b/app/task/render/render.h @@ -46,7 +46,7 @@ protected: FrameHashCache *cache, const QSize& force_size = QSize(0, 0), const QMatrix4x4& force_matrix = QMatrix4x4(), VideoParams::Format force_format = VideoParams::kFormatInvalid, - ColorProcessorPtr force_color_output = nullptr); + int force_channel_count = 0, ColorProcessorPtr force_color_output = nullptr); virtual bool DownloadFrame(QThread* thread, FramePtr frame, const rational &time); @@ -116,7 +116,7 @@ private: void IncrementRunningTickets(); - void StartTicket(QThread *watcher_thread, ColorManager *manager, const rational &time, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, const QMatrix4x4 &force_matrix, VideoParams::Format force_format, ColorProcessorPtr force_color_output); + void StartTicket(QThread *watcher_thread, ColorManager *manager, const rational &time, RenderMode::Mode mode, FrameHashCache *cache, const QSize &force_size, const QMatrix4x4 &force_matrix, VideoParams::Format force_format, int force_channel_count, ColorProcessorPtr force_color_output); ViewerOutput* viewer_;