Skip to content

fix: improve ReplayGain analysis accuracy and robustness#48

Merged
M-Igashi merged 1 commit intomasterfrom
fix/issues-41-43-47
Jan 16, 2026
Merged

fix: improve ReplayGain analysis accuracy and robustness#48
M-Igashi merged 1 commit intomasterfrom
fix/issues-41-43-47

Conversation

@M-Igashi
Copy link
Owner

Summary

This PR addresses three issues related to ReplayGain analysis and MP4 metadata handling:

Issue #41: Limited sample rate support

  • Before: Only 3 sample rates (48000, 44100, 32000 Hz) were supported, with all others falling back to 44100 Hz coefficients
  • After: All 12 sample rates from the original mp3gain are now supported (96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000 Hz)
  • Unsupported sample rates now return an error instead of silently using incorrect coefficients

Issue #43: Missing denormal float prevention

  • Added 1e-10 constant to filter processing to prevent denormal float slowdowns
  • This matches the original gain_analysis.c implementation
  • Improves performance when processing audio with silent sections

Issue #47: Bounds checking for MP4 metadata parsing

  • Added checked_add and saturating_add for safer arithmetic
  • Prevents potential panics when parsing malformed MP4 files

Testing

  • All existing tests pass
  • Added comprehensive test for all 12 supported sample rates
  • Added test to verify unsupported sample rates are properly rejected

References

Fixes #41
Fixes #43
Fixes #47

- Add filter coefficients for all 12 sample rates from original mp3gain
  (96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000,
  11025, 8000 Hz) instead of falling back to 44100 Hz for unsupported rates
- Add denormal float prevention (1e-10 constant) to filter processing
  to avoid performance degradation on silent audio sections
- Add bounds checking with checked_add/saturating_add in MP4 metadata
  parsing to prevent potential panics on malformed files

Fixes #41, fixes #43, fixes #47
@M-Igashi M-Igashi merged commit 5ad8a76 into master Jan 16, 2026
9 checks passed
@M-Igashi M-Igashi deleted the fix/issues-41-43-47 branch February 28, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant