From 110e8e9e43e7ac01c7c578cdd25fe46534c78b1e Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:41:16 -0700 Subject: [PATCH 1/6] `static wedge_codebook_16_h{gt,lt,eq}w`: Make non-`mut`. --- src/wedge.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wedge.rs b/src/wedge.rs index 1a15ea794..33ca81b17 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -46,7 +46,8 @@ pub type WedgeMasterLineType = libc::c_uint; pub const N_WEDGE_MASTER_LINES: usize = 3; pub type WedgeDirectionType = libc::c_uint; pub const _N_WEDGE_DIRECTIONS: usize = 6; -static mut wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ + +static wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ { let init = wedge_code_type { direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, @@ -176,7 +177,8 @@ static mut wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ init }, ]; -static mut wedge_codebook_16_hltw: [wedge_code_type; 16] = [ + +static wedge_codebook_16_hltw: [wedge_code_type; 16] = [ { let init = wedge_code_type { direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, @@ -306,7 +308,8 @@ static mut wedge_codebook_16_hltw: [wedge_code_type; 16] = [ init }, ]; -static mut wedge_codebook_16_heqw: [wedge_code_type; 16] = [ + +static wedge_codebook_16_heqw: [wedge_code_type; 16] = [ { let init = wedge_code_type { direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, @@ -436,6 +439,7 @@ static mut wedge_codebook_16_heqw: [wedge_code_type; 16] = [ init }, ]; + static mut wedge_masks_444_32x32: Align64<[uint8_t; 32768]> = Align64([0; 32768]); static mut wedge_masks_444_32x16: Align64<[uint8_t; 16384]> = Align64([0; 16384]); static mut wedge_masks_444_32x8: Align64<[uint8_t; 8192]> = Align64([0; 8192]); @@ -463,6 +467,7 @@ static mut wedge_masks_420_8x4: Align64<[uint8_t; 1024]> = Align64([0; 1024]); static mut wedge_masks_420_4x16: Align64<[uint8_t; 2048]> = Align64([0; 2048]); static mut wedge_masks_420_4x8: Align64<[uint8_t; 1024]> = Align64([0; 1024]); static mut wedge_masks_420_4x4: Align64<[uint8_t; 512]> = Align64([0; 512]); + #[no_mangle] pub static mut dav1d_wedge_masks: [[[[*const uint8_t; 16]; 2]; 3]; N_BS_SIZES] = [[[[0 as *const uint8_t; 16]; 2]; 3]; 22]; From 00f9173396b8b19afc875cd5aeaae6407fb48c89 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:44:51 -0700 Subject: [PATCH 2/6] `enum WedgeDirectionType`: Make a `u8`. --- src/wedge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wedge.rs b/src/wedge.rs index 33ca81b17..814381bd9 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -44,7 +44,7 @@ pub const WEDGE_MASTER_LINE_EVEN: WedgeMasterLineType = 1; pub const WEDGE_MASTER_LINE_VERT: WedgeMasterLineType = 2; pub type WedgeMasterLineType = libc::c_uint; pub const N_WEDGE_MASTER_LINES: usize = 3; -pub type WedgeDirectionType = libc::c_uint; +pub type WedgeDirectionType = u8; pub const _N_WEDGE_DIRECTIONS: usize = 6; static wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ From a90fb058cb25d6279942123f7b46a278bb342815 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:45:44 -0700 Subject: [PATCH 3/6] `enum WedgeDirectionType`: Re-order to decl order in C. --- src/wedge.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/wedge.rs b/src/wedge.rs index 814381bd9..3c9d50624 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -27,25 +27,27 @@ use crate::src::levels::BlockSize; use crate::src::levels::N_BS_SIZES; use crate::src::levels::N_INTER_INTRA_PRED_MODES; +pub type WedgeDirectionType = u8; +pub const WEDGE_HORIZONTAL: WedgeDirectionType = 0; +pub const WEDGE_VERTICAL: WedgeDirectionType = 1; +pub const WEDGE_OBLIQUE27: WedgeDirectionType = 2; +pub const WEDGE_OBLIQUE63: WedgeDirectionType = 3; +pub const WEDGE_OBLIQUE117: WedgeDirectionType = 4; +pub const WEDGE_OBLIQUE153: WedgeDirectionType = 5; +pub const _N_WEDGE_DIRECTIONS: usize = 6; + #[repr(C)] pub struct wedge_code_type { pub direction: uint8_t, pub x_offset: uint8_t, pub y_offset: uint8_t, } -pub const WEDGE_OBLIQUE117: WedgeDirectionType = 4; -pub const WEDGE_OBLIQUE63: WedgeDirectionType = 3; -pub const WEDGE_OBLIQUE153: WedgeDirectionType = 5; -pub const WEDGE_OBLIQUE27: WedgeDirectionType = 2; -pub const WEDGE_VERTICAL: WedgeDirectionType = 1; -pub const WEDGE_HORIZONTAL: WedgeDirectionType = 0; + pub const WEDGE_MASTER_LINE_ODD: WedgeMasterLineType = 0; pub const WEDGE_MASTER_LINE_EVEN: WedgeMasterLineType = 1; pub const WEDGE_MASTER_LINE_VERT: WedgeMasterLineType = 2; pub type WedgeMasterLineType = libc::c_uint; pub const N_WEDGE_MASTER_LINES: usize = 3; -pub type WedgeDirectionType = u8; -pub const _N_WEDGE_DIRECTIONS: usize = 6; static wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ { From ab6e736b679be42b1c7227fcb0015a185d33c4bb Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:46:37 -0700 Subject: [PATCH 4/6] `struct wedge_code_type::direction`: Make a `WedgeDirectionType` instead of just `u8`. --- src/wedge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wedge.rs b/src/wedge.rs index 3c9d50624..10495555c 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -38,7 +38,7 @@ pub const _N_WEDGE_DIRECTIONS: usize = 6; #[repr(C)] pub struct wedge_code_type { - pub direction: uint8_t, + pub direction: WedgeDirectionType, pub x_offset: uint8_t, pub y_offset: uint8_t, } From 12cd76fd0997777de68e340fb1253e43716ee51f Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:49:18 -0700 Subject: [PATCH 5/6] `static wedge_codebook_16_h{gt,lt,eq}w`: Remove redundant `as` casts and `init` temp vars. --- src/wedge.rs | 528 +++++++++++++++++++-------------------------------- 1 file changed, 192 insertions(+), 336 deletions(-) diff --git a/src/wedge.rs b/src/wedge.rs index 10495555c..9d0094297 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -50,395 +50,251 @@ pub type WedgeMasterLineType = libc::c_uint; pub const N_WEDGE_MASTER_LINES: usize = 3; static wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 6, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 6, + y_offset: 4, }, ]; static wedge_codebook_16_hltw: [wedge_code_type; 16] = [ - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 6, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 6, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 6, + y_offset: 4, }, ]; static wedge_codebook_16_heqw: [wedge_code_type; 16] = [ - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_HORIZONTAL as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_HORIZONTAL, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_VERTICAL as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_VERTICAL, + x_offset: 6, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE27 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE27, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 2 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 2, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE153 as libc::c_int as uint8_t, - x_offset: 4 as libc::c_int as uint8_t, - y_offset: 6 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE153, + x_offset: 4, + y_offset: 6, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE63 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE63, + x_offset: 6, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 2 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 2, + y_offset: 4, }, - { - let init = wedge_code_type { - direction: WEDGE_OBLIQUE117 as libc::c_int as uint8_t, - x_offset: 6 as libc::c_int as uint8_t, - y_offset: 4 as libc::c_int as uint8_t, - }; - init + wedge_code_type { + direction: WEDGE_OBLIQUE117, + x_offset: 6, + y_offset: 4, }, ]; From e7adee4e4b248975f452f22b0d78cdad2b80edb0 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sun, 10 Sep 2023 20:54:22 -0700 Subject: [PATCH 6/6] `fn wedge_code_type::new`: Add `const fn` to use in statics that is more concise and more closely mimics C source. --- src/wedge.rs | 298 ++++++++++----------------------------------------- 1 file changed, 58 insertions(+), 240 deletions(-) diff --git a/src/wedge.rs b/src/wedge.rs index 9d0094297..09b548378 100644 --- a/src/wedge.rs +++ b/src/wedge.rs @@ -43,6 +43,16 @@ pub struct wedge_code_type { pub y_offset: uint8_t, } +impl wedge_code_type { + const fn new(x_offset: u8, y_offset: u8, direction: WedgeDirectionType) -> Self { + Self { + direction, + x_offset, + y_offset, + } + } +} + pub const WEDGE_MASTER_LINE_ODD: WedgeMasterLineType = 0; pub const WEDGE_MASTER_LINE_EVEN: WedgeMasterLineType = 1; pub const WEDGE_MASTER_LINE_VERT: WedgeMasterLineType = 2; @@ -50,252 +60,60 @@ pub type WedgeMasterLineType = libc::c_uint; pub const N_WEDGE_MASTER_LINES: usize = 3; static wedge_codebook_16_hgtw: [wedge_code_type; 16] = [ - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 6, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 6, - y_offset: 4, - }, + wedge_code_type::new(4, 4, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE153), + wedge_code_type::new(4, 2, WEDGE_HORIZONTAL), + wedge_code_type::new(4, 4, WEDGE_HORIZONTAL), + wedge_code_type::new(4, 6, WEDGE_HORIZONTAL), + wedge_code_type::new(4, 4, WEDGE_VERTICAL), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE153), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE153), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE117), ]; static wedge_codebook_16_hltw: [wedge_code_type; 16] = [ - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 6, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 6, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 6, - y_offset: 4, - }, + wedge_code_type::new(4, 4, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE153), + wedge_code_type::new(2, 4, WEDGE_VERTICAL), + wedge_code_type::new(4, 4, WEDGE_VERTICAL), + wedge_code_type::new(6, 4, WEDGE_VERTICAL), + wedge_code_type::new(4, 4, WEDGE_HORIZONTAL), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE153), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE153), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE117), ]; static wedge_codebook_16_heqw: [wedge_code_type; 16] = [ - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_HORIZONTAL, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_VERTICAL, - x_offset: 6, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE27, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 2, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE153, - x_offset: 4, - y_offset: 6, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE63, - x_offset: 6, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 2, - y_offset: 4, - }, - wedge_code_type { - direction: WEDGE_OBLIQUE117, - x_offset: 6, - y_offset: 4, - }, + wedge_code_type::new(4, 4, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(4, 4, WEDGE_OBLIQUE153), + wedge_code_type::new(4, 2, WEDGE_HORIZONTAL), + wedge_code_type::new(4, 6, WEDGE_HORIZONTAL), + wedge_code_type::new(2, 4, WEDGE_VERTICAL), + wedge_code_type::new(6, 4, WEDGE_VERTICAL), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE27), + wedge_code_type::new(4, 2, WEDGE_OBLIQUE153), + wedge_code_type::new(4, 6, WEDGE_OBLIQUE153), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE63), + wedge_code_type::new(2, 4, WEDGE_OBLIQUE117), + wedge_code_type::new(6, 4, WEDGE_OBLIQUE117), ]; static mut wedge_masks_444_32x32: Align64<[uint8_t; 32768]> = Align64([0; 32768]);