Skip to content

Commit

Permalink
ConvertXRGB10toXRGB8 -> ConvertR10G10B10A2toBGR32.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Dec 4, 2024
1 parent 0f7d87c commit 2820c31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/DX11VideoProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,7 @@ HRESULT CDX11VideoProcessor::GetDisplayedImage(BYTE **ppDib, unsigned* pSize)
hr = m_pDeviceContext->Map(pTexture2DShared, 0, D3D11_MAP_READ, 0, &mappedResource);
if (SUCCEEDED(hr)) {
if (desc2.Format == DXGI_FORMAT_R10G10B10A2_UNORM) {
ConvertXRGB10toXRGB8(desc.Height, (BYTE*)(pBIH + 1), dst_pitch, (BYTE*)mappedResource.pData + mappedResource.RowPitch * (desc.Height - 1), -(int)mappedResource.RowPitch);
ConvertR10G10B10A2toBGR32(desc.Height, (BYTE*)(pBIH + 1), dst_pitch, (BYTE*)mappedResource.pData + mappedResource.RowPitch * (desc.Height - 1), -(int)mappedResource.RowPitch);
}
else {
CopyPlaneAsIs(desc.Height, (BYTE*)(pBIH + 1), dst_pitch, (BYTE*)mappedResource.pData + mappedResource.RowPitch * (desc.Height - 1), -(int)mappedResource.RowPitch);
Expand Down
14 changes: 13 additions & 1 deletion Source/Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,20 @@ void CopyPlane10to16(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* sr
}
}

void ConvertXRGB10toXRGB8(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* src, int src_pitch)
void ConvertR10G10B10A2toBGR32(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* src, int src_pitch)
{
// R10G10B10A2
// R - 0x000003ff
// G - 0x000ffc00
// B - 0x3ff00000
// A - 0xc0000000
//
// BGR32
// B - 0x000000ff
// G - 0x0000ff00
// R - 0x00ff0000
// X - 0xff000000

UINT line_pixels = abs(src_pitch) / 4;

for (UINT y = 0; y < lines; ++y) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void CopyFrameR210(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* src,
// YUV444P10
void CopyPlane10to16(const UINT lines, BYTE * dst, UINT dst_pitch, const BYTE * src, int src_pitch);

void ConvertXRGB10toXRGB8(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* src, int src_pitch);
void ConvertR10G10B10A2toBGR32(const UINT lines, BYTE* dst, UINT dst_pitch, const BYTE* src, int src_pitch);

void ClipToSurface(const int texW, const int texH, RECT& s, RECT& d);

Expand Down

0 comments on commit 2820c31

Please sign in to comment.