mediafoundation: Fix the frame number validation logic for motion hint

The external move region frame number was continuously generated. However, the current POC was reset based on IDR.
Modified the logic of validation and logged a warning in case of mismatch.

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40756>
This commit is contained in:
Wenfeng Gao 2026-03-23 10:04:18 -07:00 committed by Marge Bot
parent bae86c3118
commit aa5398689b
2 changed files with 14 additions and 8 deletions

View file

@ -426,14 +426,17 @@ CDX12EncHMFT::PrepareForEncodeHelper( LPDX12EncodeContext pDX12EncodeContext,
uint32_t current_poc = pPicInfo->pic_order_cnt;
// Validate frame number first
if( moveRegionFrameNum != current_poc )
// Due to the way the move region frame number is generated, there can be cases where the frame number doesn't match the
// current POC. In those cases, we will log a warning but still try to use the move regions.
if( m_uiGopSize > 0 && ( moveRegionFrameNum % m_uiGopSize ) != current_poc )
{
debug_printf( "[dx12 hmft 0x%p] MoveRegions frame mismatch (MRFN=%u, cur POC=%u), ignoring\n",
debug_printf( "[dx12 hmft 0x%p] WARNING: MoveRegions frame mismatch (MRFN=%u, cur POC=%u, GOPSize=%u)\n",
this,
moveRegionFrameNum,
current_poc );
current_poc,
m_uiGopSize );
}
else
{
MOVEREGION_INFO *pMoveInfo = reinterpret_cast<MOVEREGION_INFO *>( m_pMoveRegionBlob.data() );
uint32_t maxRects = m_EncoderCapabilities.m_HWSupportMoveRects.bits.max_motion_hints;

View file

@ -434,14 +434,17 @@ CDX12EncHMFT::PrepareForEncodeHelper( LPDX12EncodeContext pDX12EncodeContext,
uint32_t current_poc = pPicInfo->pic_order_cnt;
// Validate frame number first
if( moveRegionFrameNum != current_poc )
// Due to the way the move region frame number is generated, there can be cases where the frame number doesn't match the
// current POC. In those cases, we will log a warning but still try to use the move regions.
if( m_uiGopSize > 0 && ( moveRegionFrameNum % m_uiGopSize ) != current_poc )
{
debug_printf( "[dx12 hmft 0x%p] MoveRegions frame mismatch (MRFN=%u, cur POC=%u), ignoring\n",
debug_printf( "[dx12 hmft 0x%p] WARNING: MoveRegions frame mismatch (MRFN=%u, cur POC=%u, GOPSize=%u)\n",
this,
moveRegionFrameNum,
current_poc );
current_poc,
m_uiGopSize );
}
else
{
MOVEREGION_INFO *pMoveInfo = reinterpret_cast<MOVEREGION_INFO *>( m_pMoveRegionBlob.data() );
uint32_t maxRects = m_EncoderCapabilities.m_HWSupportMoveRects.bits.max_motion_hints;