Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

Safe AV1 decoder instance

This is the main entry point for decoding AV1 video. It wraps the internal rav1d decoder with a safe, type-safe interface.

§Example

use rav1d_safe::src::managed::Decoder;

let mut decoder = Decoder::new()?;
let obu_data = b"...";

if let Some(frame) = decoder.decode(obu_data)? {
    println!("Decoded {}x{}", frame.width(), frame.height());
}

Implementations§

Source§

impl Decoder

Source

pub fn new() -> Result<Self>

Create a new decoder with default settings

Source

pub fn with_settings(settings: Settings) -> Result<Self>

Create a decoder with custom settings

Source

pub fn decode(&mut self, data: &[u8]) -> Result<Option<Frame>>

Decode AV1 OBU data from a byte slice

Returns Ok(None) if more data is needed (the decoder is waiting for more input). Returns Ok(Some(frame)) when a frame is successfully decoded.

§Example
let mut decoder = Decoder::new()?;
let data = b"..."; // AV1 OBU data

match decoder.decode(data)? {
    Some(frame) => {
        println!("Got frame: {}x{}", frame.width(), frame.height());
    }
    None => {
        println!("Need more data");
    }
}
Source

pub fn get_frame(&mut self) -> Result<Option<Frame>>

Try to get a decoded frame without sending new data.

After calling decode(), the decoder may have buffered additional frames (e.g. from a raw OBU stream containing multiple temporal units). Call this in a loop until it returns Ok(None) to drain them.

Source

pub fn flush(&mut self) -> Result<Vec<Frame>>

Flush the decoder and return all remaining frames

This should be called after all input data has been fed to the decoder to retrieve any buffered frames.

Trait Implementations§

Source§

impl Drop for Decoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> To for T
where T: ?Sized,

Source§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Source§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.