Pin the pyramid QP-offset sweep and why the pyramid ships off
Browse files at this commit006a259e5f23c06ff7e601f15b9a3756a36d35d6Parent: 4d40670- docs
- pin the pyramid QP-offset sweep and why the pyramid ships off
1 changed file +37 -3
- crates/ec-av1/src/encoder.rs +37 -3
crates/ec-av1/src/encoder.rsmodified+37 -3
| @@ -4,7 +4,11 @@ | |||
| 4 | //! One picture in, one [`Packet`] out, same contract as the repo's other | 4 | //! One picture in, one [`Packet`] out, same contract as the repo's other |
| 5 | //! software encoder shims (`shims/rusty_h264`'s `Encoder::try_encode`, | 5 | //! software encoder shims (`shims/rusty_h264`'s `Encoder::try_encode`, |
| 6 | //! "nothing is ever held back"): [`Av1Encoder::encode`] never buffers a | 6 | //! "nothing is ever held back"): [`Av1Encoder::encode`] never buffers a |
| 7 | -//! picture past its own call, so there is no flush to drain. Internally it | 7 | +//! picture past its own call, so there is no flush to drain. That contract |
| 8 | +//! still holds for every caller that does not opt into a coding pyramid; | ||
| 9 | +//! [`Av1Encoder::with_pyramid`] does reorder pictures, and such a stream is | ||
| 10 | +//! driven through [`Av1Encoder::encode_frames`] (zero or more packets per | ||
| 11 | +//! picture) and [`Av1Encoder::flush`] instead. Internally it | ||
| 8 | //! is [`crate::encode::encode_key_frame_inner`] and | 12 | //! is [`crate::encode::encode_key_frame_inner`] and |
| 9 | //! [`crate::encode::encode_inter_frame`] driven by a small state machine — | 13 | //! [`crate::encode::encode_inter_frame`] driven by a small state machine — |
| 10 | //! a key frame every `gop` pictures, an inter frame predicting from the | 14 | //! a key frame every `gop` pictures, an inter frame predicting from the |
| @@ -325,8 +329,38 @@ pub struct Pyramid { | |||
| 325 | } | 329 | } |
| 326 | 330 | ||
| 327 | impl Default for Pyramid { | 331 | impl Default for Pyramid { |
| 328 | - /// The offsets `encode::tests::pyramid_q_offset_sweep` measured (see the | 332 | + /// The best point of the offset sweep run through the BD gate's own |
| 329 | - /// sweep's own report) at the mini-GOP size that won it. | 333 | + /// `EC_AV1_PYRAMID=<mini_gop>[:<arf_q_offset>:<leaf_q_offset>]` knob |
| 334 | + /// (`encode::tests::bd_rate_vs_libaom_and_rav1e`, 12 frames of each of | ||
| 335 | + /// the three gate clips, BD-rate vs libaom / vs rav1e): | ||
| 336 | + /// | ||
| 337 | + /// | mini_gop:arf:leaf | 1080p | 2160p | screen | | ||
| 338 | + /// |---|---|---|---| | ||
| 339 | + /// | flat (no pyramid) | +122.7 / +73.4 | +147.3 / +98.5 | +79.4 / +17.2 | | ||
| 340 | + /// | 4:0:0 | +152.2 / +97.9 | +214.7 / +158.1 | +91.4 / +26.2 | | ||
| 341 | + /// | 4:-16:8 | +139.9 / +87.1 | +201.5 / +143.7 | +78.5 / +19.5 | | ||
| 342 | + /// | 4:-24:12 | +141.3 / +85.0 | +190.0 / +132.9 | +84.5 / +22.8 | | ||
| 343 | + /// | 2:0:0 | +149.3 / +93.1 | +203.0 / +149.4 | +88.3 / +23.6 | | ||
| 344 | + /// | 2:-8:4 | +143.1 / +89.1 | +196.2 / +141.6 | +82.5 / +20.4 | | ||
| 345 | + /// | 2:-16:8 | +137.6 / +84.5 | +187.2 / +130.6 | +84.9 / +23.1 | | ||
| 346 | + /// | ||
| 347 | + /// Two things the sweep says. The quantizer offsets are real and in the | ||
| 348 | + /// direction libaom's `gf_group` spends them (0/0 is the worst row at | ||
| 349 | + /// every mini-GOP; -16/+8 buys 12-16 BD points over it), which is what | ||
| 350 | + /// these defaults are. And the pyramid as a whole does NOT yet pay: no | ||
| 351 | + /// row beats the flat baseline on all three clips, and 2160p is 40-70 | ||
| 352 | + /// points worse everywhere. | ||
| 353 | + /// | ||
| 354 | + /// The reason is measurable, not mysterious: the leaves may only reach | ||
| 355 | + /// the hidden frame through the SEARCH-FREE modes (`NEARESTMV` off the | ||
| 356 | + /// stack and `GLOBALMV`) — this lane adds no motion search — so | ||
| 357 | + /// `ALTREF_FRAME` wins about 4% of blocks, while the hidden frame itself | ||
| 358 | + /// pays the full cost of predicting `mini_gop` pictures ahead of its own | ||
| 359 | + /// reference. Backward `NEWMV` is the missing half, and it lives in the | ||
| 360 | + /// motion-search lane. Until it lands the pyramid ships OFF: nothing | ||
| 361 | + /// selects it but an explicit [`Av1Encoder::with_pyramid`] call (or | ||
| 362 | + /// `EC_AV1_PYRAMID` on the gate and on `ec-bench`), and the default | ||
| 363 | + /// one-in-one-out path is byte-identical to before it existed. | ||
| 330 | fn default() -> Self { | 364 | fn default() -> Self { |
| 331 | Self { | 365 | Self { |
| 332 | mini_gop: 4, | 366 | mini_gop: 4, |