| 852 | } |
| 853 | |
| 854 | void CDX9VideoProcessor::SetShaderConvertColorParams() |
| 855 | { |
| 856 | mp_cmat cmatrix; |
| 857 | |
| 858 | if (m_Dovi.bValid) { |
| 859 | const float brightness = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Brightness) / 255; |
| 860 | const float contrast = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Contrast); |
| 861 | |
| 862 | for (int i = 0; i < 3; i++) { |
| 863 | cmatrix.m[i][0] = (float)m_Dovi.msd.ColorMetadata.ycc_to_rgb_matrix[i * 3 + 0] * contrast; |
| 864 | cmatrix.m[i][1] = (float)m_Dovi.msd.ColorMetadata.ycc_to_rgb_matrix[i * 3 + 1] * contrast; |
| 865 | cmatrix.m[i][2] = (float)m_Dovi.msd.ColorMetadata.ycc_to_rgb_matrix[i * 3 + 2] * contrast; |
| 866 | } |
| 867 | |
| 868 | for (int i = 0; i < 3; i++) { |
| 869 | cmatrix.c[i] = brightness; |
| 870 | for (int j = 0; j < 3; j++) { |
| 871 | cmatrix.c[i] -= cmatrix.m[i][j] * m_Dovi.msd.ColorMetadata.ycc_to_rgb_offset[j]; |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | m_PSConvColorData.bEnable = true; |
| 876 | } |
| 877 | else { |
| 878 | mp_csp_params csp_params; |
| 879 | set_colorspace(m_srcExFmt, csp_params.color); |
| 880 | csp_params.brightness = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Brightness) / 255; |
| 881 | csp_params.contrast = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Contrast); |
| 882 | csp_params.hue = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Hue) / 180 * acos(-1); |
| 883 | csp_params.saturation = DXVA2FixedToFloat(m_DXVA2ProcAmpValues.Saturation); |
| 884 | csp_params.gray = m_srcParams.CSType == CS_GRAY; |
| 885 | |
| 886 | csp_params.input_bits = csp_params.texture_bits = m_srcParams.CDepth; |
| 887 | |
| 888 | mp_get_csp_matrix(&csp_params, &cmatrix); |
| 889 | |
| 890 | m_PSConvColorData.bEnable = |
| 891 | m_srcParams.CSType == CS_YUV || |
| 892 | m_srcParams.cformat == CF_GBRP8 || m_srcParams.cformat == CF_GBRP10 || m_srcParams.cformat == CF_GBRP16 || |
| 893 | fabs(csp_params.brightness) > 1e-4f || fabs(csp_params.contrast - 1.0f) > 1e-4f; |
| 894 | } |
| 895 | |
| 896 | m_PSConvColorData.Constants = { |
| 897 | {cmatrix.m[0][0], cmatrix.m[0][1], cmatrix.m[0][2], 0}, |
| 898 | {cmatrix.m[1][0], cmatrix.m[1][1], cmatrix.m[1][2], 0}, |
| 899 | {cmatrix.m[2][0], cmatrix.m[2][1], cmatrix.m[2][2], 0}, |
| 900 | {cmatrix.c[0], cmatrix.c[1], cmatrix.c[2], 0}, |
| 901 | }; |
| 902 | |
| 903 | auto& cbuffer = m_PSConvColorData.Constants; |
| 904 | |
| 905 | if (m_srcParams.cformat == CF_GBRP8 || m_srcParams.cformat == CF_GBRP10 || m_srcParams.cformat == CF_GBRP16) { |
| 906 | std::swap(cbuffer.cm_r.x, cbuffer.cm_r.y); std::swap(cbuffer.cm_r.y, cbuffer.cm_r.z); |
| 907 | std::swap(cbuffer.cm_g.x, cbuffer.cm_g.y); std::swap(cbuffer.cm_g.y, cbuffer.cm_g.z); |
| 908 | std::swap(cbuffer.cm_b.x, cbuffer.cm_b.y); std::swap(cbuffer.cm_b.y, cbuffer.cm_b.z); |
| 909 | } |
| 910 | } |
| 911 |
nothing calls this directly
no test coverage detected