Skip to content

Commit

Permalink
rename variants
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Mar 21, 2024
1 parent 64b73b1 commit 0e09852
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 65 deletions.
6 changes: 3 additions & 3 deletions src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ pub const DCT_DCT: TxfmType = 0;

#[derive(Clone, Copy, PartialEq, Eq)]
pub enum TxClass {
TX_CLASS_2D = 0,
TX_CLASS_H = 1,
TX_CLASS_V = 2,
TwoD,
H,
V,
}

pub type IntraPredMode = u8;
Expand Down
87 changes: 42 additions & 45 deletions src/recon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,13 @@ fn get_lo_ctx(

let mut mag = level(0, 1) + level(1, 0);
let offset = match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
mag += level(1, 1);
*hi_mag = mag as c_uint;
mag += level(0, 2) + level(2, 0);
ctx_offsets.unwrap()[cmp::min(y, 4)][cmp::min(x, 4)] as usize
}
TxClass::TX_CLASS_H | TxClass::TX_CLASS_V => {
TxClass::H | TxClass::V => {
mag += level(0, 2);
*hi_mag = mag as c_uint;
mag += level(0, 3) + level(0, 4);
Expand Down Expand Up @@ -581,7 +581,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
let tx2dszctx = cmp::min((*t_dim).lw as c_int, TX_32X32 as c_int)
+ cmp::min((*t_dim).lh as c_int, TX_32X32 as c_int);
let tx_class = dav1d_tx_type_class[*txtp as usize];
let is_1d = tx_class != TxClass::TX_CLASS_2D;
let is_1d = tx_class != TxClass::TwoD;
match tx2dszctx {
0 => {
let eob_bin_cdf = &mut (*ts).cdf.coef.eob_bin_16[chroma as usize][is_1d as usize];
Expand Down Expand Up @@ -689,7 +689,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
let mut mag: c_uint = 0;
let mut scan: &[u16] = &[];
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
let nonsquare_tx: c_uint =
(tx as c_uint >= RTX_4X8 as c_int as c_uint) as c_int as c_uint;
let lo_ctx_offsets = Some(
Expand All @@ -709,17 +709,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
let mut x: c_uint;
let mut y: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc = scan[eob as usize] as c_uint;
x = rc >> shift;
y = rc & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = eob as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = x << shift2 | y;
Expand All @@ -738,7 +738,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if eob_tok == 2 {
ctx = (if if tx_class == TxClass::TX_CLASS_2D {
ctx = (if if tx_class == TxClass::TwoD {
(x | y > 1 as c_uint) as c_int
} else {
(y != 0 as c_int as c_uint) as c_int
Expand Down Expand Up @@ -772,17 +772,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
while i > 0 {
let rc_i: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc_i = scan[i as usize] as c_uint;
x = rc_i >> shift;
y = rc_i & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = i as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = x << shift2 | y;
Expand All @@ -794,14 +794,14 @@ unsafe fn decode_coefs<BD: BitDepth>(
let level = &mut levels[(x as isize * stride + y as isize) as usize..];
ctx = get_lo_ctx(
level,
TxClass::TX_CLASS_2D,
tx_class,
&mut mag,
lo_ctx_offsets,
x as usize,
y as usize,
stride as usize,
) as c_uint;
if TxClass::TX_CLASS_2D as c_int == TxClass::TX_CLASS_2D as c_int {
if tx_class == TxClass::TwoD {
y |= x;
}
tok = rav1d_msac_decode_symbol_adapt4(
Expand All @@ -823,10 +823,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
if tok == 3 {
mag &= 63 as c_int as c_uint;
ctx = ((if y
> (TxClass::TX_CLASS_2D as c_int == TxClass::TX_CLASS_2D as c_int)
as c_int as c_uint
{
ctx = ((if y > (tx_class == TxClass::TwoD) as c_uint {
14 as c_int
} else {
7 as c_int
Expand Down Expand Up @@ -866,12 +863,12 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
i -= 1;
}
ctx = if TxClass::TX_CLASS_2D as c_int == TxClass::TX_CLASS_2D as c_int {
0 as c_int as c_uint
ctx = if tx_class == TxClass::TwoD {
0
} else {
get_lo_ctx(
levels,
TxClass::TX_CLASS_2D,
tx_class,
&mut mag,
lo_ctx_offsets,
0,
Expand All @@ -895,7 +892,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if dc_tok == 3 as c_uint {
if TxClass::TX_CLASS_2D as c_int == TxClass::TX_CLASS_2D as c_int {
if tx_class == TxClass::TwoD {
mag = (levels[(0 * stride + 1) as usize] as c_int
+ levels[(1 * stride + 0) as usize] as c_int
+ levels[(1 * stride + 1) as usize] as c_int)
Expand All @@ -922,7 +919,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
}
}
TxClass::TX_CLASS_H => {
TxClass::H => {
let lo_ctx_offsets = None;
let stride: ptrdiff_t = 16 as c_int as ptrdiff_t;
let shift: c_uint = ((*t_dim).lh as c_int + 2) as c_uint;
Expand All @@ -932,17 +929,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
let mut x: c_uint;
let mut y: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc = scan[eob as usize] as c_uint;
x = rc >> shift;
y = rc & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = eob as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = x << shift2 | y;
Expand All @@ -961,7 +958,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if eob_tok == 2 {
ctx = (if if tx_class == TxClass::TX_CLASS_2D {
ctx = (if if tx_class == TxClass::TwoD {
(x | y > 1 as c_uint) as c_int
} else {
(y != 0 as c_int as c_uint) as c_int
Expand Down Expand Up @@ -995,17 +992,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
while i > 0 {
let rc_i: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc_i = scan[i as usize] as c_uint;
x = rc_i >> shift;
y = rc_i & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = i as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = x << shift2 | y;
Expand All @@ -1024,7 +1021,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
y as usize,
stride as usize,
) as c_uint;
if tx_class == TxClass::TX_CLASS_2D {
if tx_class == TxClass::TwoD {
y |= x;
}
tok = rav1d_msac_decode_symbol_adapt4(
Expand All @@ -1046,7 +1043,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
if tok == 3 {
mag &= 63 as c_int as c_uint;
ctx = ((if y > (tx_class == TxClass::TX_CLASS_2D) as c_uint {
ctx = ((if y > (tx_class == TxClass::TwoD) as c_uint {
14 as c_int
} else {
7 as c_int
Expand Down Expand Up @@ -1086,7 +1083,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
i -= 1;
}
ctx = if tx_class == TxClass::TX_CLASS_2D {
ctx = if tx_class == TxClass::TwoD {
0 as c_int as c_uint
} else {
get_lo_ctx(
Expand Down Expand Up @@ -1115,7 +1112,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if dc_tok == 3 as c_uint {
if tx_class == TxClass::TX_CLASS_2D {
if tx_class == TxClass::TwoD {
mag = (levels[(0 * stride + 1) as usize] as c_int
+ levels[(1 * stride + 0) as usize] as c_int
+ levels[(1 * stride + 1) as usize] as c_int)
Expand All @@ -1142,7 +1139,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
}
}
TxClass::TX_CLASS_V => {
TxClass::V => {
let lo_ctx_offsets = None;
let stride: ptrdiff_t = 16 as c_int as ptrdiff_t;
let shift: c_uint = ((*t_dim).lw as c_int + 2) as c_uint;
Expand All @@ -1152,17 +1149,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
let mut x: c_uint;
let mut y: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc = scan[eob as usize] as c_uint;
x = rc >> shift;
y = rc & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = eob as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = eob as c_uint & mask;
y = (eob >> shift) as c_uint;
rc = x << shift2 | y;
Expand All @@ -1181,7 +1178,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if eob_tok == 2 {
ctx = (if if tx_class == TxClass::TX_CLASS_2D {
ctx = (if if tx_class == TxClass::TwoD {
(x | y > 1 as c_uint) as c_int
} else {
(y != 0 as c_int as c_uint) as c_int
Expand Down Expand Up @@ -1215,17 +1212,17 @@ unsafe fn decode_coefs<BD: BitDepth>(
while i > 0 {
let rc_i: c_uint;
match tx_class {
TxClass::TX_CLASS_2D => {
TxClass::TwoD => {
rc_i = scan[i as usize] as c_uint;
x = rc_i >> shift;
y = rc_i & mask;
}
TxClass::TX_CLASS_H => {
TxClass::H => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = i as c_uint;
}
TxClass::TX_CLASS_V => {
TxClass::V => {
x = i as c_uint & mask;
y = (i >> shift) as c_uint;
rc_i = x << shift2 | y;
Expand All @@ -1244,7 +1241,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
y as usize,
stride as usize,
) as c_uint;
if tx_class == TxClass::TX_CLASS_2D {
if tx_class == TxClass::TwoD {
y |= x;
}
tok = rav1d_msac_decode_symbol_adapt4(
Expand All @@ -1266,7 +1263,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
if tok == 3 {
mag &= 63 as c_int as c_uint;
ctx = ((if y > (tx_class == TxClass::TX_CLASS_2D) as c_int as c_uint {
ctx = ((if y > (tx_class == TxClass::TwoD) as c_int as c_uint {
14 as c_int
} else {
7 as c_int
Expand Down Expand Up @@ -1306,7 +1303,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
}
i -= 1;
}
ctx = if tx_class == TxClass::TX_CLASS_2D {
ctx = if tx_class == TxClass::TwoD {
0 as c_int as c_uint
} else {
get_lo_ctx(
Expand Down Expand Up @@ -1335,7 +1332,7 @@ unsafe fn decode_coefs<BD: BitDepth>(
);
}
if dc_tok == 3 as c_uint {
if tx_class == TxClass::TX_CLASS_2D {
if tx_class == TxClass::TwoD {
mag = (levels[(0 * stride + 1) as usize] as c_int
+ levels[(1 * stride + 0) as usize] as c_int
+ levels[(1 * stride + 1) as usize] as c_int)
Expand Down
34 changes: 17 additions & 17 deletions src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,23 +608,23 @@ pub static dav1d_skip_ctx: [[u8; 5]; 5] = [
];

pub static dav1d_tx_type_class: [TxClass; N_TX_TYPES_PLUS_LL] = [
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_2D,
TxClass::TX_CLASS_V,
TxClass::TX_CLASS_H,
TxClass::TX_CLASS_V,
TxClass::TX_CLASS_H,
TxClass::TX_CLASS_V,
TxClass::TX_CLASS_H,
TxClass::TX_CLASS_2D,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::TwoD,
TxClass::V,
TxClass::H,
TxClass::V,
TxClass::H,
TxClass::V,
TxClass::H,
TxClass::TwoD,
];

pub static dav1d_filter_2d: [[u8; Rav1dFilterMode::N_FILTERS]; Rav1dFilterMode::N_FILTERS] = [
Expand Down

0 comments on commit 0e09852

Please sign in to comment.