| 1 | |
| 2 | //! Read and write already compressed pixel data blocks. |
| 3 | //! Does not include the process of compression and decompression. |
| 4 | |
| 5 | use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::attributerust-analyzer cargo exr 1.74.0 meta/attribute/::{IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#}; |
| 6 | |
| 7 | /// A generic block of pixel information. |
| 8 | /// Contains pixel data and an index to the corresponding header. |
| 9 | /// All pixel data in a file is split into a list of chunks. |
| 10 | /// Also contains positioning information that locates this |
| 11 | /// data block in the referenced layer. |
| 12 | /// The byte data is in little-endian format, |
| 13 | /// as these bytes will be written into the file directly. |
| 14 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 15 | pub struct Chunkrust-analyzer cargo exr 1.74.0 block/chunk/Chunk# { |
| 16 | |
| 17 | /// The index of the layer that the block belongs to. |
| 18 | /// This is required as the pixel data can appear in any order in a file. |
| 19 | // PDF says u64, but source code seems to be i32 |
| 20 | pub layer_indexrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#layer_index.: usize, |
| 21 | |
| 22 | /// The compressed pixel contents. |
| 23 | /// This data is compressed and in little-endian format. |
| 24 | pub compressed_blockrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#compressed_block.: CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#, |
| 25 | } |
| 26 | |
| 27 | /// The raw, possibly compressed pixel data of a file. |
| 28 | /// Each layer in a file can have a different type. |
| 29 | /// Also contains positioning information that locates this |
| 30 | /// data block in the corresponding layer. |
| 31 | /// Exists inside a `Chunk`. |
| 32 | /// The byte data is in little-endian format, |
| 33 | /// as these bytes will be written into the file directly. |
| 34 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 35 | pub enum CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock# { |
| 36 | |
| 37 | /// Scan line blocks of flat data. |
| 38 | ScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#ScanLine#(CompressedScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#), |
| 39 | |
| 40 | /// Tiles of flat data. |
| 41 | Tilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#Tile#(CompressedTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#), |
| 42 | |
| 43 | /// Scan line blocks of deep data. |
| 44 | DeepScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepScanLine#(CompressedDeepScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#), |
| 45 | |
| 46 | /// Tiles of deep data. |
| 47 | DeepTilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepTile#(CompressedDeepTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#), |
| 48 | } |
| 49 | |
| 50 | /// A `Block` of possibly compressed flat scan lines. |
| 51 | /// Corresponds to type attribute `scanlineimage`. |
| 52 | /// The byte data is in little-endian format, |
| 53 | /// as these bytes will be written into the file directly. |
| 54 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 55 | pub struct CompressedScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock# { |
| 56 | |
| 57 | /// The block's y coordinate is the pixel space y coordinate of the top scan line in the block. |
| 58 | /// The top scan line block in the image is aligned with the top edge of the data window. |
| 59 | pub y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#y_coordinate.: i32, |
| 60 | |
| 61 | /// One or more scan lines may be stored together as a scan line block. |
| 62 | /// The number of scan lines per block depends on how the pixel data are compressed. |
| 63 | /// For each line in the tile, for each channel, the row values are contiguous. |
| 64 | /// This data is compressed and in little-endian format. |
| 65 | pub compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#compressed_pixels_le.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 66 | } |
| 67 | |
| 68 | /// This `Block` is a tile of flat (non-deep) data. |
| 69 | /// Corresponds to type attribute `tiledimage`. |
| 70 | /// The byte data is in little-endian format, |
| 71 | /// as these bytes will be written into the file directly. |
| 72 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 73 | pub struct CompressedTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock# { |
| 74 | |
| 75 | /// The tile location. |
| 76 | pub coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#coordinates.: TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#, |
| 77 | |
| 78 | /// One or more scan lines may be stored together as a scan line block. |
| 79 | /// The number of scan lines per block depends on how the pixel data are compressed. |
| 80 | /// For each line in the tile, for each channel, the row values are contiguous. |
| 81 | /// This data is compressed and in little-endian format. |
| 82 | pub compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#compressed_pixels_le.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 83 | } |
| 84 | |
| 85 | /// Indicates the position and resolution level of a `TileBlock` or `DeepTileBlock`. |
| 86 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 87 | pub struct TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates# { |
| 88 | |
| 89 | /// Index of the tile, not pixel position. |
| 90 | pub tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, |
| 91 | |
| 92 | /// Index of the Mip/Rip level. |
| 93 | pub level_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#level_index.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, |
| 94 | } |
| 95 | |
| 96 | /// This `Block` consists of one or more deep scan lines. |
| 97 | /// Corresponds to type attribute `deepscanline`. |
| 98 | /// The byte data is in little-endian format, |
| 99 | /// as these bytes will be written into the file directly. |
| 100 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 101 | pub struct CompressedDeepScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock# { |
| 102 | |
| 103 | /// The block's y coordinate is the pixel space y coordinate of the top scan line in the block. |
| 104 | /// The top scan line block in the image is aligned with the top edge of the data window. |
| 105 | pub y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#y_coordinate.: i32, |
| 106 | |
| 107 | /// Count of samples. |
| 108 | pub decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#decompressed_sample_data_size.: usize, |
| 109 | |
| 110 | /// The pixel offset table is a list of integers, one for each pixel column within the data window. |
| 111 | /// Each entry in the table indicates the total number of samples required |
| 112 | /// to store the pixel in it as well as all pixels to the left of it. |
| 113 | pub compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_pixel_offset_table.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i8>, |
| 114 | |
| 115 | /// One or more scan lines may be stored together as a scan line block. |
| 116 | /// The number of scan lines per block depends on how the pixel data are compressed. |
| 117 | /// For each line in the tile, for each channel, the row values are contiguous. |
| 118 | pub compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_sample_data_le.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 119 | } |
| 120 | |
| 121 | /// This `Block` is a tile of deep data. |
| 122 | /// Corresponds to type attribute `deeptile`. |
| 123 | /// The byte data is in little-endian format, |
| 124 | /// as these bytes will be written into the file directly. |
| 125 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 126 | pub struct CompressedDeepTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock# { |
| 127 | |
| 128 | /// The tile location. |
| 129 | pub coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#coordinates.: TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#, |
| 130 | |
| 131 | /// Count of samples. |
| 132 | pub decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#decompressed_sample_data_size.: usize, |
| 133 | |
| 134 | /// The pixel offset table is a list of integers, one for each pixel column within the data window. |
| 135 | /// Each entry in the table indicates the total number of samples required |
| 136 | /// to store the pixel in it as well as all pixels to the left of it. |
| 137 | pub compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_pixel_offset_table.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<i8>, |
| 138 | |
| 139 | /// One or more scan lines may be stored together as a scan line block. |
| 140 | /// The number of scan lines per block depends on how the pixel data are compressed. |
| 141 | /// For each line in the tile, for each channel, the row values are contiguous. |
| 142 | pub compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_sample_data_le.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, |
| 143 | } |
| 144 | |
| 145 | |
| 146 | use craterust-analyzer cargo exr 1.74.0 crate/::iorust-analyzer cargo exr 1.74.0 io/::*; |
| 147 | |
| 148 | impl TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates# { |
| 149 | |
| 150 | /// Without validation, write this instance to the byte stream. |
| 151 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 152 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(self.tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index..xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]x().(), "tile x")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 153 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(self.tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index..yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]y().(), "tile y")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 154 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(self.level_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#level_index..xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]x().(), "level x")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 155 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(self.level_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#level_index..yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]y().(), "level y")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 156 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 157 | } |
| 158 | |
| 159 | /// Read the value without validating. |
| 160 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]> { |
| 161 | let tile_x = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 162 | let tile_y = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 163 | |
| 164 | let level_x = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 165 | let level_y = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 166 | |
| 167 | if level_x 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().31 || level_y 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().31 { |
| 168 | // there can be at most 31 levels, because the largest level would have a size of 2^31, |
| 169 | // which exceeds the maximum 32-bit integer value. |
| 170 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("level index exceeding integer maximum")); |
| 171 | } |
| 172 | |
| 173 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates# { |
| 174 | tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(tile_x, tile_y).to_usizerust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<i32>`]to_usize().("tile coordinate index")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 175 | level_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#level_index.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(level_x, level_y).to_usizerust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<i32>`]to_usize().("tile coordinate level")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 176 | }) |
| 177 | } |
| 178 | |
| 179 | /// The indices which can be used to index into the arrays of a data window. |
| 180 | /// These coordinates are only valid inside the corresponding one header. |
| 181 | /// Will start at 0 and always be positive. |
| 182 | pub fn to_data_indicesrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]to_data_indices().(&self, tile_size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, max: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#> { |
| 183 | let x = self.tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index..xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]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().tile_size.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().(); |
| 184 | let y = self.tile_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#tile_index..yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]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().tile_size.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(); |
| 185 | |
| 186 | if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().max.xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]x().() || y rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().max.yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]y().() { |
| 187 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("tile index")) |
| 188 | } |
| 189 | else { |
| 190 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds# { |
| 191 | positionrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#position.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(x, "tile x")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(y, "tile y")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 192 | sizerust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#( |
| 193 | calculate_block_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_size().(max.xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]x().(), tile_size.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().(), x)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 194 | calculate_block_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_size().(max.yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]y().(), tile_size.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(), y)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 195 | ), |
| 196 | }) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | /// Absolute coordinates inside the global 2D space of a file, may be negative. |
| 201 | pub fn to_absolute_indicesrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]to_absolute_indices().(&self, tile_size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, data_window: IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#> { |
| 202 | let data = self.to_data_indicesrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]to_data_indices().(tile_size, data_window.sizerust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#size.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 203 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(data.with_originrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[IntegerBounds]with_origin().(data_window.positionrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#position.)) |
| 204 | } |
| 205 | |
| 206 | /// Returns if this is the original resolution or a smaller copy. |
| 207 | pub fn is_largest_resolution_levelrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]is_largest_resolution_level().(&self) -> bool { |
| 208 | self.level_indexrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#level_index. rust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`][`PartialEq<Self>`]eq().Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(0, 0) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | |
| 213 | |
| 214 | use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::{MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#, BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#, calculate_block_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_size().}; |
| 215 | |
| 216 | impl CompressedScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock# { |
| 217 | |
| 218 | /// Without validation, write this instance to the byte stream. |
| 219 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedScanLineBlock]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 220 | debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(self.compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#compressed_pixels_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0, "empty blocks should not be put in the file bug"); |
| 221 | |
| 222 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(self.y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#y_coordinate., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 223 | u8::write_i32_sized_slice_lerust-analyzer cargo exr 1.74.0 io/Data#write_i32_sized_slice_le().(write, &self.compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#compressed_pixels_le.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 224 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 225 | } |
| 226 | |
| 227 | /// Read the value without validating. |
| 228 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedScanLineBlock]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, max_block_byte_size: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedScanLineBlock]> { |
| 229 | let y_coordinate = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 230 | let compressed_pixels_le = u8::read_i32_sized_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_i32_sized_vec_le().(read, max_block_byte_size, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max_block_byte_size), "scan line block sample count")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 231 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CompressedScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock# { y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#y_coordinate., compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#compressed_pixels_le. }) |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | impl CompressedTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock# { |
| 236 | |
| 237 | /// Without validation, write this instance to the byte stream. |
| 238 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedTileBlock]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 239 | debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(self.compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#compressed_pixels_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0, "empty blocks should not be put in the file bug"); |
| 240 | |
| 241 | self.coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#coordinates..writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]write().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 242 | u8::write_i32_sized_slice_lerust-analyzer cargo exr 1.74.0 io/Data#write_i32_sized_slice_le().(write, &self.compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#compressed_pixels_le.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 243 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 244 | } |
| 245 | |
| 246 | /// Read the value without validating. |
| 247 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedTileBlock]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, max_block_byte_size: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedTileBlock]> { |
| 248 | let coordinates = TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]read().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 249 | let compressed_pixels_le = u8::read_i32_sized_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_i32_sized_vec_le().(read, max_block_byte_size, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max_block_byte_size), "tile block sample count")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 250 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CompressedTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock# { coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#coordinates., compressed_pixels_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#compressed_pixels_le. }) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | impl CompressedDeepScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock# { |
| 255 | |
| 256 | /// Without validation, write this instance to the byte stream. |
| 257 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepScanLineBlock]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 258 | debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_sample_data_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0, "empty blocks should not be put in the file bug"); |
| 259 | |
| 260 | i32::write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(self.y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#y_coordinate., write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 261 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_pixel_offset_table..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 262 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_sample_data_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // TODO just guessed |
| 263 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#decompressed_sample_data_size. as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 264 | i8::write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[i8][Data]write_slice_le().(write, &self.compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_pixel_offset_table.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 265 | u8::write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[u8][Data]write_slice_le().(write, &self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_sample_data_le.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 266 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 267 | } |
| 268 | |
| 269 | /// Read the value without validating. |
| 270 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepScanLineBlock]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, max_block_byte_size: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepScanLineBlock]> { |
| 271 | let y_coordinate = i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 272 | let compressed_pixel_offset_table_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., "deep table size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 273 | let compressed_sample_data_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., "deep size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 274 | let decompressed_sample_data_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., "raw deep size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 275 | |
| 276 | // doc said i32, try u8 |
| 277 | let compressed_pixel_offset_table = i8::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().( |
| 278 | read, compressed_pixel_offset_table_size, |
| 279 | 6 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().u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max_block_byte_size), |
| 280 | "deep scan line block table size" |
| 281 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 282 | |
| 283 | let compressed_sample_data_le = u8::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().( |
| 284 | read, compressed_sample_data_size, |
| 285 | 6 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().u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max_block_byte_size), |
| 286 | "deep scan line block sample count" |
| 287 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 288 | |
| 289 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CompressedDeepScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock# { |
| 290 | y_coordinaterust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#y_coordinate., |
| 291 | decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#decompressed_sample_data_size., |
| 292 | compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_pixel_offset_table., |
| 293 | compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#compressed_sample_data_le., |
| 294 | }) |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | |
| 299 | impl CompressedDeepTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock# { |
| 300 | |
| 301 | /// Without validation, write this instance to the byte stream. |
| 302 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepTileBlock]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(&self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 303 | debug_assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_ne!!(self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_sample_data_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 0, "empty blocks should not be put in the file bug"); |
| 304 | |
| 305 | self.coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#coordinates..writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]write().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 306 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_pixel_offset_table..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 307 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_sample_data_le..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // TODO just guessed |
| 308 | u64::write_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]write_le().(self.decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#decompressed_sample_data_size. as u64, write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 309 | i8::write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[i8][Data]write_slice_le().(write, &self.compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_pixel_offset_table.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 310 | u8::write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[u8][Data]write_slice_le().(write, &self.compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_sample_data_le.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 311 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 312 | } |
| 313 | |
| 314 | /// Read the value without validating. |
| 315 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepTileBlock]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, hard_max_block_byte_size: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepTileBlock]> { |
| 316 | let coordinates = TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[TileCoordinates]read().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 317 | let compressed_pixel_offset_table_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,"deep table size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 318 | let compressed_sample_data_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., "deep size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // TODO u64 just guessed |
| 319 | let decompressed_sample_data_size = u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize().(u64::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u64][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., "raw deep size")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 320 | |
| 321 | let compressed_pixel_offset_table = i8::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().( |
| 322 | read, compressed_pixel_offset_table_size, |
| 323 | 6 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().u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hard_max_block_byte_size), |
| 324 | "deep tile block table size" |
| 325 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 326 | |
| 327 | let compressed_sample_data_le = u8::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().( |
| 328 | read, compressed_sample_data_size, |
| 329 | 6 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().u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hard_max_block_byte_size), |
| 330 | "deep tile block sample count" |
| 331 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 332 | |
| 333 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(CompressedDeepTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock# { |
| 334 | coordinatesrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#coordinates., |
| 335 | decompressed_sample_data_sizerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#decompressed_sample_data_size., |
| 336 | compressed_pixel_offset_tablerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_pixel_offset_table., |
| 337 | compressed_sample_data_lerust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#compressed_sample_data_le., |
| 338 | }) |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::{UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#, Resultrust-analyzer cargo exr 1.74.0 error/Result#, Errorrust-analyzer cargo exr 1.74.0 error/Error#, u64_to_usizerust-analyzer cargo exr 1.74.0 error/u64_to_usize()., usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32()., i32_to_usizerust-analyzer cargo exr 1.74.0 error/i32_to_usize().}; |
| 343 | 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#; |
| 344 | |
| 345 | /// Validation of chunks is done while reading and writing the actual data. (For example in exr::full_image) |
| 346 | impl Chunkrust-analyzer cargo exr 1.74.0 block/chunk/Chunk# { |
| 347 | |
| 348 | /// Without validation, write this instance to the byte stream. |
| 349 | pub fn writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[Chunk]write().(&self, write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, header_count: usize) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# { |
| 350 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(self.layer_indexrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#layer_index. <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). header_count, "layer index bug"); // validation is done in full_image or simple_image |
| 351 | |
| 352 | if header_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().1 { usize_to_i32rust-analyzer cargo exr 1.74.0 error/usize_to_i32().(self.layer_indexrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#layer_index., "layer index")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; } |
| 353 | else { assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.layer_indexrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#layer_index., 0, "invalid header index for single layer file"); } |
| 354 | |
| 355 | match self.compressed_blockrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#compressed_block. { |
| 356 | CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::ScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#ScanLine# (ref value) => value.writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedScanLineBlock]write().(write), |
| 357 | CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::Tilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#Tile# (ref value) => value.writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedTileBlock]write().(write), |
| 358 | CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::DeepScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepScanLine# (ref value) => value.writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepScanLineBlock]write().(write), |
| 359 | CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::DeepTilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepTile# (ref value) => value.writerust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepTileBlock]write().(write), |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | /// Read the value without validating. |
| 364 | pub fn readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[Chunk]read().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, meta_data: &MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 block/chunk/impl#[Chunk]> { |
| 365 | let layer_number = i32_to_usizerust-analyzer cargo exr 1.74.0 error/i32_to_usize().( |
| 366 | if meta_data.requirementsrust-analyzer cargo exr 1.74.0 meta/MetaData#requirements..is_multilayerrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]is_multilayer().() { i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). } // documentation says u64, but is i32 |
| 367 | else { 0_i32 }, // reference the first header for single-layer images |
| 368 | "chunk data part number" |
| 369 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 370 | |
| 371 | if layer_number rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().meta_data.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers..lenrust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]len().() { |
| 372 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("chunk data part number")); |
| 373 | } |
| 374 | |
| 375 | let header = &meta_data.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers.[rust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][`Index<I>`]index().layer_number]rust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][`Index<I>`]index().; |
| 376 | let max_block_byte_size = header.max_block_byte_sizerust-analyzer cargo exr 1.74.0 meta/header/impl#[Header]max_block_byte_size().(); |
| 377 | |
| 378 | let chunk = Chunkrust-analyzer cargo exr 1.74.0 block/chunk/Chunk# { |
| 379 | layer_indexrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#layer_index.: layer_number, |
| 380 | compressed_blockrust-analyzer cargo exr 1.74.0 block/chunk/Chunk#compressed_block.: match header.blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks. { |
| 381 | // flat data |
| 382 | BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines# if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().header.deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep. => CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::ScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#ScanLine#(CompressedScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedScanLineBlock#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedScanLineBlock]read().(read, max_block_byte_size)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 383 | BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles#(_) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().header.deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep. => CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::Tilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#Tile#(CompressedTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedTileBlock#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedTileBlock]read().(read, max_block_byte_size)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 384 | |
| 385 | // deep data |
| 386 | BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines# => CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::DeepScanLinerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepScanLine#(CompressedDeepScanLineBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepScanLineBlock#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepScanLineBlock]read().(read, max_block_byte_size)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 387 | BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles#(_) => CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#::DeepTilerust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#DeepTile#(CompressedDeepTileBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedDeepTileBlock#::readrust-analyzer cargo exr 1.74.0 block/chunk/impl#[CompressedDeepTileBlock]read().(read, max_block_byte_size)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().), |
| 388 | }, |
| 389 | }; |
| 390 | |
| 391 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(chunk) |
| 392 | } |
| 393 | } |
| 394 |