From 04192362e5295f963dee2acedef38bf72d58e571 Mon Sep 17 00:00:00 2001 From: "Pohsiang (John) Hsu" Date: Thu, 18 Sep 2025 15:22:25 -0700 Subject: [PATCH] mediafoundation: return adjusted LTR frame (need to remove one for short term) Reviewed-by: Yubo Xie Part-of: --- src/gallium/frontends/mediafoundation/codecapi.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/mediafoundation/codecapi.cpp b/src/gallium/frontends/mediafoundation/codecapi.cpp index 981969ad7d8..ffeec3985bb 100644 --- a/src/gallium/frontends/mediafoundation/codecapi.cpp +++ b/src/gallium/frontends/mediafoundation/codecapi.cpp @@ -675,7 +675,14 @@ CDX12EncHMFT::GetParameterValues( const GUID *Api, VARIANT **Values, ULONG *Valu } else if( *Api == CODECAPI_AVEncVideoLTRBufferControl ) { - *ValuesCount = m_EncoderCapabilities.m_uiMaxHWSupportedLongTermReferences + 1; + // reserve one dpb spot for short term reference frame. + // when m_EncoderCapabilities.m_uiMaxHWSupportedLongTermReferences = m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity, we subtract one. + ULONG numSupportedLTR = m_EncoderCapabilities.m_uiMaxHWSupportedLongTermReferences; + if( numSupportedLTR > 0 && numSupportedLTR == m_EncoderCapabilities.m_uiMaxHWSupportedDPBCapacity ) + { + numSupportedLTR -= 1; + } + *ValuesCount = numSupportedLTR + 1; CHECKNULL_GOTO( *Values = (VARIANT *) CoTaskMemAlloc( ( *ValuesCount ) * sizeof( VARIANT ) ), E_OUTOFMEMORY, done ); for( ULONG i = 0; i < *ValuesCount; i++ ) {