pub struct SimpleFramePool { /* private fields */ }Expand description
A simple frame pool implementation with fixed capacity.
This pool stores a fixed number of frame buffers and reuses them during video decoding. When the pool is empty, callers must allocate new buffers directly.
§Thread Safety
This implementation uses a Mutex internally, making it safe to
share across threads.
§Examples
ⓘ
use ff_decode::{VideoDecoder, SimpleFramePool};
// Create a pool with capacity for 32 frames (automatically initialized)
let pool = SimpleFramePool::new(32);
let decoder = VideoDecoder::open("video.mp4")?
.frame_pool(pool)
.build()?;
// Frames are acquired from the pool during decoding
for frame in decoder.frames().take(100) {
let frame = frame?;
// Process frame...
}Implementations§
Source§impl SimpleFramePool
impl SimpleFramePool
Sourcepub fn new(max_capacity: usize) -> Arc<Self>
pub fn new(max_capacity: usize) -> Arc<Self>
Creates a new frame pool with the specified maximum capacity.
This function uses RAII (Resource Acquisition Is Initialization) pattern and automatically initializes the pool’s self-reference, eliminating the need for a separate initialization step.
§Arguments
max_capacity- Maximum number of buffers to keep in the pool. When the pool is full, returned buffers are dropped instead of being stored.
§Examples
use ff_decode::SimpleFramePool;
use std::sync::Arc;
// Create a pool for 32 frames - automatically initialized
let pool = SimpleFramePool::new(32);
// Use with decoder
let decoder = VideoDecoder::open("video.mp4")?
.frame_pool(pool)
.build()?;Sourcepub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
Returns the maximum capacity of this pool.
Trait Implementations§
Source§impl Debug for SimpleFramePool
impl Debug for SimpleFramePool
Auto Trait Implementations§
impl !Freeze for SimpleFramePool
impl RefUnwindSafe for SimpleFramePool
impl Send for SimpleFramePool
impl Sync for SimpleFramePool
impl Unpin for SimpleFramePool
impl UnsafeUnpin for SimpleFramePool
impl UnwindSafe for SimpleFramePool
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