Skip to content

Commit b441c58

Browse files
committed
Rav1dFrameContext_lf::lr_line_buf: Make into AlignedVec64
1 parent 929ca31 commit b441c58

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/decode.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,18 +4449,14 @@ pub(crate) unsafe fn rav1d_decode_frame_init(
44494449
if y_stride * num_lines as isize != f.lf.lr_buf_plane_sz[0] as isize
44504450
|| uv_stride * num_lines as isize * 2 != f.lf.lr_buf_plane_sz[1] as isize
44514451
{
4452-
rav1d_free_aligned(f.lf.lr_line_buf as *mut c_void);
44534452
// lr simd may overread the input, so slightly over-allocate the lpf buffer
44544453
let mut alloc_sz: usize = 128;
44554454
alloc_sz += y_stride.unsigned_abs() * num_lines as usize;
44564455
alloc_sz += uv_stride.unsigned_abs() * num_lines as usize * 2;
4457-
f.lf.lr_line_buf = rav1d_alloc_aligned(alloc_sz, 64) as *mut u8;
4458-
let mut ptr = f.lf.lr_line_buf;
4459-
if ptr.is_null() {
4460-
f.lf.lr_buf_plane_sz[1] = 0;
4461-
f.lf.lr_buf_plane_sz[0] = f.lf.lr_buf_plane_sz[1];
4462-
return Err(ENOMEM);
4463-
}
4456+
// TODO: Fallible allocation
4457+
// On allocation failure set `f.lf.lr_buf_plane_sz` to 0.
4458+
f.lf.lr_line_buf.resize(alloc_sz, 0);
4459+
let mut ptr = f.lf.lr_line_buf.as_mut_ptr();
44644460

44654461
ptr = ptr.offset(64);
44664462
if y_stride < 0 {

src/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pub struct Rav1dFrameContext_lf {
461461
pub lvl: [[[[u8; 2]; 8]; 4]; 8], /* [8 seg_id][4 dir][8 ref][2 is_gmv] */
462462
pub tx_lpf_right_edge: TxLpfRightEdge,
463463
pub cdef_line_buf: AlignedVec32<u8>, /* AlignedVec32<DynPixel> */
464-
pub lr_line_buf: *mut u8,
464+
pub lr_line_buf: AlignedVec64<u8>,
465465
pub cdef_line: [[usize; 3]; 2], /* [2 pre/post][3 plane] */
466466
pub cdef_lpf_line: [usize; 3], /* plane */
467467
pub lr_lpf_line: [*mut DynPixel; 3], /* plane */

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ impl Drop for Rav1dContext {
928928
free(f.lf.start_of_tile_row as *mut c_void);
929929
rav1d_refmvs_clear(&mut f.rf);
930930
let _ = mem::take(&mut f.lf.cdef_line_buf); // TODO: remove when context is owned
931-
rav1d_free_aligned(f.lf.lr_line_buf as *mut c_void);
931+
let _ = mem::take(&mut f.lf.lr_line_buf); // TODO: remove when context is owned
932932
n_1 = n_1.wrapping_add(1);
933933
}
934934
rav1d_free_aligned(self.fc as *mut c_void);

0 commit comments

Comments
 (0)