Skip to content

Commit e9053f8

Browse files
committed
simplify unscan_4x4
1 parent 098d76a commit e9053f8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/h264/residual.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,25 @@ impl Residual {
190190
// Figure 8-6 – Assignment of the indices of dcY to luma4x4BlkIdx
191191
#[inline]
192192
pub const fn unscan_4x4(idx: usize) -> (/* row */ usize, /* column */ usize) {
193-
let p = macroblock::get_4x4luma_block_location(idx as u8);
194-
(p.y as usize / 4, p.x as usize / 4)
193+
match idx {
194+
0 => (0, 0),
195+
1 => (0, 1),
196+
2 => (1, 0),
197+
3 => (1, 1),
198+
4 => (0, 2),
199+
5 => (0, 3),
200+
6 => (1, 2),
201+
7 => (1, 3),
202+
8 => (2, 0),
203+
9 => (2, 1),
204+
10 => (3, 0),
205+
11 => (3, 1),
206+
12 => (2, 2),
207+
13 => (2, 3),
208+
14 => (3, 2),
209+
15 => (3, 3),
210+
_ => panic!("Out of bounds unscan_4x4 index"),
211+
}
195212
}
196213

197214
// Figure 8-7 – Assignment of the indices of dcC to chroma4x4BlkIdx

0 commit comments

Comments
 (0)