diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index 4b88f984..f6911c2c 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -13630,8 +13630,14 @@ mod tests { // base now, not 16 ([`crate::encoder::Pyramid::leaf_q_offset`]) -- 9778 // -> 9835 at q=150 and 35450 -> 35798 at q=60. // `EC_AV1_PYRAMID=8:-32:16:-8:-48` restores these. + // Re-taken on lane-arfcen: the pyramid path hands every frame the + // lookahead window its temporal lambda map needs + // (`crate::encoder::tpl_pyramid`), which it never had, so every + // superblock of these four pictures is priced at its own lambda -- + // 9835 -> 9859 at q=150 and 35798 -> 35904 at q=60. + // `EC_AV1_TPL_PYRAMID=0` restores these. let pins: [(u8, usize, u64); 2] = - [(150, 9835, 0xfdac_0219_4a6e_111e), (60, 35798, 0xe57e_aa3f_8b48_d206)]; + [(150, 9859, 0x4409_f8db_e152_9fe7), (60, 35904, 0xc408_f126_2877_0ffb)]; for (q, bytes, hash) in pins { let encoded = encode_sequence(&source, q, 0.5).unwrap(); assert_eq!( diff --git a/crates/ec-av1/src/encoder.rs b/crates/ec-av1/src/encoder.rs index 942b1d9c..cac80fca 100644 --- a/crates/ec-av1/src/encoder.rs +++ b/crates/ec-av1/src/encoder.rs @@ -903,6 +903,24 @@ fn tpl_pyramid() -> bool { /// [`tpl_pyramid`]'s default. const TPL_PYRAMID: bool = true; +/// Whether a group's TOP ARF names the ARF from TWO groups back as its own +/// `ALTREF_FRAME` (lane-arfcen). It has always named `GOLDEN_SLOT` there, +/// which for a top ARF is the key frame it already reads as `GOLDEN`, i.e. +/// its second reference is the same picture as its first for the first group +/// and adds nothing after: the ARF-vs-ARF census reads +/// `LAST@-8 GOLDEN@-8` on our first ARF where rav1e's reads two DISTINCT +/// anchors. The slot the ARF is about to refresh still holds that older +/// anchor while this frame is coded, so naming it costs no extra DPB slot. +fn arf_altref() -> bool { + match std::env::var("EC_AV1_ARF_ALTREF").ok() { + Some(v) => v != "0", + None => ARF_ALTREF, + } +} + +/// [`arf_altref`]'s default. +const ARF_ALTREF: bool = false; + /// The AV1 software encoder: [`EncoderConfig`] in, one [`Packet`] out per /// [`Av1Encoder::encode`] call — or, with a [`Pyramid`] configured, a /// coding-order burst of them per [`Av1Encoder::encode_frames`] call plus a @@ -1633,7 +1651,14 @@ impl Av1Encoder { &arf_picture, anchor_slot, next_anchor_slot, - GOLDEN_SLOT, + // lane-arfcen: the slot this ARF refreshes still holds the ARF + // from two groups back, so naming it here gives the frame a + // SECOND, distinct past anchor instead of the key it already + // reads as GOLDEN. + match arf_altref() { + true => next_anchor_slot, + false => GOLDEN_SLOT, + }, false, Level::Arf, pyramid.arf_q_offset, diff --git a/lanes/arfcen.report.md b/lanes/arfcen.report.md index 27201544..0477ad12 100644 --- a/lanes/arfcen.report.md +++ b/lanes/arfcen.report.md @@ -121,3 +121,36 @@ Probe arms on film B (control = the old `&[]`): | on, depth 2 | 91328 / 45.489 | 481497 / 47.990 | -0.6% / -0.3% | Wall is unchanged (101.5 s vs 101.2 s for the two-point ladder). + +## 6. Gate tables + +Long-GOP arm (`bd_rate_film_long_gop`, 48 frames, BD vs libaom cpu-used 6 / +vs rav1e speed 6). The control arm was RUN, not quoted, and lands on the +recorded defaults to the digit: + +| arm | film A | film B | +|---|---|---| +| control (`EC_AV1_TPL_PYRAMID=0`) | +43.1% / +4.6% | +129.0% / +34.3% | +| **arm 1: tpl on the pyramid path** | **+42.8% / +4.5%** | **+127.3% / +32.9%** | + +Both film rows improve on both columns: the keep rule passes, so arm 1 ships +on by default. + +12-frame arm (`bd_rate_screen_native`), control re-run the same way: + +| arm | bars 1080p | bars 2160p | film A | film B | +|---|---|---|---|---| +| control | +1.7 / -14.5 | +12.2 / -10.2 | +37.5 / +7.6 | +54.1 / +23.9 | +| arm 1 | +2.0 / -14.2 | +12.6 / -9.9 | **+37.2 / +7.3** | **+53.2 / +23.1** | + +Both REAL film rows improve on both columns here too; the two "bars" rows are +ffmpeg `testsrc2` colour bars (recorded, never a decision) and read 0.3-0.4 +points up. + +Invariants at the shipped arm: `encoder::` scoped 33 passed / 0 failed +(release binary, 868 s, includes the bitrate test), +`the_facade_codes_the_same_bytes_as_encode_sequence` + +`tile_bytes_do_not_depend_on_the_thread_count --include-ignored` 2 passed, +`EC_COMP_MISMATCH=1` over the 48-frame film B encode: 0 lines. +Pins re-taken (the stream moves by construction): 9835 -> **9859** at q=150 +and 35798 -> **35904** at q=60; `EC_AV1_TPL_PYRAMID=0` restores the old pair.