Skip to content

fix: handle last frame before APE/ID3 tags and M4A info display#56

Merged
M-Igashi merged 1 commit intomasterfrom
fix/frame-detection-and-m4a-info
Jan 16, 2026
Merged

fix: handle last frame before APE/ID3 tags and M4A info display#56
M-Igashi merged 1 commit intomasterfrom
fix/frame-detection-and-m4a-info

Conversation

@M-Igashi
Copy link
Owner

Summary

This PR fixes two issues:

Issue #54: Last frame not modified when followed by APE/ID3 tag

Problem: When an MP3 file has metadata tags (APE or ID3v1) immediately following the last audio frame, mp3rgain was skipping the last frame during gain application.

Solution: Added find_audio_end() function that detects trailing APE/ID3v1 tags and returns the actual end of audio data. Updated all frame iteration functions to use this boundary instead of file size.

Changes:

  • Added find_audio_end() in lib.rs
  • Updated iterate_frames(), apply_gain(), apply_gain_channel(), apply_gain_wrap() to use audio_end boundary

Issue #55: M4A/AAC files incorrectly show MP3 format info

Problem: Running mp3rgain test.m4a (without -r or -a) showed incorrect MP3 format info.

Solution: Added M4A/AAC detection in process_info() to display appropriate format information.

Before:

test.m4a
  Format:      MPEG2.5 Layer III, Mono
  Frames:      1
  Gain range:  235 - 235 (avg: 235.0)

After:

test.m4a
  Format:      M4A/AAC
  Note: Use -r or -a for ReplayGain analysis

Testing

  • All existing tests pass
  • Manually tested with MP3 file containing APE tag - gain range correctly changes from 72-210 to 69-207 after applying -3 steps
  • Manually tested M4A file info display - shows correct format info

Fixes #54
Fixes #55

…55)

- Add find_audio_end() to detect trailing APE/ID3v1 tags
- Update iterate_frames, apply_gain, apply_gain_channel, apply_gain_wrap
  to use audio_end boundary instead of file_size
- This ensures last MP3 frame is correctly modified even when followed
  by metadata tags
- Add M4A/AAC detection in process_info() to show appropriate format
  info instead of incorrectly analyzing as MP3

Fixes #54, Fixes #55
@M-Igashi M-Igashi merged commit 1952fc5 into master Jan 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M4A/AAC files incorrectly show MP3 format info Last frame not modified when followed by APE/ID3 tag

1 participant