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

Method CopySample

Source/DX11VideoProcessor.cpp:2202–2597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2200}
2201
2202HRESULT CDX11VideoProcessor::CopySample(IMediaSample* pSample)
2203{
2204 CheckPointer(m_pDXGISwapChain1, E_FAIL);
2205
2206 uint64_t tick = GetPreciseTick();
2207
2208 // Get frame type
2209 m_SampleFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE; // Progressive
2210 m_bDoubleFrames = false;
2211 if (m_bInterlaced) {
2212 if (CComQIPtr<IMediaSample2> pMS2 = pSample) {
2213 AM_SAMPLE2_PROPERTIES props;
2214 if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
2215 if ((props.dwTypeSpecificFlags & AM_VIDEO_FLAG_WEAVE) == 0) {
2216 if (props.dwTypeSpecificFlags & AM_VIDEO_FLAG_FIELD1FIRST) {
2217 m_SampleFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST; // Top-field first
2218 } else {
2219 m_SampleFormat = D3D11_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST; // Bottom-field first
2220 }
2221 m_bDoubleFrames = m_iVPDeinterlacing && m_bDeintDouble && m_D3D11VP.IsReady();
2222 }
2223 }
2224 }
2225 }
2226
2227 HRESULT hr = S_OK;
2228 m_FieldDrawn = 0;
2229 bool updateStats = false;
2230
2231 m_hdr10 = {};
2232 if (CComQIPtr<IMediaSideData> pMediaSideData = pSample) {
2233 if (SourceIsPQorHLG() && (m_bHdrPassthrough || m_bHdrLocalToneMapping)) {
2234 MediaSideDataHDR* hdr = nullptr;
2235 size_t size = 0;
2236 hr = pMediaSideData->GetSideData(IID_MediaSideDataHDR, (const BYTE**)&hdr, &size);
2237 if (SUCCEEDED(hr) && size == sizeof(MediaSideDataHDR)) {
2238 const auto& primaries_x = hdr->display_primaries_x;
2239 const auto& primaries_y = hdr->display_primaries_y;
2240 if (primaries_x[0] > 0. && primaries_x[1] > 0. && primaries_x[2] > 0.
2241 && primaries_y[0] > 0. && primaries_y[1] > 0. && primaries_y[2] > 0.
2242 && hdr->white_point_x > 0. && hdr->white_point_y > 0.
2243 && hdr->max_display_mastering_luminance > 0. && hdr->min_display_mastering_luminance > 0.) {
2244 m_hdr10.bValid = true;
2245
2246 m_hdr10.hdr10.RedPrimary[0] = static_cast<UINT16>(std::lround(primaries_x[2] * 50000.0));
2247 m_hdr10.hdr10.RedPrimary[1] = static_cast<UINT16>(std::lround(primaries_y[2] * 50000.0));
2248 m_hdr10.hdr10.GreenPrimary[0] = static_cast<UINT16>(std::lround(primaries_x[0] * 50000.0));
2249 m_hdr10.hdr10.GreenPrimary[1] = static_cast<UINT16>(std::lround(primaries_y[0] * 50000.0));
2250 m_hdr10.hdr10.BluePrimary[0] = static_cast<UINT16>(std::lround(primaries_x[1] * 50000.0));
2251 m_hdr10.hdr10.BluePrimary[1] = static_cast<UINT16>(std::lround(primaries_y[1] * 50000.0));
2252 m_hdr10.hdr10.WhitePoint[0] = static_cast<UINT16>(std::lround(hdr->white_point_x * 50000.0));
2253 m_hdr10.hdr10.WhitePoint[1] = static_cast<UINT16>(std::lround(hdr->white_point_y * 50000.0));
2254
2255 m_hdr10.hdr10.MaxMasteringLuminance = static_cast<UINT>(std::lround(hdr->max_display_mastering_luminance));
2256 m_hdr10.hdr10.MinMasteringLuminance = static_cast<UINT>(std::lround(hdr->min_display_mastering_luminance * 10000.0));
2257 }
2258 }
2259

Callers

nothing calls this directly

Calls 9

GetPreciseTickFunction · 0.85
DLogFunction · 0.85
HR2StrFunction · 0.85
GetSideDataMethod · 0.80
SetInputVideoDataMethod · 0.80
GetNextInputTextureMethod · 0.80
IsReadyMethod · 0.45
ReleaseMethod · 0.45
GetDescMethod · 0.45

Tested by

no test coverage detected