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

Method InitMediaType

Source/DX9VideoProcessor.cpp:1098–1269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1096}
1097
1098BOOL CDX9VideoProcessor::InitMediaType(const CMediaType* pmt)
1099{
1100 DLog(L"CDX9VideoProcessor::InitMediaType()");
1101
1102 if (!VerifyMediaType(pmt)) {
1103 return FALSE;
1104 }
1105
1106 ReleaseVP();
1107
1108 auto FmtParams = GetFmtConvParams(pmt);
1109
1110 const BITMAPINFOHEADER* pBIH = nullptr;
1111 m_decExFmt.value = 0;
1112
1113 if (pmt->formattype == FORMAT_VideoInfo2) {
1114 const VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
1115 pBIH = &vih2->bmiHeader;
1116 m_srcRect = vih2->rcSource;
1117 m_srcAspectRatioX = vih2->dwPictAspectRatioX;
1118 m_srcAspectRatioY = vih2->dwPictAspectRatioY;
1119 if (FmtParams.CSType == CS_YUV && (vih2->dwControlFlags & (AMCONTROL_USED | AMCONTROL_COLORINFO_PRESENT))) {
1120 m_decExFmt.value = vih2->dwControlFlags;
1121 m_decExFmt.SampleFormat = AMCONTROL_USED | AMCONTROL_COLORINFO_PRESENT; // ignore other flags
1122 }
1123 m_bInterlaced = (vih2->dwInterlaceFlags & AMINTERLACE_IsInterlaced);
1124 m_rtAvgTimePerFrame = vih2->AvgTimePerFrame;
1125 }
1126 else if (pmt->formattype == FORMAT_VideoInfo) {
1127 const VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
1128 pBIH = &vih->bmiHeader;
1129 m_srcRect = vih->rcSource;
1130 m_srcAspectRatioX = 0;
1131 m_srcAspectRatioY = 0;
1132 m_bInterlaced = 0;
1133 m_rtAvgTimePerFrame = vih->AvgTimePerFrame;
1134 }
1135 else {
1136 return FALSE;
1137 }
1138
1139 m_pFilter->m_FrameStats.SetStartFrameDuration(m_rtAvgTimePerFrame);
1140 m_pFilter->m_bValidBuffer = false;
1141
1142 UINT biWidth = pBIH->biWidth;
1143 UINT biHeight = labs(pBIH->biHeight);
1144
1145 m_srcLines = biHeight * FmtParams.PitchCoeff / 2;
1146 m_srcPitch = biWidth * FmtParams.Packsize;
1147 switch (FmtParams.cformat) {
1148 case CF_Y8:
1149 case CF_NV12:
1150 case CF_RGB24:
1151 case CF_BGR48:
1152 m_srcPitch = ALIGN(m_srcPitch, 4);
1153 break;
1154 case CF_V210:
1155 m_srcPitch = ALIGN((biWidth + 5) / 6 * 16, 128);

Callers 1

SetMediaTypeMethod · 0.45

Calls 4

DLogFunction · 0.85
SpecifyExtendedFormatFunction · 0.85
SetStartFrameDurationMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected