X-Git-Url: https://git.nihav.org/?p=nihav.git;a=blobdiff_plain;f=nihav-core%2Fsrc%2Fscale%2Fmod.rs;h=cc2388e364ab9f7190f5e4aa34f760abe3a05740;hp=b67a62070350eb4180c0505d3028d7127b275f9c;hb=5f031d75f99167db3aca5e0bb25c06c487deb236;hpb=5737aac9665fb805339937e771003374ac90afb7 diff --git a/nihav-core/src/scale/mod.rs b/nihav-core/src/scale/mod.rs index b67a620..cc2388e 100644 --- a/nihav-core/src/scale/mod.rs +++ b/nihav-core/src/scale/mod.rs @@ -250,13 +250,22 @@ fn is_better_fmt(a: &ScaleInfo, b: &ScaleInfo) -> bool { } false } +fn fmt_needs_scale(ifmt: &NAPixelFormaton, ofmt: &NAPixelFormaton) -> bool { + for (ichr, ochr) in ifmt.comp_info.iter().zip(ofmt.comp_info.iter()) { + if let (Some(ic), Some(oc)) = (ichr, ochr) { + if ic.h_ss != oc.h_ss || ic.v_ss != oc.v_ss { + return true; + } + } + } + false +} fn build_pipeline(ifmt: &ScaleInfo, ofmt: &ScaleInfo, just_convert: bool) -> ScaleResult> { let inname = ifmt.fmt.get_model().get_short_name(); let outname = ofmt.fmt.get_model().get_short_name(); println!("convert {} -> {}", ifmt, ofmt); - let needs_scale = if (ofmt.fmt.get_max_subsampling() > 0) && - (ofmt.fmt.get_max_subsampling() != ifmt.fmt.get_max_subsampling()) { + let needs_scale = if fmt_needs_scale(&ifmt.fmt, &ofmt.fmt) { true } else { !just_convert @@ -530,9 +539,9 @@ mod test { let uoff = obuf.get_offset(1); let voff = obuf.get_offset(2); let odata = obuf.get_data(); - assert_eq!(odata[yoff], 28); - assert_eq!(odata[uoff], 154); - assert_eq!(odata[voff], 103); + assert_eq!(odata[yoff], 11); + assert_eq!(odata[uoff], 162); + assert_eq!(odata[voff], 118); } #[test] fn test_scale_and_convert_to_pal() { @@ -550,7 +559,7 @@ mod test { let odata = obuf.get_data(); assert_eq!(odata[dataoff], 0); assert_eq!(odata[paloff], 157); - assert_eq!(odata[paloff + 1], 99); + assert_eq!(odata[paloff + 1], 129); assert_eq!(odata[paloff + 2], 170); } }