Skip to content

Commit cbafa5c

Browse files
committed
pi4: hack: Try to hide pixel wrap issue
1 parent c7cbd6e commit cbafa5c

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/VideoLayerBridgeDRMPRIME.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h"
1212
#include "utils/log.h"
1313
#include "windowing/gbm/drm/DRMAtomic.h"
14+
#include "settings/DisplaySettings.h"
1415

1516
#include <utility>
1617

@@ -264,13 +265,24 @@ void CVideoLayerBridgeDRMPRIME::SetVideoPlane(CVideoBufferDRMPRIME* buffer, cons
264265
auto plane = m_DRM->GetVideoPlane();
265266
m_DRM->AddProperty(plane, "FB_ID", buffer->m_fb_id);
266267
m_DRM->AddProperty(plane, "CRTC_ID", m_DRM->GetCrtc()->GetCrtcId());
268+
269+
uint32_t srcw = buffer->GetWidth() << 16;
270+
uint32_t dstw = static_cast<uint32_t>(destRect.Width());
271+
uint32_t dstx = static_cast<int32_t>(destRect.x1);
272+
double scalex = (double)srcw / (double)dstw;
273+
RESOLUTION_INFO &res = CDisplaySettings::GetInstance().GetCurrentResolutionInfo();
274+
if (dstw > 2 && dstx + dstw > (uint32_t)res.iScreenWidth - 2)
275+
{
276+
dstw -= 2;
277+
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);
278+
}
267279
m_DRM->AddProperty(plane, "SRC_X", 0);
268280
m_DRM->AddProperty(plane, "SRC_Y", 0);
269-
m_DRM->AddProperty(plane, "SRC_W", buffer->GetWidth() << 16);
281+
m_DRM->AddProperty(plane, "SRC_W", srcw);
270282
m_DRM->AddProperty(plane, "SRC_H", buffer->GetHeight() << 16);
271-
m_DRM->AddProperty(plane, "CRTC_X", static_cast<int32_t>(destRect.x1) & ~1);
283+
m_DRM->AddProperty(plane, "CRTC_X", (dstx + 1) & ~1);
272284
m_DRM->AddProperty(plane, "CRTC_Y", static_cast<int32_t>(destRect.y1) & ~1);
273-
m_DRM->AddProperty(plane, "CRTC_W", (static_cast<uint32_t>(destRect.Width()) + 1) & ~1);
285+
m_DRM->AddProperty(plane, "CRTC_W", (dstw + 1) & ~1);
274286
m_DRM->AddProperty(plane, "CRTC_H", (static_cast<uint32_t>(destRect.Height()) + 1) & ~1);
275287
}
276288

xbmc/windowing/gbm/drm/DRMAtomic.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,19 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video
9292
return;
9393
}
9494

95+
uint32_t srcw = m_width << 16;
96+
uint32_t dstw = m_mode->hdisplay;
97+
double scalex = (double)srcw / (double)dstw;
98+
dstw -= 2;
99+
srcw = (uint32_t)(srcw - 2.0 * scalex + 0.5);
100+
95101
if (rendered)
96102
{
97103
AddProperty(m_gui_plane, "FB_ID", fb_id);
98104
AddProperty(m_gui_plane, "CRTC_ID", m_crtc->GetCrtcId());
99105
AddProperty(m_gui_plane, "SRC_X", 0);
100106
AddProperty(m_gui_plane, "SRC_Y", 0);
101-
AddProperty(m_gui_plane, "SRC_W", m_width << 16);
107+
AddProperty(m_gui_plane, "SRC_W", srcw);
102108
AddProperty(m_gui_plane, "SRC_H", m_height << 16);
103109
AddProperty(m_gui_plane, "CRTC_X", 0);
104110
AddProperty(m_gui_plane, "CRTC_Y", 0);
@@ -109,7 +115,7 @@ void CDRMAtomic::DrmAtomicCommit(int fb_id, int flags, bool rendered, bool video
109115
// }
110116
// else
111117
{
112-
AddProperty(m_gui_plane, "CRTC_W", m_mode->hdisplay);
118+
AddProperty(m_gui_plane, "CRTC_W", dstw);
113119
AddProperty(m_gui_plane, "CRTC_H", m_mode->vdisplay);
114120
}
115121

0 commit comments

Comments
 (0)