forge
Explore
Log in

Don't you dare go Hollow

The pyramid codes its leaves 12 quantizer steps above base, not 16

Browse files at this commit

96faf58bf287e6d6dc724418b3e15a3b6172ae4cAhmet Kaan GümüşParent: e11e279
  • feat
    • the pyramid codes its leaves 12 quantizer steps above base, not 16
Show full message
feat(av1): the pyramid codes its leaves 12 quantizer steps above base, not 16
crates/ec-av1/src/encode.rsmodified+5 -1
@@ -13570,8 +13570,12 @@ mod tests {
13570 // `base_q - 48` now ([`crate::encoder::Pyramid::key_q_offset`]), and13570 // `base_q - 48` now ([`crate::encoder::Pyramid::key_q_offset`]), and
13571 // one of these four pictures is the key -- 8590 -> 9778 at q=150 and13571 // one of these four pictures is the key -- 8590 -> 9778 at q=150 and
13572 // 28535 -> 35450 at q=60. `EC_AV1_PYRAMID=8:-32:16:-8:0` restores these.13572 // 28535 -> 35450 at q=60. `EC_AV1_PYRAMID=8:-32:16:-8:0` restores these.
13573+ // Re-taken on lane-arfq: the leaves are coded 12 quantizer steps above
13574+ // base now, not 16 ([`crate::encoder::Pyramid::leaf_q_offset`]) -- 9778
13575+ // -> 9835 at q=150 and 35450 -> 35798 at q=60.
13576+ // `EC_AV1_PYRAMID=8:-32:16:-8:-48` restores these.
13573 let pins: [(u8, usize, u64); 2] =13577 let pins: [(u8, usize, u64); 2] =
13574- [(150, 9778, 0x1f95_859a_9851_8fd6), (60, 35450, 0xd404_19e7_e2ba_84ad)];13578+ [(150, 9835, 0xfdac_0219_4a6e_111e), (60, 35798, 0xe57e_aa3f_8b48_d206)];
13575 for (q, bytes, hash) in pins {13579 for (q, bytes, hash) in pins {
13576 let encoded = encode_sequence(&source, q, 0.5).unwrap();13580 let encoded = encode_sequence(&source, q, 0.5).unwrap();
13577 assert_eq!(13581 assert_eq!(
crates/ec-av1/src/encoder.rsmodified+31 -1
@@ -734,11 +734,41 @@ impl Default for Pyramid {
734 /// The 12-frame gate keeps its numbers exactly (+43.9 / +15.6 and +68.4 /734 /// The 12-frame gate keeps its numbers exactly (+43.9 / +15.6 and +68.4 /
735 /// +38.2, byte-identical streams): a GOP that is one single mini-GOP does735 /// +38.2, byte-identical streams): a GOP that is one single mini-GOP does
736 /// not code the third level at all (see `drain_pending`).736 /// not code the third level at all (see `drain_pending`).
737+ /// THE LEAF OFFSET, RE-SWEPT ONCE THE ANCHORS MOVED (lane-arfq,
738+ /// `lanes/arfq.sweep.txt`). The table above chose `16` when the key frame
739+ /// still sat at the base quantizer; with [`Pyramid::key_q_offset`] at
740+ /// `-48` the whole run predicts off a much finer anchor and the leaves
741+ /// want to be finer with it. Long-GOP gate, control arm on the same head:
742+ ///
743+ /// | mini_gop:arf:leaf:mid:key | film A vs libaom / rav1e | film B vs libaom / rav1e |
744+ /// |---|---|---|
745+ /// | 8:-32:8:-8:-48 | +43.4 / +5.1 | +127.6 / +34.1 |
746+ /// | **8:-32:12:-8:-48** | **+43.1 / +4.6** | **+129.0 / +34.3** |
747+ /// | 8:-32:16:-8:-48 (control) | +43.5 / +4.6 | +131.3 / +35.0 |
748+ /// | 8:-32:24:-8:-48 | +45.6 / +5.6 | +138.8 / +38.4 |
749+ /// | 8:-32:12:-12:-48 | +43.4 / +5.0 | +128.1 / +33.8 |
750+ /// | 8:-32:12:-16:-48 | +44.0 / +5.6 | +127.7 / +34.1 |
751+ /// | 8:-24:12:-8:-48 | +44.5 / +5.2 | +128.6 / +33.3 |
752+ /// | 16:-32:12:-8:-48 | +47.2 / +6.3 | +134.7 / +35.6 |
753+ ///
754+ /// `12` ships: film B 2.3 / 0.7 down, film A 0.4 down against libaom and
755+ /// flat against rav1e. `8` is past the optimum (it buys film B and gives
756+ /// film A back), `24` is worse on all four. The other two axes were
757+ /// re-swept at `12` and did not move: a deeper mid (`-12`, `-16`) and a
758+ /// shallower ARF (`-24`) both trade film A away for film B, so the top
759+ /// ARF keeps its `-32` and the mid its `-8`. A 16-picture mini-GOP is
760+ /// worse on all four -- the pyramid has exactly three levels, so one mid
761+ /// frame cannot carry fifteen leaves.
762+ ///
763+ /// Unlike the third level this is NOT gated on GOP length: the 12-frame
764+ /// gate improves on every row too (film A +38.5 / +8.2 -> +37.5 / +7.6,
765+ /// film B +58.2 / +26.5 -> +54.1 / +23.9, both bars rows down, the screen
766+ /// capture byte-identical).
737 fn default() -> Self {767 fn default() -> Self {
738 Self {768 Self {
739 mini_gop: 8,769 mini_gop: 8,
740 arf_q_offset: -32,770 arf_q_offset: -32,
741- leaf_q_offset: 16,771+ leaf_q_offset: 12,
742 mid_q_offset: MID_DEFAULT,772 mid_q_offset: MID_DEFAULT,
743 key_q_offset: KEY_DEFAULT,773 key_q_offset: KEY_DEFAULT,
744 }774 }