Skip to content

Commit

Permalink
MPCVideoDec - workaround для корректного проигрывания некоторых "хитр…
Browse files Browse the repository at this point in the history
…о" уложенных H264 интерлейс потоков (ffmpeg возвращает для нескольких подряд идущих фреймов одинаковый pts).
  • Loading branch information
Aleksoid1978 committed May 28, 2024
1 parent 36b5227 commit 7824eca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/filters/transform/MPCVideoDec/MPCVideoDec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
, m_DXVADecoderGUID(GUID_NULL)
, m_nActiveCodecs(CODECS_ALL & ~CODEC_H264_MVC)
, m_rtAvrTimePerFrame(0)
, m_rtLastStart(INVALID_TIME)
, m_rtLastStop(0)
, m_rtStartCache(INVALID_TIME)
, m_bDXVACompatible(true)
Expand Down Expand Up @@ -1315,7 +1316,8 @@ REFERENCE_TIME CMPCVideoDecFilter::GetFrameDuration()

void CMPCVideoDecFilter::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
if (rtStart == INVALID_TIME) {
auto rtStartInput = rtStart;
if (rtStart == INVALID_TIME || (m_CodecId == AV_CODEC_ID_H264 && rtStart == m_rtLastStart)) {
rtStart = m_rtLastStop;
rtStop = INVALID_TIME;
}
Expand All @@ -1328,6 +1330,7 @@ void CMPCVideoDecFilter::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME
rtStop = rtStart + (frame_duration / m_dRate);
}

m_rtLastStart = rtStartInput;
m_rtLastStop = rtStop;
}

Expand Down Expand Up @@ -2465,7 +2468,7 @@ HRESULT CMPCVideoDecFilter::InitDecoder(const CMediaType* pmt)
}

if (m_CodecId == AV_CODEC_ID_H264) {
// check "Disable DXVA for SD (H.264)" option
// check "Disable DXVA for SD (H.264)" option
if (m_nDXVA_SD && std::max(m_nSurfaceWidth, m_nSurfaceHeight) <= 1024 && std::min(m_nSurfaceWidth, m_nSurfaceHeight) <= 576) {
break;
}
Expand Down Expand Up @@ -3143,6 +3146,7 @@ HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rt

m_rtStartCache = INVALID_TIME;

m_rtLastStart = INVALID_TIME;
m_rtLastStop = 0;

if (m_bReorderBFrame) {
Expand Down
3 changes: 2 additions & 1 deletion src/filters/transform/MPCVideoDec/MPCVideoDec.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class __declspec(uuid("008BAC12-FBAF-497b-9670-BC6F6FBAE2C4"))

int m_nARX, m_nARY;

REFERENCE_TIME m_rtLastStop; // rtStop for last delivered frame
REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
REFERENCE_TIME m_rtLastStop; // rtStop for last delivered frame
double m_dRate;

bool m_bUseFFmpeg;
Expand Down

0 comments on commit 7824eca

Please sign in to comment.