forge
Explore
Log in

Don't you dare go Hollow

ec-av1 rate loop: steer on the geometric mean of the last two size ratios per slot. Evidence (c-round3-full.log sizes 4176,2073,4776,2183,3861,...): a 0.77 q step cannot move a frame 4176->2073, so the swing is inter-frame coupling (a big frame leaves a good reference, the next is small), not q slope; per-frame steering chases it as a decaying period-2 cycle that biases the mean low. Averaging log-ratios over two frames cancels the alternating component. BytesPerFrame repay=false kept; Bitrate +7.4% not separately root-caused (no census run permitted); replan still repays. cargo check -p ec-av1 --all-targets clean; tests left to orchestrator

Browse files at this commit

d6f79ca28233001e125ebd153e3efb0704530258Ahmet Kaan GümüşParent: 5c168bf
crates/ec-av1/src/encoder/mod.rsmodified+11 -2
@@ -243,6 +243,7 @@ struct RateLoop {
243243 /// FIRST update of a slot is the seeding one and takes the model's whole
244244 /// step ([`RateLoop::update`]); every later one is clamped.
245245 seeded: [bool; 3],
246+ prev_ratio: [f64; 3],
246247 /// The leaf's own q offset: the zero of the level weight
247248 /// ([`WEIGHT_LEVEL_GAIN`]), so slot 1's target can be read in
248249 /// LEAF-EQUIVALENT bytes and scaled per frame by that frame's offset.
@@ -355,6 +356,7 @@ impl RateLoop {
355356 plans,
356357 scale0: scale,
357358 repay: true,
359+ prev_ratio: [1.0; 3],
358360 census: census_on(),
359361 coded: 0,
360362 }
@@ -422,8 +424,15 @@ impl RateLoop {
422424 // step and seeds `q` where the log-linear slope says it belongs; from
423425 // the second frame on the clamp is back, and nothing is accumulated
424426 // between frames, so [[vorbis-rate-loop-windup]]'s bound still holds.
425- let raw = ratio.ln() * Self::GAIN;
426- let step = if std::mem::replace(&mut self.seeded[slot], true) {
427+ let seeded = std::mem::replace(&mut self.seeded[slot], true);
428+ let smoothed = if seeded {
429+ (ratio * self.prev_ratio[slot]).sqrt()
430+ } else {
431+ ratio
432+ };
433+ self.prev_ratio[slot] = ratio;
434+ let raw = smoothed.ln() * Self::GAIN;
435+ let step = if seeded {
427436 raw.clamp(-Self::STEP_CLAMP, Self::STEP_CLAMP)
428437 } else {
429438 raw