Skip to content

Commit

Permalink
Rav1dFrameContext_lf::cdef_line_buf: Make into AlignedVec32
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Feb 29, 2024
1 parent b40cfa5 commit dae2cc1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,4 @@ impl<T: Copy, C: AlignedByteChunk> Default for AlignedVec<T, C> {
}

pub type AlignedVec64<T> = AlignedVec<T, Align64<[u8; 64]>>;
pub type AlignedVec32<T> = AlignedVec<T, Align32<[u8; 32]>>;
13 changes: 5 additions & 8 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4392,17 +4392,14 @@ pub(crate) unsafe fn rav1d_decode_frame_init(
|| need_cdef_lpf_copy != f.lf.need_cdef_lpf_copy
|| f.sbh != f.lf.cdef_buf_sbh
{
rav1d_free_aligned(f.lf.cdef_line_buf as *mut c_void);
let mut alloc_sz: usize = 64;
alloc_sz += (y_stride.unsigned_abs() * 4 * f.sbh as usize) << need_cdef_lpf_copy;
alloc_sz += (uv_stride.unsigned_abs() * 8 * f.sbh as usize) << need_cdef_lpf_copy;
f.lf.cdef_line_buf = rav1d_alloc_aligned(alloc_sz, 32) as *mut u8;
let mut ptr = f.lf.cdef_line_buf;
if ptr.is_null() {
f.lf.cdef_buf_plane_sz[1] = 0;
f.lf.cdef_buf_plane_sz[0] = f.lf.cdef_buf_plane_sz[1];
return Err(ENOMEM);
}
// TODO: Fallbile allocation. We need to do the following on allocation
// failure:
// f.lf.cdef_buf_plane_sz = [0, 0];
f.lf.cdef_line_buf.resize(alloc_sz, 0);
let mut ptr = f.lf.cdef_line_buf.as_mut_ptr();

ptr = ptr.offset(32);
if y_stride < 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ pub struct Rav1dFrameContext_lf {
pub last_sharpness: c_int,
pub lvl: [[[[u8; 2]; 8]; 4]; 8], /* [8 seg_id][4 dir][8 ref][2 is_gmv] */
pub tx_lpf_right_edge: Vec<u8>, /* len = h*2 */
pub cdef_line_buf: *mut u8,
pub cdef_line_buf: AlignedVec32<u8>, /* AlignedVec32<DynPixel> */
pub lr_line_buf: *mut u8,
pub cdef_line: [[*mut DynPixel; 3]; 2], /* [2 pre/post][3 plane] */
pub cdef_lpf_line: [*mut DynPixel; 3], /* plane */
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ impl Drop for Rav1dContext {
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);
rav1d_refmvs_clear(&mut f.rf);
rav1d_free_aligned(f.lf.cdef_line_buf as *mut c_void);
let _ = mem::take(&mut f.lf.cdef_line_buf); // TODO: remove when context is owned
rav1d_free_aligned(f.lf.lr_line_buf as *mut c_void);
n_1 = n_1.wrapping_add(1);
}
Expand Down

0 comments on commit dae2cc1

Please sign in to comment.