forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

rext.rs32 lines, 1.1 KiBHistoryRawDownload
1//! Range extension residual steps shared by the transform-skip, transquant-bypass and
2//! cross-component paths (8.6.2, 8.6.6, 8.6.8).
3
4/// Rotate an `n` x `n` block by 180 degrees in place (`transform_skip_rotation_enabled_flag`).
5pub fn rotate_180(block: &mut [i32], n: usize) {
6 block[..n * n].reverse();
7}
8
9/// The directional residual modification of RDPCM (8.6.8): each sample accumulates the
10/// one before it, horizontally for `dir` 0 and vertically for `dir` 1.
11pub fn rdpcm_accumulate(block: &mut [i32], n: usize, dir: u8) {
12 if dir == 0 {
13 for y in 0..n {
14 for x in 1..n {
15 block[y * n + x] += block[y * n + x - 1];
16 }
17 }
18 } else {
19 for y in 1..n {
20 for x in 0..n {
21 block[y * n + x] += block[(y - 1) * n + x];
22 }
23 }
24 }
25}
26
27/// Cross-component prediction (8.6.6): `r += (ResScaleVal * ((rY << BitDepthC) >> BitDepthY)) >> 3`.
28pub fn cross_component(chroma: &mut [i32], luma: &[i32], res_scale: i32, bd_y: u32, bd_c: u32) {
29 for (c, &l) in chroma.iter_mut().zip(luma) {
30 *c += (res_scale * ((l << bd_c) >> bd_y)) >> 3;
31 }
32}