Created
March 17, 2024 08:33
-
-
Save KiyoNetcat/56eefd522559da135b00a8dc80064308 to your computer and use it in GitHub Desktop.
Patch to https://github.com/RoblKyogre/Sunshine to stretch the stream to the output aspect ratio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/platform/linux/cuda.cu b/src/platform/linux/cuda.cu | |
| index 8fb1a5e..6f4928d 100644 | |
| --- a/src/platform/linux/cuda.cu | |
| +++ b/src/platform/linux/cuda.cu | |
| @@ -259,9 +259,13 @@ tex_t::~tex_t() { | |
| sws_t::sws_t(int in_width, int in_height, int out_width, int out_height, int pitch, int threadsPerBlock, ptr_t &&color_matrix) | |
| : threadsPerBlock { threadsPerBlock }, color_matrix { std::move(color_matrix) } { | |
| // Ensure aspect ratio is maintained | |
| - auto scalar = std::fminf(out_width / (float)in_width, out_height / (float)in_height); | |
| + /*auto scalar = std::fminf(out_width / (float)in_width, out_height / (float)in_height); | |
| auto out_width_f = in_width * scalar; | |
| - auto out_height_f = in_height * scalar; | |
| + auto out_height_f = in_height * scalar;*/ | |
| + | |
| + auto out_width_f = out_width; | |
| + auto out_height_f = out_height; | |
| + auto scalar = 1.0f; | |
| // result is always positive | |
| auto offsetX_f = (out_width - out_width_f) / 2; | |
| diff --git a/src/platform/linux/graphics.cpp b/src/platform/linux/graphics.cpp | |
| index b412988..cfa5724 100644 | |
| --- a/src/platform/linux/graphics.cpp | |
| +++ b/src/platform/linux/graphics.cpp | |
| @@ -739,9 +739,12 @@ namespace egl { | |
| sws.serial = std::numeric_limits<std::uint64_t>::max(); | |
| // Ensure aspect ratio is maintained | |
| - auto scalar = std::fminf(out_width / (float) in_width, out_height / (float) in_height); | |
| + /*auto scalar = std::fminf(out_width / (float) in_width, out_height / (float) in_height); | |
| auto out_width_f = in_width * scalar; | |
| - auto out_height_f = in_height * scalar; | |
| + auto out_height_f = in_height * scalar;*/ | |
| + | |
| + auto out_width_f = out_width; | |
| + auto out_height_f = out_height; | |
| // result is always positive | |
| auto offsetX_f = (out_width - out_width_f) / 2; | |
| diff --git a/src/platform/windows/display_vram.cpp b/src/platform/windows/display_vram.cpp | |
| index 1baa128..efac9fb 100644 | |
| --- a/src/platform/windows/display_vram.cpp | |
| +++ b/src/platform/windows/display_vram.cpp | |
| @@ -455,9 +455,12 @@ namespace platf::dxgi { | |
| float in_height = display->height; | |
| // Ensure aspect ratio is maintained | |
| - auto scalar = std::fminf(out_width / in_width, out_height / in_height); | |
| + /*auto scalar = std::fminf(out_width / in_width, out_height / in_height); | |
| auto out_width_f = in_width * scalar; | |
| - auto out_height_f = in_height * scalar; | |
| + auto out_height_f = in_height * scalar;*/ | |
| + | |
| + auto out_width_f = out_width; | |
| + auto out_height_f = out_height; | |
| // result is always positive | |
| auto offsetX = (out_width - out_width_f) / 2; | |
| @@ -506,10 +509,10 @@ namespace platf::dxgi { | |
| } | |
| // Clear the RTVs to ensure the aspect ratio padding is black | |
| - const float y_black[] = { 0.0f, 0.0f, 0.0f, 0.0f }; | |
| + /*const float y_black[] = { 0.0f, 0.0f, 0.0f, 0.0f }; | |
| device_ctx->ClearRenderTargetView(nv12_Y_rt.get(), y_black); | |
| const float uv_black[] = { 0.5f, 0.5f, 0.5f, 0.5f }; | |
| - device_ctx->ClearRenderTargetView(nv12_UV_rt.get(), uv_black); | |
| + device_ctx->ClearRenderTargetView(nv12_UV_rt.get(), uv_black);*/ | |
| return 0; | |
| } | |
| diff --git a/src/video.cpp b/src/video.cpp | |
| index 920ce1a..936b63c 100644 | |
| --- a/src/video.cpp | |
| +++ b/src/video.cpp | |
| @@ -171,11 +171,11 @@ namespace video { | |
| */ | |
| void | |
| prefill() { | |
| - auto frame = sw_frame ? sw_frame.get() : this->frame; | |
| + /*auto frame = sw_frame ? sw_frame.get() : this->frame; | |
| av_frame_get_buffer(frame, 0); | |
| av_frame_make_writable(frame); | |
| ptrdiff_t linesize[4] = { frame->linesize[0], frame->linesize[1], frame->linesize[2], frame->linesize[3] }; | |
| - av_image_fill_black(frame->data, linesize, (AVPixelFormat) frame->format, frame->color_range, frame->width, frame->height); | |
| + av_image_fill_black(frame->data, linesize, (AVPixelFormat) frame->format, frame->color_range, frame->width, frame->height);*/ | |
| } | |
| int | |
| @@ -199,9 +199,9 @@ namespace video { | |
| auto out_height = frame->height; | |
| // Ensure aspect ratio is maintained | |
| - auto scalar = std::fminf((float) out_width / in_width, (float) out_height / in_height); | |
| + /*auto scalar = std::fminf((float) out_width / in_width, (float) out_height / in_height); | |
| out_width = in_width * scalar; | |
| - out_height = in_height * scalar; | |
| + out_height = in_height * scalar;*/ | |
| sws_input_frame.reset(av_frame_alloc()); | |
| sws_input_frame->width = in_width; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment