forge
Explore
Log in

Don't you dare go Hollow

NEWMV census prints the hp symbol count

Browse files at this commit

057f20be8e9382914007d37a2b9cb605385219ffAhmet Kaan GümüşParent: c5d3832
  • test
    • NEWMV census prints the hp symbol count
    • lane-hpmv report
Show full message
test(av1): NEWMV census prints the hp symbol count; lane-hpmv report

The eighth-pel capability is refuted as a default on both films: film B
12 frames control +24.6/-2.0 vs +25.0/-1.8 (qindex<96), +25.1/-1.8
(qindex<128, libaom's own rule), +26.6/-0.3 (always on) -- monotone worse
in how much high precision is armed. It fires (53% of the hp bits coded
are zero, i.e. vectors the control cannot name) and costs 1.2-1.5 more mv
bits per coded NEWMV than it earns. Film A flat (+20.3/-5.0 -> +20.3/-4.9).
Ships default off (HP_MV_QTHRESH = 0); no default stream moved, so no byte
pin moved.
crates/ec-av1/src/encode.rsmodified+7 -0
@@ -4486,6 +4486,13 @@ pub(crate) fn dump_newmv_census() {
4486 v[7] as f64 / off / 64.0,4486 v[7] as f64 / off / 64.0,
4487 );4487 );
4488 }4488 }
4489+ // lane-hpmv: how many mv components this encode coded an eighth-pel bit
4490+ // for, and how many of those named a vector no non-hp frame can code.
4491+ let (hp_all, hp_eighth) = crate::tile::hp_symbols();
4492+ eprintln!(
4493+ "NEWMVCENSUS hp symbols {hp_all}, of them eighth-pel {hp_eighth} ({:.1}%)",
4494+ 100.0 * hp_eighth as f64 / hp_all.max(1) as f64,
4495+ );
4489 let g: [u64; 4] = std::array::from_fn(|i| NEWMV_CENSUS[32 + i].load(Relaxed));4496 let g: [u64; 4] = std::array::from_fn(|i| NEWMV_CENSUS[32 + i].load(Relaxed));
4490 eprintln!(4497 eprintln!(
4491 "NEWMVCENSUS pre-RD margin skips: extra-reference {}/{} ({:.1}%), \4498 "NEWMVCENSUS pre-RD margin skips: extra-reference {}/{} ({:.1}%), \
crates/ec-av1/src/tile.rsmodified+6 -0
@@ -852,6 +852,12 @@ pub(crate) fn take_hp_symbols() -> (u64, u64) {
852 (all, HP_SYMBOLS[1].swap(0, std::sync::atomic::Ordering::Relaxed))852 (all, HP_SYMBOLS[1].swap(0, std::sync::atomic::Ordering::Relaxed))
853 }853 }
854 854
855+/// [`take_hp_symbols`] without clearing -- what the NEWMV census prints.
856+pub(crate) fn hp_symbols() -> (u64, u64) {
857+ use std::sync::atomic::Ordering::Relaxed;
858+ (HP_SYMBOLS[0].load(Relaxed), HP_SYMBOLS[1].load(Relaxed))
859+}
860+
855 /// Writer-side counterpart of decode.rs `read_compound_ref_frames` (spec861 /// Writer-side counterpart of decode.rs `read_compound_ref_frames` (spec
856 /// 5.11.25's `comp_reference_type`/`uni_comp_ref`/`comp_ref`/`comp_bwdref`862 /// 5.11.25's `comp_reference_type`/`uni_comp_ref`/`comp_ref`/`comp_bwdref`
857 /// trees), symbol for symbol at the same contexts -- which are, as that863 /// trees), symbol for symbol at the same contexts -- which are, as that
lanes/hpmv.report.mdadded+108 -0
@@ -0,0 +1,108 @@
1+# lane-hpmv — eighth-pel motion vectors: the capability, and why it does not ship on
2+
3+Worktree `edith_codecs-hpmv`, branch `lane-hpmv` off main 12c99b84. Every BD
4+row is the release lib-test binary (`bd_rate_screen_native`, 12 pictures,
5+`gop 12`, four quantizers, native `gate_crop`), each row detached under its own
6+`systemd-run` unit and read off the log's own clip line.
7+
8+## 1. What was missing
9+
10+`allow_high_precision_mv` was off in every frame this writer coded, so
11+`tile::write_mv_component` REFUSED any residual whose eighth-pel bit is zero
12+and `encode::round_to_valid_mv` rounded the search's winner down to an even
13+1/8-pel count first — the finest vector the encoder could commit to was a
14+quarter pel. The DECODER already read `mv_hp`/`mv_class0_hp` (it decodes
15+libaom's low-q streams exactly), so this lane is writer-side only.
16+
17+Built (commit `a2cc1120`):
18+
19+* the header bit, from libaom's own rule — `av1_pick_and_set_high_precision_mv`
20+ (`mv_prec.c`): `use_hp = qindex < HIGH_PRECISION_MV_QTHRESH` (128). Ours is
21+ `encode::HP_MV_QTHRESH`, swept through `EC_AV1_HP_MV`
22+ (`0`/`off`, `all`, or a threshold).
23+* `write_mv_component`: the `mv_class0_hp` / `mv_hp` symbol per non-zero
24+ component in a high-precision frame, nothing coded otherwise (spec 5.11.32).
25+* `encode::mv_component_bits`: the same symbol priced, and no `None` refusal
26+ in a high-precision frame; `round_to_valid_mv` returns `mv` untouched there.
27+* `motion::search`: a FOURTH refinement stage at `EIGHTH_PEL_Q3`, run only in
28+ a high-precision frame.
29+* the frame's bit armed per worker beside the order hints
30+ (`tile::arm_high_precision_mv`), because the SEARCH reads it before the
31+ writer does.
32+
33+Not needed: `lower_mv_precision`. The spec applies it to the GLOBAL and
34+TEMPORAL (tpl) candidates only; this encoder writes `use_ref_frame_mvs: false`
35+and identity global motion, and `mvstack`'s tpl entry points already take the
36+flag. Spatial stack candidates keep their own precision either way.
37+
38+## 2. Witness (red before, green after)
39+
40+`encode::tests::a_high_precision_frame_codes_eighth_pel_motion_vectors_both_decoders_read`
41+— three frames of a panned test card, encoded twice with
42+`set_high_precision_mv(Some(false|true))`:
43+
44+```
45+hp witness: off 0 hp symbols / 862 B, on 6 hp symbols (5 eighth-pel) / 867 B
46+test ... ok
47+```
48+
49+Both arms decode sample-exact (Y, U, V, every frame) through ffmpeg AND
50+`crate::stream::decode_stream`. RED BEFORE by construction: before this commit
51+no frame could carry the bit at all (`allow_high_precision_mv: false`, no
52+setter, and `write_mv_component` erroring on the eighth-pel residual), so the
53+`on` arm could not be encoded — the count could only ever be 0. The
54+"5 of 6 hp symbols are ZERO" assertion is the signal, not the symbol: a zero
55+hp bit names a vector a non-hp frame cannot code at all.
56+
57+## 3. The policy sweep — film B, 12 frames (the deciding row)
58+
59+| arm | vs libaom | vs rav1e | hp symbols | of them eighth-pel |
60+|---|---|---|---|---|
61+| **control (off)** | **+24.6** | **-2.0** | 0 | — |
62+| `qindex < 96` | +25.0 | -1.8 | 58019 | 52.6% |
63+| `qindex < 128` (libaom's rule) | +25.1 | -1.8 | — | — |
64+| always on | +26.6 | -0.3 | 108001 | 53.9% |
65+
66+Monotone worse in how much high precision is armed, on BOTH columns. The
67+capability fires: over half the hp symbols coded are ZERO bits, i.e. vectors
68+the control cannot name.
69+
70+NEWMV census, same clip and quantizers, control -> always-on:
71+
72+| side | won% | mv bits | mv==nearest |
73+|---|---|---|---|
74+| 8 | 31.5 -> 29.4 | 8.29 -> 9.56 | 36.7 -> 32.4 |
75+| 16 | 41.1 -> 40.7 | 7.99 -> 9.48 | 30.3 -> 26.0 |
76+| 32 | 24.3 -> 24.9 | 7.07 -> 8.38 | 35.5 -> 32.4 |
77+
78+Search evals/call 81.3 -> 93.6 (the fourth stage). So the finer vector is
79+FOUND and CODED; it just costs 1.2-1.5 more mv bits per coded `NEWMV` than the
80+extra prediction accuracy earns back on this content, and the NEWMV share
81+falls with it. This is not a flat/inert result — it is a priced loss.
82+
83+## 4. Film A, 12 frames (best arm only)
84+
85+| arm | vs libaom | vs rav1e |
86+|---|---|---|
87+| control | +20.3 | -5.0 |
88+| `qindex < 128` | +20.3 | -4.9 |
89+
90+Flat on libaom, 0.1 worse on rav1e. With film B 0.4-0.5 worse on libaom at
91+every threshold, the keep rule ("both film rows improve on both columns, or
92+one >=0.5 down and the other flat +-0.3") cannot be met by any arm, so the
93+screen row and the long-GOP arm were not run — no candidate could have shipped
94+on their result.
95+
96+## 5. What ships
97+
98+The CAPABILITY, default OFF: `HP_MV_QTHRESH = 0`. `EC_AV1_HP_MV` sweeps it
99+without a rebuild, `set_high_precision_mv` arms it from a test. No default
100+stream moved, so no byte pin moved:
101+`the_encoders_own_streams_are_byte_identical_to_their_pins` is green UNCHANGED
102+(`(150, 8252, ...), (60, 33053, ...)` still the pinned bytes).
103+
104+Worth re-testing when the block-level mv pricing changes: the loss is entirely
105+a rate loss on the mv syntax, so a lane that moves `MV_LAMBDA`/the DRL pricing
106+or ships a smarter `NEWMV` share may flip its sign. libaom's own rule reads
107+`qindex < 128` on OUR ladder as "the two lowest-q points", i.e. it is the
108+low-q end that pays for it there.