Video: Aspect ratio now takes overscan settings into account to give an accurate pixel aspect ratio, no matter the overscan

This commit is contained in:
Souryo 2016-12-09 09:23:04 -05:00
parent c023a87dd9
commit cad8995696
6 changed files with 12 additions and 7 deletions

View file

@ -4,6 +4,7 @@
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#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()

View file

@ -5,5 +5,7 @@ struct FrameInfo
{
uint32_t Width;
uint32_t Height;
uint32_t OriginalWidth;
uint32_t OriginalHeight;
uint32_t BitsPerPixel;
};

View file

@ -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)

View file

@ -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()

View file

@ -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()

View file

@ -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));
}
}
}