}
}
+fn fill_plane<T: Copy>(dst: &mut [T], w: usize, h: usize, stride: usize, val: T) {
+ for row in dst.chunks_mut(stride).take(h) {
+ for el in row.iter_mut().take(w) {
+ *el = val;
+ }
+ }
+}
+
macro_rules! scale_loop {
($sbuf:expr, $dbuf:expr) => {
let fmt = $sbuf.get_info().get_format();
doff += dstride;
}
}
+ let dfmt = $dbuf.get_info().get_format();
+ let ndcomp = dfmt.get_num_comp();
+ if ndcomp > ncomp {
+ if !fmt.alpha && dfmt.alpha {
+ let acomp = ndcomp - 1;
+ let dstride = $dbuf.get_stride(acomp);
+ let (dw, dh) = $dbuf.get_dimensions(acomp);
+ let doff = $dbuf.get_offset(acomp);
+ let dst = $dbuf.get_data_mut().unwrap();
+ fill_plane(&mut dst[doff..], dw, dh, dstride, 0);
+ }
+ if fmt.model.is_yuv() && ((!fmt.alpha && ncomp == 1) || (fmt.alpha && ncomp == 2)) && ndcomp >= 3 {
+ let uval = 1 << (dfmt.comp_info[1].unwrap().depth - 1);
+ let vval = 1 << (dfmt.comp_info[2].unwrap().depth - 1);
+
+ let ustride = $dbuf.get_stride(1);
+ let vstride = $dbuf.get_stride(2);
+ let (uw, uh) = $dbuf.get_dimensions(1);
+ let (vw, vh) = $dbuf.get_dimensions(2);
+ let uoff = $dbuf.get_offset(1);
+ let voff = $dbuf.get_offset(2);
+ let dst = $dbuf.get_data_mut().unwrap();
+ fill_plane(&mut dst[uoff..], uw, uh, ustride, uval);
+ fill_plane(&mut dst[voff..], vw, vh, vstride, vval);
+ }
+ }
};
}