From 4474d4391b8bb0b221471918fb602d7aeeaef0a0 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Mon, 21 Sep 2015 04:42:21 +0300 Subject: [PATCH] GSdx: capture - print recomended resolution and DAR to the console This is the internal resolution which GSdx uses and recording at this resolution is optimal, i.e. without any dumb scaling, with all relevant pixels and without redundant pixels. The resulting clip still doesn't have the correct aspect ratio set, but that's just a property which can be set to the clip afterwards, which is where the DAR becomes useful. Since it's usually anamorphic, when muxing later with the audio use the DAR to set the playback aspect ratio. --- plugins/GSdx/GSCapture.cpp | 3 ++- plugins/GSdx/GSCapture.h | 2 +- plugins/GSdx/GSRenderer.cpp | 5 ++++- plugins/GSdx/GSRenderer.h | 3 +++ plugins/GSdx/GSRendererHW.cpp | 9 +++++++++ plugins/GSdx/GSRendererHW.h | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index 7e358e9a8c..54f1791dc6 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -391,8 +391,9 @@ GSCapture::~GSCapture() EndCapture(); } -bool GSCapture::BeginCapture(float fps) +bool GSCapture::BeginCapture(float fps, GSVector2i recomendedResolution, float aspect) { + printf("Recomended resolution: %d x %d, DAR for muxing: %.4f\n", recomendedResolution.x, recomendedResolution.y, aspect); std::lock_guard lock(m_lock); ASSERT(fps != 0); diff --git a/plugins/GSdx/GSCapture.h b/plugins/GSdx/GSCapture.h index f98ee25cbe..e522da5555 100644 --- a/plugins/GSdx/GSCapture.h +++ b/plugins/GSdx/GSCapture.h @@ -52,7 +52,7 @@ public: GSCapture(); virtual ~GSCapture(); - bool BeginCapture(float fps); + bool BeginCapture(float fps, GSVector2i recomendedResolution, float aspect); bool DeliverFrame(const void* bits, int pitch, bool rgba); bool EndCapture(); diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 961575a589..a0f8e36e25 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -533,7 +533,10 @@ bool GSRenderer::MakeSnapshot(const string& path) bool GSRenderer::BeginCapture() { - return m_capture.BeginCapture(GetTvRefreshRate()); + GSVector4i disp = m_wnd->GetClientRect().fit(m_aspectratio); + float aspect = (float)disp.width() / max(1, disp.height()); + + return m_capture.BeginCapture(GetTvRefreshRate(), GetInternalResolution(), aspect); } void GSRenderer::EndCapture() diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index 6e8a513df6..4459c5ead5 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -69,6 +69,9 @@ public: virtual void KeyEvent(GSKeyEventData* e); virtual bool CanUpscale() {return false;} virtual int GetUpscaleMultiplier() {return 1;} + virtual GSVector2i GetInternalResolution() { + return GSVector2i(GetDisplayRect().width(), GetDisplayRect().height()); + } void SetAspectRatio(int aspect) {m_aspectratio = aspect;} void SetVSync(bool enabled); void SetFrameLimit(bool limit); diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index 4fcbfab781..6e8b4483f2 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -100,6 +100,15 @@ int GSRendererHW::GetUpscaleMultiplier() return m_upscale_multiplier ? m_upscale_multiplier : 1; } +GSVector2i GSRendererHW::GetInternalResolution() { + GSVector2i dr(GetDisplayRect().width(), GetDisplayRect().height()); + + if (m_upscale_multiplier) + return GSVector2i(dr.x * m_upscale_multiplier, dr.y * m_upscale_multiplier); + else + return GSVector2i(m_width, m_height); +} + void GSRendererHW::Reset() { // TODO: GSreset can come from the main thread too => crash diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 190dbe038f..2f2c5f8237 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -155,6 +155,7 @@ public: void SetGameCRC(uint32 crc, int options); bool CanUpscale(); int GetUpscaleMultiplier(); + virtual GSVector2i GetInternalResolution(); void SetScaling(); void Reset();