Skip to content

av2_mux fails on any stream with more than one key frame (multi-CVS)聽#10

Description

@podborski

Reported by Yunqing Wang (Google) thanks for spotting this 馃

av2_mux rejects any bitstream with more than one key frame, which is essentially every real encode (--kf-max-dist):

[error] Non-monotonic stream: base xlayer has 3 CLK frames (multi-CVS); the v1 DOH lifter does not reset across CVS boundaries.

Reproduce

avmenc in.y4m --kf-max-dist=10 --limit=30 --lag-in-frames=19 --auto-alt-ref=1 \
  --min-gf-interval=16 --max-gf-interval=16 --gf-min-pyr-height=4 --gf-max-pyr-height=4 \
  --use-fixed-qp-offsets=1 --deltaq-mode=0 --enable-tpl-model=0 \
  --enable-keyframe-filtering=1 --end-usage=q --qp=235 --cpu-used=5 --obu -o multi_kf.obu

av2_mux multi_kf.obu -o out.mp4 --fps 30.0     # fails

--kf-max-dist=9999 muxes fine, so the discriminator is exactly "more than one key frame".

Cause

Each CVS restarts order_hint at 0. In display_order_lifter.cpp a CLK takes the lifted = lsbs shortcut and anchor_ is latched once from the first frame, so the second CVS's key frame lifts to display order 0 again and collides with sample 0.
check_doh_lifter_supported() in av2_muxer.cpp guards against this by refusing the
stream.

Possible fix

  • Track the max lifted value in the current CVS; on each CLK after the first set
    cvs_base_ = max_lifted_ + 1 and add it to subsequent lifted values. Gives 0-9,
    10-19, 20-29 for the stream above. Remove the clk_count > 1 guard.
  • Every CLK sample must be signalled as a sync sample (stss / sample_is_non_sync_sample=0).
  • Repeated sequence headers that are byte-identical to the first can be dropped from the samples; the initial one stays in the sample entry (no redundant sample entries)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions