| 2141 | } |
| 2142 | |
| 2143 | HRESULT CDX11VideoProcessor::ProcessSample(IMediaSample* pSample) |
| 2144 | { |
| 2145 | REFERENCE_TIME rtStart, rtEnd; |
| 2146 | if (FAILED(pSample->GetTime(&rtStart, &rtEnd))) { |
| 2147 | rtStart = m_pFilter->m_FrameStats.GeTimestamp(); |
| 2148 | } |
| 2149 | const REFERENCE_TIME rtFrameDur = m_pFilter->m_FrameStats.GetAverageFrameDuration(); |
| 2150 | rtEnd = rtStart + rtFrameDur; |
| 2151 | |
| 2152 | m_rtStart = rtStart; |
| 2153 | CRefTime rtClock(rtStart); |
| 2154 | |
| 2155 | HRESULT hr = CopySample(pSample); |
| 2156 | if (FAILED(hr)) { |
| 2157 | m_RenderStats.failed++; |
| 2158 | return hr; |
| 2159 | } |
| 2160 | |
| 2161 | // always Render(1) a frame after CopySample() |
| 2162 | hr = Render(1, rtStart); |
| 2163 | m_pFilter->m_DrawStats.Add(GetPreciseTick()); |
| 2164 | if (m_pFilter->m_filterState == State_Running) { |
| 2165 | m_pFilter->StreamTime(rtClock); |
| 2166 | } |
| 2167 | |
| 2168 | m_RenderStats.syncoffset = rtClock - rtStart; |
| 2169 | |
| 2170 | int so = (int)std::clamp(m_RenderStats.syncoffset, -UNITS, UNITS); |
| 2171 | #if SYNC_OFFSET_EX |
| 2172 | m_SyncDevs.Add(so - m_Syncs.Last()); |
| 2173 | #endif |
| 2174 | m_Syncs.Add(so); |
| 2175 | |
| 2176 | if (m_bDoubleFrames) { |
| 2177 | if (rtEnd < rtClock) { |
| 2178 | m_RenderStats.dropped2++; |
| 2179 | return S_FALSE; // skip frame |
| 2180 | } |
| 2181 | |
| 2182 | rtStart += rtFrameDur / 2; |
| 2183 | |
| 2184 | hr = Render(2, rtStart); |
| 2185 | m_pFilter->m_DrawStats.Add(GetPreciseTick()); |
| 2186 | if (m_pFilter->m_filterState == State_Running) { |
| 2187 | m_pFilter->StreamTime(rtClock); |
| 2188 | } |
| 2189 | |
| 2190 | m_RenderStats.syncoffset = rtClock - rtStart; |
| 2191 | |
| 2192 | so = (int)std::clamp(m_RenderStats.syncoffset, -UNITS, UNITS); |
| 2193 | #if SYNC_OFFSET_EX |
| 2194 | m_SyncDevs.Add(so - m_Syncs.Last()); |
| 2195 | #endif |
| 2196 | m_Syncs.Add(so); |
| 2197 | } |
| 2198 | |
| 2199 | return hr; |
| 2200 | } |
nothing calls this directly
no test coverage detected