Skip to content

Mark error-resilient switch frames as restricted#5094

Merged
urvangjoshi merged 1 commit into
AOMediaCodec:mainfrom
xinzhao-apple:mr/avm-bugfix
Jul 10, 2026
Merged

Mark error-resilient switch frames as restricted#5094
urvangjoshi merged 1 commit into
AOMediaCodec:mainfrom
xinzhao-apple:mr/avm-bugfix

Conversation

@xinzhao-apple

@xinzhao-apple xinzhao-apple commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

When the encoder is run in error-resilient mode (--global-error-resilient=1), switch frames are emitted without their reference frames being marked as restricted. This produces a bitstream that is not AV2-compliant and that decoders reject.

This MR sets restricted_prediction_switch for error-resilient switch frames as well, so switch frames generated in that mode carry the correct restricted-reference semantics.

In error-resilient mode (--global-error-resilient=1), the current AVM encoder converts alt-ref–type frames (which are reordered/future frames) into switch frames. When such a switch is left unconstrained (non-restricted), the encoder can assign it a low display order hint (e.g. 1) while a frame with a higher display order hint (e.g. 4) has already been output, producing a non-monotonic output order. Because a non-restricted switch does not reset the OrderHint counter, this violates the conformance constraint below (AV2 spec §7.3.6, "Coded extended layer unit"):

If monotonic_output_order_flag is equal to 0, it is a requirement of bitstream conformance that within a coded video sequence, for a given value of obu_xlayer_id and obu_mlayer_id, if a coded output frame unit X has an associated OrderHint value equal to ohX, there shall not be a coded output frame unit Y in the same extended layer and embedded layer that appears later than X in output order and has an associated OrderHint value less than or equal to ohX, unless a switch frame with restricted_prediction_switch equal to 1 appears between X and Y in coding order.
NOTE: The value of OrderHint is reset at the start of a new coded video sequence and at a switch frame with restricted_prediction_switch equal to 1. In both cases, the OrderHint counter is effectively restarted, allowing OrderHint values to be reused in subsequent coded output frame units.

@urvangjoshi urvangjoshi enabled auto-merge (squash) July 10, 2026 17:52
@urvangjoshi urvangjoshi merged commit 344bc7c into AOMediaCodec:main Jul 10, 2026
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants