MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / GetAlignmentSize

Method GetAlignmentSize

Source/DX11VideoProcessor.cpp:2055–2141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2053}
2054
2055BOOL CDX11VideoProcessor::GetAlignmentSize(const CMediaType& mt, SIZE& Size)
2056{
2057 if (VerifyMediaType(&mt)) {
2058 const auto& FmtParams = GetFmtConvParams(&mt);
2059
2060 if (FmtParams.cformat == CF_RGB24) {
2061 Size.cx = ALIGN(Size.cx, 4);
2062 }
2063 else if (FmtParams.cformat == CF_RGB48 || FmtParams.cformat == CF_BGR48) {
2064 Size.cx = ALIGN(Size.cx, 2);
2065 }
2066 else if (FmtParams.cformat == CF_BGRA64 || FmtParams.cformat == CF_B64A) {
2067 // nothing
2068 }
2069 else {
2070 auto pBIH = GetBIHfromVIHs(&mt);
2071 if (!pBIH) {
2072 return FALSE;
2073 }
2074
2075 auto biWidth = pBIH->biWidth;
2076 auto biHeight = labs(pBIH->biHeight);
2077
2078 if (!m_Alignment.cx || m_Alignment.cformat != FmtParams.cformat
2079 || m_Alignment.texture.desc.Width != biWidth || m_Alignment.texture.desc.Height != biHeight) {
2080 m_Alignment.texture.Release();
2081 m_Alignment.cformat = {};
2082 m_Alignment.cx = {};
2083 }
2084
2085 if (!m_Alignment.texture.pTexture) {
2086 auto VP11Format = FmtParams.VP11Format;
2087 if (VP11Format != DXGI_FORMAT_UNKNOWN) {
2088 bool disableD3D11VP = false;
2089 switch (FmtParams.cformat) {
2090 case CF_NV12: disableD3D11VP = !m_VPFormats.bNV12; break;
2091 case CF_P010:
2092 case CF_P016: disableD3D11VP = !m_VPFormats.bP01x; break;
2093 case CF_YUY2: disableD3D11VP = !m_VPFormats.bYUY2; break;
2094 default: disableD3D11VP = !m_VPFormats.bOther; break;
2095 }
2096 if (disableD3D11VP) {
2097 VP11Format = DXGI_FORMAT_UNKNOWN;
2098 }
2099 }
2100
2101 HRESULT hr = E_FAIL;
2102 if (VP11Format != DXGI_FORMAT_UNKNOWN) {
2103 hr = m_Alignment.texture.Create(m_pDevice, VP11Format, biWidth, biHeight, Tex2D_DynamicShaderWriteNoSRV);
2104 }
2105 if (FAILED(hr) && FmtParams.DX11Format != DXGI_FORMAT_UNKNOWN) {
2106 hr = m_Alignment.texture.CreateEx(m_pDevice, FmtParams.DX11Format, FmtParams.pDX11Planes, biWidth, biHeight, Tex2D_DynamicShaderWrite);
2107 }
2108 if (FAILED(hr)) {
2109 return FALSE;
2110 }
2111
2112 UINT RowPitch = 0;

Callers

nothing calls this directly

Calls 4

GetBIHfromVIHsFunction · 0.85
ReleaseMethod · 0.45
CreateMethod · 0.45
CreateExMethod · 0.45

Tested by

no test coverage detected