| 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 allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!; |
| 10 | 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#; |
| 11 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().; |
| 12 | |
| 13 | use zune_corerust-analyzer cargo zune-core 0.5.1 crate/::colorspacerust-analyzer cargo zune-core 0.5.1 colorspace/::ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#; |
| 14 | |
| 15 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::color_convertrust-analyzer cargo zune-jpeg 0.5.15 color_convert/::ycbcr_to_grayscalerust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/ycbcr_to_grayscale().; |
| 16 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::componentsrust-analyzer cargo zune-jpeg 0.5.15 components/::{Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components#, SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#}; |
| 17 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::decoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/::{ColorConvert16Ptrrust-analyzer cargo zune-jpeg 0.5.15 decoder/ColorConvert16Ptr#, MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.}; |
| 18 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::errorsrust-analyzer cargo zune-jpeg 0.5.15 errors/::DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#; |
| 19 | |
| 20 | /// fast 0..255 * 0..255 => 0..255 rounded multiplication |
| 21 | /// |
| 22 | /// Borrowed from stb |
| 23 | #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] |
| 24 | #[inline] |
| 25 | fn blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(in_val: u8, y: u8) -> u8 { |
| 26 | let t = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(in_val) 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<u8>`]from().(y) 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().128; |
| 27 | return ((t 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().(t rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().8)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().8) as u8; |
| 28 | } |
| 29 | |
| 30 | #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] |
| 31 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn color_convertrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert().( |
| 32 | unprocessed: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], color_convert_16: ColorConvert16Ptrrust-analyzer cargo zune-jpeg 0.5.15 decoder/ColorConvert16Ptr#, |
| 33 | input_colorspace: ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#, output_colorspace: ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#, output: &mut [u8], width: usize, |
| 34 | padded_width: usize |
| 35 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> { |
| 36 | if input_colorspace.num_componentsrust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace]num_components().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().3 && input_colorspace rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq().==rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq(). rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq().output_colorspace { |
| 37 | // sort things like RGB to RGB conversion |
| 38 | copy_removing_paddingrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding().(unprocessed, width, padded_width, output); |
| 39 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 40 | } |
| 41 | if input_colorspace.num_componentsrust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace]num_components().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().4 && input_colorspace rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq().==rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq(). rust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace][`PartialEq<Self>`]eq().output_colorspace { |
| 42 | copy_removing_padding_4xrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding_4x().(unprocessed, width, padded_width, output); |
| 43 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 44 | } |
| 45 | // color convert |
| 46 | match (input_colorspace, output_colorspace) { |
| 47 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCbCrrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCbCr# | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::Lumarust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#Luma#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::Lumarust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#Luma#) => { |
| 48 | ycbcr_to_grayscalerust-analyzer cargo zune-jpeg 0.5.15 color_convert/scalar/ycbcr_to_grayscale().(unprocessed[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., width, padded_width, output); |
| 49 | } |
| 50 | ( |
| 51 | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCbCrrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCbCr#, |
| 52 | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGB# | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBArust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGBA# | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::BGRrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#BGR# | ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::BGRArust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#BGRA# |
| 53 | ) => { |
| 54 | color_convert_ycbcrrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycbcr().( |
| 55 | unprocessed, |
| 56 | width, |
| 57 | padded_width, |
| 58 | output_colorspace, |
| 59 | color_convert_16, |
| 60 | output |
| 61 | ); |
| 62 | } |
| 63 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCCKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCCK#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGB#) => { |
| 64 | color_convert_ycck_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycck_to_rgb().::<3>( |
| 65 | unprocessed, |
| 66 | width, |
| 67 | padded_width, |
| 68 | output_colorspace, |
| 69 | color_convert_16, |
| 70 | output |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCCKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCCK#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBArust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGBA#) => { |
| 75 | color_convert_ycck_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycck_to_rgb().::<4>( |
| 76 | unprocessed, |
| 77 | width, |
| 78 | padded_width, |
| 79 | output_colorspace, |
| 80 | color_convert_16, |
| 81 | output |
| 82 | ); |
| 83 | } |
| 84 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::CMYKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#CMYK#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGB#) => { |
| 85 | color_convert_cymk_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_cymk_to_rgb().::<3>(unprocessed, width, padded_width, output); |
| 86 | } |
| 87 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::CMYKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#CMYK#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBArust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGBA#) => { |
| 88 | color_convert_cymk_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_cymk_to_rgb().::<4>(unprocessed, width, padded_width, output); |
| 89 | } |
| 90 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::MultiBandrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#MultiBand#(n), _) => { |
| 91 | if n.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().2 { |
| 92 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::Formatrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#Format#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 93 | "Unknown multiband sample ({n}), please share sample" |
| 94 | ))); |
| 95 | } |
| 96 | copy_removing_padding_genericrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding_generic().( |
| 97 | unprocessed, |
| 98 | width, |
| 99 | padded_width, |
| 100 | output, |
| 101 | n.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() as usize |
| 102 | ); |
| 103 | } |
| 104 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::Lumarust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#Luma#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGB#) => { |
| 105 | // duplicate the luma channel three times to form RGB |
| 106 | // Note, this may assume the direct conversion |
| 107 | // from luma to RGB is by duplicating |
| 108 | // |
| 109 | // There may be a bit more complex ways |
| 110 | // of doing it but won't get onto it |
| 111 | convert_luma_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/convert_luma_to_rgb().(unprocessed, width, padded_width, output) |
| 112 | } |
| 113 | (ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::Lumarust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#Luma#, ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::RGBArust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#RGBA#) => { |
| 114 | // duplicate the luma channel three times to form RGB |
| 115 | // add 255 as alpha |
| 116 | // Note, this may assume the direct conversion |
| 117 | // from luma to RGB is by duplicating |
| 118 | // |
| 119 | // There may be a bit more complex ways |
| 120 | // of doing it but won't get onto it |
| 121 | convert_luma_to_rgbarust-analyzer cargo zune-jpeg 0.5.15 worker/convert_luma_to_rgba().(unprocessed, width, padded_width, output) |
| 122 | } |
| 123 | |
| 124 | // For the other components we do nothing(currently) |
| 125 | _ => { |
| 126 | let msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 127 | "Unimplemented colorspace mapping from {input_colorspace:?} to {output_colorspace:?}"); |
| 128 | |
| 129 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::Formatrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#Format#(msg)); |
| 130 | } |
| 131 | } |
| 132 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 133 | } |
| 134 | |
| 135 | fn convert_luma_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/convert_luma_to_rgb().( |
| 136 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8] |
| 137 | ) { |
| 138 | for (pix_w, y_w) in output |
| 139 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3) |
| 140 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 141 | { |
| 142 | for (pix, c) in pix_w.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(3).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w) { |
| 143 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 144 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 145 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | fn convert_luma_to_rgbarust-analyzer cargo zune-jpeg 0.5.15 worker/convert_luma_to_rgba().( |
| 150 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8] |
| 151 | ) { |
| 152 | for (pix_w, y_w) in output |
| 153 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().4) |
| 154 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 155 | { |
| 156 | for (pix, c) in pix_w.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(4).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w) { |
| 157 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 158 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 159 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 160 | pix[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; |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | /// Copy a block to output removing padding bytes from input |
| 165 | /// if necessary |
| 166 | #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] |
| 167 | fn copy_removing_paddingrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding().( |
| 168 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8] |
| 169 | ) { |
| 170 | for (((pix_w, c_w), m_w), y_w) in output |
| 171 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3) |
| 172 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 173 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 174 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 175 | { |
| 176 | for (((pix, c), y), m) in pix_w.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(3).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(c_w).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(m_w).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w) { |
| 177 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 178 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().y as u8; |
| 179 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m as u8; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] |
| 184 | fn copy_removing_padding_4xrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding_4x().( |
| 185 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8] |
| 186 | ) { |
| 187 | for ((((pix_w, c_w), m_w), y_w), k_w) in output |
| 188 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().4) |
| 189 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 190 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 191 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 192 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 193 | { |
| 194 | for ((((pix, c), y), m), k) in pix_w |
| 195 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(4) |
| 196 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(c_w) |
| 197 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(m_w) |
| 198 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w) |
| 199 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(k_w) |
| 200 | { |
| 201 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 202 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().y as u8; |
| 203 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m as u8; |
| 204 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k as u8; |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] |
| 209 | fn copy_removing_padding_genericrust-analyzer cargo zune-jpeg 0.5.15 worker/copy_removing_padding_generic().( |
| 210 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8], |
| 211 | channels: usize |
| 212 | ) { |
| 213 | match channels { |
| 214 | // just do 2 for now |
| 215 | 2 => { |
| 216 | for ((pix_w, y_w), k_w) in output |
| 217 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().channels) |
| 218 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 219 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 220 | { |
| 221 | for ((pix, c), k) in pix_w.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(2).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(k_w) { |
| 222 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 223 | pix[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(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k as u8; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!() |
| 228 | } |
| 229 | } |
| 230 | /// Convert YCCK image to rgb |
| 231 | #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] |
| 232 | fn color_convert_ycck_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycck_to_rgb().<const NUM_COMPONENTS: usize>( |
| 233 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, |
| 234 | output_colorspace: ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#, color_convert_16: ColorConvert16Ptrrust-analyzer cargo zune-jpeg 0.5.15 decoder/ColorConvert16Ptr#, output: &mut [u8] |
| 235 | ) { |
| 236 | color_convert_ycbcrrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycbcr().( |
| 237 | mcu_block, |
| 238 | width, |
| 239 | padded_width, |
| 240 | output_colorspace, |
| 241 | color_convert_16, |
| 242 | output |
| 243 | ); |
| 244 | for (pix_w, m_w) in output |
| 245 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3) |
| 246 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 247 | { |
| 248 | for (pix, m) in pix_w.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(NUM_COMPONENTS).ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(m_w) { |
| 249 | let m = (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m) as u8; |
| 250 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(255 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().pix[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., m); |
| 251 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(255 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().pix[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., m); |
| 252 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(255 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().pix[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., m); |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | #[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)] |
| 258 | fn color_convert_cymk_to_rgbrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_cymk_to_rgb().<const NUM_COMPONENTS: usize>( |
| 259 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, output: &mut [u8] |
| 260 | ) { |
| 261 | for ((((pix_w, c_w), m_w), y_w), k_w) in output |
| 262 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().NUM_COMPONENTS) |
| 263 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 264 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 265 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 266 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 267 | { |
| 268 | for ((((pix, c), m), y), k) in pix_w |
| 269 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(3) |
| 270 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(c_w) |
| 271 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(m_w) |
| 272 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(y_w) |
| 273 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(k_w) |
| 274 | { |
| 275 | let c = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().c as u8; |
| 276 | let m = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().m as u8; |
| 277 | let y = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().y as u8; |
| 278 | let k = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k as u8; |
| 279 | |
| 280 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(c, k); |
| 281 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(m, k); |
| 282 | pix[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(). = blinn_8x8rust-analyzer cargo zune-jpeg 0.5.15 worker/blinn_8x8().(y, k); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /// Do color-conversion for interleaved MCU |
| 288 | #[allow( |
| 289 | clippy::similar_names, |
| 290 | clippy::too_many_arguments, |
| 291 | clippy::needless_pass_by_value, |
| 292 | clippy::unwrap_used |
| 293 | )] |
| 294 | fn color_convert_ycbcrrust-analyzer cargo zune-jpeg 0.5.15 worker/color_convert_ycbcr().( |
| 295 | mcu_block: &[&[i16]; MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.], width: usize, padded_width: usize, |
| 296 | output_colorspace: ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#, color_convert_16: ColorConvert16Ptrrust-analyzer cargo zune-jpeg 0.5.15 decoder/ColorConvert16Ptr#, output: &mut [u8] |
| 297 | ) { |
| 298 | let num_components = output_colorspace.num_componentsrust-analyzer cargo zune-core 0.5.1 colorspace/impl#[ColorSpace]num_components().(); |
| 299 | |
| 300 | let stride = width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components; |
| 301 | // Allocate temporary buffer for small widths less than 16. |
| 302 | let mut temp = [0; 64]; |
| 303 | // We need to chunk per width to ensure we can discard extra values at the end of the width. |
| 304 | // Since the encoder may pad bits to ensure the width is a multiple of 8. |
| 305 | for (((y_width, cb_width), cr_width), out) in mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 306 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width) |
| 307 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 308 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(mcu_block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(padded_width)) |
| 309 | .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().(stride)) |
| 310 | { |
| 311 | if width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().16 { |
| 312 | // allocate temporary buffers for the values received from idct |
| 313 | let mut y_out = [0; 16]; |
| 314 | let mut cb_out = [0; 16]; |
| 315 | let mut cr_out = [0; 16]; |
| 316 | // copy those small widths to that buffer |
| 317 | // Use a min with 16 to prevent some panics, see https://github.com/etemesi254/zune-image/issues/331 |
| 318 | y_out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(y_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&y_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(y_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 319 | cb_out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(cb_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). |
| 320 | .copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&cb_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(cb_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 321 | cr_out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(cr_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). |
| 322 | .copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&cr_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(cr_width.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), 16)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 323 | // we handle widths less than 16 a bit differently, allocating a temporary |
| 324 | // buffer and writing to that and then flushing to the out buffer |
| 325 | // because of the optimizations applied below, |
| 326 | (color_convert_16)(&y_out, &cb_out, &cr_out, &mut temp, &mut 0); |
| 327 | // copy to stride |
| 328 | 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/range/Range#width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&temp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 329 | // next |
| 330 | continue; |
| 331 | } |
| 332 | |
| 333 | // Chunk in outputs of 16 to pass to color_convert as an array of 16 i16's. |
| 334 | for (((y, cb), cr), out_c) in y_width |
| 335 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16) |
| 336 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cb_width.chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16)) |
| 337 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cr_width.chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16)) |
| 338 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(out.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components)) |
| 339 | { |
| 340 | (color_convert_16)( |
| 341 | y.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 342 | cb.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 343 | cr.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 344 | out_c, |
| 345 | &mut 0 |
| 346 | ); |
| 347 | } |
| 348 | //we have more pixels in the end that can't be handled by the main loop. |
| 349 | //move pointer back a little bit to get last 16 bytes, |
| 350 | //color convert, and overwrite |
| 351 | //This means some values will be color converted twice. |
| 352 | for ((y, cb), cr) in y_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 353 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16) |
| 354 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cb_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16)) |
| 355 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cr_width[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().16..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16)) |
| 356 | .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(1) |
| 357 | { |
| 358 | (color_convert_16)( |
| 359 | y.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 360 | cb.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 361 | cr.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 362 | &mut temp, |
| 363 | &mut 0 |
| 364 | ); |
| 365 | } |
| 366 | |
| 367 | let rem = out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().(width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). |
| 368 | .chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().num_components) |
| 369 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`ChunksExactMut<'a, T>`][Iterator]next().() |
| 370 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 371 | |
| 372 | rem.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&temp[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#rem.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().); |
| 373 | } |
| 374 | } |
| 375 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn upsamplerust-analyzer cargo zune-jpeg 0.5.15 worker/upsample().( |
| 376 | component: &mut Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components#, mcu_height: usize, i: usize, upsampler_scratch_space: &mut [i16], |
| 377 | has_vertical_sample: bool |
| 378 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> { |
| 379 | match component.sample_ratiorust-analyzer cargo zune-jpeg 0.5.15 components/Components#sample_ratio. { |
| 380 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Vrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#V# | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::HVrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#HV# => { |
| 381 | /* |
| 382 | When upsampling vertically sampled images, we have a certain problem |
| 383 | which is that we do not have all MCU's decoded, this usually sucks at boundaries |
| 384 | e.g we can't upsample the last mcu row, since the row_down currently doesn't exist |
| 385 | |
| 386 | To solve this we need to do two things |
| 387 | |
| 388 | 1. Carry over coefficients when we lack enough data to upsample |
| 389 | 2. Upsample when we have enough data |
| 390 | |
| 391 | To achieve (1), we store a previous row, and the current row in components themselves |
| 392 | which will later be used to make (2) |
| 393 | |
| 394 | To achieve (2), we take the stored previous row(second last MCU row), |
| 395 | current row(last mcu row) and row down(first row of newly decoded MCU) |
| 396 | |
| 397 | and upsample that and store it in first_row_upsample_dest, this contains |
| 398 | up-sampled coefficients for the last for the previous decoded mcu row. |
| 399 | |
| 400 | The caller is then expected to process first_row_upsample_dest before processing data |
| 401 | in component.upsample_dest which stores the up-sampled components excluding the last row |
| 402 | */ |
| 403 | |
| 404 | let mut dest_start = 0; |
| 405 | let stride_bytes_written = component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().component.sample_ratiorust-analyzer cargo zune-jpeg 0.5.15 components/Components#sample_ratio..samplerust-analyzer cargo zune-jpeg 0.5.15 components/impl#[SampleRatios]sample().(); |
| 406 | |
| 407 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 { |
| 408 | // Handle the last MCU of the previous row |
| 409 | // This wasn't up-sampled as we didn't have the row_down |
| 410 | // so we do it now |
| 411 | |
| 412 | let stride = component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.; |
| 413 | |
| 414 | let dest = &mut component.first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#stride_bytes_written]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().; |
| 415 | |
| 416 | // get current row |
| 417 | let row = &component.rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 418 | let row_up = &component.row_uprust-analyzer cargo zune-jpeg 0.5.15 components/Components#row_up.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 419 | let row_down = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 420 | (component.up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.)(row, row_up, row_down, upsampler_scratch_space, dest); |
| 421 | } |
| 422 | |
| 423 | // we have the Y component width stride. |
| 424 | // this may be higher than the actual width,(2x because vertical sampling) |
| 425 | // |
| 426 | // This will not upsample the last row |
| 427 | |
| 428 | // if false, do not upsample. |
| 429 | // set to false on the last row of an mcu |
| 430 | let mut upsample = true; |
| 431 | |
| 432 | let stride = component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().component.vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample.; |
| 433 | let stop_offset = component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.; |
| 434 | |
| 435 | if component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().stop_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride { |
| 436 | // slice would panic below |
| 437 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::FormatStaticrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#FormatStatic#( |
| 438 | "Invalid component dimensions, would panic" |
| 439 | )); |
| 440 | } |
| 441 | for (pos, curr_row) in component |
| 442 | .raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff. |
| 443 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.) |
| 444 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 445 | { |
| 446 | let mut dest: &mut [i16] = &mut []; |
| 447 | let mut row_up: &[i16] = &[]; |
| 448 | // row below current sample |
| 449 | let mut row_down: &[i16] = &[]; |
| 450 | |
| 451 | // Order of ifs matters |
| 452 | |
| 453 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 && pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 454 | // first IMAGE row, row_up is the same as current row |
| 455 | // row_down is the row below. |
| 456 | row_up = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 457 | row_down = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 458 | } else if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 && pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 459 | // first row of a new mcu, previous row was copied so use that |
| 460 | row_up = &component.rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 461 | row_down = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 462 | } else if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().mcu_height.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1) && pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().stop_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 { |
| 463 | // last IMAGE row, adjust pointer to use previous row and current row |
| 464 | row_up = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 465 | row_down = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 466 | } else if pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 && pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().stop_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 { |
| 467 | // other rows, get row up and row down relative to our current row |
| 468 | // ignore last row of each mcu |
| 469 | row_up = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 470 | row_down = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 471 | } else if pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().stop_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 { |
| 472 | // last MCU in a row |
| 473 | // |
| 474 | // we need a row at the next MCU but we haven't decoded that MCU yet |
| 475 | // so we should save this and when we have the next MCU, |
| 476 | // do the upsampling |
| 477 | |
| 478 | // store the current row and previous row in a buffer |
| 479 | let prev_row = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().stride]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 480 | |
| 481 | component.row_uprust-analyzer cargo zune-jpeg 0.5.15 components/Components#row_up..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(prev_row); |
| 482 | component.rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(curr_row); |
| 483 | upsample = false; |
| 484 | } else { |
| 485 | unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("Uh oh!"); |
| 486 | } |
| 487 | if upsample { |
| 488 | dest = |
| 489 | &mut component.upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().dest_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#dest_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().stride_bytes_written]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().; |
| 490 | dest_start 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().stride_bytes_written; |
| 491 | } |
| 492 | |
| 493 | if upsample { |
| 494 | // upsample |
| 495 | (component.up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.)( |
| 496 | curr_row, |
| 497 | row_up, |
| 498 | row_down, |
| 499 | upsampler_scratch_space, |
| 500 | dest |
| 501 | ); |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Hrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#H# => { |
| 506 | //assert_eq!(component.raw_coeff.len() * 2, component.upsample_dest.len()); |
| 507 | // Before it was an assert, but numerous and numerous and numerous |
| 508 | // bug fixes and ad hoc solutions later, I have now just decided to keep it as a resize |
| 509 | component |
| 510 | .upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest. |
| 511 | .resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2, 0); |
| 512 | |
| 513 | let raw_coeff = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.; |
| 514 | let dest_coeff = &mut component.upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest.; |
| 515 | |
| 516 | if has_vertical_sample { |
| 517 | /* |
| 518 | There have been images that have the following configurations. |
| 519 | |
| 520 | Component ID:Y HS:2 VS:2 QT:0 |
| 521 | Component ID:Cb HS:1 VS:1 QT:1 |
| 522 | Component ID:Cr HS:1 VS:2 QT:1 |
| 523 | |
| 524 | This brings out a nasty case of misaligned sampling factors. Cr will need to save a row because |
| 525 | of the way we process boundaries but Cb won't since Cr is horizontally sampled while Cb is |
| 526 | HV sampled with respect to the image sampling factors. |
| 527 | |
| 528 | So during decoding of one MCU, we could only do 7 and not 8 rows, but the SampleRatio::H never had to |
| 529 | save a single line, since it doesn't suffer from boundary issues. |
| 530 | |
| 531 | Now this takes care of that, saving the last MCU row in case it will be needed. |
| 532 | We save the previous row before up-sampling this row because the boundary issue is in |
| 533 | the last MCU row of the previous MCU. |
| 534 | |
| 535 | PS(cae): I can't add the image to the repo as it is nsfw, but can send if required |
| 536 | */ |
| 537 | let length = component.first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 538 | component |
| 539 | .first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest. |
| 540 | .copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&dest_coeff.rchunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]rchunks_exact().(length).nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`RChunksExact<'a, T>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()); |
| 541 | } |
| 542 | // up-sample each row |
| 543 | for (single_row, output_stride) in raw_coeff |
| 544 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.) |
| 545 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(dest_coeff.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2)) |
| 546 | { |
| 547 | // upsample using the fn pointer, should only be H, so no need for |
| 548 | // row up and row down |
| 549 | (component.up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.)(single_row, &[], &[], &mut [], output_stride); |
| 550 | } |
| 551 | } |
| 552 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Genericrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#Generic#(h, v) => { |
| 553 | let raw_coeff = &component.raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.; |
| 554 | let dest_coeff = &mut component.upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest.; |
| 555 | |
| 556 | //let size = component.width_stride.div_ceil(v); |
| 557 | |
| 558 | // for (single_row, output_stride) in raw_coeff |
| 559 | // .chunks_exact(size) |
| 560 | // .zip(dest_coeff.chunks_exact_mut(component.width_stride * h)) |
| 561 | // { |
| 562 | // (component.up_sampler)(single_row, &[], &[], &mut [], output_stride); |
| 563 | // |
| 564 | // } |
| 565 | for (single_row, output_stride) in raw_coeff |
| 566 | .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.) |
| 567 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(dest_coeff.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().v)) |
| 568 | { |
| 569 | for row in output_stride.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(component.width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().h) { |
| 570 | (component.up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.)(single_row, &[], &[], &mut [], row); |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Nonerust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#None# => {} |
| 575 | }; |
| 576 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 577 | } |