Skip to main content

shine_rs/
lib.rs

1//! # Rust MP3 Encoder
2//!
3//! A pure Rust implementation of an MP3 encoder based on the shine library.
4//! This library provides a complete MP3 Layer III encoding solution with
5//! support for various sample rates, bitrates, and channel configurations.
6//!
7
8use std::sync::atomic::{AtomicI32, Ordering};
9
10/// Global frame counter for debugging consistency across modules
11pub static GLOBAL_FRAME_COUNT: AtomicI32 = AtomicI32::new(0);
12
13/// Get the current frame number and increment the global counter
14pub fn get_next_frame_number() -> i32 {
15    GLOBAL_FRAME_COUNT.fetch_add(1, Ordering::SeqCst) + 1
16}
17
18/// Get the current frame number without incrementing
19pub fn get_current_frame_number() -> i32 {
20    GLOBAL_FRAME_COUNT.load(Ordering::SeqCst)
21}
22
23pub mod bitstream;
24pub mod encoder;
25pub mod error;
26pub mod huffman;
27pub mod mdct;
28pub mod mp3_encoder;
29pub mod quantization;
30pub mod reservoir;
31pub mod subband;
32pub mod tables;
33pub mod types;
34
35#[cfg(feature = "diagnostics")]
36pub mod diagnostics_data;
37
38
39
40// Re-export high-level interface (recommended for most users)
41pub use mp3_encoder::{
42    Mp3Encoder, Mp3EncoderConfig, StereoMode, encode_pcm_to_mp3,
43    SUPPORTED_SAMPLE_RATES, SUPPORTED_BITRATES
44};
45
46// Re-export low-level interface (for advanced users)
47pub use encoder::{ShineConfig, ShineWave, ShineMpeg, shine_initialise, shine_encode_buffer_interleaved, shine_flush, shine_close, shine_set_config_mpeg_defaults};
48pub use error::{EncoderError, ConfigError, InputDataError, EncodingError, EncodingResult};
49pub use types::ShineGlobalConfig;