/rust/registry/src/index.crates.io-1949cf8c6b5b557f/av-scenechange-0.14.1/src/data/superblock.rs
Line | Count | Source |
1 | | use crate::data::{ |
2 | | block::{BlockOffset, MIB_SIZE_LOG2}, |
3 | | tile::TileBlockOffset, |
4 | | }; |
5 | | |
6 | | pub const MAX_SB_SIZE_LOG2: usize = 7; |
7 | | pub const SUPERBLOCK_TO_BLOCK_SHIFT: usize = MIB_SIZE_LOG2; |
8 | | pub const SB_SIZE_LOG2: usize = 6; |
9 | | pub const SB_SIZE: usize = 1 << SB_SIZE_LOG2; |
10 | | pub const MI_SIZE_LOG2: usize = 2; |
11 | | pub const MI_SIZE: usize = 1 << MI_SIZE_LOG2; |
12 | | |
13 | | /// Absolute offset in superblocks inside a tile, where a superblock is defined |
14 | | /// to be an `N*N` square where `N == (1 << SUPERBLOCK_TO_PLANE_SHIFT)`. |
15 | | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
16 | | pub struct TileSuperBlockOffset(pub SuperBlockOffset); |
17 | | |
18 | | impl TileSuperBlockOffset { |
19 | | /// Offset of a block inside the current superblock. |
20 | 0 | pub const fn block_offset(self, block_x: usize, block_y: usize) -> TileBlockOffset { |
21 | 0 | TileBlockOffset(self.0.block_offset(block_x, block_y)) |
22 | 0 | } |
23 | | } |
24 | | |
25 | | /// Absolute offset in superblocks inside a plane, where a superblock is defined |
26 | | /// to be an `N*N` square where `N == (1 << SUPERBLOCK_TO_PLANE_SHIFT)`. |
27 | | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
28 | | pub struct PlaneSuperBlockOffset(pub SuperBlockOffset); |
29 | | |
30 | | /// Absolute offset in superblocks, where a superblock is defined |
31 | | /// to be an `N*N` square where `N == (1 << SUPERBLOCK_TO_PLANE_SHIFT)`. |
32 | | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
33 | | pub struct SuperBlockOffset { |
34 | | pub x: usize, |
35 | | pub y: usize, |
36 | | } |
37 | | |
38 | | impl SuperBlockOffset { |
39 | | /// Offset of a block inside the current superblock. |
40 | 0 | const fn block_offset(self, block_x: usize, block_y: usize) -> BlockOffset { |
41 | 0 | BlockOffset { |
42 | 0 | x: (self.x << SUPERBLOCK_TO_BLOCK_SHIFT) + block_x, |
43 | 0 | y: (self.y << SUPERBLOCK_TO_BLOCK_SHIFT) + block_y, |
44 | 0 | } |
45 | 0 | } |
46 | | } |