| 1044 | } |
| 1045 | |
| 1046 | BOOL CDX9VideoProcessor::GetAlignmentSize(const CMediaType& mt, SIZE& Size) |
| 1047 | { |
| 1048 | if ((m_srcDXVA2Format != D3DFMT_UNKNOWN && mt == m_pFilter->m_inputMT) || InitMediaType(&mt)) { |
| 1049 | const auto& FmtParams = GetFmtConvParams(&mt); |
| 1050 | |
| 1051 | if (FmtParams.cformat == CF_RGB24) { |
| 1052 | Size.cx = ALIGN(Size.cx, 4); |
| 1053 | } |
| 1054 | else if (FmtParams.cformat == CF_RGB48 || FmtParams.cformat == CF_BGR48) { |
| 1055 | Size.cx = ALIGN(Size.cx, 2); |
| 1056 | } |
| 1057 | else if (FmtParams.cformat == CF_BGRA64 || FmtParams.cformat == CF_B64A) { |
| 1058 | // nothing |
| 1059 | } |
| 1060 | else { |
| 1061 | CComPtr<IDirect3DSurface9> pSurface; |
| 1062 | if (m_DXVA2VP.IsReady()) { |
| 1063 | pSurface = m_DXVA2VP.GetNextInputSurface(0, m_CurrentSampleFmt); |
| 1064 | } else { |
| 1065 | pSurface = m_TexSrcVideo.pSurface; |
| 1066 | } |
| 1067 | |
| 1068 | if (!pSurface) { |
| 1069 | return FALSE; |
| 1070 | } |
| 1071 | |
| 1072 | INT Pitch = 0; |
| 1073 | D3DLOCKED_RECT lr; |
| 1074 | if (SUCCEEDED(pSurface->LockRect(&lr, nullptr, D3DLOCK_NOSYSLOCK))) { // don't use D3DLOCK_DISCARD here on AMD card |
| 1075 | Pitch = lr.Pitch; |
| 1076 | pSurface->UnlockRect(); |
| 1077 | } |
| 1078 | |
| 1079 | if (!Pitch) { |
| 1080 | return FALSE; |
| 1081 | } |
| 1082 | |
| 1083 | Size.cx = Pitch / FmtParams.Packsize; |
| 1084 | } |
| 1085 | |
| 1086 | if (FmtParams.cformat == CF_RGB24 || FmtParams.cformat == CF_XRGB32 || FmtParams.cformat == CF_ARGB32) { |
| 1087 | Size.cy = -abs(Size.cy); // only for biCompression == BI_RGB |
| 1088 | } else { |
| 1089 | Size.cy = abs(Size.cy); // need additional checks |
| 1090 | } |
| 1091 | |
| 1092 | return TRUE; |
| 1093 | } |
| 1094 | |
| 1095 | return FALSE; |
| 1096 | } |
| 1097 | |
| 1098 | BOOL CDX9VideoProcessor::InitMediaType(const CMediaType* pmt) |
| 1099 | { |
no test coverage detected