| 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 | //! This module exports a single struct to store information about |
| 10 | //! JPEG image components |
| 11 | //! |
| 12 | //! The data is extracted from a SOF header. |
| 13 | |
| 14 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 15 | 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!, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/}; |
| 16 | |
| 17 | use zune_corerust-analyzer cargo zune-core 0.5.1 crate/::logrust-analyzer cargo log 0.4.29 crate/::tracerust-analyzer cargo log 0.4.29 macros/trace!; |
| 18 | |
| 19 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#; |
| 20 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::decoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/::MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.; |
| 21 | 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#; |
| 22 | use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::upsamplerrust-analyzer cargo zune-jpeg 0.5.15 upsampler/::upsample_no_oprust-analyzer cargo zune-jpeg 0.5.15 upsampler/upsample_no_op().; |
| 23 | const MAX_SAMP_FACTORrust-analyzer cargo zune-jpeg 0.5.15 components/MAX_SAMP_FACTOR.: usize = 4; |
| 24 | |
| 25 | /// Represents an up-sampler function, this function will be called to upsample |
| 26 | /// a down-sampled image |
| 27 | |
| 28 | pub type UpSamplerrust-analyzer cargo zune-jpeg 0.5.15 components/UpSampler# = fn( |
| 29 | input: &[i16], |
| 30 | in_near: &[i16], |
| 31 | in_far: &[i16], |
| 32 | scratch_space: &mut [i16], |
| 33 | output: &mut [i16] |
| 34 | ); |
| 35 | |
| 36 | /// Component Data from start of frame |
| 37 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 38 | pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) struct Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components# { |
| 39 | /// The type of component that has the metadata below, can be Y,Cb or Cr |
| 40 | pub component_idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#component_id.: ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#, |
| 41 | /// Sub-sampling ratio of this component in the x-plane |
| 42 | pub vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample.: usize, |
| 43 | /// Sub-sampling ratio of this component in the y-plane |
| 44 | pub horizontal_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#horizontal_sample.: usize, |
| 45 | /// DC huffman table position |
| 46 | pub dc_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_huff_table.: usize, |
| 47 | /// AC huffman table position for this element. |
| 48 | pub ac_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#ac_huff_table.: usize, |
| 49 | /// Quantization table number |
| 50 | pub quantization_table_numberrust-analyzer cargo zune-jpeg 0.5.15 components/Components#quantization_table_number.: u8, |
| 51 | /// Specifies quantization table to use with this component |
| 52 | pub quantization_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#quantization_table.: [i32; 64], |
| 53 | /// dc prediction for the component |
| 54 | pub dc_predrust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_pred.: i32, |
| 55 | /// An up-sampling function, can be basic or SSE, depending |
| 56 | /// on the platform |
| 57 | pub up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.: UpSamplerrust-analyzer cargo zune-jpeg 0.5.15 components/UpSampler#, |
| 58 | /// How pixels do we need to go to get to the next line? |
| 59 | pub width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.: usize, |
| 60 | /// Component ID for progressive |
| 61 | pub idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#id.: u8, |
| 62 | /// Whether we need to decode this image component. |
| 63 | pub neededrust-analyzer cargo zune-jpeg 0.5.15 components/Components#needed.: bool, |
| 64 | /// Upsample scanline |
| 65 | pub raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i16>, |
| 66 | /// Upsample destination, stores a scanline worth of sub sampled data |
| 67 | pub upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i16>, |
| 68 | /// previous row, used to handle MCU boundaries |
| 69 | pub row_uprust-analyzer cargo zune-jpeg 0.5.15 components/Components#row_up.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i16>, |
| 70 | /// current row, used to handle MCU boundaries again |
| 71 | pub rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i16>, |
| 72 | pub first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i16>, |
| 73 | pub idct_posrust-analyzer cargo zune-jpeg 0.5.15 components/Components#idct_pos.: usize, |
| 74 | pub xrust-analyzer cargo zune-jpeg 0.5.15 components/Components#x.: usize, |
| 75 | pub w2rust-analyzer cargo zune-jpeg 0.5.15 components/Components#w2.: usize, |
| 76 | pub yrust-analyzer cargo zune-jpeg 0.5.15 components/Components#y.: usize, |
| 77 | pub sample_ratiorust-analyzer cargo zune-jpeg 0.5.15 components/Components#sample_ratio.: SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#, |
| 78 | // a very annoying bug |
| 79 | pub fix_an_annoying_bugrust-analyzer cargo zune-jpeg 0.5.15 components/Components#fix_an_annoying_bug.: usize |
| 80 | } |
| 81 | |
| 82 | impl Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components# { |
| 83 | /// Create a new instance from three bytes from the start of frame |
| 84 | #[inline] |
| 85 | pub fn fromrust-analyzer cargo zune-jpeg 0.5.15 components/impl#[Components]from().(a: [u8; 3], pos: u8) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components#, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> { |
| 86 | // it's a unique identifier. |
| 87 | // doesn't have to be ascending |
| 88 | // see tests/inputs/huge_sof_number |
| 89 | // |
| 90 | // For such cases, use the position of the component |
| 91 | // to determine width |
| 92 | |
| 93 | let id = match pos { |
| 94 | 0 => ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#::Yrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Y#, |
| 95 | 1 => ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#::Cbrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Cb#, |
| 96 | 2 => ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#::Crrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Cr#, |
| 97 | 3 => ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#::Qrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Q#, |
| 98 | _ => { |
| 99 | 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!!( |
| 100 | "Unknown component id found,{pos}, expected value between 1 and 4" |
| 101 | ))) |
| 102 | } |
| 103 | }; |
| 104 | |
| 105 | let horizontal_sample = (a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shr<i32>`]shr().4) as usize; |
| 106 | let vertical_sample = (a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitAnd<Self>`]bitand().0x0f) as usize; |
| 107 | // Match libjpeg turbo on checking for sampling factors |
| 108 | // Reject anything above 4 |
| 109 | if horizontal_sample 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().MAX_SAMP_FACTORrust-analyzer cargo zune-jpeg 0.5.15 components/MAX_SAMP_FACTOR. { |
| 110 | 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!!( |
| 111 | "Bogus Horizontal Sampling Factor {horizontal_sample}" |
| 112 | ))); |
| 113 | } |
| 114 | if vertical_sample 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().MAX_SAMP_FACTORrust-analyzer cargo zune-jpeg 0.5.15 components/MAX_SAMP_FACTOR. { |
| 115 | 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!!( |
| 116 | "Bogus Vertical Sampling Factor {vertical_sample}" |
| 117 | ))); |
| 118 | } |
| 119 | |
| 120 | let quantization_table_number = a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 121 | // confirm quantization number is between 0 and MAX_COMPONENTS |
| 122 | if usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(quantization_table_number) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS. { |
| 123 | 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!!( |
| 124 | "Too large quantization number :{quantization_table_number}, expected value between 0 and {MAX_COMPONENTS}" |
| 125 | ))); |
| 126 | } |
| 127 | // check that upsampling ratios are powers of two |
| 128 | // if these fail, it's probably a corrupt image. |
| 129 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().horizontal_sample.is_power_of_tworust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]is_power_of_two().() { |
| 130 | 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!!( |
| 131 | "Horizontal sample is not a power of two({horizontal_sample}) cannot decode" |
| 132 | ))); |
| 133 | } |
| 134 | |
| 135 | // if !vertical_sample.is_power_of_two() { |
| 136 | // return Err(DecodeErrors::Format(format!( |
| 137 | // "Vertical sub-sample is not power of two({vertical_sample}) cannot decode" |
| 138 | // ))); |
| 139 | // } |
| 140 | if vertical_sample 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 { |
| 141 | // Check for invalid vertical sample |
| 142 | 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#("Vertical sample is zero".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 143 | } |
| 144 | tracerust-analyzer cargo log 0.4.29 macros/trace!!( |
| 145 | "Component ID:{:?} \tHS:{} VS:{} QT:{}", |
| 146 | id, |
| 147 | horizontal_sample, |
| 148 | vertical_sample, |
| 149 | quantization_table_number |
| 150 | ); |
| 151 | |
| 152 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components# { |
| 153 | component_idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#component_id.: id, |
| 154 | vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample., |
| 155 | horizontal_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#horizontal_sample., |
| 156 | quantization_table_numberrust-analyzer cargo zune-jpeg 0.5.15 components/Components#quantization_table_number., |
| 157 | first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 158 | // These two will be set with sof marker |
| 159 | dc_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_huff_table.: 0, |
| 160 | ac_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#ac_huff_table.: 0, |
| 161 | quantization_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#quantization_table.: [0; 64], |
| 162 | dc_predrust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_pred.: 0, |
| 163 | up_samplerrust-analyzer cargo zune-jpeg 0.5.15 components/Components#up_sampler.: upsample_no_oprust-analyzer cargo zune-jpeg 0.5.15 upsampler/upsample_no_op()., |
| 164 | // set later |
| 165 | width_striderust-analyzer cargo zune-jpeg 0.5.15 components/Components#width_stride.: horizontal_sample, |
| 166 | idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#id.: a[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 array/impl#[`[T; N]`][`Index<I>`]index()., |
| 167 | neededrust-analyzer cargo zune-jpeg 0.5.15 components/Components#needed.: true, |
| 168 | raw_coeffrust-analyzer cargo zune-jpeg 0.5.15 components/Components#raw_coeff.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 169 | upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 170 | row_uprust-analyzer cargo zune-jpeg 0.5.15 components/Components#row_up.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 171 | rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |
| 172 | idct_posrust-analyzer cargo zune-jpeg 0.5.15 components/Components#idct_pos.: 0, |
| 173 | xrust-analyzer cargo zune-jpeg 0.5.15 components/Components#x.: 0, |
| 174 | yrust-analyzer cargo zune-jpeg 0.5.15 components/Components#y.: 0, |
| 175 | w2rust-analyzer cargo zune-jpeg 0.5.15 components/Components#w2.: 0, |
| 176 | sample_ratiorust-analyzer cargo zune-jpeg 0.5.15 components/Components#sample_ratio.: SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Nonerust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#None#, |
| 177 | fix_an_annoying_bugrust-analyzer cargo zune-jpeg 0.5.15 components/Components#fix_an_annoying_bug.: 1 |
| 178 | }) |
| 179 | } |
| 180 | /// Setup space for upsampling |
| 181 | /// |
| 182 | /// During upsample, we need a reference of the last row so that upsampling can |
| 183 | /// proceed correctly, |
| 184 | /// so we store the last line of every scanline and use it for the next upsampling procedure |
| 185 | /// to store this, but since we don't need it for 1v1 upsampling, |
| 186 | /// we only call this for routines that need upsampling |
| 187 | /// |
| 188 | /// # Requirements |
| 189 | /// - width stride of this element is set for the component. |
| 190 | pub fn setup_upsample_scanlinerust-analyzer cargo zune-jpeg 0.5.15 components/impl#[Components]setup_upsample_scanline().(&mut self) { |
| 191 | self.rowrust-analyzer cargo zune-jpeg 0.5.15 components/Components#row. = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; self.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(). self.vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample.]; |
| 192 | self.row_uprust-analyzer cargo zune-jpeg 0.5.15 components/Components#row_up. = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; self.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(). self.vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample.]; |
| 193 | self.first_row_upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#first_row_upsample_dest. = |
| 194 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![128; self.vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). self.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(). self.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().()]; |
| 195 | self.upsample_destrust-analyzer cargo zune-jpeg 0.5.15 components/Components#upsample_dest. = |
| 196 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; self.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(). self.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().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). self.fix_an_annoying_bugrust-analyzer cargo zune-jpeg 0.5.15 components/Components#fix_an_annoying_bug. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 8]; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /// Component ID's |
| 201 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 202 | pub enum ComponentIDrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID# { |
| 203 | /// Luminance channel |
| 204 | Yrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Y#, |
| 205 | /// Blue chrominance |
| 206 | Cbrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Cb#, |
| 207 | /// Red chrominance |
| 208 | Crrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Cr#, |
| 209 | /// Q or fourth component |
| 210 | Qrust-analyzer cargo zune-jpeg 0.5.15 components/ComponentID#Q# |
| 211 | } |
| 212 | |
| 213 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 214 | pub enum SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios# { |
| 215 | HVrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#HV#, |
| 216 | Vrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#V#, |
| 217 | Hrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#H#, |
| 218 | Genericrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#Generic#(usize, usize), |
| 219 | #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:] |
| 220 | Nonerust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#None# |
| 221 | } |
| 222 | |
| 223 | impl SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios# { |
| 224 | pub fn samplerust-analyzer cargo zune-jpeg 0.5.15 components/impl#[SampleRatios]sample().(self) -> usize { |
| 225 | match self { |
| 226 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::HVrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#HV# => 4, |
| 227 | 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#::Hrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#H# => 2, |
| 228 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Genericrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#Generic#(a, b) => a 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().b, |
| 229 | SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Nonerust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#None# => 1 |
| 230 | } |
| 231 | } |
| 232 | } |