diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-21 18:21:50 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-10-21 18:21:50 +0200 |
commit | 4997179df78d982965603a1835c52df1f14eb5ef (patch) | |
tree | f305eab9b0c7e3d3d24af6cffeeb7f556a350c52 | |
parent | bbbf86dde30ec4f81e926b84ff58c7435da08b75 (diff) | |
download | nihav-4997179df78d982965603a1835c52df1f14eb5ef.tar.gz |
core/scale: process only common components in packing/unpacking
-rw-r--r-- | nihav-core/src/scale/repack.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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<NABufferType> { - 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<NABufferType> { - 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<Option<NAPixelChromaton>> = 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); |