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

Function SpecifyExtendedFormat

Source/Helper.cpp:1169–1211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1167}
1168
1169DXVA2_ExtendedFormat SpecifyExtendedFormat(DXVA2_ExtendedFormat exFormat, const FmtConvParams_t& fmtParams, const UINT width, const UINT height)
1170{
1171 if (fmtParams.CSType == CS_RGB) {
1172 exFormat.value = 0u;
1173 }
1174 else if (fmtParams.CSType == CS_YUV) {
1175 // https://docs.microsoft.com/en-us/windows/desktop/api/dxva2api/ns-dxva2api-dxva2_extendedformat
1176
1177 if (fmtParams.Subsampling != 420) {
1178 exFormat.VideoChromaSubsampling = DXVA2_VideoChromaSubsampling_Unknown;
1179 }
1180 else if (exFormat.VideoChromaSubsampling == DXVA2_VideoChromaSubsampling_Unknown) {
1181 exFormat.VideoChromaSubsampling = DXVA2_VideoChromaSubsampling_MPEG2;
1182 }
1183
1184 if (exFormat.NominalRange == DXVA2_NominalRange_Unknown) {
1185 exFormat.NominalRange = DXVA2_NominalRange_16_235;
1186 }
1187
1188 if (exFormat.VideoTransferMatrix == DXVA2_VideoTransferMatrix_Unknown) {
1189 if (width <= 1024 && height <= 576) { // SD (more reliable way to determine SD than MicroSoft offers)
1190 exFormat.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT601;
1191 }
1192 else { // HD
1193 exFormat.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709;
1194 }
1195 }
1196
1197 if (exFormat.VideoLighting == DXVA2_VideoLighting_Unknown) {
1198 exFormat.VideoLighting = DXVA2_VideoLighting_dim;
1199 }
1200
1201 if (exFormat.VideoPrimaries == DXVA2_VideoPrimaries_Unknown) {
1202 exFormat.VideoPrimaries = DXVA2_VideoPrimaries_BT709; // pick BT.709 to minimize damage
1203 }
1204
1205 if (exFormat.VideoTransferFunction == DXVA2_VideoTransFunc_Unknown) {
1206 exFormat.VideoTransferFunction = DXVA2_VideoTransFunc_709;
1207 }
1208 }
1209
1210 return exFormat;
1211}
1212
1213void GetExtendedFormatString(LPCSTR (&strs)[6], const DXVA2_ExtendedFormat exFormat, const ColorSystem_t colorSystem)
1214{

Callers 2

InitMediaTypeMethod · 0.85
InitMediaTypeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected