pub struct AvBuffer(*mut AVBufferRef);
Expand description
Wrapper around AVBuffer
and AVBufferRef
.
libavcodec can manage its own memory for input and output data. Doing so implies a transparent copy of user-provided data (packets or frames) from and to this memory, which is wasteful.
This copy can be avoided by explicitly providing our own buffers to libavcodec using
AVBufferRef
. Doing so means that the lifetime of these buffers becomes managed by avcodec.
This struct helps make this process safe by taking full ownership of an AvBufferSource
and
dropping it when libavcodec is done with it.
Tuple Fields§
§0: *mut AVBufferRef
Implementations§
source§impl AvBuffer
impl AvBuffer
sourcepub fn new<D: AvBufferSource + 'static>(source: D) -> Option<Self>
pub fn new<D: AvBufferSource + 'static>(source: D) -> Option<Self>
Create a new AvBuffer
from an AvBufferSource
.
Ownership of source
is transferred to libavcodec, which will drop it when the number of
references to this buffer reaches zero.
Returns None
if the buffer could not be created due to an error in libavcodec.
sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Return a slice to the data contained in this buffer.
sourcepub fn into_raw(self) -> *mut AVBufferRef
pub fn into_raw(self) -> *mut AVBufferRef
Consumes the AVBuffer
, returning a AVBufferRef
that can be used in AVFrame
, AVPacket
and others.
After calling, the caller is responsible for unref-ing the returned AVBufferRef, either
directly or through one of the automatic management facilities in AVFrame
, AVPacket
or
others.