forge
Explore
Log in

Don't you dare go Hollow

ec-av1 RateLoop::update: do not lower q on a tiny frame (actual < target/4). Root cause: the 48-frame 384 kbps gate's fade (n=36..44, actual 818,799,41,452,193,76,278,125,50 vs targets 1.7k-4.5k) stepped q down by STEP_CLAMP each frame to q=1 (census base_q 61.6->1.6->0.0); the scene cut at n=45..47 then coded at raw_q 1 for 9619,9338,6085 bytes, the whole +7.4% overshoot (103132 vs 96000). Fix: a frame under target/TINY_FRAME_DIVISOR (4) carries no slope information, so a negative step is held at 0; q may still rise. Census reasoning: n=38..44 held at eff_q 50, n=45 coded near q 50 instead of 1. Not run; orchestrator to verify with the 48-frame gate.

Browse files at this commit

a5f823fb95b658e2c02b51d8d96d7279d332473aAhmet Kaan GümüşParent: b8d3de0
crates/ec-av1/src/encoder/mod.rsmodified+5 -0
@@ -298,6 +298,7 @@ impl RateLoop {
298 /// target), which is how the first cut of this fix froze every level of a298 /// target), which is how the first cut of this fix froze every level of a
299 /// run at whatever quantizer it had reached.299 /// run at whatever quantizer it had reached.
300 const REPLAN_FLOOR: f64 = 0.25;300 const REPLAN_FLOOR: f64 = 0.25;
301+ const TINY_FRAME_DIVISOR: f64 = 4.0;
301 302
302 fn new(target_bytes: f64, start_q: f64, pyramid: Option<Pyramid>, gop: usize) -> Self {303 fn new(target_bytes: f64, start_q: f64, pyramid: Option<Pyramid>, gop: usize) -> Self {
303 // THE LEVEL MODEL. Every coded frame of the run is priced by its own304 // THE LEVEL MODEL. Every coded frame of the run is priced by its own
@@ -437,6 +438,10 @@ impl RateLoop {
437 } else {438 } else {
438 raw439 raw
439 };440 };
441+ let step = match ratio < 1.0 / Self::TINY_FRAME_DIVISOR && step < 0.0 {
442+ true => 0.0,
443+ false => step,
444+ };
440 self.q[slot] = (self.q[slot] + step).clamp(0.0, 255.0);445 self.q[slot] = (self.q[slot] + step).clamp(0.0, 255.0);
441 let bound = !(1..=255).contains(&raw_q);446 let bound = !(1..=255).contains(&raw_q);
442 if let Some(plan) = self447 if let Some(plan) = self