Skip to content

Conversation

@zlatinski
Copy link
Contributor

No description provided.

During a resolution change (e.g., 352x288 → 176x144), the parser was
incorrectly managing DPB slot indices, leading to out-of-bounds access
and driver crashes.

Root cause #1: Wrong sequence update detection
----------------------------------------------
The code used nMaxWidth/nMaxHeight to detect if this was a sequence
update vs. first sequence:

    bool sequenceUpdate = ((m_nvsi.nMaxWidth != 0) && (m_nvsi.nMaxHeight != 0));

Problem: nMaxWidth/nMaxHeight can legitimately be 0 for many H.264
bitstreams (they're optional VUI fields). This caused the second
sequence to be incorrectly treated as 'first sequence'.

Fix: Use nCodedWidth/nCodedHeight instead, which are always set.

Root cause #2: Stale DPB slot indices carried across resize
-----------------------------------------------------------
When sequenceUpdate was incorrectly false, the DPB was reinitialized
but the old m_pictureToDpbSlotMap entries persisted with slot indices
that could exceed the new (possibly smaller) m_dpbMaxSize.

Later, when the parser tried to FreeSlot(slot >= new m_dpbMaxSize),
it triggered:
  - Debug: assert '(uint8_t)slot < m_dpbMaxSize' failed
  - Release: undefined behavior → driver crash / device lost

Fix: On coded-extent reconfigure, fully reset DPB state:
  - m_dpbSlotsMask = 0
  - m_fieldPicFlagMask = 0
  - m_pictureToDpbSlotMap[*] = -1

This ensures the new sequence starts with a clean DPB, which is
correct since a resolution change implies an IDR with no references
to the previous sequence.

Note: This fix works together with the timeline semaphore fix in
VulkanVideoFrameBuffer.cpp (commit d437b6a9) to fully resolve the
resize crash.

Signed-off-by: Tony Zlatinski <[email protected]>
@zlatinski zlatinski force-pushed the fix-slot-management-across-sequence branch from 90386c0 to b8cdff0 Compare December 24, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants