Skip to content

Commit

Permalink
struct RefMvsFrame::{rp,rp_ref}: Remove raw ptr fields and pass thr…
Browse files Browse the repository at this point in the history
…ough the callstack.
  • Loading branch information
kkysen committed Apr 19, 2024
1 parent 75d0d06 commit d3f252e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
18 changes: 14 additions & 4 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3913,6 +3913,8 @@ pub(crate) unsafe fn rav1d_decode_tile_sbrow(
if c.tc.len() > 1 && frame_hdr.use_ref_frame_mvs != 0 {
c.refmvs_dsp.load_tmvs(
&f.rf,
f.mvs,
&f.ref_mvs,
ts.tiling.row,
ts.tiling.col_start >> 1,
ts.tiling.col_end >> 1,
Expand Down Expand Up @@ -4023,6 +4025,7 @@ pub(crate) unsafe fn rav1d_decode_tile_sbrow(
c.refmvs_dsp.save_tmvs(
&t.rt,
&f.rf,
f.mvs,
ts.tiling.col_start >> 1,
ts.tiling.col_end >> 1,
t.b.y >> 1,
Expand Down Expand Up @@ -4318,7 +4321,6 @@ pub(crate) unsafe fn rav1d_decode_frame_init(
seq_hdr,
frame_hdr,
&f.refpoc,
f.mvs,
&f.refrefpoc,
&f.ref_mvs,
c.tc.len() as u32,
Expand Down Expand Up @@ -4514,16 +4516,24 @@ unsafe fn rav1d_decode_frame_main(c: &Rav1dContext, f: &mut Rav1dFrameData) -> R
t.b.y = sby << 4 + seq_hdr.sb128;
let by_end = t.b.y + f.sb_step >> 1;
if frame_hdr.use_ref_frame_mvs != 0 {
c.refmvs_dsp
.load_tmvs(&f.rf, tile_row as c_int, 0, f.bw >> 1, t.b.y >> 1, by_end);
c.refmvs_dsp.load_tmvs(
&f.rf,
f.mvs,
&f.ref_mvs,
tile_row as c_int,
0,
f.bw >> 1,
t.b.y >> 1,
by_end,
);
}
for col in 0..cols {
t.ts = tile_row * cols + col;
rav1d_decode_tile_sbrow(c, &mut t, f).map_err(|()| EINVAL)?;
}
if f.frame_hdr().frame_type.is_inter_or_switch() {
c.refmvs_dsp
.save_tmvs(&t.rt, &f.rf, 0, f.bw >> 1, t.b.y >> 1, by_end);
.save_tmvs(&t.rt, &f.rf, f.mvs, 0, f.bw >> 1, t.b.y >> 1, by_end);
}

// loopfilter + cdef + restoration
Expand Down
14 changes: 5 additions & 9 deletions src/refmvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ pub(crate) struct RefMvsFrame {
pub mfmv_ref2cur: [c_int; 3],
pub mfmv_ref2ref: [[c_int; 7]; 3],
pub n_mfmvs: c_int,
pub rp: *mut refmvs_temporal_block,
pub rp_ref: *const *mut refmvs_temporal_block,
pub rp_proj: DisjointMut<AlignedVec64<refmvs_temporal_block>>,
pub rp_stride: u32,
pub r: DisjointMut<AlignedVec64<refmvs_block>>,
Expand Down Expand Up @@ -311,6 +309,8 @@ impl Rav1dRefmvsDSPContext {
pub unsafe fn load_tmvs(
&self,
rf: &RefMvsFrame,
rp: *mut refmvs_temporal_block,
rp_ref: &[*mut refmvs_temporal_block; 7],
tile_row_idx: c_int,
col_start8: c_int,
col_end8: c_int,
Expand All @@ -331,8 +331,6 @@ impl Rav1dRefmvsDSPContext {
mfmv_ref2cur,
mfmv_ref2ref,
n_mfmvs,
rp,
rp_ref,
ref rp_proj,
rp_stride,
ref r,
Expand All @@ -358,7 +356,7 @@ impl Rav1dRefmvsDSPContext {
mfmv_ref2ref,
n_mfmvs,
rp,
rp_ref,
rp_ref: rp_ref.as_ptr(),
rp_proj: rp_proj.as_mut_ptr(),
rp_stride: rp_stride as _,
r: r.as_mut_ptr(),
Expand All @@ -384,6 +382,7 @@ impl Rav1dRefmvsDSPContext {
&self,
rt: &refmvs_tile,
rf: &RefMvsFrame,
rp: *mut refmvs_temporal_block,
col_start8: c_int,
col_end8: c_int,
row_start8: c_int,
Expand All @@ -395,7 +394,7 @@ impl Rav1dRefmvsDSPContext {
let col_end8 = cmp::min(col_end8, rf.iw8);
let stride = rf.rp_stride as isize;
let ref_sign = &rf.mfmv_sign;
let rp = rf.rp.offset(row_start8 as isize * stride);
let rp = rp.offset(row_start8 as isize * stride);
let ri = <&[_; 31]>::try_from(&rt.r[6..]).unwrap();

// SAFETY: Note that for asm calls, disjointedness is unchecked here,
Expand Down Expand Up @@ -1545,7 +1544,6 @@ pub(crate) fn rav1d_refmvs_init_frame(
seq_hdr: &Rav1dSequenceHeader,
frm_hdr: &Rav1dFrameHeader,
ref_poc: &[c_uint; 7],
rp: *mut refmvs_temporal_block,
ref_ref_poc: &[[c_uint; 7]; 7],
rp_ref: &[*mut refmvs_temporal_block; 7],
n_tile_threads: u32,
Expand Down Expand Up @@ -1582,8 +1580,6 @@ pub(crate) fn rav1d_refmvs_init_frame(
rf.n_tile_rows = n_tile_rows;
rf.n_tile_threads = n_tile_threads;
rf.n_frame_threads = n_frame_threads;
rf.rp = rp;
rf.rp_ref = rp_ref.as_ptr();
let poc = frm_hdr.frame_offset as c_uint;
for i in 0..7 {
let poc_diff = get_poc_diff(seq_hdr.order_hint_n_bits, ref_poc[i] as c_int, poc as c_int);
Expand Down

0 comments on commit d3f252e

Please sign in to comment.