Debian Codegraph @

src/headers.rs

raw symbols SCIP
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 //! Decode Decoder markers/segments
10 //!
11 //! This file deals with decoding header information in a jpeg file
12 //!
13 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!;
14 use 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#;
15 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#;
16
17 use zune_corerust-analyzer cargo zune-core 0.5.1 crate/::bytestreamrust-analyzer cargo zune-core 0.5.1 bytestream/::ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#;
18 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#;
19 use zune_corerust-analyzer cargo zune-core 0.5.1 crate/::logrust-analyzer cargo log 0.4.29 crate/::{debugrust-analyzer cargo log 0.4.29 macros/debug!, tracerust-analyzer cargo log 0.4.29 macros/trace!, warnrust-analyzer cargo log 0.4.29 macros/warn!};
20
21 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/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().;
22
23 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#};
24 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::decoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/::{ExtendedXmpSegmentrust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment#, GainMapInforust-analyzer cargo zune-jpeg 0.5.15 decoder/GainMapInfo#, ICCChunkrust-analyzer cargo zune-jpeg 0.5.15 decoder/ICCChunk#, JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#, MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS.};
25 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#;
26 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::huffmanrust-analyzer cargo zune-jpeg 0.5.15 huffman/::HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#;
27 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::miscrust-analyzer cargo zune-jpeg 0.5.15 misc/::{SOFMarkersrust-analyzer cargo zune-jpeg 0.5.15 misc/SOFMarkers#, UN_ZIGZAGrust-analyzer cargo zune-jpeg 0.5.15 misc/UN_ZIGZAG.};
28
29 ///**B.2.4.2 Huffman table-specification syntax**
30 #[allow(clippy::similar_names, clippy::cast_sign_loss)]
31 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_huffmanrust-analyzer cargo zune-jpeg 0.5.15 headers/parse_huffman().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
32 decoder: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
33 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
34 where
35 {
36 // Read the length of the Huffman table
37 let mut dht_length = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u16>`]from().(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]checked_sub().(2).ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(
38 DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::FormatStaticrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#FormatStatic#("Invalid Huffman length in image")
39 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
40
41 while dht_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().16 {
42 // HT information
43 let ht_info = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
44 // third bit indicates whether the huffman encoding is DC or AC type
45 let dc_or_ac = (ht_info 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) 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().0xF;
46 // Indicate the position of this table, should be less than 4;
47 let index = (ht_info 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().0xF) as usize;
48 // read the number of symbols
49 let mut num_symbols: [u8; 17] = [0; 17];
50
51 if index 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. {
52 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#::HuffmanDecoderust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#HuffmanDecode#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
53 "Invalid DHT index {index}, expected between 0 and 3"
54 )));
55 }
56
57 if dc_or_ac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().1 {
58 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#::HuffmanDecoderust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#HuffmanDecode#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
59 "Invalid DHT position {dc_or_ac}, should be 0 or 1"
60 )));
61 }
62
63 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_exact_bytes().(&mut num_symbols[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#17]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
64
65 dht_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().1 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().16;
66
67 let symbols_sum: i32 = num_symbols.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|f| i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().f)).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
68
69 // The sum of the number of symbols cannot be greater than 256;
70 if symbols_sum rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().256 {
71 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#(
72 "Encountered Huffman table with excessive length in DHT"
73 ));
74 }
75 if symbols_sum rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().dht_length {
76 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#::HuffmanDecoderust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#HuffmanDecode#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
77 "Excessive Huffman table of length {symbols_sum} found when header length is {dht_length}"
78 )));
79 }
80 dht_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`SubAssign<Self>`]sub_assign().symbols_sum;
81 // A table containing symbols in increasing code length
82 let mut symbols = [0; 256];
83
84 decoder
85 .streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream.
86 .read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_exact_bytes().(&mut symbols[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#(symbols_sum as usize)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
87 // store
88 match dc_or_ac {
89 0 => {
90 decoder.dc_huffman_tablesrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#dc_huffman_tables.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#::newrust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]new().(
91 &num_symbols,
92 symbols,
93 true,
94 decoder.is_progressiverust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#is_progressive.
95 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
96 }
97 _ => {
98 decoder.ac_huffman_tablesrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#ac_huffman_tables.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#::newrust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]new().(
99 &num_symbols,
100 symbols,
101 false,
102 decoder.is_progressiverust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#is_progressive.
103 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
104 }
105 }
106 }
107
108 if dht_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().0 {
109 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#("Bogus Huffman table definition"));
110 }
111
112 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
113 }
114
115 ///**B.2.4.1 Quantization table-specification syntax**
116 #[allow(clippy::cast_possible_truncation, clippy::needless_range_loop)]
117 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_dqtrust-analyzer cargo zune-jpeg 0.5.15 headers/parse_dqt().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(img: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
118 // read length
119 let mut qt_length =
120 img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream.
121 .get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
122 .checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]checked_sub().(2)
123 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::FormatStaticrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#FormatStatic#(
124 "Invalid DQT length. Length should be greater than 2"
125 ))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
126 // A single DQT header may have multiple QT's
127 while qt_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 {
128 let qt_info = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
129 // 0 = 8 bit otherwise 16 bit dqt
130 let precision = (qt_info 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;
131 // last 4 bits give us position
132 let table_position = (qt_info 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;
133 let precision_value = 64 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().(precision 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);
134
135 if (precision_value 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) as u16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().qt_length {
136 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#::DqtErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#DqtError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid QT table bytes left :{}. Too small to construct a valid qt table which should be {} long", qt_length, precision_value +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1)));
137 }
138
139 let dct_table = match precision {
140 0 => {
141 let mut qt_values = [0; 64];
142
143 img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_exact_bytes().(&mut qt_values)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
144
145 qt_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().(precision_value as u16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().1 /*QT BIT*/;
146 // carry out un zig-zag here
147 un_zig_zagrust-analyzer cargo zune-jpeg 0.5.15 headers/un_zig_zag().(&qt_values)
148 }
149 1 => {
150 // 16 bit quantization tables
151 let mut qt_values = [0_u16; 64];
152
153 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#64 {
154 qt_values[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
155 }
156 qt_length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().(precision_value as u16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().1;
157
158 un_zig_zagrust-analyzer cargo zune-jpeg 0.5.15 headers/un_zig_zag().(&qt_values)
159 }
160 _ => {
161 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#::DqtErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#DqtError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
162 "Expected QT precision value of either 0 or 1, found {precision:?}"
163 )));
164 }
165 };
166
167 if table_position 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. {
168 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#::DqtErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#DqtError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
169 "Too large table position for QT :{table_position}, expected between 0 and 3"
170 )));
171 }
172
173 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Assigning qt table {table_position} with precision {precision}");
174 img.qt_tablesrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#qt_tables.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().table_position]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dct_table);
175 }
176
177 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
178 }
179
180 /// Section:`B.2.2 Frame header syntax`
181
182 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_start_of_framerust-analyzer cargo zune-jpeg 0.5.15 headers/parse_start_of_frame().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
183 sof: SOFMarkersrust-analyzer cargo zune-jpeg 0.5.15 misc/SOFMarkers#, img: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
184 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
185 if img.seen_sofrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#seen_sof. {
186 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(
187 "Two Start of Frame Markers".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
188 ));
189 }
190 // Get length of the frame header
191 let length = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
192 // usually 8, but can be 12 and 16, we currently support only 8
193 // so sorry about that 12 bit images
194 let dt_precision = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
195
196 if dt_precision rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().8 {
197 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
198 "The library can only parse 8-bit images, the image has {dt_precision} bits of precision"
199 )));
200 }
201
202 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..set_densityrust-analyzer cargo zune-jpeg 0.5.15 decoder/impl#[ImageInfo]set_density().(dt_precision);
203
204 // read and set the image height.
205 let img_height = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
206 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..set_heightrust-analyzer cargo zune-jpeg 0.5.15 decoder/impl#[ImageInfo]set_height().(img_height);
207
208 // read and set the image width
209 let img_width = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
210 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..set_widthrust-analyzer cargo zune-jpeg 0.5.15 decoder/impl#[ImageInfo]set_width().(img_width);
211
212 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Image width :{}", img_width);
213 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Image height :{}", img_height);
214
215 if usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(img_width) 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().img.optionsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#options..max_widthrust-analyzer cargo zune-core 0.5.1 options/decoder/impl#[DecoderOptions]max_width().() {
216 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!!("Image width {} greater than width limit {}. If use `set_limits` if you want to support huge images", img_width, img.optionsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#options..max_widthrust-analyzer cargo zune-core 0.5.1 options/decoder/impl#[DecoderOptions]max_width().())));
217 }
218
219 if usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(img_height) 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().img.optionsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#options..max_heightrust-analyzer cargo zune-core 0.5.1 options/decoder/impl#[DecoderOptions]max_height().() {
220 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!!("Image height {} greater than height limit {}. If use `set_limits` if you want to support huge images", img_height, img.optionsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#options..max_heightrust-analyzer cargo zune-core 0.5.1 options/decoder/impl#[DecoderOptions]max_height().())));
221 }
222
223 // Check image width or height is zero
224 if img_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 || img_height rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().0 {
225 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#::ZeroErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#ZeroError#);
226 }
227
228 // Number of components for the image.
229 let num_components = img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
230
231 if num_components rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 {
232 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(
233 "Number of components cannot be zero.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
234 ));
235 }
236
237 let expected = 8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Mul<Self>`]mul().u16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`From<u8>`]from().(num_components);
238 // length should be equal to num components
239 if length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().expected {
240 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
241 "Length of start of frame differs from expected {expected},value is {length}"
242 )));
243 }
244
245 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Image components : {}", num_components);
246
247 if num_components rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().1 {
248 // SOF sets the number of image components
249 // and that to us translates to setting input and output
250 // colorspaces to zero
251 img.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#input_colorspace. = ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::Lumarust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#Luma#;
252 //img.options = img.options.jpeg_set_out_colorspace(ColorSpace::Luma);
253 debugrust-analyzer cargo log 0.4.29 macros/debug!!("Overriding default colorspace set to Luma");
254 }
255 if num_components rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().4 && img.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#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().ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCbCrrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCbCr# {
256 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Input image has 4 components, defaulting to CMYK colorspace");
257 // https://entropymine.wordpress.com/2018/10/22/how-is-a-jpeg-images-color-type-determined/
258 img.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#input_colorspace. = ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::CMYKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#CMYK#;
259 }
260
261 // set number of components
262 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#components. = num_components;
263
264 let mut components = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(num_components as usize);
265 let mut temp = [0; 3];
266
267 for pos in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_components {
268 // read 3 bytes for each component
269 img.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_exact_bytesrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_exact_bytes().(&mut temp)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
270
271 // create a component.
272 let component = Componentsrust-analyzer cargo zune-jpeg 0.5.15 components/Components#::fromrust-analyzer cargo zune-jpeg 0.5.15 components/impl#[Components]from().(temp, pos)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
273
274 components.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(component);
275 }
276 img.seen_sofrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#seen_sof. = true;
277
278 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..set_sof_markerrust-analyzer cargo zune-jpeg 0.5.15 decoder/impl#[ImageInfo]set_sof_marker().(sof);
279
280 img.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components. = components;
281
282 let mut h_max = 1;
283 let mut v_max = 1;
284
285 for comp in &img.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components. {
286 h_max = maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(h_max, comp.horizontal_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#horizontal_sample.);
287 v_max = maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(v_max, comp.vertical_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#vertical_sample.);
288 }
289
290 img.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..sample_ratiorust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#sample_ratio. = match (h_max, v_max) {
291 (1, 1) => SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Nonerust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#None#,
292 (1, 2) => SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Vrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#V#,
293 (2, 1) => SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Hrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#H#,
294 (2, 2) => SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::HVrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#HV#,
295 (hs, vs) => SampleRatiosrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#::Genericrust-analyzer cargo zune-jpeg 0.5.15 components/SampleRatios#Generic#(hs, vs)
296 };
297
298 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
299 }
300
301 /// Parse a start of scan data
302 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_sosrust-analyzer cargo zune-jpeg 0.5.15 headers/parse_sos().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
303 image: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
304 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
305 // Scan header length
306 let ls = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_be_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
307 // Number of image components in scan
308 let ns = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
309
310 let mut seen: [_; 5] = [-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1; { MAX_COMPONENTSrust-analyzer cargo zune-jpeg 0.5.15 decoder/MAX_COMPONENTS. 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 }];
311
312 image.num_scansrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#num_scans. = ns;
313 let smallest_size = 6 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().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(ns);
314
315 if ls 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().smallest_size {
316 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
317 "Bad SOS length {ls},corrupt jpeg"
318 )));
319 }
320
321 // Check number of components.
322 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#5).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]contains().(&ns) {
323 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
324 "Invalid number of components in start of scan {ns}, expected in range 1..5"
325 )));
326 }
327
328 if image.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#components. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().0 {
329 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#(
330 "Error decoding SOF Marker, Number of components cannot be zero."
331 ));
332 }
333
334 // consume spec parameters
335 image.scan_subsampledrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#scan_subsampled. = false;
336
337 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#ns {
338 let id = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
339
340 if seen.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(id)) {
341 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
342 "Duplicate ID {id} seen twice in the same component"
343 )));
344 }
345
346 seen[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(i)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(id);
347 // DC and AC huffman table position
348 // top 4 bits contain dc huffman destination table
349 // lower four bits contain ac huffman destination table
350 let y = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
351
352 let mut j = 0;
353
354 while j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().image.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#components. {
355 if image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().j as usize]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#id. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().id {
356 break;
357 }
358
359 j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1;
360 }
361
362 if j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().image.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#components. {
363 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#::SofErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SofError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
364 "Invalid component id {}, expected one one of {:?}",
365 id,
366 image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| c.idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#id.).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
367 )));
368 }
369
370 let component = &mut image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(j)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().;
371 component.dc_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_huff_table. = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().((y 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) 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().0xF);
372 component.ac_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#ac_huff_table. = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(y 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().0xF);
373 image.z_orderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#z_order.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = j as usize;
374
375 if component.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 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().1 || component.horizontal_samplerust-analyzer cargo zune-jpeg 0.5.15 components/Components#horizontal_sample. 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().1 {
376 image.scan_subsampledrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#scan_subsampled. = true;
377 }
378
379 tracerust-analyzer cargo log 0.4.29 macros/trace!!(
380 "Assigned huffman tables {}/{} to component {j}, id={}",
381 image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(j)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..dc_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#dc_huff_table.,
382 image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(j)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..ac_huff_tablerust-analyzer cargo zune-jpeg 0.5.15 components/Components#ac_huff_table.,
383 image.componentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#components.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(j)]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..idrust-analyzer cargo zune-jpeg 0.5.15 components/Components#id.,
384 );
385 }
386
387 // Collect the component spec parameters
388 // This is only needed for progressive images but I'll read
389 // them in order to ensure they are correct according to the spec
390
391 // Extract progressive information
392
393 // https://www.w3.org/Graphics/JPEG/itu-t81.pdf
394 // Page 42
395
396 // Start of spectral / predictor selection. (between 0 and 63)
397 image.spec_startrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_start. = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
398 // End of spectral selection
399 image.spec_endrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_end. = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
400
401 let bit_approx = image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8_errrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8_err().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
402 // successive approximation bit position high
403 image.succ_highrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_high. = bit_approx 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;
404
405 if image.spec_endrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().63 {
406 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
407 "Invalid Se parameter {}, range should be 0-63",
408 image.spec_endrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_end.
409 )));
410 }
411 if image.spec_startrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().63 {
412 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
413 "Invalid Ss parameter {}, range should be 0-63",
414 image.spec_startrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_start.
415 )));
416 }
417 if image.succ_highrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_high. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().13 {
418 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
419 "Invalid Ah parameter {}, range should be 0-13",
420 image.succ_lowrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_low.
421 )));
422 }
423 // successive approximation bit position low
424 image.succ_lowrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_low. = bit_approx 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().0xF;
425
426 if image.succ_lowrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_low. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]gt().13 {
427 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#::SosErrorrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#SosError#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
428 "Invalid Al parameter {}, range should be 0-13",
429 image.succ_lowrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_low.
430 )));
431 }
432 // skip any bytes not read
433 image.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(smallest_size.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(ls))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
434
435 tracerust-analyzer cargo log 0.4.29 macros/trace!!(
436 "Ss={}, Se={} Ah={} Al={}",
437 image.spec_startrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_start.,
438 image.spec_endrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#spec_end.,
439 image.succ_highrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_high.,
440 image.succ_lowrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#succ_low.
441 );
442
443 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
444 }
445
446 /// Parse the APP13 (IPTC) segment.
447 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_app13rust-analyzer cargo zune-jpeg 0.5.15 headers/parse_app13().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
448 decoder: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
449 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
450 const IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX.: &[u8] = b"Photoshop 3.0\0";
451 // skip length.
452 let mut length = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().());
453
454 if length 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().2 {
455 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#("Too small APP13 length"));
456 }
457 // length bytes.
458 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().2;
459
460 if length 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().IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX. {
461 // skip bytes we read above.
462 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch().;
463 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().IPTC_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/IPTC_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
464
465 let iptc_bytes = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
466
467 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..iptc_datarust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#iptc_data. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(iptc_bytes);
468 }
469
470 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
471 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
472 }
473
474 /// Parse Adobe App14 segment
475 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_app14rust-analyzer cargo zune-jpeg 0.5.15 headers/parse_app14().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
476 decoder: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
477 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
478 // skip length
479 let mut length = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().());
480
481 if length 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().2 {
482 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#("Too small APP14 length"));
483 }
484
485 if decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, 5)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b"Adobe" {
486 if length 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().14 {
487 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#(
488 "Too short of a length for App14 segment"
489 ));
490 }
491 // move stream 6 bytes to remove adobe id
492 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(6)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
493 // skip version, flags0 and flags1
494 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(5)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
495 // get color transform
496 let transform = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8rust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8().();
497 // https://exiftool.org/TagNames/JPEG.html#Adobe
498 match transform {
499 0 => decoder.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#input_colorspace. = ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::CMYKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#CMYK#,
500 1 => decoder.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#input_colorspace. = ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCbCrrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCbCr#,
501 2 => decoder.input_colorspacerust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#input_colorspace. = ColorSpacerust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#::YCCKrust-analyzer cargo zune-core 0.5.1 colorspace/ColorSpace#YCCK#,
502 _ => {
503 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!!(
504 "Unknown Adobe colorspace {transform}"
505 )))
506 }
507 }
508 // length = 2
509 // adobe id = 6
510 // version = 5
511 // transform = 1
512 length = length.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(14);
513 } else {
514 warnrust-analyzer cargo log 0.4.29 macros/warn!!("Not a valid Adobe APP14 Segment, skipping {} bytes", length);
515 length = length.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(2);
516 }
517 // skip any proceeding lengths.
518 // we do not need them
519 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
520
521 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
522 }
523
524 /// Parse the APP1 segment
525 ///
526 /// This contains the exif tag
527 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_app1rust-analyzer cargo zune-jpeg 0.5.15 headers/parse_app1().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
528 decoder: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
529 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
530 const XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX.: &[u8] = b"http://ns.adobe.com/xap/1.0/\0";
531 const EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX.: &[u8] = b"http://ns.adobe.com/xmp/extension/\0";
532 const EXTENDED_XMP_GUID_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_GUID_SIZE.: usize = 32;
533 const EXTENDED_XMP_TOTAL_SIZE_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_TOTAL_SIZE_SIZE.: usize = 4;
534 const EXTENDED_XMP_OFFSET_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_OFFSET_SIZE.: usize = 4;
535 const EXTENDED_XMP_HEADER_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_HEADER_SIZE.: usize =
536 EXTENDED_XMP_GUID_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_GUID_SIZE. 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().EXTENDED_XMP_TOTAL_SIZE_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_TOTAL_SIZE_SIZE. 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().EXTENDED_XMP_OFFSET_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_OFFSET_SIZE.;
537
538 // contains exif data
539 let mut length = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().());
540
541 if length 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().2 {
542 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#("Too small app1 length"));
543 }
544 // length bytes
545 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().2;
546
547 if length 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().6 && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, 6)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().b"Exif\x00\x00" {
548 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Exif segment present");
549 // skip bytes we read above
550 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(6)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
551 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().6;
552
553 let exif_bytes = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
554
555 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..exif_datarust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#exif_data. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(exif_bytes);
556 } else if length 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().XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
557 && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX.
558 {
559 tracerust-analyzer cargo log 0.4.29 macros/trace!!("XMP Data Present");
560 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch().;
561 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/XMP_NAMESPACE_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
562 let xmp_data = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
563 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..xmp_datarust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#xmp_data. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(xmp_data);
564 } else if length 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().EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
565 && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch().
566 ==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX.
567 {
568 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Extended XMP Data Present");
569 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX..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 result/impl#[`Result<T, E>`][Try]branch().;
570 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().EXTENDED_XMP_NAMESPACE_PREFIXrust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_NAMESPACE_PREFIX..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
571
572 if length 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().EXTENDED_XMP_HEADER_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_HEADER_SIZE. {
573 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#("Too small Extended XMP segment"));
574 }
575
576 let header = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, EXTENDED_XMP_HEADER_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_HEADER_SIZE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
577 let guid = header[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#EXTENDED_XMP_GUID_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_GUID_SIZE.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
578
579 let total_size_start = EXTENDED_XMP_GUID_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_GUID_SIZE.;
580 let total_size_end = total_size_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().EXTENDED_XMP_TOTAL_SIZE_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_TOTAL_SIZE_SIZE.;
581 let total_size =
582 u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().total_size_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#total_size_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
583
584 let offset_start = total_size_end;
585 let offset_end = offset_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().EXTENDED_XMP_OFFSET_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_OFFSET_SIZE.;
586 let offset = u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().offset_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#offset_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
587
588 let data = decoder
589 .streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream.
590 .peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(EXTENDED_XMP_HEADER_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_HEADER_SIZE., length 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().EXTENDED_XMP_HEADER_SIZErust-analyzer cargo zune-jpeg 0.5.15 headers/EXTENDED_XMP_HEADER_SIZE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
591 .to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
592
593 decoder.extended_xmp_segmentsrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#extended_xmp_segments..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ExtendedXmpSegmentrust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment# { offsetrust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment#offset., total_sizerust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment#total_size., guidrust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment#guid., datarust-analyzer cargo zune-jpeg 0.5.15 decoder/ExtendedXmpSegment#data. });
594 } else {
595 warnrust-analyzer cargo log 0.4.29 macros/warn!!("Unknown format for APP1 tag, skipping");
596 }
597
598 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
599 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
600 }
601
602 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn parse_app2rust-analyzer cargo zune-jpeg 0.5.15 headers/parse_app2().<T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#>(
603 decoder: &mut JpegDecoderrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#<T>
604 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
605 static HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META.: &[u8] = b"urn:iso:std:iso:ts:21496:-1\0";
606 static MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA.: &[u8] = b"MPF\0";
607
608 let mut length = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().());
609
610 if length 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().2 {
611 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#("Too small app2 segment"));
612 }
613 // length bytes
614 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().2;
615
616 if length 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().14 && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, 12)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`&[T]`][`PartialEq<[U; N]>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`&[T]`][`PartialEq<[U; N]>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`&[T]`][`PartialEq<[U; N]>`]eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b"ICC_PROFILE\0" {
617 tracerust-analyzer cargo log 0.4.29 macros/trace!!("ICC Profile present");
618 // skip 12 bytes which indicate ICC profile
619 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().12;
620 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(12)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
621 let seq_no = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8rust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8().();
622 let num_markers = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..read_u8rust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_u8().();
623 // deduct the two bytes we read above
624 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().2;
625
626 let data = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
627
628 let icc_chunk = ICCChunkrust-analyzer cargo zune-jpeg 0.5.15 decoder/ICCChunk# {
629 seq_norust-analyzer cargo zune-jpeg 0.5.15 decoder/ICCChunk#seq_no.,
630 num_markersrust-analyzer cargo zune-jpeg 0.5.15 decoder/ICCChunk#num_markers.,
631 datarust-analyzer cargo zune-jpeg 0.5.15 decoder/ICCChunk#data.
632 };
633 decoder.icc_datarust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#icc_data..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(icc_chunk);
634 } else if length 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().HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META..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 result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META. {
635 length = length.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
636 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(HDR_METArust-analyzer cargo zune-jpeg 0.5.15 headers/HDR_META..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 result/impl#[`Result<T, E>`][Try]branch().;
637 tracerust-analyzer cargo log 0.4.29 macros/trace!!("Gain Map metadata found");
638 match length {
639 4 => {
640 // If gain map metadata length == 4 then here it variables
641 // https://github.com/google/libultrahdr/blob/bf2aa439eea9ad5da483003fa44182f990f74091/lib/src/jpegr.cpp#L1076C1-L1077C35
642 // 2 bytes minimum_version: (00 00)
643 // 2 bytes writer_version: (00 00)
644 // Perhaps nothing to do with it ?
645 let _ = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().();
646 let _ = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..get_u16_berust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]get_u16_be().();
647 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().4;
648 decoder
649 .inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info.
650 .gain_map_inforust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#gain_map_info.
651 .pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(GainMapInforust-analyzer cargo zune-jpeg 0.5.15 decoder/GainMapInfo# { datarust-analyzer cargo zune-jpeg 0.5.15 decoder/GainMapInfo#data.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() });
652 }
653 n if n 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().4 => {
654 // If there is perhaps useful gain map info
655 // we'll read this until end
656 // https://github.com/google/libultrahdr/blob/bf2aa439eea9ad5da483003fa44182f990f74091/lib/src/jpegr.cpp#L1323
657 let data = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
658 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
659 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(data.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 result/impl#[`Result<T, E>`][Try]branch().;
660
661 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..gain_map_inforust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#gain_map_info..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(GainMapInforust-analyzer cargo zune-jpeg 0.5.15 decoder/GainMapInfo# { datarust-analyzer cargo zune-jpeg 0.5.15 decoder/GainMapInfo#data. });
662 }
663 _ => {}
664 }
665 } else if length 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().MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() && decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA..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 result/impl#[`Result<T, E>`][Try]branch(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA. {
666 tracerust-analyzer cargo log 0.4.29 macros/trace!!("MPF Signature present");
667 length = length.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
668 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(MPF_DATArust-analyzer cargo zune-jpeg 0.5.15 headers/MPF_DATA..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 result/impl#[`Result<T, E>`][Try]branch().;
669 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..multi_picture_information_offsetrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#multi_picture_information_offset. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..positionrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]position().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
670 // MPF signature taken from here
671 // https://github.com/google/libultrahdr/blob/bf2aa439eea9ad5da483003fa44182f990f74091/lib/include/ultrahdr/multipictureformat.h#L50
672 // https://github.com/google/libultrahdr/blob/bf2aa439eea9ad5da483003fa44182f990f74091/lib/src/multipictureformat.cpp#L36
673 // More info https://www.cipa.jp/std/documents/e/DC-X007-KEY_E.pdf
674 let data = decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..peek_atrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]peek_at().(0, length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().();
675 length rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
676 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(data.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 result/impl#[`Result<T, E>`][Try]branch().;
677 decoder.inforust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#info..multi_picture_informationrust-analyzer cargo zune-jpeg 0.5.15 decoder/ImageInfo#multi_picture_information. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(data);
678 }
679
680 decoder.streamrust-analyzer cargo zune-jpeg 0.5.15 decoder/JpegDecoder#stream..skiprust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]skip().(length)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
681
682 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
683 }
684
685 /// Small utility function to print Un-zig-zagged quantization tables
686
687 fn un_zig_zagrust-analyzer cargo zune-jpeg 0.5.15 headers/un_zig_zag().<T>(a: &[T]) -> [i32; 64]
688 where
689 T: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
690 i32: 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/::Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<T>
691 {
692 let mut output = [i32::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/impl#[i32][Default]default().(); 64];
693
694 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#64 {
695 output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().UN_ZIGZAGrust-analyzer cargo zune-jpeg 0.5.15 misc/UN_ZIGZAG.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
696 }
697
698 output
699 }