From: Kostya Shishkov Date: Wed, 21 Oct 2020 16:21:50 +0000 (+0200) Subject: core/scale: process only common components in packing/unpacking X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=4997179df78d982965603a1835c52df1f14eb5ef core/scale: process only common components in packing/unpacking --- diff --git a/nihav-core/src/scale/repack.rs b/nihav-core/src/scale/repack.rs index f0e5956..23ba2c9 100644 --- a/nihav-core/src/scale/repack.rs +++ b/nihav-core/src/scale/repack.rs @@ -34,7 +34,7 @@ impl PackKernel { impl Kernel for PackKernel { fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult { - self.ncomps = in_fmt.fmt.components as usize; + self.ncomps = in_fmt.fmt.components.min(dest_fmt.fmt.components) as usize; for i in 0..self.ncomps { let ichr = in_fmt.fmt.comp_info[i].unwrap(); let ochr = dest_fmt.fmt.comp_info[i].unwrap(); @@ -121,7 +121,7 @@ impl UnpackKernel { impl Kernel for UnpackKernel { fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult { - self.ncomps = in_fmt.fmt.components as usize; + self.ncomps = in_fmt.fmt.components.min(dest_fmt.fmt.components) as usize; let mut chr: Vec> = Vec::with_capacity(MAX_CHROMATONS); for i in 0..self.ncomps { let ichr = in_fmt.fmt.comp_info[i].unwrap(); @@ -144,6 +144,7 @@ impl Kernel for UnpackKernel { } let mut df = in_fmt.fmt; df.comp_info[..self.ncomps].clone_from_slice(&chr[..self.ncomps]); + df.components = self.ncomps as u8; df.palette = false; println!(" [intermediate format {}]", df); let res = alloc_video_buffer(NAVideoInfo::new(in_fmt.width, in_fmt.height, false, df), 3);