Ahmed Doghri Logo Image
Ahmed Doghri

codecguard

A clean candidate passes four gates. A low-pass, stereo-collapsed build is blocked on spectrum, transients, width, and SNR.

codecguard waveform compression quality gate
codecguard working browser demo

Codec Changes Need Regression Tests

A successful transcode only proves that a decoder can open the result. It says nothing about lost attacks, collapsed width, spectral smearing, or accidental silence.

codecguard synthesizes a deterministic stereo master, runs a real FFmpeg encode and decode, aligns encoder priming, and evaluates four independent dimensions.

The Demo

The release candidate reaches 33.396 dB SNR, 0.02087 spectral convergence, 0.9954 transient retention, and 0.00025 stereo-width error, passing every gate. The degraded build fails all four.

Signal metrics make CI deterministic but do not replace perceptual codecs, formal listening panels, or content-diverse mastering review.

Implementation Basis

The gate combines multi-resolution frequency evidence with time-domain transients, stereo energy, and aligned waveform error.

Read the FFmpeg codec documentation.

A Gate That Couldn't Measure Short Clips

A CI quality gate has to work on the actual assets a pipeline produces, not just a three-second reference master. The multi-resolution spectral check floored its frame count to a minimum of one, even when a clip was shorter than the FFT window it was about to build.

Verified directly: any clip under 8,192 samples — about 170 ms at 48kHz, an entirely ordinary length for a short SFX cue or dialogue snippet — crashed the measurement with an unhandled index error. The repo's own test was named to guarantee short clips stay measurable, and only passed by luck because its fixture happened to be just long enough.

Fixed by only using FFT window sizes that actually fit the clip, falling back to a single whole-clip window for very short audio. The published demo numbers — 33.396 dB SNR, 0.02087 spectral convergence, 0.9954 transient retention, 0.00025 stereo-width error — are unchanged.

Tools Used

Python
NumPy
FFmpeg
Audio DSP
Codec QA
Edge-Case Hardening
Docker