From e4fbe999018b279cf8cedf43ee329cb95f96e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 13:34:36 +0300 Subject: [PATCH] U11: ec-mp3 drop exit-reason census and EC_MP3_LOOP_TRACE env aid (debug only, no output change) --- crates/ec-mp3/src/encode.rs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/crates/ec-mp3/src/encode.rs b/crates/ec-mp3/src/encode.rs index 2eea5984..14502707 100644 --- a/crates/ec-mp3/src/encode.rs +++ b/crates/ec-mp3/src/encode.rs @@ -1201,8 +1201,7 @@ fn quantise_granule( // Short blocks carry twelve bands, long ones twenty-one. let bands = if block_type == 2 { 12 } else { SFB_LONG }; let threshold = band_thresholds(threshold, block_type, sample_rate); - let mut exit = ("cap", 19usize); - for round in 0..20 { + for _ in 0..20 { let (granule, noise) = code_with(xr, block_type, target_bits, &scalefac, sample_rate); let ratios: Vec = (0..bands) .map(|b| f64::from(noise[b]) / f64::from(threshold[b]).max(1e-30)) @@ -1218,7 +1217,6 @@ fn quantise_granule( best = Some((granule, score, bands)); } if score <= 0.0 { - exit = ("mask", round); break; // every band is already exactly at the mask; nothing left to buy } // Where to stop amplifying, as a fraction of the frame's budget. Swept @@ -1241,7 +1239,6 @@ fn quantise_granule( // the MSE optimum, so perceptual redistribution can only trade away // what this gate scores. Don't re-run it: change the metric first. if spent * 100 > target_bits * 85 { - exit = ("budget", round); break; // the budget is spent; amplifying now only coarsens } // Bands over their mask get the bits first, worst three per round so @@ -1258,29 +1255,16 @@ fn quantise_granule( .take(3) .collect(); if chosen.is_empty() { - exit = ("saturated", round); break; } for band in chosen { scalefac[band] += 1; } } - census(exit); let (granule, score, bands) = best.expect("at least one round runs"); (granule, score / bands as f64) } -/// Exit-reason census for the distortion loop: with `EC_MP3_LOOP_TRACE` set, -/// one `mp3loop ` line per granule on stderr, so a sweep can be -/// counted with `sort | uniq -c`. The loop's shape is the encoder's open -/// question; without this the only evidence it ever iterates is indirect. -fn census(exit: (&str, usize)) { - static ON: std::sync::OnceLock = std::sync::OnceLock::new(); - if *ON.get_or_init(|| std::env::var_os("EC_MP3_LOOP_TRACE").is_some()) { - eprintln!("mp3loop {} {}", exit.0, exit.1); - } -} - /// Puts a spectrum into bitstream order in `out`. /// /// A short granule is coded band by band, window by window, line by line,