Debian Codegraph @

src/compression/piz/wavelet.rs

raw symbols SCIP
1
2 //! Wavelet encoding and decoding.
3 // see https://github.com/AcademySoftwareFoundation/openexr/blob/8cd1b9210855fa4f6923c1b94df8a86166be19b1/OpenEXR/IlmImf/ImfWav.cpp
4
5 use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#;
6 use craterust-analyzer cargo exr 1.74.0 crate/::mathrust-analyzer cargo exr 1.74.0 math/::Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#;
7
8 #[allow(unused)]
9 #[inline]
10 pub fn encoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode().(buffer: &mut [u16], count: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max_value: u16) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
11 if is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(max_value) { encode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14_or_16_bit().(buffer, count, size, true) }
12 else { encode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14_or_16_bit().(buffer, count, size, false) }
13 }
14
15 #[allow(unused)]
16 #[inline]
17 pub fn encode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14_or_16_bit().(
18 buffer: &mut [u16],
19 Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(count_x, count_y): Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>,
20 Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(offset_x, offset_y): Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>,
21 is_14_bit: bool // true if maximum buffer[i] value < (1 << 14)
22 ) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>
23 {
24 let count = count_x.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(count_y);
25 let encode = if is_14_bit { encode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14bit(). } else { encode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_16bit(). }; // assume inlining and constant propagation
26
27 let mut p: usize = 1; // TODO i32?
28 let mut p2: usize = 2; // TODO what is p??
29
30 while p2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().count {
31
32 let mut position_y = 0;
33 let end_y = 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
34 let (offset1_x, offset1_y) = (offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p, offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p);
35 let (offset2_x, offset2_y) = (offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p2, offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p2);
36
37 // y-loop
38 while position_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_y { // TODO: for py in (index..ey).nth(offset_2.0)
39
40 let mut position_x = position_y;
41 let end_x = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
42
43 // x-loop
44 while position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_x {
45 let pos_right = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
46 let pos_top = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_y;
47 let pos_top_right = pos_top rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
48
49 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(position_x <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
50 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_right <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
51 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_top <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
52 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_top_right <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
53
54 if is_14_bit {
55 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(selfrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().));
56 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(selfrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().));
57 }
58
59 let (center, right) = encode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
60 let (top, top_right) = encode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
61
62 let (center, top) = encode(center, top);
63 let (right, top_right) = encode(right, top_right);
64
65 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center; // TODO rustify
66 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top;
67 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = right;
68 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top_right;
69
70 position_x 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().offset2_x;
71 }
72
73 // encode remaining odd pixel column
74 if count_x 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().p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
75 let pos_top = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_y;
76 let (center, top) = encode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
77
78 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center;
79 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top;
80 }
81
82 position_y 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().offset2_y;
83 }
84
85 // encode possibly remaining odd row
86 if count_y 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().p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
87 let mut position_x = position_y;
88 let end_x = position_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
89
90 while position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_x {
91 let pos_right = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
92 let (center, right) = encode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
93
94 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = right;
95 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center;
96
97 position_x 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().offset2_x;
98 }
99 }
100
101 p = p2;
102 p2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign().1;
103 }
104
105 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
106 }
107
108 #[inline]
109 pub fn decoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode().(buffer: &mut [u16], count: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max_value: u16) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
110 if is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(max_value) { decode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14_or_16_bit().(buffer, count, size, true) }
111 else { decode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14_or_16_bit().(buffer, count, size, false) }
112 }
113
114 #[inline]
115 pub fn decode_14_or_16_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14_or_16_bit().(
116 buffer: &mut [u16],
117 Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(count_x, count_y): Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>,
118 Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(offset_x, offset_y): Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>,
119 is_14_bit: bool // true if maximum buffer[i] value < (1 << 14)
120 ) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>
121 {
122 let count = count_x.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(count_y);
123 let decode = if is_14_bit { decode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14bit(). } else { decode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_16bit(). }; // assume inlining and constant propagation
124
125 let mut p: usize = 1; // TODO i32?
126 let mut p2: usize; // TODO i32?
127
128 // search max level
129 while p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().count {
130 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign().<<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShlAssign<i32>`]shl_assign().1;
131 }
132
133 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().>>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().1;
134 p2 = p;
135 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().>>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().1;
136
137 while p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().1 {
138
139 let mut position_y = 0;
140 let end_y = 0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
141
142 let (offset1_x, offset1_y) = (offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p, offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p);
143 let (offset2_x, offset2_y) = (offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p2, offset_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().p2);
144
145 debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(offset_x, 0, "offset should not be zero");
146 debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(offset_y, 0, "offset should not be zero");
147
148 while position_y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_y {
149 let mut position_x = position_y;
150 let end_x = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
151
152 while position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_x {
153 let pos_right = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
154 let pos_top = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_y;
155 let pos_top_right = pos_top rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
156
157 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(position_x <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
158 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_right <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
159 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_top <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
160 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(pos_top_right <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). buffer.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
161
162 let (center, top) = decode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
163 let (right, top_right) = decode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
164
165 let (center, right) = decode(center, right);
166 let (top, top_right) = decode(top, top_right);
167
168 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center; // TODO rustify
169 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top;
170 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = right;
171 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top_right;
172
173 position_x 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().offset2_x;
174 }
175
176 // decode last odd remaining x value
177 if count_x 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().p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
178 let pos_top = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_y;
179 let (center, top) = decode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
180
181 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center;
182 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_top]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = top;
183 }
184
185 position_y 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().offset2_y;
186 }
187
188 // decode remaining odd row
189 if count_y 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().p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
190 let mut position_x = position_y;
191 let end_x = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(count_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().p2);
192
193 while position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().end_x {
194 let pos_right = position_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().offset1_x;
195 let (center, right) = decode(buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
196
197 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().position_x]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = center;
198 buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().pos_right]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = right;
199
200 position_x 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().offset2_x;
201 }
202 }
203
204 p2 = p;
205 p rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().>>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`ShrAssign<i32>`]shr_assign().1;
206 }
207
208 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
209 }
210
211 #[inline]
212 fn is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(value: u16) -> bool {
213 value rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u16][`Shl<i32>`]shl().14)
214 }
215
216 /// Untransformed data values should be less than (1 << 14).
217 #[inline]
218 #[allow(unused)]
219 fn encode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14bit().(a: u16, b: u16) -> (u16, u16) {
220 let (a, b) = (a as i16, b as i16);
221
222 let m = (a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().b) 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().1;
223 let d = a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Sub<Self>`]sub().b;
224
225 (m as u16, d as u16) // TODO explicitly wrap?
226 }
227
228 #[inline]
229 #[allow(unused)]
230 fn decode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14bit().(l: u16, h: u16) -> (u16, u16) {
231 let (l, h) = (l as i16, h as i16);
232
233 let hi = h as i32;
234 let ai = l as i32 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().(hi 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().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(hi 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().1);
235
236 let a = ai as i16; // TODO explicitly wrap?
237 let b = (ai 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().hi) as i16; // TODO explicitly wrap?
238
239 (a as u16, b as u16) // TODO explicitly wrap?
240 }
241
242
243 const BIT_COUNTrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/BIT_COUNT.: i32 = 16;
244 const OFFSETrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/OFFSET.: i32 = 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().(BIT_COUNTrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/BIT_COUNT. 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);
245 const MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.: i32 = (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().BIT_COUNTrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/BIT_COUNT.) 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;
246
247 #[inline]
248 fn encode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_16bit().(a: u16, b: u16) -> (u16, u16) {
249 let (a, b) = (a as i32, b as i32);
250
251 let a_offset = (a 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().OFFSETrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/OFFSET.) 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().MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.;
252 let mut m = (a_offset 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().b) 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().1;
253 let d = a_offset 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().b;
254
255 if d 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 { m = (m 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().OFFSETrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/OFFSET.) 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().MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.; }
256 let d = d 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().MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.;
257
258 (m as u16, d as u16) // TODO explicitly wrap?
259 }
260
261 #[inline]
262 fn decode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_16bit().(l: u16, h: u16) -> (u16, u16) {
263 let (m, d) = (l as i32, h as i32);
264
265 let b = (m 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().(d 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().1)) 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().MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.;
266 let a = (d 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().b 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().OFFSETrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/OFFSET.) 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().MOD_MASKrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/MOD_MASK.;
267
268 (a as u16, b as u16) // TODO explicitly wrap?
269 }
270
271
272
273 #[cfg(test)]
274 mod testrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/ {
275 use craterust-analyzer cargo exr 1.74.0 crate/::mathrust-analyzer cargo exr 1.74.0 math/::Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#;
276 use craterust-analyzer cargo exr 1.74.0 crate/::compressionrust-analyzer cargo exr 1.74.0 compression/::pizrust-analyzer cargo exr 1.74.0 compression/piz/::waveletrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().;
277
278 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
279 fn roundtrip_14_bit_valuesrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip_14_bit_values().(){
280 let data = [
281 (13, 54), (3, 123), (423, 53), (1, 23), (23, 515), (513, 43),
282 (16374, 16381), (16284, 3), (2, 1), (0, 0), (0, 4), (3, 0)
283 ];
284
285 for &values in &data {
286 let (l, h) = superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::encode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_14bit().(values.0, values.1);
287 let result = superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::decode_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_14bit().(l, h);
288 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(values, result);
289 }
290 }
291
292 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
293 fn roundtrip_16_bit_valuesrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip_16_bit_values().(){
294 let data = [
295 (13, 54), (3, 123), (423, 53), (1, 23), (23, 515), (513, 43),
296 (16385, 56384), (18384, 36384), (2, 1), (0, 0), (0, 4), (3, 0)
297 ];
298
299 for &values in &data {
300 let (l, h) = superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::encode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode_16bit().(values.0, values.1);
301 let result = superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::decode_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode_16bit().(l, h);
302 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(values, result);
303 }
304 }
305
306 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
307 fn roundtrip_14bit_imagerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip_14bit_image().(){
308 let data: [u16; 6 * 4] = [
309 13, 54, 3, 123, 423, 53,
310 1, 23, 23, 515, 513, 43,
311 16374, 16381, 16284, 3, 2, 1,
312 0, 0, 0, 4, 3, 0,
313 ];
314
315 let max = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
316 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(max));
317
318 let mut transformed = data.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][Clone]clone().();
319
320 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::encoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode().(&mut transformed, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(6, 4), Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1,6), max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
321 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::decoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode().(&mut transformed, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(6, 4), Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1,6), max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
322
323 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, transformed);
324 }
325
326 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
327 fn roundtrip_16bit_imagerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip_16bit_image().(){
328 let data: [u16; 6 * 4] = [
329 13, 54, 3, 123, 423, 53,
330 1, 23, 23, 515, 513, 43,
331 16385, 56384, 18384, 36384, 2, 1,
332 0, 0, 0, 4, 3, 0,
333 ];
334
335 let max = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
336 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_14_bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/is_14_bit().(max));
337
338 let mut transformed = data.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][Clone]clone().();
339
340 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::encoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode().(&mut transformed, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(6, 4), Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1,6), max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
341 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::decoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode().(&mut transformed, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(6, 4), Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1,6), max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
342
343 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, transformed);
344 }
345
346 /// inspired by https://github.com/AcademySoftwareFoundation/openexr/blob/master/OpenEXR/IlmImfTest/testWav.cpp
347 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
348 fn ground_truthrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/ground_truth().(){
349 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(1, 1);
350 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(2, 2);
351 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(32, 32);
352 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(1024, 16);
353 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(16, 1024);
354 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(997, 37);
355 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(37, 997);
356 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(1024, 1024);
357 test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(997, 997);
358
359 fn test_sizerust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/test_size().(x: usize, y: usize) {
360 let xy = Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(x, y);
361 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(noise_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/noise_14bit().(xy), xy);
362 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(noise_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/noise_16bit().(xy), xy);
363 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0), xy);
364 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 1), xy);
365 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0xffff), xy);
366 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0x3fff), xy);
367 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0x3ffe), xy);
368 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0x3fff), xy);
369 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0xfffe), xy);
370 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(xy, 0xffff), xy);
371 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(verticalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/verticals().(xy, 0xffff), xy);
372 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(verticalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/verticals().(xy, 0x3fff), xy);
373 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(horizontalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/horizontals().(xy, 0xffff), xy);
374 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(horizontalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/horizontals().(xy, 0x3fff), xy);
375 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(diagonalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/diagonals().(xy, 0xffff), xy);
376 roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(diagonalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/diagonals().(xy, 0x3fff), xy);
377 }
378
379 fn roundtriprust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/roundtrip().(data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16>, size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>){
380 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), size.arearust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]area().());
381
382 let max = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#max().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
383 let offset = Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1, size.0rust-analyzer cargo exr 1.74.0 math/Vec2#0.);
384
385 let mut transformed = data.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
386 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::encoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/encode().(&mut transformed, size, offset, max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
387 superrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/::decoderust-analyzer cargo exr 1.74.0 compression/piz/wavelet/decode().(&mut transformed, size, offset, max).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
388
389 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(data, transformed);
390 }
391
392 fn noise_14bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/noise_14bit().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
393 (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.arearust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]area().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| (randrust-analyzer cargo rand 0.8.5 crate/::randomrust-analyzer cargo rand 0.8.5 random().::<i32>() 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().0x3fff) as u16).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
394 }
395
396 fn noise_16bitrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/noise_16bit().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
397 (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.arearust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]area().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| randrust-analyzer cargo rand 0.8.5 crate/::randomrust-analyzer cargo rand 0.8.5 random().::<u16>()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
398 }
399
400 fn solidrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/solid().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, value: u16) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
401 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![value; size.arearust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]area().()]
402 }
403
404 fn verticalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/verticals().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max_value: u16) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
405 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeat_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat_with/repeat_with().(|| (0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.0rust-analyzer cargo exr 1.74.0 math/Vec2#0.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| if x 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().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 { 0 } else { max_value }))
406 .takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(size.1rust-analyzer cargo exr 1.74.0 math/Vec2#1.).flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
407 }
408
409 fn horizontalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/horizontals().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max_value: u16) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
410 (0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.1rust-analyzer cargo exr 1.74.0 math/Vec2#1.)
411 .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|y| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(if y 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().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 { 0 } else { max_value }).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(size.0rust-analyzer cargo exr 1.74.0 math/Vec2#0.))
412 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
413 }
414
415 fn diagonalsrust-analyzer cargo exr 1.74.0 compression/piz/wavelet/test/diagonals().(size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max_value: u16) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> {
416 (0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.1rust-analyzer cargo exr 1.74.0 math/Vec2#1.).flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|y| {
417 (0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#size.0rust-analyzer cargo exr 1.74.0 math/Vec2#0.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |x| if (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().y) 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().1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 { 0 } else { max_value })
418 }).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
419 }
420
421 }
422 }