Debian Codegraph @

src/bitstream.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 #![allow(
10 clippy::if_not_else,
11 clippy::similar_names,
12 clippy::inline_always,
13 clippy::doc_markdown,
14 clippy::cast_sign_loss,
15 clippy::cast_possible_truncation
16 )]
17
18 //! This file exposes a single struct that can decode a huffman encoded
19 //! Bitstream in a JPEG file
20 //!
21 //! This code is optimized for speed.
22 //! It's meant to be super duper super fast, because everyone else depends on this being fast.
23 //! It's (annoyingly) serial hence we cant use parallel bitstreams(it's variable length coding.)
24 //!
25 //! Furthermore, on the case of refills, we have to do bytewise processing because the standard decided
26 //! that we want to support markers in the middle of streams(seriously few people use RST markers).
27 //!
28 //! So we pull in all optimization steps:
29 //! - use `inline[always]`? ✅ ,
30 //! - pre-execute most common cases ✅,
31 //! - add random comments ✅
32 //! - fast paths ✅.
33 //!
34 //! Speed-wise: It is probably the fastest JPEG BitStream decoder to ever sail the seven seas because of
35 //! a couple of optimization tricks.
36 //! 1. Fast refills from libjpeg-turbo
37 //! 2. As few as possible branches in decoder fast paths.
38 //! 3. Accelerated AC table decoding borrowed from stb_image.h written by Fabian Gissen (@ rygorous),
39 //! improved by me to handle more cases.
40 //! 4. Safe and extensible routines(e.g. cool ways to eliminate bounds check)
41 //! 5. No unsafe here
42 //!
43 //! Readability comes as a second priority(I tried with variable names this time, and we are wayy better than libjpeg).
44 //!
45 //! Anyway if you are reading this it means your cool and I hope you get whatever part of the code you are looking for
46 //! (or learn something cool)
47 //!
48 //! Knock yourself out.
49 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!;
50 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#;
51 use zune_corerust-analyzer cargo zune-core 0.5.1 crate/::logrust-analyzer cargo log 0.4.29 crate/::warnrust-analyzer cargo log 0.4.29 macros/warn!;
52 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().;
53
54 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#, ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#};
55
56 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#;
57 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#, HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.};
58 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::markerrust-analyzer cargo zune-jpeg 0.5.15 marker/::Markerrust-analyzer cargo zune-jpeg 0.5.15 marker/Marker#;
59 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::mcurust-analyzer cargo zune-jpeg 0.5.15 mcu/::DCT_BLOCKrust-analyzer cargo zune-jpeg 0.5.15 mcu/DCT_BLOCK.;
60 use craterust-analyzer cargo zune-jpeg 0.5.15 crate/::miscrust-analyzer cargo zune-jpeg 0.5.15 misc/::UN_ZIGZAGrust-analyzer cargo zune-jpeg 0.5.15 misc/UN_ZIGZAG.;
61
62 macro_rules! decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff! {
63 ($stream:tt,$symbol:tt,$table:tt) => {
64 let mut code_length = $symbol >> HUFF_LOOKAHEAD;
65
66 ($symbol) &= (1 << HUFF_LOOKAHEAD) - 1;
67
68 if code_length > i32::from(HUFF_LOOKAHEAD)
69 {
70 // if the symbol cannot be resolved in the first HUFF_LOOKAHEAD bits,
71 // we know it lies somewhere between HUFF_LOOKAHEAD and 16 bits since jpeg imposes 16 bit
72 // limit, we can therefore look 16 bits ahead and try to resolve the symbol
73 // starting from 1+HUFF_LOOKAHEAD bits.
74 $symbol = ($stream).peek_bits::<16>() as i32;
75 // (Credits to Sean T. Barrett stb library for this optimization)
76 // maxcode is pre-shifted 16 bytes long so that it has (16-code_length)
77 // zeroes at the end hence we do not need to shift in the inner loop.
78 while code_length < 17{
79 if $symbol < $table.maxcode[code_length as usize] {
80 break;
81 }
82 code_length += 1;
83 }
84
85 if code_length == 17{
86 // symbol could not be decoded.
87 //
88 // We may think, lets fake zeroes, noo
89 // panic, because Huffman codes are sensitive, probably everything
90 // after this will be corrupt, so no need to continue.
91 // panic!("Bad Huffman code length");
92 return Err(DecodeErrors::Format(format!("Bad Huffman Code 0x{:X}, corrupt JPEG",$symbol)))
93 }
94
95 $symbol >>= (16-code_length);
96 ($symbol) = i32::from(
97 ($table).values
98 [(($symbol + ($table).offset[code_length as usize]) & 0xFF) as usize],
99 );
100 }
101 if code_length> i32::from(($stream).bits_left){
102 return Err(DecodeErrors::Format(format!("Code length {code_length} more than bits left {}",($stream).bits_left)))
103 }
104 // drop bits read
105 ($stream).drop_bits(code_length as u8);
106 };
107 }
108
109 /// A `BitStream` struct, a bit by bit reader with super powers
110 ///
111 #[rustfmt::skip]
112 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) struct BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
113 /// A MSB type buffer that is used for some certain operations
114 pub bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer.: u64,
115 /// A TOP aligned MSB type buffer that is used to accelerate some operations like
116 /// peek_bits and get_bits.
117 ///
118 /// By top aligned, I mean the top bit (63) represents the top bit in the buffer.
119 aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer.: u64,
120 /// Tell us the bits left the two buffer
121 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.: u8,
122 /// Did we find a marker(RST/EOF) during decoding?
123 pub markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Markerrust-analyzer cargo zune-jpeg 0.5.15 marker/Marker#>,
124 /// An i16 with the bit corresponding to successive_low set to 1, others 0.
125 pub successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.: i16,
126 spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start.: u8,
127 spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end.: u8,
128 pub eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run.: i32,
129 pub overread_byrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#overread_by.: usize,
130 /// True if we have seen end of image marker.
131 /// Don't read anything after that.
132 pub seen_eoirust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#seen_eoi.: bool,
133 }
134
135 impl BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
136 /// Create a new BitStream
137 #[rustfmt::skip]
138 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) const fn newrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]new().() -> BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
139 BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
140 bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer.: 0,
141 aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer.: 0,
142 bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.: 0,
143 markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
144 successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.: 1,
145 spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start.: 0,
146 spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end.: 0,
147 eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run.: 0,
148 overread_byrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#overread_by.: 0,
149 seen_eoirust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#seen_eoi.: false,
150 }
151 }
152
153 /// Create a new Bitstream for progressive decoding
154 #[allow(clippy::redundant_field_names)]
155 #[rustfmt::skip]
156 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn new_progressiverust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]new_progressive().(al: u8, spec_start: u8, spec_end: u8) -> BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
157 BitStreamrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream# {
158 bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer.: 0,
159 aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer.: 0,
160 bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.: 0,
161 markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
162 successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.: 1i16 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().al,
163 spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start.: spec_start,
164 spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end.: spec_end,
165 eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run.: 0,
166 overread_byrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#overread_by.: 0,
167 seen_eoirust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#seen_eoi.: false,
168 }
169 }
170
171 /// Refill the bit buffer by (a maximum of) 32 bits
172 ///
173 /// # Arguments
174 /// - `reader`:`&mut BufReader<R>`: A mutable reference to an underlying
175 /// File/Memory buffer containing a valid JPEG stream
176 ///
177 /// This function will only refill if `self.count` is less than 32
178 #[inline(always)] // to many call sites? ( perf improvement by 4%)
179 pub fn refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().<T>(&mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
180 where
181 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
182 {
183 /// Macro version of a single byte refill.
184 /// Arguments
185 /// buffer-> our io buffer, because rust macros cannot get values from
186 /// the surrounding environment bits_left-> number of bits left
187 /// to full refill
188 macro_rules! refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/refill! {
189 ($buffer:expr,$byte:expr,$bits_left:expr) => {
190 // read a byte from the stream
191 $byte = u64::from(reader.read_u8());
192 self.overread_by += usize::from(reader.eof()?);
193 // append to the buffer
194 // JPEG is a MSB type buffer so that means we append this
195 // to the lower end (0..8) of the buffer and push the rest bits above..
196 $buffer = ($buffer << 8) | $byte;
197 // Increment bits left
198 $bits_left += 8;
199 // Check for special case of OxFF, to see if it's a stream or a marker
200 if $byte == 0xff {
201 // read next byte
202 let mut next_byte = u64::from(reader.read_u8());
203 // Byte snuffing, if we encounter byte snuff, we skip the byte
204 if next_byte != 0x00 {
205 // skip that byte we read
206 while next_byte == 0xFF {
207 next_byte = u64::from(reader.read_u8());
208 }
209
210 if next_byte != 0x00 {
211 // Undo the byte append and return
212 $buffer >>= 8;
213 $bits_left -= 8;
214
215 if $bits_left != 0 {
216 self.aligned_buffer = $buffer << (64 - $bits_left);
217 }
218
219 let marker = Marker::from_u8(next_byte as u8);
220 self.marker = marker;
221
222 if let Some(Marker::UNKNOWN(_)) = marker{
223 return Err(DecodeErrors::Format("Unknown marker in bit stream".to_string()));
224 }
225 if next_byte == 0xD9 {
226 // special handling for eoi, fill some bytes,even if its zero,
227 // removes some panics
228 self.buffer <<= 8;
229 self.bits_left += 8;
230 self.aligned_buffer = self.buffer << (64 - self.bits_left);
231 }
232
233 return Ok(false);
234 }
235 }
236 }
237 };
238 }
239
240 // 32 bits is enough for a decode(16 bits) and receive_extend(max 16 bits)
241 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().32 {
242 if self.markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() || self.seen_eoirust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#seen_eoi. {
243 // found a marker, or we are in EOI
244 // also we are in over-reading mode, where we fill it with zeroes
245
246 // fill with zeroes
247 self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign().32;
248 self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().32;
249 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. = self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().(64 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().self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
250 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
251 }
252
253 if self.overread_byrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#overread_by. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
254 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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 {
255 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#::ExhaustedDatarust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#ExhaustedData#);
256 }
257 // We already hit EOF while refilling. Continue consuming the buffered bits
258 // but don't synthesize additional bytes from zero-fill.
259 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
260 }
261
262 // we optimize for the case where we don't have 255 in the stream and have 4 bytes left
263 // as it is the common case
264 //
265 // so we always read 4 bytes, if read_fixed_bytes errors out, the cursor is
266 // guaranteed not to advance in case of failure (is this true), so
267 // we revert the read later on (if we have 255), if this fails, we use the normal
268 // byte at a time read
269
270 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes) = reader.read_fixed_bytes_or_errorrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]read_fixed_bytes_or_error().::<4>() {
271 // we have 4 bytes to spare, read the 4 bytes into a temporary buffer
272 // create buffer
273 let msb_buf = u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(bytes);
274 // check if we have 0xff
275 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().has_byterust-analyzer cargo zune-jpeg 0.5.15 bitstream/has_byte().(msb_buf, 255) {
276 self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().32;
277 self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<i32>`]shl_assign().32;
278 self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().u64::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u64][`From<u32>`]from().(msb_buf);
279 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. = self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().(64 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().self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
280 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
281 }
282
283 reader.rewindrust-analyzer cargo zune-core 0.5.1 bytestream/reader/impl#[`ZReader<T>`]rewind().(4)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
284 }
285 // This serves two reasons,
286 // 1: Make clippy shut up
287 // 2: Favour register reuse
288 let mut byte;
289 // 4 refills, if all succeed the stream should contain enough bits to decode a
290 // value
291 refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/refill!!(self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer., byte, self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
292 refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/refill!!(self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer., byte, self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
293 refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/refill!!(self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer., byte, self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
294 refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/refill!!(self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer., byte, self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
295 // Construct an MSB buffer whose top bits are the bitstream we are currently holding.
296 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. = self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().(64 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().self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left.);
297 }
298 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
299 }
300 /// Decode the DC coefficient in a MCU block.
301 ///
302 /// The decoded coefficient is written to `dc_prediction`
303 ///
304 #[allow(
305 clippy::cast_possible_truncation,
306 clippy::cast_sign_loss,
307 clippy::unwrap_used
308 )]
309 #[inline(always)]
310 fn decode_dcrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_dc().<T>(
311 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, dc_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, dc_prediction: &mut i32
312 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
313 where
314 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
315 {
316 let (mut symbol, r);
317
318 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().32 {
319 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
320 };
321 // look a head HUFF_LOOKAHEAD bits into the bitstream
322 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
323 symbol = dc_table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
324
325 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, dc_table);
326
327 if symbol 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 {
328 r = self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(symbol as u8);
329 symbol = huff_extendrust-analyzer cargo zune-jpeg 0.5.15 bitstream/huff_extend().(r, symbol);
330 }
331 // Update DC prediction
332 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().dc_prediction = dc_prediction.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]wrapping_add().(symbol);
333
334 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
335 }
336
337 /// Like `decode_dc` but we do not need the result of the component, we only want to remove it
338 /// from the bitstream of the MCU.
339 fn discard_dcrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]discard_dc().<T>(
340 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, dc_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#
341 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
342 where
343 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
344 {
345 let mut symbol;
346
347 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().32 {
348 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
349 };
350 // look a head HUFF_LOOKAHEAD bits into the bitstream
351 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
352 symbol = dc_table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
353
354 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, dc_table);
355
356 if symbol 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 {
357 let _ = self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(symbol as u8);
358 }
359
360 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
361 }
362
363 /// Decode a Minimum Code Unit(MCU) as quickly as possible
364 ///
365 /// # Arguments
366 /// - reader: The bitstream from where we read more bits.
367 /// - dc_table: The Huffman table used to decode the DC coefficient
368 /// - ac_table: The Huffman table used to decode AC values
369 /// - block: A memory region where we will write out the decoded values
370 /// - DC prediction: Last DC value for this component
371 ///
372 #[allow(
373 clippy::many_single_char_names,
374 clippy::cast_possible_truncation,
375 clippy::cast_sign_loss
376 )]
377 #[inline(never)]
378 pub fn decode_mcu_blockrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_mcu_block().<T>(
379 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, dc_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, ac_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#,
380 qt_table: &[i32; DCT_BLOCKrust-analyzer cargo zune-jpeg 0.5.15 mcu/DCT_BLOCK.], block: &mut [i32; 64], dc_prediction: &mut i32
381 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u16, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
382 where
383 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
384 {
385 // Get fast AC table as a reference before we enter the hot path
386 let ac_lookup = ac_table.ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
387
388 let (mut symbol, mut r, mut fast_ac);
389 // Decode AC coefficients
390 let mut pos: usize = 1;
391 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 && self.markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
392 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#(
393 "No more bytes left in stream before marker".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
394 ));
395 }
396 // decode DC, dc prediction will contain the value
397 self.decode_dcrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_dc().(reader, dc_table, dc_prediction)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
398
399 // set dc to be the dc prediction.
400 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().dc_prediction rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().qt_table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
401
402 while pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().64 {
403 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
404 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
405 fast_ac = ac_lookup[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
406 symbol = ac_table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
407
408 if fast_ac 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 {
409 // FAST AC path
410 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().((fast_ac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().4) 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().15) as usize; // run
411 let t_pos = 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().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(pos, 63)]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63;
412
413 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().t_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(fast_ac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().(qt_table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().t_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); // Value
414 self.drop_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]drop_bits().((fast_ac 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().15) as u8);
415 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
416 } else {
417 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, ac_table);
418
419 r = symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().4;
420 symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().15;
421
422 if symbol 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 {
423 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().r as usize;
424 r = self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(symbol as u8);
425 symbol = huff_extendrust-analyzer cargo zune-jpeg 0.5.15 bitstream/huff_extend().(r, symbol);
426 let t_pos = 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().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63;
427
428 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().t_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().qt_table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().t_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
429
430 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
431 } else if r 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().15 {
432 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(pos as u16);
433 } else {
434 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().16;
435 }
436 }
437 }
438
439 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(64);
440 }
441
442 /// Advance the bitstream over a block but ignore the data contained.
443 ///
444 /// This updates DC prediction but we never dequantize and we never do any Zig-Zag translation
445 /// either. Still returns the index of the last component read.
446 pub fn discard_mcu_blockrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]discard_mcu_block().<T>(
447 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, dc_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, ac_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#
448 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u16, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
449 where
450 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
451 {
452 // Get fast AC table as a reference before we enter the hot path
453 let ac_lookup = ac_table.ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
454
455 let (mut symbol, mut r, mut fast_ac);
456 // Decode AC coefficients
457 let mut pos: usize = 1;
458
459 // decode DC, dc prediction will contain the value
460 self.discard_dcrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]discard_dc().(reader, dc_table)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
461
462 while pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().64 {
463 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
464 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
465 fast_ac = ac_lookup[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
466 symbol = ac_table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
467
468 if fast_ac 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 {
469 // FAST AC path
470 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().((fast_ac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().4) 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().15) as usize; // run
471
472 self.drop_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]drop_bits().((fast_ac 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().15) as u8);
473 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
474 } else {
475 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, ac_table);
476
477 r = symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().4;
478 symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().15;
479
480 if symbol 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 {
481 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().r as usize;
482 // Advance over bits but ignore.
483 let _ = self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(symbol as u8);
484
485 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
486 } else if r 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().15 {
487 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(pos as u16);
488 } else {
489 pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().16;
490 }
491 }
492 }
493
494 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(64);
495 }
496
497 /// Peek `look_ahead` bits ahead without discarding them from the buffer
498 #[inline(always)]
499 #[allow(clippy::cast_possible_truncation)]
500 const fn peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().<const LOOKAHEAD: u8>(&self) -> i32 {
501 (self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<u8>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<u8>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<u8>`]shr().(64 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().LOOKAHEAD)) as i32
502 }
503
504 /// Discard the next `N` bits without checking
505 #[inline]
506 fn drop_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]drop_bits().(&mut self, n: u8) {
507 // PS: Its a good check, but triggers fuzzer and a lot of false positives
508 //debug_assert!(self.bits_left >= n);
509 //self.bits_left -= n;
510 self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. = self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left..saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]saturating_sub().(n);
511 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<u8>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<u8>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`ShlAssign<u8>`]shl_assign().n;
512 }
513
514 /// Read `n_bits` from the buffer and discard them
515 #[inline(always)]
516 #[allow(clippy::cast_possible_truncation)]
517 fn get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(&mut self, n_bits: u8) -> i32 {
518 let mask = (1_u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<u8>`]shl().n_bits) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().1;
519
520 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. = self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer..rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]rotate_left().(u32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`From<u8>`]from().(n_bits));
521 let bits = (self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().mask) as i32;
522 self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. = self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left..wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]wrapping_sub().(n_bits);
523 bits
524 }
525
526 /// Decode a DC block
527 #[allow(clippy::cast_possible_truncation)]
528 #[inline]
529 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn decode_prog_dc_firstrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_prog_dc_first().<T>(
530 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, dc_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, block: &mut i16,
531 dc_prediction: &mut i32
532 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
533 where
534 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
535 {
536 self.decode_dcrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_dc().(reader, dc_table, dc_prediction)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
537 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().block = (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().dc_prediction as i16).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_mul().(self.successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.);
538 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
539 }
540 #[inline]
541 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn decode_prog_dc_refinerust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_prog_dc_refine().<T>(
542 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, block: &mut i16
543 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
544 where
545 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
546 {
547 // refinement scan
548 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 {
549 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
550 // if we find a marker, it may happens we don't refill.
551 // So let's confirm again that refill worked
552 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 {
553 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#(
554 "Marker found where not expected in refine bit".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
555 ));
556 }
557 }
558
559 if self.get_bitrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bit().() 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 {
560 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().block = block.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_add().(self.successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.);
561 }
562
563 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
564 }
565
566 /// Get a single bit from the bitstream
567 fn get_bitrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bit().(&mut self) -> u8 {
568 let k = (self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().63) as u8;
569 // discard a bit
570 self.drop_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]drop_bits().(1);
571 return k;
572 }
573 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn decode_mcu_ac_firstrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_mcu_ac_first().<T>(
574 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, ac_table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, block: &mut [i16; 64]
575 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
576 where
577 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
578 {
579 let fast_ac = ac_table.ac_lookuprust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#ac_lookup..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
580 let bit = self.successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.;
581
582 let mut k = self.spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start. as usize;
583 let (mut symbol, mut r, mut fac);
584
585 // EOB runs are handled in mcu_prog.rs
586 'block: loop {
587 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
588 // Check for marker in the stream
589
590 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
591 fac = fast_ac[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
592 symbol = ac_table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
593
594 if fac 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 {
595 // fast ac path
596 k 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().((fac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().4) 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().15) as usize; // run
597 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#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().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(k, 63)]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = (fac rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().8).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_mul().(bit); // value
598 self.drop_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]drop_bits().((fac 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().15) as u8);
599 k 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;
600 } else {
601 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, ac_table);
602
603 r = symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().4;
604 symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().15;
605
606 if symbol 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 {
607 k 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().r as usize;
608 r = self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(symbol as u8);
609 symbol = huff_extendrust-analyzer cargo zune-jpeg 0.5.15 bitstream/huff_extend().(r, symbol);
610 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#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().k rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = (symbol as i16).wrapping_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_mul().(bit);
611 k 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;
612 } else {
613 if r 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().15 {
614 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. = 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().r;
615 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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().self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(r as u8);
616 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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;
617 break;
618 }
619
620 k 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().16;
621 }
622 }
623
624 if k 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().self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. as usize {
625 break 'block;
626 }
627 }
628 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
629 }
630 #[allow(clippy::too_many_lines, clippy::op_ref)]
631 pub(craterust-analyzer cargo zune-jpeg 0.5.15 crate/) fn decode_mcu_ac_refinerust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]decode_mcu_ac_refine().<T>(
632 &mut self, reader: &mut ZReaderrust-analyzer cargo zune-core 0.5.1 bytestream/reader/ZReader#<T>, table: &HuffmanTablerust-analyzer cargo zune-jpeg 0.5.15 huffman/HuffmanTable#, block: &mut [i16; 64]
633 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<bool, DecodeErrorsrust-analyzer cargo zune-jpeg 0.5.15 errors/DecodeErrors#>
634 where
635 T: ZByteReaderTraitrust-analyzer cargo zune-core 0.5.1 bytestream/traits/ZByteReaderTrait#
636 {
637 let bit = self.successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask.;
638
639 let mut k = self.spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start.;
640 let (mut symbol, mut r);
641
642 if self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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().0 {
643 'no_eob: loop {
644 // Decode a coefficient from the bit stream
645 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
646
647 symbol = self.peek_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]peek_bits().::<HUFF_LOOKAHEADrust-analyzer cargo zune-jpeg 0.5.15 huffman/HUFF_LOOKAHEAD.>();
648 symbol = table.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/Index#index().symbol as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
649
650 decode_huffrust-analyzer cargo zune-jpeg 0.5.15 bitstream/decode_huff!!(self, symbol, table);
651
652 r = symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().4;
653 symbol rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAndAssign<Self>`]bitand_assign().15;
654
655 if symbol 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().0 {
656 if r 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().15 {
657 // EOB run is 2^r + bits
658 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. = 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().r;
659 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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().self.get_bitsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bits().(r as u8);
660 // EOB runs are handled by the eob logic
661 break 'no_eob;
662 }
663 } else {
664 // libjpeg-turbo also doesn't return an error here, so let's also warn.
665 if symbol 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().1 {
666 warnrust-analyzer cargo log 0.4.29 macros/warn!!("Bad Huffman code, corrupt JPEG?");
667 }
668 // get sign bit
669 // We assume we have enough bits, which should be correct for sane images
670 // since we refill by 32 above
671 if self.get_bitrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bit().() 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 {
672 symbol = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(bit);
673 } else {
674 symbol = i32::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[i32][`From<i16>`]from().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][Neg]neg().bit);
675 }
676 }
677
678 // Advance over already nonzero coefficients appending
679 // correction bits to the non-zeroes.
680 // A correction bit is 1 if the absolute value of the coefficient must be increased
681
682 if k 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().self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. {
683 'advance_nonzero: loop {
684 let coefficient = &mut block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#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().k as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().;
685
686 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient 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 {
687 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 {
688 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
689 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 && self.markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
690 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#(
691 "Marker found where not expected in refine bit".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
692 ));
693 }
694 }
695 if self.get_bitrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bit().() 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 && (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient 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().bit) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 {
696 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]gt().0 {
697 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient = coefficient.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_add().(bit);
698 } else {
699 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient = coefficient.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_sub().(bit);
700 }
701 }
702 } else {
703 r 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;
704
705 if r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
706 // reached target zero coefficient.
707 break 'advance_nonzero;
708 }
709 };
710
711 if k 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().self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. {
712 break 'advance_nonzero;
713 }
714
715 k 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;
716 }
717 }
718
719 if symbol 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 {
720 let pos = 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().k as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
721 // output new non-zero coefficient.
722 block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = symbol as i16;
723 }
724
725 k 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;
726
727 if k 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().self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. {
728 break 'no_eob;
729 }
730 }
731 }
732 if self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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 {
733 // only run if block does not consists of purely zeroes
734 if &block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]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#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().&[0; 63] {
735 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
736
737 while k 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().self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. {
738 let coefficient = &mut block[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#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().k as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]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 ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().63]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().;
739
740 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient 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 && self.get_bitrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]get_bit().() 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 {
741 // check if we already modified it, if so do nothing, otherwise
742 // append the correction bit.
743 if (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient 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().bit) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialEq<Self>`]eq().0 {
744 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i16][`PartialOrd<Self>`]ge().0 {
745 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient = coefficient.wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_add().(bit);
746 } else {
747 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().coefficient = coefficient.wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]wrapping_sub().(bit);
748 }
749 }
750 }
751 if self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. 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().1 {
752 // refill at the last possible moment
753 self.refillrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]refill().(reader)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
754 }
755 k 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;
756 }
757 }
758 // count a block completed in EOB run
759 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. 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;
760 }
761 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true);
762 }
763
764 pub fn update_progressive_paramsrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]update_progressive_params().(&mut self, _ah: u8, al: u8, spec_start: u8, spec_end: u8) {
765 self.successive_low_maskrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#successive_low_mask. = 1i16 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().al;
766 self.spec_startrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_start. = spec_start;
767 self.spec_endrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#spec_end. = spec_end;
768 }
769
770 /// Reset the stream if we have a restart marker
771 ///
772 /// Restart markers indicate drop those bits in the stream and zero out
773 /// everything
774 #[cold]
775 pub fn resetrust-analyzer cargo zune-jpeg 0.5.15 bitstream/impl#[BitStream]reset().(&mut self) {
776 self.bits_leftrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#bits_left. = 0;
777 self.markerrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#marker. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
778 self.bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#buffer. = 0;
779 self.aligned_bufferrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#aligned_buffer. = 0;
780 self.eob_runrust-analyzer cargo zune-jpeg 0.5.15 bitstream/BitStream#eob_run. = 0;
781 }
782 }
783
784 /// Do the equivalent of JPEG HUFF_EXTEND
785 #[inline(always)]
786 fn huff_extendrust-analyzer cargo zune-jpeg 0.5.15 bitstream/huff_extend().(x: i32, s: i32) -> i32 {
787 // if x<s return x else return x+offset[s] where offset[s] = ( (-1<<s)+1)
788 (x) 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().((((x) 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().(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().((s) 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().1))) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`Shr<Self>`]shr().31) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().(((-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().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().(s)) 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))
789 }
790
791 const fn has_zerorust-analyzer cargo zune-jpeg 0.5.15 bitstream/has_zero().(v: u32) -> bool {
792 // Retrieved from Stanford bithacks
793 // @ https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
794 return !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][Not]not().((((v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x7F7F_7F7F) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().0x7F7F_7F7F) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().v) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().0x7F7F_7F7F) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0;
795 }
796
797 const fn has_byterust-analyzer cargo zune-jpeg 0.5.15 bitstream/has_byte().(b: u32, val: u8) -> bool {
798 // Retrieved from Stanford bithacks
799 // @ https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
800 has_zerorust-analyzer cargo zune-jpeg 0.5.15 bitstream/has_zero().(b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().^rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitXor<Self>`]bitxor().((!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][Not]not().0_u32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Div<Self>`]div().255) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().(val as u32)))
801 }
802
803 // mod tests {
804 // use zune_core::bytestream::ZCursor;
805 // use zune_core::colorspace::ColorSpace;
806 // use zune_core::options::DecoderOptions;
807 //
808 // use crate::JpegDecoder;
809 //
810 // #[test]
811 // fn test_image() {
812 // let img = "/Users/etemesi/Downloads/test_IDX_45_RAND_168601280367171438891916_minimized_837.jpg";
813 // let data = std::fs::read(img).unwrap();
814 // let options = DecoderOptions::new_cmd().jpeg_set_out_colorspace(ColorSpace::RGB);
815 // let mut decoder = JpegDecoder::new_with_options(ZCursor::new(&data[..]), options);
816 //
817 // decoder.decode().unwrap();
818 // println!("{:?}", decoder.options.jpeg_get_out_colorspace())
819 // }
820 // }