pub struct OpusMSDecoder { /* private fields */ }Expand description
Multistream decoder: decode each stream and remux to the output channels.
Implementations§
Source§impl OpusMSDecoder
impl OpusMSDecoder
Sourcepub fn new(
sample_rate: i32,
channels: usize,
mapping_family: u8,
) -> Result<Self>
pub fn new( sample_rate: i32, channels: usize, mapping_family: u8, ) -> Result<Self>
Create a surround decoder for channels channels.
mapping_family selects the layout, as in
OpusMSEncoder::new; for a stream read from a file it is the one
OpusHead::mapping_family carries.
Sourcepub fn decode(
&mut self,
packet: &[u8],
frame_size: usize,
output: &mut [f32],
) -> Result<usize>
pub fn decode( &mut self, packet: &[u8], frame_size: usize, output: &mut [f32], ) -> Result<usize>
Decode a multistream packet into interleaved output (nb_channels per
sample). Returns the number of samples per channel.
Decode one multistream packet into interleaved float PCM.
As with OpusDecoder::decode, the output is not bounded by ±1.
Sourcepub fn decode_s16(
&mut self,
packet: &[u8],
frame_size: usize,
output: &mut [i16],
) -> Result<usize>
pub fn decode_s16( &mut self, packet: &[u8], frame_size: usize, output: &mut [i16], ) -> Result<usize>
Decode one multistream packet into interleaved 16-bit PCM.
Each stream is soft-clipped on its own before the channels are remuxed,
which is where libopus applies it too (opus_multistream_decode_native
hands soft_clip to each stream’s decoder). Clipping the remuxed result
instead would let one stream’s peak bend another’s audio.
Sourcepub fn layout(&self) -> &ChannelLayout
pub fn layout(&self) -> &ChannelLayout
The channel layout this decoder produces.
Sourcepub fn nb_streams(&self) -> usize
pub fn nb_streams(&self) -> usize
Opus streams this decoder expects in each packet.
Sourcepub fn sample_rate(&self) -> i32
pub fn sample_rate(&self) -> i32
The sample rate this decoder was created with, in Hz.
Sourcepub fn streams_mut(&mut self) -> &mut [OpusDecoder]
pub fn streams_mut(&mut self) -> &mut [OpusDecoder]
The per-stream decoders, so every OpusDecoder setting is reachable.
The counterpart of OpusMSEncoder::streams_mut, and the only route to
gain_q8 — which is not a nicety. RFC 7845 §5.1
says a player SHOULD apply the gain a file declares, and it says nothing
about mapping family, so a surround stream carrying a non-zero
OpusHead::output_gain_q8 plays at
the wrong level with no other symptom. A multistream decoder is N
ordinary decoders and the gain belongs on every one of them:
let mut dec = OpusMSDecoder::new(48_000, 6, head.mapping_family)?;
for d in dec.streams_mut() {
d.gain_q8 = head.output_gain_q8 as i32;
}For mono and stereo, OpusHead::decoder
does this for you and there is nothing to remember.
Sourcepub fn streams(&self) -> &[OpusDecoder]
pub fn streams(&self) -> &[OpusDecoder]
The per-stream decoders, for reading. See
streams_mut to change their settings.
final_range per stream is what a
conformance check compares against a reference decoder’s.
Sourcepub fn reset_state(&mut self) -> Result<()>
pub fn reset_state(&mut self) -> Result<()>
Discard every stream’s coding state, as OpusDecoder::reset_state
does for one.