Debian Codegraph @

src/huffman.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 //! This file contains a single struct `HuffmanTable` that
10 //! stores Huffman tables needed during `BitStream` decoding.
11 #![allow(clippy::similar_names, clippy::module_name_repetitions)]
12
13 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#;
14
15 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#;
16
17 /// Determines how many bits of lookahead we have for our bitstream decoder.
18
19 pub const HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.: u8 = 9;
20
21 /// A struct which contains necessary tables for decoding a JPEG
22 /// huffman encoded bitstream
23
24 pub struct HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable# {
25 // element `[0]` of each array is unused
26 /// largest code of length k
27 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) maxcoderust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#maxcode.: [i32; 18],
28 /// offset for codes of length k
29 /// Answers the question, where do code-lengths of length k end
30 /// Element 0 is unused
31 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) offsetrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#offset.: [i32; 18],
32 /// lookup table for fast decoding
33 ///
34 /// top bits above HUFF_LOOKAHEAD contain the code length.
35 ///
36 /// Lower (8) bits contain the symbol in order of increasing code length.
37 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#lookup.: [i32; 1 << HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.],
38
39 /// A table which can be used to decode small AC coefficients and
40 /// do an equivalent of receive_extend
41 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<[i16; 1 << HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.]>,
42
43 /// Directly represent contents of a JPEG DHT marker
44 ///
45 /// \# number of symbols with codes of length `k` bits
46 // bits[0] is unused
47 /// Symbols in order of increasing code length
48 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) valuesrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#values.: [u8; 256]
49 }
50
51 impl HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable# {
52 pub fn newrust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]new().(
53 codes: &[u8; 17], values: [u8; 256], is_dc: bool, is_progressive: bool
54 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
55 let too_long_code = (i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) 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().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.;
56 let mut p = HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable# {
57 maxcoderust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#maxcode.: [0; 18],
58 offsetrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#offset.: [0; 18],
59 lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#lookup.: [too_long_code; 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.],
60 valuesrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#values.,
61 ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
62 };
63
64 p.make_derived_tablerust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]make_derived_table().(is_dc, is_progressive, codes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
65
66 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(p)
67 }
68
69 /// Create a new huffman tables with values that aren't fixed
70 /// used by fill_mjpeg_tables
71 pub fn new_unfilledrust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]new_unfilled().(
72 codes: &[u8; 17], values: &[u8], is_dc: bool, is_progressive: bool
73 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
74 let mut buf = [0; 256];
75 buf[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 ops/range/RangeTo#values.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(values);
76 HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#::newrust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]new().(codes, buf, is_dc, is_progressive)
77 }
78
79 /// Compute derived values for a Huffman table
80 ///
81 /// This routine performs some validation checks on the table
82 #[allow(
83 clippy::cast_possible_truncation,
84 clippy::cast_possible_wrap,
85 clippy::cast_sign_loss,
86 clippy::too_many_lines,
87 clippy::needless_range_loop
88 )]
89 fn make_derived_tablerust-analyzer cargo zune-jpeg 0.5.15 huffman/impl#[HuffmanTable]make_derived_table().(
90 &mut self, is_dc: bool, _is_progressive: bool, bits: &[u8; 17]
91 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#> {
92 // build a list of code size
93 let mut huff_size = [0; 257];
94 // Huffman code lengths
95 let mut huff_code: [u32; 257] = [0; 257];
96 // figure C.1 make table of Huffman code length for each symbol
97 let mut p = 0;
98
99 for l in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#16 {
100 let mut i = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(bits[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().l]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
101 // table overrun is checked before ,so we dont need to check
102 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 {
103 huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = l as u8;
104 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
105 i 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;
106 }
107 }
108
109 huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = 0;
110
111 let num_symbols = p;
112 // Generate the codes themselves
113 // We also validate that the counts represent a legal Huffman code tree
114 let mut code = 0;
115 let mut si = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
116
117 p = 0;
118
119 while huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core 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().0 {
120 while i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().si {
121 huff_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = code;
122 code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`AddAssign<Self>`]add_assign().1;
123 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
124 }
125 // maximum code of length si, pre-shifted by 16-k bits
126 self.maxcoderust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#maxcode.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().si as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = (code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().(16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().si)) as i32;
127 // code is now 1 more than the last code used for code-length si; but
128 // it must still fit in si bits, since no code is allowed to be all ones.
129 if (code as i32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<Self>`]shl().si) {
130 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#::HuffmanDecoderust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#HuffmanDecode#("Bad Huffman Table".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
131 }
132
133 code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShlAssign<i32>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShlAssign<i32>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`ShlAssign<i32>`]shl_assign().1;
134 si rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1;
135 }
136
137 // Figure F.15 generate decoding tables for bit-sequential decoding
138 p = 0;
139
140 for l in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#16 {
141 if bits[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().l]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 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 {
142 // -1 if no codes of this length
143 self.maxcoderust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#maxcode.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().l]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 ops/arith/impl#[i32][Neg]neg().1;
144 } else {
145 // offset[l]=codes[index of 1st symbol of code length l
146 // minus minimum code of length l]
147 self.offsetrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#offset.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().l]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = (p as i32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().(huff_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) as i32;
148 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(bits[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().l]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
149 }
150 }
151
152 self.offsetrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#offset.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().17]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = 0;
153 // we ensure that decode terminates
154 self.maxcoderust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#maxcode.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().17]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = 0x000F_FFFF;
155
156 /*
157 * Compute lookahead tables to speed up decoding.
158 * First we set all the table entries to 0(left justified), indicating "too long";
159 * (Note too long was set during initialization)
160 * then we iterate through the Huffman codes that are short enough and
161 * fill in all the entries that correspond to bit sequences starting
162 * with that code.
163 */
164
165 p = 0;
166
167 for l in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. {
168 for _ in 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(bits[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u8>`]from().(l)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) {
169 // l -> Current code length,
170 // p => Its index in self.code and self.values
171 // Generate left justified code followed by all possible bit sequences
172 let mut look_bits = (huff_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as usize) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().l);
173
174 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().l) {
175 self.lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#lookup.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().look_bits]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). =
176 (i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(l) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<u8>`]from().(self.valuesrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#values.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().p]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
177 look_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
178 }
179
180 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
181 }
182 }
183 // build an ac table that does an equivalent of decode and receive_extend
184 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_dc {
185 let mut fast = [255; 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.];
186 // Iterate over number of symbols
187 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_symbols {
188 // get code size for an item
189 let s = huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
190
191 if s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]le().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. {
192 // if it's lower than what we need for our lookup table create the table
193 let c = (huff_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<u8>`]shl().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().s)) as usize;
194 let m = (1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shl<u8>`]shl().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().s)) as usize;
195
196 for j in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#m {
197 fast[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().c 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().j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i as i16;
198 }
199 }
200 }
201
202 // build a table that decodes both magnitude and value of small ACs in
203 // one go.
204 let mut fast_ac = [0; 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.];
205
206 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) {
207 let fast_v = fast[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
208
209 if fast_v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().255 {
210 // get symbol value from AC table
211 let rs = self.valuesrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#values.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().fast_v as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
212 // shift by 4 to get run length
213 let run = i16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`From<u8>`]from().((rs 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().15);
214 // get magnitude bits stored at the lower 3 bits
215 let mag_bits = i16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`From<u8>`]from().(rs 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().15);
216 // length of the bit we've read
217 let len = i16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`From<u8>`]from().(huff_size[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().fast_v as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
218
219 if mag_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]ne().0 && (len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().mag_bits) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]le().i16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`From<u8>`]from().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) {
220 // magnitude code followed by receive_extend code
221 let mut k = (((i as i16) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().len) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`BitAnd<Self>`]bitand().((1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<u8>`]shl().HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1))
222 >>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<Self>`]shr().(i16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i16][`From<u8>`]from().(HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().mag_bits);
223 let m = 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().(mag_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().1);
224
225 if k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]lt().m {
226 k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`AddAssign<Self>`]add_assign().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][Not]not().0_i16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<Self>`]shl().mag_bits) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().1;
227 };
228
229 // if result is small enough fit into fast ac table
230 if (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().128..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#127).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(&k) {
231 fast_ac[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(). = (k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(run rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shl<i32>`]shl().4) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().(len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().mag_bits);
232 }
233 }
234 }
235 }
236 self.ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fast_ac);
237 }
238
239 // Validate symbols as being reasonable
240 // For AC tables, we make no check, but accept all byte values 0..255
241 // For DC tables, we require symbols to be in range 0..15
242 if is_dc {
243 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_symbols {
244 let sym = self.valuesrust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#values.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().;
245
246 if sym 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().15 {
247 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#("Bad Huffman Table".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
248 }
249 }
250 }
251
252 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
253 }
254 }