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

Function GetShaderConvertColor

Source/Shaders.cpp:593–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591//////////////////////////////
592
593HRESULT GetShaderConvertColor(
594 const bool bDX11,
595 const UINT width,
596 const long texW, long texH,
597 const RECT rect,
598 const FmtConvParams_t& fmtParams,
599 const DXVA2_ExtendedFormat exFmt,
600 const MediaSideDataDOVIMetadata* const pDoviMetadata,
601 const int chromaScaling,
602 const int convertType,
603 const bool blendDeinterlace,
604 ID3DBlob** ppCode)
605{
606 DLog(L"GetShaderConvertColor() started for {} {}x{} extfmt:{:#010x} chroma:{}", fmtParams.str, texW, texH, exFmt.value, chromaScaling);
607
608 std::string code;
609 HRESULT hr = S_OK;
610 LPVOID data;
611 DWORD size;
612
613 const bool bBT2020Primaries = (exFmt.VideoPrimaries == MFVideoPrimaries_BT2020);
614 const bool bConvertHDRtoSDR = (convertType == SHADER_CONVERT_TO_SDR && (exFmt.VideoTransferFunction == MFVideoTransFunc_2084 || exFmt.VideoTransferFunction == MFVideoTransFunc_HLG || pDoviMetadata));
615 const bool bApplyHLG = (exFmt.VideoTransferFunction == MFVideoTransFunc_HLG && !pDoviMetadata);
616 const bool bConvertHLGtoPQ = (convertType == SHADER_CONVERT_TO_PQ && bApplyHLG);
617
618 if (bApplyHLG) {
619 hr = GetDataFromResource(data, size, IDF_HLSL_HLG);
620 if (S_OK == hr) {
621 code.append((LPCSTR)data, size);
622 code += '\n';
623 }
624 }
625
626 if (bConvertHDRtoSDR || bConvertHLGtoPQ || pDoviMetadata) {
627 hr = GetDataFromResource(data, size, IDF_HLSL_ST2084);
628 if (S_OK == hr) {
629 code.append((LPCSTR)data, size);
630 code += '\n';
631 }
632 }
633
634 if (bBT2020Primaries || bConvertHDRtoSDR) {
635 float matrix_conv_prim[3][3];
636 GetColorspaceGamutConversionMatrix(matrix_conv_prim, MP_CSP_PRIM_BT_2020, MP_CSP_PRIM_BT_709);
637 code.append("static const float3x3 matrix_conv_prim = {\n");
638 for (int i = 0; i < 3; i++) {
639 for (int j = 0; j < 3; j++) {
640 code += std::format("{}, ", matrix_conv_prim[i][j]);
641 }
642 code.append("\n");
643 }
644 code.append("};\n");
645 }
646
647 if (bConvertHDRtoSDR) {
648 hr = GetDataFromResource(data, size, IDF_HLSL_HDR_TONE_MAPPING);
649 if (S_OK == hr) {
650 code.append((LPCSTR)data, size);

Callers 2

Calls 8

DLogFunction · 0.85
GetDataFromResourceFunction · 0.85
ShaderGetPixelsFunction · 0.85
ShaderDoviReshapeFunction · 0.85
ShaderDoviReshapePolyFunction · 0.85
mul_matrix3x3Function · 0.85
CompileShaderFunction · 0.85

Tested by

no test coverage detected