impl Kernel for RgbToYuv {
fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult<NABufferType> {
let mut df = dest_fmt.fmt;
impl Kernel for RgbToYuv {
fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult<NABufferType> {
let mut df = dest_fmt.fmt;
- let r = src[roff + x] as f32;
- let g = src[goff + x] as f32;
- let b = src[boff + x] as f32;
+ let r = f32::from(src[roff + x]);
+ let g = f32::from(src[goff + x]);
+ let b = f32::from(src[boff + x]);
let (y, u, v) = matrix_mul(&self.matrix, r, g, b);
dst[yoff + x] = (y as i16).max(0).min(255) as u8;
let (y, u, v) = matrix_mul(&self.matrix, r, g, b);
dst[yoff + x] = (y as i16).max(0).min(255) as u8;
impl Kernel for YuvToRgb {
fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult<NABufferType> {
let mut df = dest_fmt.fmt;
impl Kernel for YuvToRgb {
fn init(&mut self, in_fmt: &ScaleInfo, dest_fmt: &ScaleInfo) -> ScaleResult<NABufferType> {
let mut df = dest_fmt.fmt;
- let y = src[yoff + x] as f32;
- let u = ((src[uoff + (x >> sv0)] as i16) - 128) as f32;
- let v = ((src[voff + (x >> sv1)] as i16) - 128) as f32;
+ let y = f32::from(src[yoff + x]);
+ let u = f32::from(i16::from(src[uoff + (x >> sv0)]) - 128);
+ let v = f32::from(i16::from(src[voff + (x >> sv1)]) - 128);
let (r, g, b) = matrix_mul(&self.matrix, y, u, v);
dst[roff + x] = (r as i16).max(0).min(255) as u8;
let (r, g, b) = matrix_mul(&self.matrix, y, u, v);
dst[roff + x] = (r as i16).max(0).min(255) as u8;