Commit ff5bd0b6 authored by Luca Barbato's avatar Luca Barbato Committed by Luca Barbato

Drop bytes

It is not needed by the encoder.
parent 2a024c32
......@@ -26,7 +26,6 @@ const LOOKAHEAD_FRAMES: u64 = 10;
pub struct VideoDetails {
pub width: usize,
pub height: usize,
pub bytes: usize,
pub mono: bool,
pub bit_depth: usize,
pub chroma_sampling: ChromaSampling,
......@@ -39,7 +38,6 @@ impl Default for VideoDetails {
VideoDetails {
width: 640,
height: 480,
bytes: 1,
mono: false,
bit_depth: 8,
chroma_sampling: ChromaSampling::Cs420,
......
......@@ -13,7 +13,6 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
fn get_video_details(&self) -> VideoDetails {
let width = self.get_width();
let height = self.get_height();
let bytes = self.get_bytes_per_sample();
let color_space = self.get_colorspace();
let bit_depth = color_space.get_bit_depth();
let mono = match color_space {
......@@ -26,7 +25,6 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
VideoDetails {
width,
height,
bytes,
bit_depth,
mono,
chroma_sampling,
......@@ -36,6 +34,7 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
}
fn read_frame(&mut self, cfg: &VideoDetails) -> Result<Frame, DecodeError> {
let bytes = self.get_bytes_per_sample();
self.read_frame()
.map(|frame| {
let mut f = Frame::new(
......@@ -43,16 +42,16 @@ impl Decoder for y4m::Decoder<'_, Box<dyn Read>> {
cfg.height.align_power_of_two(3),
cfg.chroma_sampling
);
f.planes[0].copy_from_raw_u8(frame.get_y_plane(), cfg.width * cfg.bytes, cfg.bytes);
f.planes[0].copy_from_raw_u8(frame.get_y_plane(), cfg.width * bytes, bytes);
f.planes[1].copy_from_raw_u8(
frame.get_u_plane(),
cfg.width * cfg.bytes / 2,
cfg.bytes
cfg.width * bytes / 2,
bytes
);
f.planes[2].copy_from_raw_u8(
frame.get_v_plane(),
cfg.width * cfg.bytes / 2,
cfg.bytes
cfg.width * bytes / 2,
bytes
);
f
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment