Commits
Commits on
5591c0e1dfbc7e0137f2c8d4fb224bfcb05d01baFiltered to crates/ec-vorbis/src/encode.rsClear filter2026-08-23
vorbis rate: ≥100 kbps target scale 1.0→0.98, sweep 14/14Ahmet Kaan Gümüş · 583d94d
vorbis rate: ≥100 kbps target scale 1.0→0.98, sweep 14/14 dl8a@128 +3.50%→+1.41% (was the only FAIL). New RATE_TARGET_SCALE_HI = 0.98 for the ≥100 kbps branch of update_rate; <100 kbps keeps 0.97. No row's gap worse than baseline by >.001 (max +.0003). Suite green.
vorbis: clamp reservoir debt, split rate scale and HF co-mask cap at 100 kbpsAhmet Kaan Gümüş · 14e8a86
vorbis: clamp reservoir debt, split rate scale and HF co-mask cap at 100 kbps Per-second dropouts at 96 kbps were reservoir windup: debt reached 831 k bits with repayment bounded to 25% of a block, so headroom stayed suppressed for ~90 s after each transient run. Clamp the debt to 8x the block budget. Short blocks get a 31 dB headroom floor with a ramp. The 0.97 target scale applies only below 100 kbps and the bark>19 co-mask cap (-30 dB) likewise, since both cost high-rate rows. Equal-size sweep vs libvorbis on the library: 13/14 PASS, max corr gap +.0027, 0 dropout seconds; dl8a@128 rate +3.5% remains.
E3: HF per-region RMS refuted (gap 0.0073, rate +2.8%) — revert to peak-hold, keep E2 tiltAhmet Kaan Gümüş · 63444aaBrowse files
E2: add HF tilt -3 dB (4-6 kHz) — full gate PASS, mean gap 0.00188, 8/8Ahmet Kaan Gümüş · 8c3661eBrowse files
E1: LF tilt +12 dB — mean gap 0.00261 (6/8 PASS), beats T=6's 0.00536Ahmet Kaan Gümüş · 070e7ebBrowse files
E1: LF headroom tilt +6 dB (1.1-2 kHz) — mean gap 0.00536 (was 0.01525)Ahmet Kaan Gümüş · 982ef46Browse files
Revert encode.rs to main: envelope-following refuted, peak is bestAhmet Kaan Gümüş · c3f777bBrowse files
2026-08-22
test(vorbis): decoder-side residue reference — valid histogram oracle (cherry-pick 5ede0ed)Ahmet Kaan Gümüş · 454cb75
test(vorbis): decoder-side residue reference — valid histogram oracle (cherry-pick 5ede0ed) Resolve add/add conflicts in oracle.rs: keep both residue_histogram_vs_reference (theirs) and real_library_sweep_vs_reference (ours); git auto-merged identical ffmpeg_decode_limited/shellexpand bodies. Adapt capture hook to main's BlockConfig (main has no residue_end field — codes full half*channels region, so coded=half).
fix(vorbis): bit reservoir stops the rate loop winding up on short-block runsAhmet Kaan Gümüş · fc5a0f8
fix(vorbis): bit reservoir stops the rate loop winding up on short-block runs Blocks next to a short window are quantised with a forced minimum precision the loop cannot lower, yet their overspend stepped the headroom -2 dB each; a 16-32 block run drove it to the -24 dB floor, the floor sat above the signal, and ~10 silent long blocks followed every transient: 200 ms dropouts at -20 dBFS on reelm.wav, per-second corr 0.27-0.70 where libvorbis holds 0.99. Forced blocks now bank their excess as reservoir debt that steady blocks repay at <=25% of a block's share, so the rate still lands on target over about a second. reelm 128k: all 30 seconds >= 0.9935; quiet_content_reaches_the_target_or_is_transparent, failing since 5314f5a for the same reason, passes. The library sweep joins the oracle binary (ignored, SWEEP_ONLY=name,...). ffmpeg's libvorbis under -b:a is unmanaged VBR and lands 10-30% under nominal on real music, so ours is encoded at the size libvorbis produced and compared there (rate within 3%, correlation gap <= .005): source kbps ours ref rate% corr_ours corr_ref gap nik 96 84.0 84.5 -0.61 0.9690 0.9903 0.0213 nik 128 115.5 115.8 -0.24 0.9838 0.9951 0.0113 reelo 96 81.5 81.8 -0.30 0.9739 0.9922 0.0183 reelo 128 109.1 108.6 +0.45 0.9868 0.9955 0.0087 her 96 89.9 89.9 +0.04 0.9668 0.9867 0.0199 her 128 123.5 124.9 -1.13 0.9810 0.9927 0.0117 reell 96 85.4 85.5 -0.12 0.9792 0.9923 0.0131 reell 128 121.3 120.9 +0.39 0.9914 0.9968 0.0054 reelm 96 80.5 79.3 +1.52 0.9796 0.9865 0.0069 reelm 128 93.5 91.0 +2.70 0.9890 0.9906 0.0017 PASS dl8a 96 86.9 86.9 -0.01 0.9655 0.9916 0.0261 dl8a 128 118.7 117.8 +0.80 0.9826 0.9957 0.0132 hein 96 80.3 79.1 +1.53 0.9789 0.9869 0.0080 hein 128 92.8 90.7 +2.31 0.9883 0.9906 0.0023 PASS Rate tracks on every row; the remaining gap is the psychoacoustic model, not dropouts.
2026-08-21
2026-08-20
perf(vorbis-enc): quality per bit on real music — finer residue classes, co-mask cap, point stereo, drum-only transient detectorAhmet Kaan Gümüş · 9203ba6
perf(vorbis-enc): quality per bit on real music — finer residue classes, co-mask cap, point stereo, drum-only transient detector Three 30 s tracks at 128 kbps, correlation with the source: 0.9812/0.9745/0.9911 (9ac19d6) -> 0.9711/0.9663/0.9984 (f1fa335, block switching firing ~1/s on music with 16 short blocks each) -> 0.9955/0.9936/1.0000 now, at 131/131/109 kbps. At the reference encoder's own size (109/116/92 kbps): 0.9906/0.9901/0.9999 vs its 0.9970/0.9960/0.9986. - residue: nine classes one octave of range apart (+-1 ... +-64, +-127), 16 coefficients per long partition, books from measured per-class statistics (mean |v| ~ range/6): 0.977 -> 0.988 on the two rock tracks alone - floor: 12 long points instead of 20 (16/20/32/44 each worse on music) - co-mask cap: nothing under loudest-50 dB in a long block is coded; corner-cut named in the code, upgrade is a Bark-domain spread - point stereo above 4 kHz while the rate loop is starving (headroom under the range); lossless pair coding otherwise - transient detector: jump measured against the loudest of the four ticks before, -60 dBFS absolute floor; music now fires 16-32 short blocks per 30 s - short blocks quantised with at least 42 dB headroom whatever the loop's state, and no co-mask cap: fixes the 6 ch / 96 kHz onset leak (peak 0.0106 -> 0.0062 at 36 dB, under 0.005 at 42) that the sweep now covers (onset sweep: 44.1k 1/2 ch, 48k 1/2/6 ch, 96k 6 ch) Known failing: quiet_content_reaches_the_target_within_25pct — the quiet fixture codes at corr 0.9999 and 74 kbps at every target; with the cheaper residue and 12-point floor nothing codable is left inside the 36 dB range, so the loop cannot spend up to 128/192 kbps on it.
fix(vorbis-enc): 42 dB residue range in short blocks, with a clamp-guarded floor refit; onset test sweeps phase, hop offset and per-channel contentAhmet Kaan Gümüş · a554dfa
fix(vorbis-enc): 42 dB residue range in short blocks, with a clamp-guarded floor refit; onset test sweeps phase, hop offset and per-channel content An onset inside a short block leaked up to 0.0113 peak (1.6x the 0.01*amp bar) because the block's step was the 36 dB pair range. The full 42 dB could not be used: the floor is set per X point from its region's peak and drawn as straight lines, so a peak at a region's edge sits further under the curve than the range states and clamps at 127 — catastrophically (0.11 peak) on some phases. Now any block whose quantised values exceed the range lifts the floor points around the clamping bins and refits, so short blocks run at 42 dB and long blocks keep 36. Worst gap peak over the 40-case sweep: 0.0113 -> 0.0053; worst RMS 0.000245 -> 0.000140. Fixture 46492 -> 46493 bytes, 60 s stereo unchanged.
fix(vorbis-enc): let rate-loop headroom past the residue range lower the ATH bound, so quiet/sparse content reaches the targetAhmet Kaan Gümüş · 14b96be
fix(vorbis-enc): let rate-loop headroom past the residue range lower the ATH bound, so quiet/sparse content reaches the target The widest residue book states +-127 and a coupled angle is a difference of two magnitudes, so a pair's step cannot usefully go past 36 dB under the peak. On sparse or quiet content the floor sits on the absolute threshold almost everywhere, those partitions code as class 0 at any step, and the loop pegged at 36 dB with ~44 kbps against a 128 kbps target. Headroom now clamps at 84 dB; the part past 36 dB lowers the threshold bound instead of the step, which gives the loop bins under the old threshold to spend on. Decoder and stream syntax untouched.
fix(vorbis-enc): cap the ATH at -80 dBFS so an onset inside a short block is not coded against a -10 dB floorAhmet Kaan Gümüş · 9b7e0e0
fix(vorbis-enc): cap the ATH at -80 dBFS so an onset inside a short block is not coded against a -10 dB floor The pre-echo the verifier measured (gap RMS 0.002261 at 44.1k, peak 0.073) lived entirely in the one short block whose window straddles the onset, not in the long->short transition block: the block plan already puts the onset mid short-run. Its DC bin and every bin above ~17 kHz were quantised against the absolute-threshold floor, whose own curve sits at -13 / -10 dBFS there, so a 0.1-amplitude step coefficient took a 0.2-0.3 quantiser step and its error spread over the whole 256-sample window at -38 dB. Capping the ATH at -80 dBFS gives gap RMS 0.000059 / peak 0.0028 (reference encoder on the same input: 0.000120 / 0.0057). Also gate a steady long block on its lookahead hop being buffered: with chunked input the plan was committed before the detector could see the transient it is supposed to make room for. Test now places the onset off the block grid (0.9137 s) as well as on it, measures the whole [0, onset) gap plus its peak, mono and stereo, 44.1k/48k, our decoder and the reference oracle.
feat(vorbis-enc): real block switching — short blocks eliminate pre-echo at silence→onsetAhmet Kaan Gümüş · 63f547a
feat(vorbis-enc): real block switching — short blocks eliminate pre-echo at silence→onset Two modes now: 2048-sample long blocks (steady state) and 256-sample short blocks, with their own floor1 X-grids and residue partition sizing but sharing the encoder's designed codebooks. A per-hop energy-tick transient detector (an onset after digital silence is the degenerate, always-firing case of the general jump-past-predecessor check) swaps a pair of would-be long blocks for long-with-short-right-window, a run of short blocks over the transient, and long-with-short-left-window resuming steady state — a run sized to land the transient safely inside short-block coverage rather than in a transition block's own flat (unwindowed) span, which is what silently reintroduced the leak the first cut of this fix produced. Granule advance across a switch is exactly N long hops, so it never moves the steady-state grid; a stationary signal still never leaves long-block mode (tested). New oracle test onset_after_silence_has_no_pre_echo measures gap RMS immediately before the onset at 44.1/48 kHz through both our own decoder and the reference oracle: 0.0064 -> 0.0 (both rates, both decoders).
fix(vorbis): flush() delivers the terminal block's un-overlapped tailAhmet Kaan Gümüş · 750facc
fix(vorbis): flush() delivers the terminal block's un-overlapped tail VorbisDecoder::flush() set drained=true and returned without emitting self.lap, the accumulator holding the last decoded block's samples past the final centre that had not yet been overlap-added into an output frame. Per Vorbis I §1.3.2 those samples, up to the stream's final granule position, are valid output the decoder must deliver — dropping them left every decode exactly one hop (1024 samples at typical rates) short of the encoded length at true EOS. flush() now emits any non-empty self.lap as one final Frame::Audio, permuted through the same to_ec channel map decode_audio uses, before marking drained. Also converts encode.rs's debug_tail_granule_44100_mono from a panic-driven probe into a real assertion (packets==45, last granule==44100), and adds oracle.rs::flush_delivers_the_terminal_hop, a decoder-trait (send_packet/receive_frame/flush) round trip over a sample count that is deliberately not a multiple of the hop, checking exact output length and tail correlation against the source.
2026-08-14
feat(vorbis): Vorbis I decoder and encoderAhmet Kaan Gümüş · c0023ff
feat(vorbis): Vorbis I decoder and encoder Decode is the whole format: codebooks with the entry-order codeword rule (not sorted-canonical - a Laplacian book assigns differently and every packet desynchronises silently), floor 0 and floor 1, residues 0/1/2, square-polar coupling, every blocksize and the four long-window shapes. Encode writes its own codebooks and a setup header per channel layout, centres the first block on input sample 0 so no caller pre-roll is needed, and states the input's own sample count as the last granule.