pub struct TileEncoder { /* private fields */ }Expand description
Splits a frame into tiles and encodes them in parallel using Rayon.
§Example
use oximedia_codec::tile::{TileConfig, TileEncoder, TileEncodeOp, TileResult};
use oximedia_codec::error::CodecResult;
use oximedia_codec::frame::VideoFrame;
use oximedia_core::PixelFormat;
struct NullOp;
impl TileEncodeOp for NullOp {
fn encode_tile(&self, _f: &VideoFrame, _x: u32, _y: u32, _w: u32, _h: u32)
-> CodecResult<Vec<u8>>
{
Ok(vec![0u8; 16])
}
}
let cfg = TileConfig::new(2, 2, 0)?;
let encoder = TileEncoder::new(cfg, 1920, 1080);
let mut frame = VideoFrame::new(PixelFormat::Yuv420p, 1920, 1080);
frame.allocate();
let results = encoder.encode(&frame, &NullOp)?;
assert_eq!(results.len(), 4);Implementations§
Source§impl TileEncoder
impl TileEncoder
Sourcepub fn new(config: TileConfig, frame_width: u32, frame_height: u32) -> Self
pub fn new(config: TileConfig, frame_width: u32, frame_height: u32) -> Self
Create a TileEncoder for frames of size frame_width × frame_height.
Sourcepub fn encode<O: TileEncodeOp>(
&self,
frame: &VideoFrame,
op: &O,
) -> CodecResult<Vec<TileResult>>
pub fn encode<O: TileEncodeOp>( &self, frame: &VideoFrame, op: &O, ) -> CodecResult<Vec<TileResult>>
Encode frame using op in parallel.
The returned Vec<TileResult> is sorted in raster order (tile index
0 first).
§Errors
Returns the first CodecError produced by any tile’s encoding, or
CodecError::InvalidParameter if the frame dimensions do not match
the encoder configuration.
Sourcepub fn config(&self) -> &TileConfig
pub fn config(&self) -> &TileConfig
The tile configuration.
Sourcepub const fn frame_width(&self) -> u32
pub const fn frame_width(&self) -> u32
Frame width.
Sourcepub const fn frame_height(&self) -> u32
pub const fn frame_height(&self) -> u32
Frame height.
Sourcepub fn tile_count(&self) -> usize
pub fn tile_count(&self) -> usize
Total number of tiles.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TileEncoder
impl RefUnwindSafe for TileEncoder
impl Send for TileEncoder
impl Sync for TileEncoder
impl Unpin for TileEncoder
impl UnsafeUnpin for TileEncoder
impl UnwindSafe for TileEncoder
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more