Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ jobs:
- name: cargo check
run: cargo check --all-targets

msrv:
name: MSRV Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@1.87.0
- name: cargo check
run: cargo check --all-targets

tests:
name: Tests
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -101,6 +111,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg wget
- name: Clippy with dred
run: cargo clippy --features dred --all-targets -- -D warnings
- name: Build with dred
run: cargo build --features dred
- name: Test with dred
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "opus-codec"
version = "0.1.1"
version = "0.1.2"
edition = "2024"
authors = ["Denis Avvakumov"]
description = "Safe Rust bindings for the Opus audio codec"
rust-version = "1.87"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Deniskore/opus-codec"
homepage = "https://github.com/Deniskore"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# opus-codec

[![Build Status](https://github.com/Deniskore/opus-codec/actions/workflows/ci.yml/badge.svg)](https://github.com/Deniskore/opus-codec/actions/workflows/ci.yml)
[![Crates.io](https://img.shields.io/crates/v/opus-codec.svg)](https://crates.io/crates/opus-codec)
[![API reference](https://docs.rs/opus-codec/badge.svg)](https://docs.rs/opus-codec)
[![MSRV](https://img.shields.io/badge/MSRV-1.87.0-blue)](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field)
[![License](https://img.shields.io/crates/l/opus-codec.svg)](https://crates.io/crates/opus-codec)

Safe Rust wrappers around libopus for encoding/decoding Opus audio, with tests that validate core functionality against ffmpeg.

## Features
Expand All @@ -8,6 +14,10 @@ Safe Rust wrappers around libopus for encoding/decoding Opus audio, with tests t
- `dred`: Enable libopus DRED support (downloads the model when building the bundled library). The bundled DRED build currently assumes a Unix-like host with `sh`, `wget`, and `tar`, it is not supported on Windows.
- `system-lib`: Link against a system-provided libopus instead of the bundled sources.

## MSRV

Minimum Supported Rust Version (MSRV): **1.87.0**.

## License

This crate is licensed under either of
Expand Down
29 changes: 29 additions & 0 deletions src/alloc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// Aligned storage for libopus state structures.
#[derive(Debug)]
pub struct AlignedBuffer {
buf: Vec<usize>,
bytes: usize,
}

impl AlignedBuffer {
/// Allocate at least `bytes` of pointer-aligned storage.
#[must_use]
pub fn with_capacity_bytes(bytes: usize) -> Self {
let word = std::mem::size_of::<usize>();
let len = bytes.div_ceil(word);
let buf = vec![0usize; len];
let bytes = len * word;
Self { buf, bytes }
}

/// Total available capacity in bytes.
#[must_use]
pub fn capacity_bytes(&self) -> usize {
self.bytes
}

/// Borrow the underlying buffer as a mutable pointer.
pub fn as_mut_ptr<T>(&mut self) -> *mut T {
self.buf.as_mut_ptr().cast()
}
}
Loading