Pin that the filter search fires, and record the measured ladder
Browse files at this commit06cf00ea8febeb8ac7a3c4ea0c49a959b2943556Parent: df76271- test
- pin that the filter search fires, and record the measured ladder
1 changed file +64 -7
- crates/ec-av1/src/encode.rs +64 -7
crates/ec-av1/src/encode.rsmodified+64 -7
| @@ -524,7 +524,9 @@ pub struct Encoded { | |||
| 524 | } | 524 | } |
| 525 | 525 | ||
| 526 | /// The sequence and frame headers a picture of this size is coded under: one | 526 | /// The sequence and frame headers a picture of this size is coded under: one |
| 527 | -/// tile, one transform size per block, no in-loop filtering, no CDF adaptation | 527 | +/// tile, one transform size per block, no in-loop filter parameters yet |
| 528 | +/// (`crate::encode::pick_and_apply_filters` fills the deblocking levels and | ||
| 529 | +/// CDEF strengths in once the tile is coded), no CDF adaptation | ||
| 528 | /// and no tool the tile writer does not code. | 530 | /// and no tool the tile writer does not code. |
| 529 | /// | 531 | /// |
| 530 | /// # Errors | 532 | /// # Errors |
| @@ -4479,6 +4481,46 @@ mod tests { | |||
| 4479 | /// A picture with something of everything in it: a gradient, an edge, a | 4481 | /// A picture with something of everything in it: a gradient, an edge, a |
| 4480 | /// ripple and a block of flat colour, none of them aligned to the block | 4482 | /// ripple and a block of flat colour, none of them aligned to the block |
| 4481 | /// grid. | 4483 | /// grid. |
| 4484 | + /// The in-loop filters actually FIRE and the stream still decodes to | ||
| 4485 | + /// exactly what the encoder kept as its reconstruction | ||
| 4486 | + /// (gate-blind-to-feature: a filter search that always answered "off" | ||
| 4487 | + /// would leave every other test just as green, and the BD gate that | ||
| 4488 | + /// would notice is `#[ignore]`d). | ||
| 4489 | + /// | ||
| 4490 | + /// Run: | ||
| 4491 | + /// cargo test -p ec-av1 --release --lib -- \ | ||
| 4492 | + /// encode::tests::the_filter_search_picks_real_filters | ||
| 4493 | + #[test] | ||
| 4494 | + fn the_filter_search_picks_real_filters() { | ||
| 4495 | + let fctx = &crate::decode::FrameCtx::new(); | ||
| 4496 | + let pictures: Vec<_> = (0..3).map(|i| panned_test_card(128, 128, i * 3)).collect(); | ||
| 4497 | + let encoded = encode_sequence_with_ctx(&pictures, 120, 0.5, fctx).unwrap(); | ||
| 4498 | + let fired = encoded | ||
| 4499 | + .frames | ||
| 4500 | + .iter() | ||
| 4501 | + .filter(|f| f.loop_filter.level[0] > 0 || f.cdef.y_pri_strength[0] > 0) | ||
| 4502 | + .count(); | ||
| 4503 | + assert!( | ||
| 4504 | + fired > 0, | ||
| 4505 | + "no frame of this sequence chose any in-loop filtering: {:?}", | ||
| 4506 | + encoded | ||
| 4507 | + .frames | ||
| 4508 | + .iter() | ||
| 4509 | + .map(|f| (f.loop_filter.level, f.cdef.y_pri_strength[0])) | ||
| 4510 | + .collect::<Vec<_>>() | ||
| 4511 | + ); | ||
| 4512 | + // The reconstruction the encoder predicts from is the FILTERED one, | ||
| 4513 | + // and it is what a decoder of the stream produces -- byte for byte, | ||
| 4514 | + // frame for frame. | ||
| 4515 | + let decoded = crate::stream::decode_stream(&encoded.stream).unwrap(); | ||
| 4516 | + assert_eq!(decoded.len(), encoded.frames.len()); | ||
| 4517 | + for (i, (dec, enc)) in decoded.iter().zip(&encoded.frames).enumerate() { | ||
| 4518 | + assert_eq!(dec.y, enc.reconstruction.y, "frame {i} luma"); | ||
| 4519 | + assert_eq!(dec.u, enc.reconstruction.u, "frame {i} U"); | ||
| 4520 | + assert_eq!(dec.v, enc.reconstruction.v, "frame {i} V"); | ||
| 4521 | + } | ||
| 4522 | + } | ||
| 4523 | + | ||
| 4482 | fn test_card(width: usize, height: usize) -> Picture { | 4524 | fn test_card(width: usize, height: usize) -> Picture { |
| 4483 | let mut picture = Picture::grey(width, height); | 4525 | let mut picture = Picture::grey(width, height); |
| 4484 | for y in 0..height { | 4526 | for y in 0..height { |
| @@ -6876,15 +6918,30 @@ mod tests { | |||
| 6876 | /// ours: `base_q_idx {60,90,120,150}`. Every PSNR is all-plane, on | 6918 | /// ours: `base_q_idx {60,90,120,150}`. Every PSNR is all-plane, on |
| 6877 | /// ffmpeg-decoded frames of each encoder's own stream. | 6919 | /// ffmpeg-decoded frames of each encoder's own stream. |
| 6878 | /// | 6920 | /// |
| 6879 | - /// Measured 2026-09-06 after the inter partition search (lane-av1rd2), | 6921 | + /// Measured 2026-09-06 after the in-loop filters (lane-av1filt: per-frame |
| 6880 | - /// 12 frames, this box (wall = the four encodes of that ladder | 6922 | + /// deblocking levels and CDEF strengths, both chosen by re-decoding the |
| 6881 | - /// together): | 6923 | + /// coded tile -- `crate::filter_search`), 12 frames, this box (wall = the |
| 6924 | + /// four encodes of that ladder together): | ||
| 6882 | /// | 6925 | /// |
| 6883 | /// | clip | ours (q 150/120/90/60) | BD-rate vs libaom | vs rav1e | wall ours:aom:rav1e | | 6926 | /// | clip | ours (q 150/120/90/60) | BD-rate vs libaom | vs rav1e | wall ours:aom:rav1e | |
| 6884 | /// |---|---|---|---|---| | 6927 | /// |---|---|---|---|---| |
| 6885 | - /// | 1080p fixture | 41.16 dB/22349 B .. 49.97 dB/83178 B | +234.0% | +171.9% | 9.8s:1.1s:2.6s | | 6928 | + /// | 1080p fixture | 42.11 dB/17774 B .. 50.99 dB/76838 B | +143.6% | +94.0% | 9.2s:1.1s:2.6s | |
| 6886 | - /// | 2160p fixture | 42.01 dB/14687 B .. 50.82 dB/52415 B | +260.3% | +203.2% | 9.3s:1.0s:2.2s | | 6929 | + /// | 2160p fixture | 42.84 dB/12480 B .. 51.43 dB/46557 B | +179.5% | +128.8% | 8.6s:1.0s:2.2s | |
| 6887 | - /// | screen capture | 37.49 dB/12797 B .. 46.19 dB/50643 B | +318.5% | +155.3% | 9.1s:1.0s:2.1s | | 6930 | + /// | screen capture | 39.76 dB/9536 B .. 48.87 dB/29189 B | +88.0% | +21.5% | 7.2s:1.0s:2.1s | |
| 6931 | + /// | ||
| 6932 | + /// The three steps of that lane, same recipe (vs libaom, then vs rav1e): | ||
| 6933 | + /// | ||
| 6934 | + /// | step | 1080p | 2160p | screen | | ||
| 6935 | + /// |---|---|---|---| | ||
| 6936 | + /// | no in-loop filter | +234.0 / +171.9 | +260.3 / +203.2 | +318.5 / +155.3 | | ||
| 6937 | + /// | + deblocking | +198.2 / +143.1 | +218.1 / +162.4 | +136.9 / +52.7 | | ||
| 6938 | + /// | + CDEF | +143.6 / +94.0 | +179.5 / +128.8 | +88.0 / +21.5 | | ||
| 6939 | + /// | ||
| 6940 | + /// Loop restoration is NOT in yet: it is the one filter whose parameters | ||
| 6941 | + /// are per restoration UNIT inside the tile payload, so it needs both | ||
| 6942 | + /// tile writers to code `lr` syntax and an encoder-visible post-CDEF | ||
| 6943 | + /// buffer to solve against -- neither of which this frame-header-level | ||
| 6944 | + /// search reaches. | ||
| 6888 | /// | 6945 | /// |
| 6889 | /// The baseline it replaced, before an inter frame's blocks chose their | 6946 | /// The baseline it replaced, before an inter frame's blocks chose their |
| 6890 | /// own partition, was +501.4/+504.4/+440.9 against libaom and | 6947 | /// own partition, was +501.4/+504.4/+440.9 against libaom and |