Skip to content

Commit

Permalink
fn dav1d_init_mode_tree: Cleanup (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen authored Aug 25, 2023
2 parents 4e48d89 + de3b5c5 commit 1386dd6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 61 deletions.
73 changes: 22 additions & 51 deletions src/intra_edge.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::iter;
use std::ptr;
use std::slice;

use crate::include::stdint::uint8_t;
use ::libc;
pub type EdgeFlags = uint8_t;
pub const EDGE_I420_LEFT_HAS_BOTTOM: EdgeFlags = 32;
pub const EDGE_I422_LEFT_HAS_BOTTOM: EdgeFlags = 16;
Expand Down Expand Up @@ -196,61 +196,32 @@ unsafe fn init_mode_node(
}
};
}
#[no_mangle]
pub unsafe extern "C" fn dav1d_init_mode_tree(

pub unsafe fn dav1d_init_mode_tree(
root_node: *mut EdgeNode,
nt: *mut EdgeTip,
allow_sb128: libc::c_int,
nt: &mut [EdgeTip],
allow_sb128: bool,
) {
let root: *mut EdgeBranch = root_node as *mut EdgeBranch;
let mut mem: ModeSelMem = ModeSelMem {
nwc: [0 as *mut EdgeBranch; 3],
nt: 0 as *mut EdgeTip,
let root = root_node as *mut EdgeBranch;
let mut mem = ModeSelMem {
nwc: [ptr::null_mut(); 3],
nt: nt.as_mut_ptr(),
};
mem.nt = nt;
if allow_sb128 != 0 {
mem.nwc[BL_128X128 as libc::c_int as usize] = &mut *root.offset(1) as *mut EdgeBranch;
mem.nwc[BL_64X64 as libc::c_int as usize] =
&mut *root.offset((1 + 4) as isize) as *mut EdgeBranch;
mem.nwc[BL_32X32 as libc::c_int as usize] =
&mut *root.offset((1 + 4 + 16) as isize) as *mut EdgeBranch;
if allow_sb128 {
mem.nwc[BL_128X128 as usize] = root.offset(1);
mem.nwc[BL_64X64 as usize] = root.offset(1 + 4);
mem.nwc[BL_32X32 as usize] = root.offset(1 + 4 + 16);
init_mode_node(&mut *root, BL_128X128, &mut mem, true, false);
if !(mem.nwc[BL_128X128 as libc::c_int as usize]
== &mut *root.offset((1 + 4) as isize) as *mut EdgeBranch)
{
unreachable!();
}
if !(mem.nwc[BL_64X64 as libc::c_int as usize]
== &mut *root.offset((1 + 4 + 16) as isize) as *mut EdgeBranch)
{
unreachable!();
}
if !(mem.nwc[BL_32X32 as libc::c_int as usize]
== &mut *root.offset((1 + 4 + 16 + 64) as isize) as *mut EdgeBranch)
{
unreachable!();
}
if !(mem.nt == &mut *nt.offset(256) as *mut EdgeTip) {
unreachable!();
}
assert_eq!(mem.nwc[BL_128X128 as usize], root.offset(1 + 4));
assert_eq!(mem.nwc[BL_64X64 as usize], root.offset(1 + 4 + 16));
assert_eq!(mem.nwc[BL_32X32 as usize], root.offset(1 + 4 + 16 + 64));
} else {
mem.nwc[BL_128X128 as libc::c_int as usize] = 0 as *mut EdgeBranch;
mem.nwc[BL_64X64 as libc::c_int as usize] = &mut *root.offset(1) as *mut EdgeBranch;
mem.nwc[BL_32X32 as libc::c_int as usize] =
&mut *root.offset((1 + 4) as isize) as *mut EdgeBranch;
mem.nwc[BL_128X128 as usize] = ptr::null_mut();
mem.nwc[BL_64X64 as usize] = root.offset(1);
mem.nwc[BL_32X32 as usize] = root.offset(1 + 4);
init_mode_node(&mut *root, BL_64X64, &mut mem, true, false);
if !(mem.nwc[BL_64X64 as libc::c_int as usize]
== &mut *root.offset((1 + 4) as isize) as *mut EdgeBranch)
{
unreachable!();
}
if !(mem.nwc[BL_32X32 as libc::c_int as usize]
== &mut *root.offset((1 + 4 + 16) as isize) as *mut EdgeBranch)
{
unreachable!();
}
if !(mem.nt == &mut *nt.offset(64) as *mut EdgeTip) {
unreachable!();
}
assert_eq!(mem.nwc[BL_64X64 as usize], root.offset(1 + 4));
assert_eq!(mem.nwc[BL_32X32 as usize], root.offset(1 + 4 + 16));
};
assert_eq!(mem.nt, nt.as_mut_ptr_range().end);
}
15 changes: 5 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::include::stddef::*;
use crate::include::stdint::*;

use crate::src::intra_edge::dav1d_init_mode_tree;
use crate::stderr;
use ::libc;
use cfg_if::cfg_if;
Expand Down Expand Up @@ -73,7 +73,6 @@ extern "C" {
__arg: *mut libc::c_void,
) -> libc::c_int;
fn dav1d_refmvs_dsp_init(dsp: *mut Dav1dRefmvsDSPContext);
fn dav1d_init_mode_tree(root: *mut EdgeNode, nt: *mut EdgeTip, allow_sb128: libc::c_int);
fn pthread_join(__th: pthread_t, __thread_return: *mut *mut libc::c_void) -> libc::c_int;
fn dav1d_refmvs_clear(rf: *mut refmvs_frame);
fn dav1d_cdf_thread_unref(cdf: *mut CdfThreadContext);
Expand Down Expand Up @@ -217,8 +216,6 @@ use crate::src::picture::PICTURE_FLAG_NEW_TEMPORAL_UNIT;
use crate::include::dav1d::dav1d::DAV1D_INLOOPFILTER_NONE;
use crate::src::internal::Dav1dContext_intra_edge;
use crate::src::intra_edge::EdgeFlags;
use crate::src::intra_edge::EdgeNode;
use crate::src::intra_edge::EdgeTip;

use crate::src::refmvs::Dav1dRefmvsDSPContext;
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -1285,9 +1282,8 @@ pub unsafe extern "C" fn dav1d_open(
(*c).intra_edge.root[BL_128X128
as libc::c_int
as usize],
((*c).intra_edge.tip_sb128)
.as_mut_ptr(),
1 as libc::c_int,
&mut (*c).intra_edge.tip_sb128,
true,
);
(*c).intra_edge.root[BL_64X64
as libc::c_int
Expand All @@ -1301,9 +1297,8 @@ pub unsafe extern "C" fn dav1d_open(
(*c).intra_edge.root[BL_64X64
as libc::c_int
as usize],
((*c).intra_edge.tip_sb64)
.as_mut_ptr(),
0 as libc::c_int,
&mut (*c).intra_edge.tip_sb64,
false,
);
pthread_attr_destroy(&mut thread_attr);
return 0 as libc::c_int;
Expand Down

0 comments on commit 1386dd6

Please sign in to comment.