Skip to content

Commit

Permalink
fixup: pi4: hack: Avoid adjusting narrow (e.g. 4:3) videos
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Jan 25, 2021
1 parent 36ca126 commit 2767440
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h"
#include "utils/log.h"
#include "windowing/gbm/drm/DRMAtomic.h"
#include "settings/DisplaySettings.h"

#include <utility>

Expand Down Expand Up @@ -267,15 +268,19 @@ void CVideoLayerBridgeDRMPRIME::SetVideoPlane(CVideoBufferDRMPRIME* buffer, cons

uint32_t srcw = buffer->GetWidth() << 16;
uint32_t dstw = static_cast<uint32_t>(destRect.Width());
uint32_t dstx = static_cast<int32_t>(destRect.x1);
double scalex = (double)srcw / (double)dstw;
dstw -= 2;
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);

RESOLUTION_INFO &res = CDisplaySettings::GetInstance().GetCurrentResolutionInfo();
if (dstx + dstw > (uint32_t)res.iScreenWidth - 2)
{
dstw -= 2;
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);
}
m_DRM->AddProperty(plane, "SRC_X", 0);
m_DRM->AddProperty(plane, "SRC_Y", 0);
m_DRM->AddProperty(plane, "SRC_W", srcw);
m_DRM->AddProperty(plane, "SRC_H", buffer->GetHeight() << 16);
m_DRM->AddProperty(plane, "CRTC_X", static_cast<int32_t>(destRect.x1) & ~1);
m_DRM->AddProperty(plane, "CRTC_X", (dstx + 1) & ~1);
m_DRM->AddProperty(plane, "CRTC_Y", static_cast<int32_t>(destRect.y1) & ~1);
m_DRM->AddProperty(plane, "CRTC_W", (dstw + 1) & ~1);
m_DRM->AddProperty(plane, "CRTC_H", (static_cast<uint32_t>(destRect.Height()) + 1) & ~1);
Expand Down

0 comments on commit 2767440

Please sign in to comment.