Skip to content
vbloom-x3 edited this page Oct 4, 2025 · 4 revisions

BLOS Audio Codec

BLOS is a modern, open-source, efficient audio codec designed for high-quality audio compression with low computational complexity. It combines Linear Predictive Coding (LPC) with Rice coding and innovative transient bypass to achieve good compression ratios while maintaining audio quality.

Overview

BLOS is a lossless audio codec that provides:

  • High Compression Efficiency: Leverages LPC prediction and Rice coding for compact representation
  • Low Computational Complexity: Fast encoding and decoding suitable for real-time applications
  • Transient Handling: Smart escape mechanism for handling transients and large residuals
  • Stereo Support: Mid/Side (M/S) stereo encoding for better compression

Quick Start

Prerequisites

  • GCC compiler
  • libsndfile development libraries
  • Make build system

Installation

git clone https://github.com/vbloom-x3/audio-format.git
cd audio-format
make
make install  # Optional installation

Basic Usage

# Encode a WAV file to BLOS format
libblos input.wav output.blos

# Decode a BLOS file back to WAV
libblos -d input.blos output.wav

File Format

Global Header (32 bytes)

Offset  Size    Description
0       4       Magic number: "BLOS"
4       4       Sample rate (uint32_t, little-endian)
8       4       Total frames (uint32_t)
12      1       Channels (uint8_t, always 2 for stereo)
13      4       Frame size (uint32_t, typically 512)
17      4       Number of frames (uint32_t)
21      11      Reserved/padding

Frame Structure

  • Frame Header: Frame size, LPC order, Rice parameters
  • Seeds: Initial samples for LPC reconstruction (int16_t)
  • Coefficients: Double-precision LPC coefficients
  • Residuals: Rice-coded residuals with escape sequences

Architecture

Key Features

  • Adaptive LPC Order: Automatically selects optimal prediction order (2-16)
  • Rice Coding: Efficient residual encoding with adaptive k-parameter
  • Transient Bypass: Raw sample storage when residuals exceed threshold
  • Mid/Side Stereo: Improved stereo channel correlation
  • Frame-Based Processing: 512-sample frames with bit-packing

Algorithm Pipeline

  1. Frame Splitting: Input divided into 512-sample frames
  2. M/S Conversion: Left/Right → Mid/Side channels
  3. LPC Analysis: Levinson-Durbin algorithm for prediction coefficients
  4. Residual Calculation: Difference between actual and predicted samples
  5. Rice Encoding: Efficient residual compression with escape handling
  6. Bit Packing: Compact binary representation

Performance

BLOS is optimized for:

  • Fast decoding for real-time playback
  • Low memory footprint
  • Progressive decoding support

Typical compression percentages are 1-6% depending on content complexity.

Building from Source

Dependencies

# Ubuntu/Debian
sudo apt-get install libsndfile1-dev build-essential


### Compilation
```bash
make          # Build the codec
make clean    # Clean build artifacts
make install  # Install to system (optional)

License

BLOS is released under the GNU GPL v3.0 License - see the LICENSE file for details.


🎵 Let's build the future of open audio compression!