Tags: kierank/x262
Tags
MPEG-2: improve b-adapt 2 --b-adapt 2 lost to --b-adapt 1 in ways unrelated to its placement decisions 1. mbtree boundary-anchor over-boost. The keyint-capped trellis types the anchor right before the next keyframe as P before mbtree runs, and the transient all-P typing past the cap then chains the whole window's propagation into it -- a large QP boost for a frame whose quality the imminent keyframe replaces (mobile_cif crf12: QP 21.5 / 2816 B vs b-adapt 1's QP 24.8 / 1376 B, ~1.4 KB wasted per 15-frame GOP). b-adapt 1 dodges this purely by ordering: its boundary- oblivious typing leaves that frame B while mbtree runs, and only the post-mbtree keyframe enforcement flips it to P, so it never receives propagation. Retype the pre-boundary anchor B around the mbtree call (decision-neutral; only qp offsets move). 2. Interlaced lowres distance-parity artifact. The frame-based lowres underprices even reference distances on combed content because field parity survives even frame distances while odd distances comb: on the src10 pan, lowres says P(d2)/P(d1) = 0.93 where real coded bits (CQP, forced IPPP/IBPBP/IBBP structures) say 1.10. That hands single-B alternation a fake advantage in the path sums and collapses pan GOPs to IBPBPBP. Real cost is non-decreasing in distance (field MC covers the parity; also verified 1.17 on a second interlaced clip), so clamp each anchor's path cost to its cost at shorter distances, interlaced only. Increase-only, so the path search's pruning threshold stays sound. Fades are the real exception (longer distances can genuinely be cheaper), so the clamp is vetoed where the lookahead weights analysis found brightness weights; dissolves are not detectable that way and keep a small cost on dissolve-heavy content (ntia tea: +0.36% vs unfixed), against -1.0% on the pan archetype. BD-XPSNR of b-adapt 2 vs b-adapt 1, before -> after (100 frames, --preset slow --bframes 2 --keyint 15, crf 6/12/18/24; BD-SSIM2 agrees on every clip): foreman CIF-p -0.32 -> -0.39 (win improves) mobile CIF-p +1.12 -> +0.77 src10 SD-576i +1.91 -> +0.64 src13 SD-486i -0.54 -> -0.54 (win, output unchanged) park_joy HD-p +0.49 -> +0.39 (+0.45 at 200 frames) For now, b-adapt 2 still stays off slower presets. The residual is a mbtree free-run interaction that favors b-adapt 1's transient typing dynamics regardless of placement, not a placement mis-ranking. Forcing b-adapt 2's placements under b-adapt 1 costs only +0.17% on mobile.