diff --git a/src/decode.rs b/src/decode.rs index aaa15dfec..cce28f018 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -4247,39 +4247,35 @@ unsafe fn decode_sb( } } else { let b = &mut *(f.frame_thread.b).offset(t.by as isize * f.b4_stride + t.bx as isize); - bp = if b.bl as BlockLevel == bl { - b.bp as BlockPartition - } else { - PARTITION_SPLIT - }; + bp = if b.bl == bl { b.bp } else { PARTITION_SPLIT }; } let b = &dav1d_block_sizes[bl as usize][bp as usize]; match bp { PARTITION_NONE => { let node = &*node; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_NONE, node.o) != 0 { + if decode_b(t, bl, b[0], bp, node.o) != 0 { return -1; } } PARTITION_H => { let node = &*node; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H, node.h[0]) != 0 { + if decode_b(t, bl, b[0], bp, node.h[0]) != 0 { return -1; } t.by += hsz; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H, node.h[1]) != 0 { + if decode_b(t, bl, b[0], bp, node.h[1]) != 0 { return -1; } t.by -= hsz; } PARTITION_V => { let node = &*node; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V, node.v[0]) != 0 { + if decode_b(t, bl, b[0], bp, node.v[0]) != 0 { return -1; } t.bx += hsz; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V, node.v[1]) != 0 { + if decode_b(t, bl, b[0], bp, node.v[1]) != 0 { return -1; } t.bx -= hsz; @@ -4288,22 +4284,22 @@ unsafe fn decode_sb( if bl == BL_8X8 { let tip = &*(node as *const EdgeTip); assert!(hsz == 1); - if decode_b(t, bl, BS_4x4, PARTITION_SPLIT, tip.split[0]) != 0 { + if decode_b(t, bl, BS_4x4, bp, tip.split[0]) != 0 { return -1; } let tl_filter = t.tl_4x4_filter; t.bx += 1; - if decode_b(t, bl, BS_4x4, PARTITION_SPLIT, tip.split[1]) != 0 { + if decode_b(t, bl, BS_4x4, bp, tip.split[1]) != 0 { return -1; } t.bx -= 1; t.by += 1; - if decode_b(t, bl, BS_4x4, PARTITION_SPLIT, tip.split[2]) != 0 { + if decode_b(t, bl, BS_4x4, bp, tip.split[2]) != 0 { return -1; } t.bx += 1; t.tl_4x4_filter = tl_filter; - if decode_b(t, bl, BS_4x4, PARTITION_SPLIT, tip.split[3]) != 0 { + if decode_b(t, bl, BS_4x4, bp, tip.split[3]) != 0 { return -1; } t.bx -= 1; @@ -4340,73 +4336,31 @@ unsafe fn decode_sb( } PARTITION_T_TOP_SPLIT => { let branch = &*(node as *const EdgeBranch); - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_TOP_SPLIT, - branch.tts[0], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.tts[0]) != 0 { return -1; } t.bx += hsz; - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_TOP_SPLIT, - branch.tts[1], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.tts[1]) != 0 { return -1; } t.bx -= hsz; t.by += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_TOP_SPLIT, - branch.tts[2], - ) != 0 - { + if decode_b(t, bl, b[1], bp, branch.tts[2]) != 0 { return -1; } t.by -= hsz; } PARTITION_T_BOTTOM_SPLIT => { let branch = &*(node as *const EdgeBranch); - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_BOTTOM_SPLIT, - branch.tbs[0], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.tbs[0]) != 0 { return -1; } t.by += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_BOTTOM_SPLIT, - branch.tbs[1], - ) != 0 - { + if decode_b(t, bl, b[1], bp, branch.tbs[1]) != 0 { return -1; } t.bx += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_BOTTOM_SPLIT, - branch.tbs[2], - ) != 0 - { + if decode_b(t, bl, b[1], bp, branch.tbs[2]) != 0 { return -1; } t.bx -= hsz; @@ -4414,73 +4368,31 @@ unsafe fn decode_sb( } PARTITION_T_LEFT_SPLIT => { let branch = &*(node as *const EdgeBranch); - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_LEFT_SPLIT, - branch.tls[0], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.tls[0]) != 0 { return -1; } t.by += hsz; - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_LEFT_SPLIT, - branch.tls[1], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.tls[1]) != 0 { return -1; } t.by -= hsz; t.bx += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_LEFT_SPLIT, - branch.tls[2], - ) != 0 - { + if decode_b(t, bl, b[1], bp, branch.tls[2]) != 0 { return -1; } t.bx -= hsz; } PARTITION_T_RIGHT_SPLIT => { let branch = &*(node as *const EdgeBranch); - if decode_b( - t, - bl, - b[0] as BlockSize, - PARTITION_T_RIGHT_SPLIT, - branch.trs[0], - ) != 0 - { + if decode_b(t, bl, b[0], bp, branch.trs[0]) != 0 { return -1; } t.bx += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_RIGHT_SPLIT, - branch.trs[1], - ) != 0 - { + if decode_b(t, bl, b[1], bp, branch.trs[1]) != 0 { return -1; } t.by += hsz; - if decode_b( - t, - bl, - b[1] as BlockSize, - PARTITION_T_RIGHT_SPLIT, - (*branch).trs[2], - ) != 0 - { + if decode_b(t, bl, b[1], bp, (*branch).trs[2]) != 0 { return -1; } t.by -= hsz; @@ -4488,20 +4400,20 @@ unsafe fn decode_sb( } PARTITION_H4 => { let branch = &*(node as *const EdgeBranch); - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H4, branch.h4[0]) != 0 { + if decode_b(t, bl, b[0], bp, branch.h4[0]) != 0 { return -1; } t.by += hsz >> 1; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H4, branch.h4[1]) != 0 { + if decode_b(t, bl, b[0], bp, branch.h4[1]) != 0 { return -1; } t.by += hsz >> 1; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H4, branch.h4[2]) != 0 { + if decode_b(t, bl, b[0], bp, branch.h4[2]) != 0 { return -1; } t.by += hsz >> 1; if t.by < f.bh { - if decode_b(t, bl, b[0] as BlockSize, PARTITION_H4, branch.h4[3]) != 0 { + if decode_b(t, bl, b[0], bp, branch.h4[3]) != 0 { return -1; } } @@ -4509,20 +4421,20 @@ unsafe fn decode_sb( } PARTITION_V4 => { let branch = &*(node as *const EdgeBranch); - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V4, branch.v4[0]) != 0 { + if decode_b(t, bl, b[0], bp, branch.v4[0]) != 0 { return -1; } t.bx += hsz >> 1; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V4, branch.v4[1]) != 0 { + if decode_b(t, bl, b[0], bp, branch.v4[1]) != 0 { return -1; } t.bx += hsz >> 1; - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V4, branch.v4[2]) != 0 { + if decode_b(t, bl, b[0], bp, branch.v4[2]) != 0 { return -1; } t.bx += hsz >> 1; if t.bx < f.bw { - if decode_b(t, bl, b[0] as BlockSize, PARTITION_V4, branch.v4[3]) != 0 { + if decode_b(t, bl, b[0], bp, branch.v4[3]) != 0 { return -1; } } @@ -4552,7 +4464,7 @@ unsafe fn decode_sb( } } else { let b = &mut *(f.frame_thread.b).offset(t.by as isize * f.b4_stride + t.bx as isize); - is_split = b.bl as BlockLevel != bl; + is_split = b.bl != bl; } assert!(bl < BL_8X8); @@ -4572,8 +4484,8 @@ unsafe fn decode_sb( if decode_b( t, bl, - dav1d_block_sizes[bl as usize][PARTITION_H as usize][0] as BlockSize, - PARTITION_H, + dav1d_block_sizes[bl as usize][bp as usize][0], + bp, (*node).h[0], ) != 0 { @@ -4606,7 +4518,7 @@ unsafe fn decode_sb( } } else { let b = &mut *(f.frame_thread.b).offset(t.by as isize * f.b4_stride + t.bx as isize); - is_split = b.bl as BlockLevel != bl; + is_split = b.bl != bl; } assert!(bl < BL_8X8); @@ -4626,8 +4538,8 @@ unsafe fn decode_sb( if decode_b( t, bl, - dav1d_block_sizes[bl as usize][PARTITION_V as usize][0] as BlockSize, - PARTITION_V, + dav1d_block_sizes[bl as usize][bp as usize][0], + bp, (*node).v[0], ) != 0 { diff --git a/src/levels.rs b/src/levels.rs index 5e8d48293..437ed794f 100644 --- a/src/levels.rs +++ b/src/levels.rs @@ -18,7 +18,7 @@ pub const TX_32X32: TxfmSize = 3; pub const TX_16X16: TxfmSize = 2; pub const TX_8X8: TxfmSize = 1; pub const TX_4X4: TxfmSize = 0; -pub type BlockLevel = libc::c_uint; +pub type BlockLevel = u8; pub const N_BL_LEVELS: BlockLevel = 5; pub const BL_8X8: BlockLevel = 4; pub const BL_16X16: BlockLevel = 3; @@ -96,7 +96,7 @@ pub const II_SMOOTH_PRED: InterIntraPredMode = 3; pub const II_HOR_PRED: InterIntraPredMode = 2; pub const II_VERT_PRED: InterIntraPredMode = 1; pub const II_DC_PRED: InterIntraPredMode = 0; -pub type BlockPartition = libc::c_uint; +pub type BlockPartition = u8; pub const N_SUB8X8_PARTITIONS: BlockPartition = 4; pub const N_PARTITIONS: BlockPartition = 10; pub const PARTITION_V4: BlockPartition = 9; @@ -109,7 +109,7 @@ pub const PARTITION_SPLIT: BlockPartition = 3; pub const PARTITION_V: BlockPartition = 2; pub const PARTITION_H: BlockPartition = 1; pub const PARTITION_NONE: BlockPartition = 0; -pub type BlockSize = libc::c_uint; +pub type BlockSize = u8; pub const N_BS_SIZES: BlockSize = 22; pub const BS_4x4: BlockSize = 21; pub const BS_4x8: BlockSize = 20; diff --git a/src/tables.rs b/src/tables.rs index 3ff848505..256e892f5 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -30,6 +30,7 @@ use crate::src::levels::BS_8x16; use crate::src::levels::BS_8x32; use crate::src::levels::BS_8x4; use crate::src::levels::BS_8x8; +use crate::src::levels::BlockSize; use crate::src::levels::ADST_ADST; use crate::src::levels::ADST_DCT; use crate::src::levels::ADST_FLIPADST; @@ -119,7 +120,7 @@ pub static dav1d_al_part_ctx: [[[u8; 10]; 5]; 2] = [ ], ]; -pub static dav1d_block_sizes: [[[u8; 2]; 10]; 5] = [ +pub static dav1d_block_sizes: [[[BlockSize; 2]; 10]; 5] = [ [ [BS_128x128 as u8, 0], [BS_128x64 as u8, 0],