From cad8995696ce03ef714fda4e9a6f59d0d3ee29c7 Mon Sep 17 00:00:00 2001 From: Souryo Date: Fri, 9 Dec 2016 09:23:04 -0500 Subject: [PATCH] Video: Aspect ratio now takes overscan settings into account to give an accurate pixel aspect ratio, no matter the overscan --- Core/DefaultVideoFilter.cpp | 3 ++- Core/FrameInfo.h | 2 ++ Core/HdVideoFilter.cpp | 2 +- Core/NtscFilter.cpp | 2 +- Core/ScaleFilter.cpp | 2 +- Core/VideoDecoder.cpp | 8 +++++--- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Core/DefaultVideoFilter.cpp b/Core/DefaultVideoFilter.cpp index 11d0b888..b1f45f5d 100644 --- a/Core/DefaultVideoFilter.cpp +++ b/Core/DefaultVideoFilter.cpp @@ -4,6 +4,7 @@ #define _USE_MATH_DEFINES #include #include +#include "PPU.h" DefaultVideoFilter::DefaultVideoFilter() { @@ -38,7 +39,7 @@ void DefaultVideoFilter::InitConversionMatrix(double hueShift, double saturation FrameInfo DefaultVideoFilter::GetFrameInfo() { OverscanDimensions overscan = GetOverscan(); - return { overscan.GetScreenWidth(), overscan.GetScreenHeight(), 4 }; + return { overscan.GetScreenWidth(), overscan.GetScreenHeight(), PPU::ScreenWidth, PPU::ScreenHeight, 4 }; } void DefaultVideoFilter::OnBeforeApplyFilter() diff --git a/Core/FrameInfo.h b/Core/FrameInfo.h index f2938cfb..623aeaa2 100644 --- a/Core/FrameInfo.h +++ b/Core/FrameInfo.h @@ -5,5 +5,7 @@ struct FrameInfo { uint32_t Width; uint32_t Height; + uint32_t OriginalWidth; + uint32_t OriginalHeight; uint32_t BitsPerPixel; }; diff --git a/Core/HdVideoFilter.cpp b/Core/HdVideoFilter.cpp index f849d9ee..06751c9d 100644 --- a/Core/HdVideoFilter.cpp +++ b/Core/HdVideoFilter.cpp @@ -12,7 +12,7 @@ FrameInfo HdVideoFilter::GetFrameInfo() OverscanDimensions overscan = GetOverscan(); uint32_t hdScale = _hdNesPack->GetScale(); - return { overscan.GetScreenWidth() * hdScale, overscan.GetScreenHeight() * hdScale, 4 }; + return { overscan.GetScreenWidth() * hdScale, overscan.GetScreenHeight() * hdScale, PPU::ScreenWidth*hdScale, PPU::ScreenHeight*hdScale, 4 }; } void HdVideoFilter::SetHdScreenTiles(HdPpuPixelInfo *screenTiles) diff --git a/Core/NtscFilter.cpp b/Core/NtscFilter.cpp index 7c02507b..2add6a2a 100644 --- a/Core/NtscFilter.cpp +++ b/Core/NtscFilter.cpp @@ -15,7 +15,7 @@ FrameInfo NtscFilter::GetFrameInfo() OverscanDimensions overscan = GetOverscan(); int overscanLeft = overscan.Left > 0 ? NES_NTSC_OUT_WIDTH(overscan.Left) : 0; int overscanRight = overscan.Right > 0 ? NES_NTSC_OUT_WIDTH(overscan.Right) : 0; - return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2, 4 }; + return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2, NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), PPU::ScreenHeight * 2, 4 }; } void NtscFilter::OnBeforeApplyFilter() diff --git a/Core/ScaleFilter.cpp b/Core/ScaleFilter.cpp index 29699805..8f765ac7 100644 --- a/Core/ScaleFilter.cpp +++ b/Core/ScaleFilter.cpp @@ -28,7 +28,7 @@ ScaleFilter::~ScaleFilter() FrameInfo ScaleFilter::GetFrameInfo() { OverscanDimensions overscan = GetOverscan(); - return{ overscan.GetScreenWidth()*_filterScale, overscan.GetScreenHeight()*_filterScale, 4 }; + return{ overscan.GetScreenWidth()*_filterScale, overscan.GetScreenHeight()*_filterScale, PPU::ScreenWidth*_filterScale, PPU::ScreenHeight*_filterScale, 4 }; } void ScaleFilter::ApplyPrescaleFilter() diff --git a/Core/VideoDecoder.cpp b/Core/VideoDecoder.cpp index 3de09c4e..60ab2774 100644 --- a/Core/VideoDecoder.cpp +++ b/Core/VideoDecoder.cpp @@ -31,11 +31,13 @@ VideoDecoder::~VideoDecoder() void VideoDecoder::GetScreenSize(ScreenSize &size, bool ignoreScale) { if(_videoFilter) { + FrameInfo frameInfo = _videoFilter->GetFrameInfo(); double aspectRatio = EmulationSettings::GetAspectRatio(); - size.Width = (int32_t)(_videoFilter->GetFrameInfo().Width * (ignoreScale ? 1 : EmulationSettings::GetVideoScale())); - size.Height = (int32_t)(_videoFilter->GetFrameInfo().Height * (ignoreScale ? 1 : EmulationSettings::GetVideoScale())); + double scale = (ignoreScale ? 1 : EmulationSettings::GetVideoScale()); + size.Width = (int32_t)(frameInfo.Width * scale); + size.Height = (int32_t)(frameInfo.Height * scale); if(aspectRatio != 0.0) { - size.Width = (uint32_t)(size.Height * aspectRatio); + size.Width = (uint32_t)(frameInfo.OriginalHeight * scale * aspectRatio * ((double)frameInfo.Width / frameInfo.OriginalWidth)); } } }