Skip to content

v0.3.0 - Ogg Opus Support & Security Hardening

Choose a tag to compare

@decriptor decriptor released this 31 Dec 06:49
· 77 commits to main since this release

What's New

Added

Ogg Opus Format Support

  • OggOpusFile class for reading and writing Opus audio files
  • OpusHead identification header parsing (RFC 7845)
    • Version, channels, pre-skip, input sample rate, output gain
    • Channel mapping family support
  • OpusTags (Vorbis Comment) metadata support (no framing bit, per RFC 7845)
  • Full read/write round-trip support with atomic file saves

Audio Properties for Opus

  • AudioProperties.FromOpus() factory method
  • Duration calculation from granule position (always 48kHz output)
  • Pre-skip compensation for accurate duration

MediaFile Factory Updates

  • MediaFormat.Opus enum value
  • Automatic Opus vs Vorbis detection by inspecting first Ogg packet
  • .opus file extension support

R128 Loudness Convenience Properties

  • R128TrackGainDb and R128AlbumGainDb properties on Tag base class
  • Convert Q7.8 fixed-point integers to/from decibels as doubles

Fixed

RFC 3533 Compliance (Ogg Container)

  • Add segment table overflow validation in OggPageHelper.BuildOggPage
  • Add bounds check in FindLastGranulePosition for truncated pages
  • Add BuildMultiPagePacket helper for large metadata spanning multiple pages

RFC 7845 Compliance (Opus Codec)

  • Add channel mapping family 1 validation (1-8 channels per §5.1.1.2)
  • Existing OpusHead minimum size validation (19 bytes) now tested

R128 Gain Handling

  • Fix integer overflow in R128TrackGainDb and R128AlbumGainDb setters for extreme values
  • Add ClampToQ78 helper to safely clamp dB values to Q7.8 format range

Vorbis Validation

  • Add validation for invalid vorbis_version in identification header (must be 0 per spec)
  • Return explicit error for Vorbis files with zero sample rate or channel count

Security Hardening

  • Add 16 MB max packet size limit in OggPageHelper.ExtractHeaderPackets to prevent DoS
  • Add stream/coupled count validation for Opus mapping families 1 & 255

Changed

  • Refactor: OggVorbisFile now uses shared OggPageHelper code (eliminates ~160 lines of duplicate code)
  • Test count increased from 1939 to 2077 (+138 tests)
  • Code coverage: 89.4% line / 75.8% branch

Full Changelog: https://github.com/decriptor/tagsharp/blob/main/CHANGELOG.md