Skip to content

Commit

Permalink
struct Rav1dFrameContext_lf::start_of_tile_row: Make into Vec (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison authored Mar 12, 2024
2 parents 0d6e175 + 437dda6 commit f65d252
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
16 changes: 5 additions & 11 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4262,22 +4262,16 @@ pub(crate) unsafe fn rav1d_decode_frame_init(
c: &Rav1dContext,
f: &mut Rav1dFrameData,
) -> Rav1dResult {
if f.sbh > f.lf.start_of_tile_row_sz {
free(f.lf.start_of_tile_row as *mut c_void);
f.lf.start_of_tile_row = malloc(f.sbh as usize * ::core::mem::size_of::<u8>()) as *mut u8;
if f.lf.start_of_tile_row.is_null() {
f.lf.start_of_tile_row_sz = 0;
return Err(ENOMEM);
}
f.lf.start_of_tile_row_sz = f.sbh;
}
// TODO: Fallible allocation
f.lf.start_of_tile_row.resize(f.sbh as usize, 0);

let frame_hdr = &***f.frame_hdr.as_ref().unwrap();
let mut sby = 0;
for tile_row in 0..frame_hdr.tiling.rows {
*f.lf.start_of_tile_row.offset(sby as isize) = tile_row as u8;
f.lf.start_of_tile_row[sby as usize] = tile_row as u8;
sby += 1;
while sby < frame_hdr.tiling.row_start_sb[(tile_row + 1) as usize] as c_int {
*f.lf.start_of_tile_row.offset(sby as isize) = 0;
f.lf.start_of_tile_row[sby as usize] = 0;
sby += 1;
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ pub struct Rav1dFrameContext_lf {
pub lr_lpf_line: [*mut DynPixel; 3], /* plane */

// in-loop filter per-frame state keeping
pub start_of_tile_row: *mut u8,
pub start_of_tile_row_sz: c_int,
pub start_of_tile_row: Vec<u8>,
pub p: [*mut DynPixel; 3],
pub sr_p: [*mut DynPixel; 3],
pub restore_planes: c_int, // enum LrRestorePlanes
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ pub(crate) unsafe fn rav1d_open(c_out: &mut *mut Rav1dContext, s: &Rav1dSettings
addr_of_mut!(f.lf.tx_lpf_right_edge).write(Default::default());
addr_of_mut!(f.lf.cdef_line_buf).write(Default::default());
addr_of_mut!(f.lf.lr_line_buf).write(Default::default());
addr_of_mut!(f.lf.start_of_tile_row).write(Default::default());
f.lf.last_sharpness = -(1 as c_int);
rav1d_refmvs_init(&mut f.rf);
n = n.wrapping_add(1);
Expand Down Expand Up @@ -926,7 +927,7 @@ impl Drop for Rav1dContext {
let _ = mem::take(&mut f.lf.lr_mask); // TODO: remove when context is owned
let _ = mem::take(&mut f.lf.level);
let _ = mem::take(&mut f.lf.tx_lpf_right_edge); // TODO: remove when context is owned
free(f.lf.start_of_tile_row as *mut c_void);
let _ = mem::take(&mut f.lf.start_of_tile_row); // TODO: remove when context is owned
rav1d_refmvs_clear(&mut f.rf);
let _ = mem::take(&mut f.lf.cdef_line_buf); // TODO: remove when context is owned
let _ = mem::take(&mut f.lf.lr_line_buf); // TODO: remove when context is owned
Expand Down
2 changes: 1 addition & 1 deletion src/recon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,7 @@ pub(crate) unsafe fn rav1d_filter_sbrow_deblock_cols<BD: BitDepth>(
&p_offset,
mask_offset as usize,
sby,
*(f.lf.start_of_tile_row).offset(sby as isize) as c_int,
f.lf.start_of_tile_row[sby as usize] as c_int,
);
}

Expand Down

0 comments on commit f65d252

Please sign in to comment.