pub struct ProjectionDecoderRef<'a> { /* private fields */ }Expand description
Borrowed wrapper around a projection decoder state.
The owning handle cannot be moved out of this borrowed wrapper:
ⓘ
use opus_codec::projection::{ProjectionDecoder, ProjectionDecoderRef};
fn extract<'a>(
state: &mut ProjectionDecoderRef<'a>,
replacement: ProjectionDecoder,
) -> ProjectionDecoder {
std::mem::replace(&mut **state, replacement)
}Implementations§
Source§impl<'a> ProjectionDecoderRef<'a>
impl<'a> ProjectionDecoderRef<'a>
Sourcepub unsafe fn from_raw(
ptr: *mut OpusProjectionDecoder,
sample_rate: SampleRate,
channels: u8,
streams: u8,
coupled_streams: u8,
) -> Self
pub unsafe fn from_raw( ptr: *mut OpusProjectionDecoder, sample_rate: SampleRate, channels: u8, streams: u8, coupled_streams: u8, ) -> Self
Wrap an externally-initialized projection decoder without taking ownership.
§Safety
ptrmust point to valid, initialized memory of at leastProjectionDecoder::size()bytesptrmust be aligned to at leastalign_of::<usize>()(malloc-style alignment)sample_rate,channels,streams, andcoupled_streamsmust exactly match the decoder state already stored atptr- The memory must remain valid for the lifetime
'a - Caller is responsible for freeing the memory after this wrapper is dropped
Passing mismatched metadata is undefined behavior: later safe methods may validate buffer sizes with the wrong layout and then call libopus with out-of-bounds buffers.
§Panics
Panics if ptr is null or not pointer-aligned, or if the channel/stream
counts are invalid.
Use ProjectionDecoder::init_in_place to initialize the memory before calling this.
Sourcepub fn init_in(
buf: &'a mut AlignedBuffer,
sample_rate: SampleRate,
channels: u8,
streams: u8,
coupled_streams: u8,
demixing_matrix: &[u8],
) -> Result<Self>
pub fn init_in( buf: &'a mut AlignedBuffer, sample_rate: SampleRate, channels: u8, streams: u8, coupled_streams: u8, demixing_matrix: &[u8], ) -> Result<Self>
Initialize and wrap an externally allocated buffer.
§Errors
Returns Error::BadArg if the buffer is too small, or a mapped libopus error.
Methods from Deref<Target = ProjectionDecoder>§
Sourcepub fn coupled_streams(&self) -> u8
pub fn coupled_streams(&self) -> u8
Number of coupled coded streams expected in the input bitstream.
Sourcepub fn sample_rate(&self) -> SampleRate
pub fn sample_rate(&self) -> SampleRate
Decoder sample rate.
Trait Implementations§
Source§impl Deref for ProjectionDecoderRef<'_>
impl Deref for ProjectionDecoderRef<'_>
impl Send for ProjectionDecoderRef<'_>
Auto Trait Implementations§
impl<'a> !Sync for ProjectionDecoderRef<'a>
impl<'a> !UnwindSafe for ProjectionDecoderRef<'a>
impl<'a> Freeze for ProjectionDecoderRef<'a>
impl<'a> RefUnwindSafe for ProjectionDecoderRef<'a>
impl<'a> Unpin for ProjectionDecoderRef<'a>
impl<'a> UnsafeUnpin for ProjectionDecoderRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more