pub struct Encoder { /* private fields */ }Expand description
Video encoder.
This encoder uses semi-standard pipeline with the simplest and fastest implementation for each stage. Currently the following stages are implemented.
| Stage | How it is implemented |
|---|---|
| RGB to YUV conversion | PGF (no division). |
| Transform | Haar transform (no division). |
| Quantization | Scalar quantization without a deadzone. |
| Motion estimation | Simple delta encoding. |
| Bit encoder | Sign-magniude conversion and rANS encoder. |
§Example
use core::num::NonZero;
use corevm_codec::video;
let rgb_frame = [
0, 0, 0,
100, 0, 0,
0, 100, 0,
0, 0, 100,
];
let width = NonZero::new(2).unwrap();
let height = width;
let mut output = Vec::new();
let config = video::Config::default();
let mut encoder = video::Encoder::new(width, height, config);
encoder.start(&mut output);
encoder.write_rgb888_frame(&rgb_frame, &mut output);
encoder.finish(&mut output);Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(width: NonZero<u16>, height: NonZero<u16>, config: Config) -> Self
pub fn new(width: NonZero<u16>, height: NonZero<u16>, config: Config) -> Self
Creates new encoder with the provided width, height, and configuration.
Sourcepub fn write_rgb888_frame(
&mut self,
rgb_frame: &[u8],
output: &mut impl Output,
) -> Stats
pub fn write_rgb888_frame( &mut self, rgb_frame: &[u8], output: &mut impl Output, ) -> Stats
Encode RGB888 frame and append the resulting bytes to the output.
Sourcepub fn write_rgb888_indexed8_frame(
&mut self,
indexed_rgb_frame: &[u8],
output: &mut impl Output,
) -> Stats
pub fn write_rgb888_indexed8_frame( &mut self, indexed_rgb_frame: &[u8], output: &mut impl Output, ) -> Stats
Encode indexed RGB888 frame and append the resulting bytes to the output.
The frame consists of a 256-color palette and an array of 8-bit indices into the palette. Each palette element is encoded as RGB888.
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
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