summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Present.cpp
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2023-06-27 12:41:14 +0300
committerFiloppi <filippotarpini@hotmail.it>2023-08-18 02:14:00 +0300
commitfae3aee9e0b6bc7f193bccf71a4c34a06237e4aa (patch)
treed212160aae4b1489db24509f7e6464d49b153598 /Source/Core/VideoCommon/Present.cpp
parent1854ff01422a69bde7b2267e9ed4fc69c30ee37a (diff)
Video: The `% 4` that was done on the rendering resolution was only meant to be done when recording videos (due to encoding limitations) but one case was missed (this had no consequences really, as it was just in the code that automatically resizes the window). The hardcoded `4` has been replaced with `VIDEO_ENCODER_LMC` for clarity.
Diffstat (limited to 'Source/Core/VideoCommon/Present.cpp')
-rw-r--r--Source/Core/VideoCommon/Present.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp
index b89c9fa32d..4d17a6519b 100644
--- a/Source/Core/VideoCommon/Present.cpp
+++ b/Source/Core/VideoCommon/Present.cpp
@@ -23,6 +23,9 @@
std::unique_ptr<VideoCommon::Presenter> g_presenter;
+// The video encoder needs the image to be a multiple of x samples.
+static constexpr int VIDEO_ENCODER_LCM = 4;
+
namespace VideoCommon
{
static float AspectToWidescreen(float aspect)
@@ -441,11 +444,14 @@ void Presenter::UpdateDrawRectangle()
crop_width = win_width;
}
- // ensure divisibility by 4 to make it compatible with all the video encoders
if (g_frame_dumper->IsFrameDumping())
{
- draw_width = std::ceil(draw_width) - static_cast<int>(std::ceil(draw_width)) % 4;
- draw_height = std::ceil(draw_height) - static_cast<int>(std::ceil(draw_height)) % 4;
+ // ensure divisibility by "VIDEO_ENCODER_LCM" to make it compatible with all the video encoders.
+ // Note that this is theoretically only necessary when recording videos and not screenshots.
+ draw_width =
+ std::ceil(draw_width) - static_cast<int>(std::ceil(draw_width)) % VIDEO_ENCODER_LCM;
+ draw_height =
+ std::ceil(draw_height) - static_cast<int>(std::ceil(draw_height)) % VIDEO_ENCODER_LCM;
}
m_target_rectangle.left = static_cast<int>(std::round(win_width / 2.0 - draw_width / 2.0));
@@ -482,10 +488,13 @@ std::tuple<int, int> Presenter::CalculateOutputDimensions(int width, int height)
width = static_cast<int>(std::ceil(scaled_width));
height = static_cast<int>(std::ceil(scaled_height));
- // UpdateDrawRectangle() makes sure that the rendered image is divisible by four for video
- // encoders, so do that here too to match it
- width -= width % 4;
- height -= height % 4;
+ if (g_frame_dumper->IsFrameDumping())
+ {
+ // UpdateDrawRectangle() makes sure that the rendered image is divisible by "VIDEO_ENCODER_LCM"
+ // for video encoders, so do that here too to match it
+ width -= width % VIDEO_ENCODER_LCM;
+ height -= height % VIDEO_ENCODER_LCM;
+ }
return std::make_tuple(width, height);
}