From b5978d6132ed818ba4f1b071cc67118b0d714c1b Mon Sep 17 00:00:00 2001 From: Nicole LeGare Date: Mon, 11 Mar 2024 12:29:35 -0700 Subject: [PATCH] `Rav1dFrameContext_lf::start_of_tile_row`: Make into `Vec` --- src/decode.rs | 16 +++++----------- src/internal.rs | 3 +-- src/lib.rs | 2 +- src/recon.rs | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/decode.rs b/src/decode.rs index 191cab357..b5bd58884 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -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::()) 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; } } diff --git a/src/internal.rs b/src/internal.rs index 02139885d..8676b60cb 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -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, pub p: [*mut DynPixel; 3], pub sr_p: [*mut DynPixel; 3], pub restore_planes: c_int, // enum LrRestorePlanes diff --git a/src/lib.rs b/src/lib.rs index 76b5f5165..2c9e4276f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -926,7 +926,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 diff --git a/src/recon.rs b/src/recon.rs index 7c46594f8..01c1f67b5 100644 --- a/src/recon.rs +++ b/src/recon.rs @@ -4536,7 +4536,7 @@ pub(crate) unsafe fn rav1d_filter_sbrow_deblock_cols( &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, ); }