The partition breakout knob, swept and left off
Browse files at this commit04ff5f8a48e1cac9d5ca4365ff144ce781f9ab09Parent: 06a3123- perf
- the partition breakout knob, swept and left off
1 changed file +34 -2
- crates/ec-av1/src/encode.rs +34 -2
crates/ec-av1/src/encode.rsmodified+34 -2
| @@ -150,6 +150,30 @@ fn split_inter_blocks() -> bool { | |||
| 150 | } | 150 | } |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | +/// libaom's `partition_search_breakout` shape: how many non-zero luma | ||
| 154 | +/// coefficients per 256 luma samples a block may code and still be judged | ||
| 155 | +/// well enough predicted that the split below it is not worth trying. `0` | ||
| 156 | +/// disables the breakout (only the existing all-skip prune applies), which | ||
| 157 | +/// is the default until the sweep below justifies otherwise. | ||
| 158 | +/// | ||
| 159 | +/// Swept on the BD gate (`EC_AV1_SPLIT_BREAKOUT`, test builds only), which | ||
| 160 | +/// is where this lane's wall would have gone: 1 cuts the three clips' | ||
| 161 | +/// encode wall 6.3/6.0/6.2 s -> 3.6/3.2/4.4 s but costs +18.4/+24.0/+7.9 | ||
| 162 | +/// BD-rate points against libaom; 2 costs +23.4/+29.4/+18.8 and 4 costs | ||
| 163 | +/// +31.7/+40.6/+27.8, for barely more speed. The split trial is where this | ||
| 164 | +/// encoder's inter quality lives, so `0` ships and the knob stays for a | ||
| 165 | +/// future explicit speed preset. | ||
| 166 | +const SPLIT_BREAKOUT_COEFFS: usize = 0; | ||
| 167 | + | ||
| 168 | +/// [`SPLIT_BREAKOUT_COEFFS`], swept by `EC_AV1_SPLIT_BREAKOUT` in a test | ||
| 169 | +/// build. | ||
| 170 | +fn split_breakout_coeffs() -> usize { | ||
| 171 | + match std::env::var("EC_AV1_SPLIT_BREAKOUT").ok() { | ||
| 172 | + Some(v) if cfg!(test) => v.parse().unwrap_or(SPLIT_BREAKOUT_COEFFS), | ||
| 173 | + _ => SPLIT_BREAKOUT_COEFFS, | ||
| 174 | + } | ||
| 175 | +} | ||
| 176 | + | ||
| 153 | /// How often each partition decision was taken since the last | 177 | /// How often each partition decision was taken since the last |
| 154 | /// [`take_partition_hits`], so a gate can report how often a new partition | 178 | /// [`take_partition_hits`], so a gate can report how often a new partition |
| 155 | /// fires rather than assume it does (gate-blind-to-feature). Index 0 is an | 179 | /// fires rather than assume it does (gate-blind-to-feature). Index 0 is an |
| @@ -3387,7 +3411,13 @@ pub(crate) fn encode_inter_frame( | |||
| 3387 | header.mi_rows, | 3411 | header.mi_rows, |
| 3388 | ) | 3412 | ) |
| 3389 | }); | 3413 | }); |
| 3390 | - let split = (!block.skip && leaves_legal && split_inter_blocks()) | 3414 | + // The breakout above: a 32x32 block that codes almost |
| 3415 | + // nothing is not offered the split at all. | ||
| 3416 | + let breakout = split_breakout_coeffs(); | ||
| 3417 | + let split = (!block.skip | ||
| 3418 | + && (breakout == 0 || block.luma.len() > 4 * breakout) | ||
| 3419 | + && leaves_legal | ||
| 3420 | + && split_inter_blocks()) | ||
| 3391 | .then(|| { | 3421 | .then(|| { |
| 3392 | restore(&mut luma, &mut chroma, (x, y), BLOCK, &base); | 3422 | restore(&mut luma, &mut chroma, (x, y), BLOCK, &base); |
| 3393 | let mut cost = search.lambda * partition_bits(BLOCK, true); | 3423 | let mut cost = search.lambda * partition_bits(BLOCK, true); |
| @@ -3418,7 +3448,9 @@ pub(crate) fn encode_inter_frame( | |||
| 3418 | // the writer codes as a real PARTITION_SPLIT | 3448 | // the writer codes as a real PARTITION_SPLIT |
| 3419 | // at BLOCK_16X16 (lane-av1rd2). Same | 3449 | // at BLOCK_16X16 (lane-av1rd2). Same |
| 3420 | // skipped-block prune as the level above. | 3450 | // skipped-block prune as the level above. |
| 3421 | - let eight = (!leaf.skip && split_inter_8()) | 3451 | + let eight = (!leaf.skip |
| 3452 | + && (breakout == 0 || leaf.luma.len() > breakout) | ||
| 3453 | + && split_inter_8()) | ||
| 3422 | .then(|| { | 3454 | .then(|| { |
| 3423 | restore( | 3455 | restore( |
| 3424 | &mut luma, &mut chroma, (lx, ly), SUB, &leaf_base, | 3456 | &mut luma, &mut chroma, (lx, ly), SUB, &leaf_base, |