pub struct Mp3Decoder {
pub output_buffer: Vec<i16>,
pub frames_decoded: u64,
pub last_header: Option<Mp3FrameHeader>,
/* private fields */
}Expand description
MP3 decoder state
Fields§
§output_buffer: Vec<i16>Output PCM buffer
frames_decoded: u64Total frames decoded
last_header: Option<Mp3FrameHeader>Last parsed header
Implementations§
Source§impl Mp3Decoder
impl Mp3Decoder
Sourcepub fn find_sync(data: &[u8], start: usize) -> Option<usize>
pub fn find_sync(data: &[u8], start: usize) -> Option<usize>
Find the next MP3 frame sync in the data
Scans for the 0xFFE0 sync word. Returns the byte offset of the sync.
Sourcepub fn decode_frame(&mut self, data: &[u8]) -> CodecResult<usize>
pub fn decode_frame(&mut self, data: &[u8]) -> CodecResult<usize>
Decode a single MP3 frame
Returns the number of bytes consumed from the input.
Sourcepub fn decode_all(&mut self, data: &[u8]) -> CodecResult<(u32, u8, Vec<i16>)>
pub fn decode_all(&mut self, data: &[u8]) -> CodecResult<(u32, u8, Vec<i16>)>
Decode an entire MP3 file to PCM
Returns (sample_rate, channels, pcm_samples).
Sourcepub fn sample_rate(&self) -> Option<u32>
pub fn sample_rate(&self) -> Option<u32>
Get the sample rate from the last decoded frame