mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-27 12:07:02 -06:00
- crates/media: probe (duration, rate/channels, size/fps; WMA/WMV recognised), audio decode to f32 PCM (MP3, AAC M4A/ADTS, ALAC, WAV, AIFF, CAF, FLAC, Vorbis via symphonia; Opus with our decoder in Ogg/WebM/MKV), video decode (MP4/MOV/WebM/MKV) with YUV->RGBA, poster frames, trim/fade/volume, Player mixer + per-voice clock (device-clocked or wall-clocked), VideoFeed. - Codec crates ported from FilmCraft: bitstream, h264, hevc, vp9, av1, isobmff, matroska, ogg, opus. - insert.audio/insert.video probe and store duration/size and a poster frame; unplayable media is embedded with a warning. New media.play/pause/toggle/stop/seek/info/posterFrame. - UI: MediaHost (cpal output injected by the desktop app), control bar under media, video frames on canvas and in the show; autoplay, click to play, loop, rewind, across slides, hide, full screen. - Tests with in-code WAV/AIFF and CC0 self-generated fixtures (make.sh, ATTRIBUTION.md rows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.6 KiB
Rust
47 lines
1.6 KiB
Rust
//! Clean-room pure-Rust Opus decoder (RFC 6716, updated by RFC 8251).
|
|
//!
|
|
//! Layer L0: no dependencies beyond `std`; no `unsafe`; builds for `wasm32-unknown-unknown`.
|
|
|
|
// Spec-style indexed loops (FilmCraft allows this lint workspace-wide).
|
|
#![allow(clippy::needless_range_loop)]
|
|
#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable))]
|
|
// The fixed-point parts mirror the normative integer arithmetic; keep C-like shift expressions.
|
|
#![allow(clippy::precedence, clippy::int_plus_one)]
|
|
|
|
pub(crate) mod celt;
|
|
mod decoder;
|
|
mod header;
|
|
mod multistream;
|
|
pub mod packet;
|
|
pub(crate) mod range;
|
|
pub(crate) mod silk;
|
|
|
|
pub use decoder::{SAMPLE_RATES, StreamDecoder};
|
|
pub use header::OpusHead;
|
|
pub use multistream::Decoder;
|
|
pub use packet::{Bandwidth, Mode, Packet, Toc};
|
|
|
|
/// Errors from header parsing and decoding.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum Error {
|
|
InvalidArgument(&'static str),
|
|
InvalidPacket(&'static str),
|
|
InvalidHeader(&'static str),
|
|
Unsupported(&'static str),
|
|
}
|
|
|
|
impl std::fmt::Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Error::InvalidArgument(s) => write!(f, "invalid argument: {s}"),
|
|
Error::InvalidPacket(s) => write!(f, "invalid packet: {s}"),
|
|
Error::InvalidHeader(s) => write!(f, "invalid header: {s}"),
|
|
Error::Unsupported(s) => write!(f, "unsupported: {s}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|