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)
Reported by Yunqing Wang (Google) thanks for spotting this 馃
av2_muxrejects any bitstream with more than one key frame, which is essentially every real encode (--kf-max-dist):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=9999muxes fine, so the discriminator is exactly "more than one key frame".Cause
Each CVS restarts
order_hintat 0. Indisplay_order_lifter.cppa CLK takes thelifted = lsbsshortcut andanchor_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()inav2_muxer.cppguards against this by refusing thestream.
Possible fix
cvs_base_ = max_lifted_ + 1and add it to subsequent lifted values. Gives 0-9,10-19, 20-29 for the stream above. Remove the
clk_count > 1guard.stss/sample_is_non_sync_sample=0).