| 1 | /* |
| 2 | * Copyright (c) 2023. |
| 3 | * |
| 4 | * This software is free software; |
| 5 | * |
| 6 | * You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license |
| 7 | */ |
| 8 | |
| 9 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryIntorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#; |
| 10 | |
| 11 | // Bt.601 Full Range inverse coefficients computed with 14 bits of precision with MPFR. |
| 12 | // This is important to keep them in i16. |
| 13 | // In most cases LLVM will detect what we're doing i16 widening to i32 math and will use |
| 14 | // appropriate optimizations. |
| 15 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const Y_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/Y_CF.: i16 = 16384; |
| 16 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const CR_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CR_CF.: i16 = 22970; |
| 17 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const CB_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CB_CF.: i16 = 29032; |
| 18 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const C_G_CR_COEF_1rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CR_COEF_1.: i16 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().11700; |
| 19 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const C_G_CB_COEF_2rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CB_COEF_2.: i16 = -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().5638; |
| 20 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.: i16 = 14; |
| 21 | // Rounding const for YUV -> RGB conversion: floating equivalent 0.499(9). |
| 22 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const YUV_RNDrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_RND.: i16 = (1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().(YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1; |
| 23 | |
| 24 | /// Limit values to 0 and 255 |
| 25 | #[inline] |
| 26 | #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss, dead_code)] |
| 27 | fn clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(a: i32) -> u8 { |
| 28 | a.clamprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][Ord]clamp().(0, 255) as u8 |
| 29 | } |
| 30 | |
| 31 | /// YCbCr to RGBA color conversion |
| 32 | |
| 33 | /// Convert YCbCr to RGB/BGR |
| 34 | /// |
| 35 | /// Converts to RGB if const BGRA is false |
| 36 | /// |
| 37 | /// Converts to BGR if const BGRA is true |
| 38 | pub fn ycbcr_to_rgba_inner_16_scalarrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/ycbcr_to_rgba_inner_16_scalar().<const BGRA: bool>( |
| 39 | y: &[i16; 16], cb: &[i16; 16], cr: &[i16; 16], output: &mut [u8], pos: &mut usize |
| 40 | ) { |
| 41 | let (_, output_position) = output.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos); |
| 42 | |
| 43 | // Convert into a slice with 64 elements for Rust to see we won't go out of bounds. |
| 44 | let opt: &mut [u8; 64] = output_position |
| 45 | .get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#64) |
| 46 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Slice to small cannot write") |
| 47 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 48 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 49 | for ((&y, (cb, cr)), out) in y |
| 50 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 51 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cb.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cr.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().())) |
| 52 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(opt.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(4)) |
| 53 | { |
| 54 | let cr = cr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().128; |
| 55 | let cb = cb rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().128; |
| 56 | |
| 57 | let y0 = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(Y_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/Y_CF.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(YUV_RNDrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_RND.); |
| 58 | |
| 59 | let r = (y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cr) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(CR_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CR_CF.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 60 | let g = (y0 |
| 61 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cr) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(C_G_CR_COEF_1rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CR_COEF_1.) |
| 62 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cb) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(C_G_CB_COEF_2rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CB_COEF_2.)) |
| 63 | >>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 64 | let b = (y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cb) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(CB_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CB_CF.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 65 | |
| 66 | if BGRA { |
| 67 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(b); |
| 68 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(g); |
| 69 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(r); |
| 70 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 255; |
| 71 | } else { |
| 72 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(r); |
| 73 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(g); |
| 74 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(b); |
| 75 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 255; |
| 76 | } |
| 77 | } |
| 78 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().64; |
| 79 | } |
| 80 | |
| 81 | /// Convert YCbCr to RGB/BGR |
| 82 | /// |
| 83 | /// Converts to RGB if const BGRA is false |
| 84 | /// |
| 85 | /// Converts to BGR if const BGRA is true |
| 86 | pub fn ycbcr_to_rgb_inner_16_scalarrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/ycbcr_to_rgb_inner_16_scalar().<const BGRA: bool>( |
| 87 | y: &[i16; 16], cb: &[i16; 16], cr: &[i16; 16], output: &mut [u8], pos: &mut usize |
| 88 | ) { |
| 89 | let (_, output_position) = output.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos); |
| 90 | |
| 91 | // Convert into a slice with 48 elements |
| 92 | let opt: &mut [u8; 48] = output_position |
| 93 | .get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#48) |
| 94 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Slice to small cannot write") |
| 95 | .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().() |
| 96 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 97 | |
| 98 | for ((&y, (cb, cr)), out) in y |
| 99 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 100 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cb.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cr.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().())) |
| 101 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(opt.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(3)) |
| 102 | { |
| 103 | let cr = cr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().128; |
| 104 | let cb = cb rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i16`][`Sub<i16>`]sub().128; |
| 105 | |
| 106 | let y0 = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(y) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(Y_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/Y_CF.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(YUV_RNDrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_RND.); |
| 107 | |
| 108 | let r = (y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cr) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(CR_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CR_CF.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 109 | let g = (y0 |
| 110 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cr) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(C_G_CR_COEF_1rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CR_COEF_1.) |
| 111 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cb) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(C_G_CB_COEF_2rust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/C_G_CB_COEF_2.)) |
| 112 | >>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 113 | let b = (y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(cb) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(CB_CFrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/CB_CF.)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<i16>`]shr().YUV_PRECrust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/YUV_PREC.; |
| 114 | |
| 115 | if BGRA { |
| 116 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(b); |
| 117 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(g); |
| 118 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(r); |
| 119 | } else { |
| 120 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(r); |
| 121 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(g); |
| 122 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = clamprust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/clamp().(b); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // Increment pos |
| 127 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().48; |
| 128 | } |
| 129 | |
| 130 | pub fn ycbcr_to_grayscalerust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/ycbcr_to_grayscale().(y: &[i16], width: usize, padded_width: usize, output: &mut [u8]) { |
| 131 | for (y_in, out) in y |
| 132 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width) |
| 133 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(output.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width)) |
| 134 | { |
| 135 | for (y, out) in y_in.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(out.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().()) { |
| 136 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().out = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().y as u8; |
| 137 | } |
| 138 | } |
| 139 | } |