diff --git a/src/decode.rs b/src/decode.rs index 45f94608d..b93a42e7d 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -1106,7 +1106,7 @@ unsafe fn read_vartx_tree( t.by += h as c_int; } t.by -= bh4 as c_int; - if debug_block_info!(&*f, &*t) { + if debug_block_info!(f, &*t) { println!( "Post-vartxtree[{}/{}]: r={}", tx_split[0], @@ -3520,7 +3520,7 @@ unsafe fn decode_sb( ); } } else { - let b = &mut f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; + let b = &f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; bp = if b.bl == bl { b.bp } else { PARTITION_SPLIT }; } let b = &dav1d_block_sizes[bl as usize][bp as usize]; @@ -3671,7 +3671,7 @@ unsafe fn decode_sb( ); } } else { - let b = &mut f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; + let b = &f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; is_split = b.bl != bl; } @@ -3719,7 +3719,7 @@ unsafe fn decode_sb( ); } } else { - let b = &mut f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; + let b = &f.frame_thread.b[(t.by as isize * f.b4_stride + t.bx as isize) as usize]; is_split = b.bl != bl; } diff --git a/src/lf_apply.rs b/src/lf_apply.rs index 45a09eac9..eb030534b 100644 --- a/src/lf_apply.rs +++ b/src/lf_apply.rs @@ -37,7 +37,7 @@ unsafe fn backup_lpf( lr_backup: c_int, ) { let cdef_backup = (lr_backup == 0) as c_int; - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); let dst_w = if frame_hdr.size.super_res.enabled != 0 { frame_hdr.size.width[1] + ss_hor >> ss_hor } else { @@ -109,11 +109,11 @@ unsafe fn backup_lpf( } dst = dst.offset(4 * BD::pxstride(dst_stride as usize) as isize); } - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); if lr_backup != 0 && frame_hdr.size.width[0] != frame_hdr.size.width[1] { while row + stripe_h <= row_h { let n_lines = 4 - (row + stripe_h + 1 == h) as c_int; - ((*(*f).dsp).mc.resize)( + ((*f.dsp).mc.resize)( dst.cast(), dst_stride, src.cast(), @@ -121,9 +121,9 @@ unsafe fn backup_lpf( dst_w, n_lines, src_w, - (*f).resize_step[ss_hor as usize], - (*f).resize_start[ss_hor as usize], - (*f).bitdepth_max, + f.resize_step[ss_hor as usize], + f.resize_start[ss_hor as usize], + f.bitdepth_max, ); row += stripe_h; // unmodified stripe_h for the 1st stripe stripe_h = 64 >> ss_ver; @@ -176,25 +176,25 @@ pub(crate) unsafe fn rav1d_copy_lpf( sby: c_int, ) { let have_tt = (c.tc.len() > 1) as c_int; - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); let resize = (frame_hdr.size.width[0] != frame_hdr.size.width[1]) as c_int; let offset = 8 * (sby != 0) as c_int; - let src_stride: *const ptrdiff_t = ((*f).cur.stride).as_mut_ptr(); - let lr_stride: *const ptrdiff_t = ((*f).sr_cur.p.stride).as_mut_ptr(); - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let src_stride: *const ptrdiff_t = (f.cur.stride).as_mut_ptr(); + let lr_stride: *const ptrdiff_t = (f.sr_cur.p.stride).as_mut_ptr(); + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); let tt_off = have_tt * sby * ((4 as c_int) << seq_hdr.sb128); let dst: [*mut BD::Pixel; 3] = [ - ((*f).lf.lr_lpf_line[0] as *mut BD::Pixel) + (f.lf.lr_lpf_line[0] as *mut BD::Pixel) .offset(tt_off as isize * BD::pxstride(*lr_stride.offset(0) as usize) as isize), - ((*f).lf.lr_lpf_line[1] as *mut BD::Pixel) + (f.lf.lr_lpf_line[1] as *mut BD::Pixel) .offset(tt_off as isize * BD::pxstride(*lr_stride.offset(1) as usize) as isize), - ((*f).lf.lr_lpf_line[2] as *mut BD::Pixel) + (f.lf.lr_lpf_line[2] as *mut BD::Pixel) .offset(tt_off as isize * BD::pxstride(*lr_stride.offset(1) as usize) as isize), ]; - let restore_planes = (*f).lf.restore_planes; + let restore_planes = f.lf.restore_planes; if seq_hdr.cdef != 0 || restore_planes & LR_RESTORE_Y as c_int != 0 { - let h = (*f).cur.p.h; - let w = (*f).bw << 2; + let h = f.cur.p.h; + let w = f.bw << 2; let row_h = cmp::min((sby + 1) << 6 + seq_hdr.sb128, h - 1); let y_stripe = (sby << 6 + seq_hdr.sb128) - offset; if restore_planes & LR_RESTORE_Y as c_int != 0 || resize == 0 { @@ -223,7 +223,7 @@ pub(crate) unsafe fn rav1d_copy_lpf( backup_lpf::( c, f, - ((*f).lf.cdef_lpf_line[0] as *mut BD::Pixel).offset(cdef_off_y as isize), + (f.lf.cdef_lpf_line[0] as *mut BD::Pixel).offset(cdef_off_y as isize), *src_stride.offset(0), (*src.offset(0)).offset( -offset as isize * BD::pxstride(*src_stride.offset(0) as usize) as isize, @@ -241,12 +241,12 @@ pub(crate) unsafe fn rav1d_copy_lpf( } } if (seq_hdr.cdef != 0 || restore_planes & (LR_RESTORE_U as c_int | LR_RESTORE_V as c_int) != 0) - && (*f).cur.p.layout != Rav1dPixelLayout::I400 + && f.cur.p.layout != Rav1dPixelLayout::I400 { - let ss_ver = ((*f).sr_cur.p.p.layout == Rav1dPixelLayout::I420) as c_int; - let ss_hor = ((*f).sr_cur.p.p.layout != Rav1dPixelLayout::I444) as c_int; - let h_0 = (*f).cur.p.h + ss_ver >> ss_ver; - let w_0 = (*f).bw << 2 - ss_hor; + let ss_ver = (f.sr_cur.p.p.layout == Rav1dPixelLayout::I420) as c_int; + let ss_hor = (f.sr_cur.p.p.layout != Rav1dPixelLayout::I444) as c_int; + let h_0 = f.cur.p.h + ss_ver >> ss_ver; + let w_0 = f.bw << 2 - ss_hor; let row_h_0 = cmp::min((sby + 1) << 6 - ss_ver + seq_hdr.sb128, h_0 - 1); let offset_uv = offset >> ss_ver; let y_stripe_0 = (sby << 6 - ss_ver + seq_hdr.sb128) - offset_uv; @@ -277,7 +277,7 @@ pub(crate) unsafe fn rav1d_copy_lpf( backup_lpf::( c, f, - ((*f).lf.cdef_lpf_line[1] as *mut BD::Pixel).offset(cdef_off_uv as isize), + (f.lf.cdef_lpf_line[1] as *mut BD::Pixel).offset(cdef_off_uv as isize), *src_stride.offset(1), (*src.offset(1)).offset( -offset_uv as isize * BD::pxstride(*src_stride.offset(1) as usize) as isize, @@ -298,7 +298,7 @@ pub(crate) unsafe fn rav1d_copy_lpf( if restore_planes & LR_RESTORE_V as c_int != 0 || resize == 0 { backup_lpf::( c, - &*f, + f, dst[2], *lr_stride.offset(1), (*src.offset(2)).offset( @@ -319,7 +319,7 @@ pub(crate) unsafe fn rav1d_copy_lpf( backup_lpf::( c, f, - ((*f).lf.cdef_lpf_line[2] as *mut BD::Pixel).offset(cdef_off_uv as isize), + (f.lf.cdef_lpf_line[2] as *mut BD::Pixel).offset(cdef_off_uv as isize), *src_stride.offset(1), (*src.offset(2)).offset( -offset_uv as isize * BD::pxstride(*src_stride.offset(1) as usize) as isize, @@ -353,7 +353,7 @@ fn unaligned_lvl_slice(lvl: &[[u8; 4]], y: usize) -> &[[u8; 4]] { #[inline] unsafe fn filter_plane_cols_y( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, have_left: bool, lvl: &[[u8; 4]], b4_stride: ptrdiff_t, @@ -364,7 +364,7 @@ unsafe fn filter_plane_cols_y( starty4: c_int, endy4: c_int, ) { - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; for x in 0..w as usize { if !(!have_left && x == 0) { let mut hmask: [u32; 4] = [0; 4]; @@ -389,9 +389,9 @@ unsafe fn filter_plane_cols_y( hmask.as_mut_ptr(), &lvl[x as usize], b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, endy4 - starty4, - (*f).bitdepth_max, + f.bitdepth_max, ); } } @@ -399,7 +399,7 @@ unsafe fn filter_plane_cols_y( #[inline] unsafe fn filter_plane_rows_y( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, have_top: bool, lvl: &[[u8; 4]], b4_stride: ptrdiff_t, @@ -410,7 +410,7 @@ unsafe fn filter_plane_rows_y( starty4: c_int, endy4: c_int, ) { - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; for (y, lvl) in (starty4..endy4).zip(lvl.chunks(b4_stride as usize)) { if !(!have_top && y == 0) { let vmask: [u32; 4] = [ @@ -425,9 +425,9 @@ unsafe fn filter_plane_rows_y( vmask.as_ptr(), unaligned_lvl_slice(&lvl[0..], 1).as_ptr(), b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, w, - (*f).bitdepth_max, + f.bitdepth_max, ); } dst = dst.offset(4 * BD::pxstride(ls as usize) as isize); @@ -436,7 +436,7 @@ unsafe fn filter_plane_rows_y( #[inline] unsafe fn filter_plane_cols_uv( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, have_left: bool, lvl: &[[u8; 4]], b4_stride: ptrdiff_t, @@ -449,7 +449,7 @@ unsafe fn filter_plane_cols_uv( endy4: c_int, ss_ver: c_int, ) { - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; for x in 0..w { if !(!have_left && x == 0) { let mut hmask: [u32; 3] = [0; 3]; @@ -471,9 +471,9 @@ unsafe fn filter_plane_cols_uv( hmask.as_mut_ptr(), unaligned_lvl_slice(&lvl[x as usize..], 2).as_ptr(), b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, endy4 - starty4, - (*f).bitdepth_max, + f.bitdepth_max, ); (*dsp).lf.loop_filter_sb[1][0]( v.offset((x * 4) as isize).cast(), @@ -481,9 +481,9 @@ unsafe fn filter_plane_cols_uv( hmask.as_mut_ptr(), unaligned_lvl_slice(&lvl[x as usize..], 3).as_ptr(), b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, endy4 - starty4, - (*f).bitdepth_max, + f.bitdepth_max, ); } } @@ -491,7 +491,7 @@ unsafe fn filter_plane_cols_uv( #[inline] unsafe fn filter_plane_rows_uv( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, have_top: bool, lvl: &[[u8; 4]], b4_stride: ptrdiff_t, @@ -504,7 +504,7 @@ unsafe fn filter_plane_rows_uv( endy4: c_int, ss_hor: c_int, ) { - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; let mut off_l: ptrdiff_t = 0; for (y, lvl) in (starty4..endy4).zip(lvl.chunks(b4_stride as usize)) { if !(!have_top && y == 0) { @@ -519,9 +519,9 @@ unsafe fn filter_plane_rows_uv( vmask.as_ptr(), unaligned_lvl_slice(&lvl[0..], 2).as_ptr(), b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, w, - (*f).bitdepth_max, + f.bitdepth_max, ); (*dsp).lf.loop_filter_sb[1][1]( v.offset(off_l as isize).cast(), @@ -529,9 +529,9 @@ unsafe fn filter_plane_rows_uv( vmask.as_ptr(), unaligned_lvl_slice(&lvl[0..], 3).as_ptr(), b4_stride, - &(*f).lf.lim_lut.0, + &f.lf.lim_lut.0, w, - (*f).bitdepth_max, + f.bitdepth_max, ); } off_l += 4 * BD::pxstride(ls as usize) as isize; @@ -539,36 +539,36 @@ unsafe fn filter_plane_rows_uv( } pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, p: &[*mut BD::Pixel; 3], lflvl: *mut Av1Filter, sby: c_int, start_of_tile_row: c_int, ) { let mut have_left; - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); let is_sb64 = (seq_hdr.sb128 == 0) as c_int; let starty4 = (sby & is_sb64) << 4; let sbsz = 32 >> is_sb64; let sbl2 = 5 - is_sb64; - let halign = (*f).bh + 31 & !(31 as c_int); - let ss_ver = ((*f).cur.p.layout == Rav1dPixelLayout::I420) as c_int; - let ss_hor = ((*f).cur.p.layout != Rav1dPixelLayout::I444) as c_int; + let halign = f.bh + 31 & !(31 as c_int); + let ss_ver = (f.cur.p.layout == Rav1dPixelLayout::I420) as c_int; + let ss_hor = (f.cur.p.layout != Rav1dPixelLayout::I444) as c_int; let vmask = 16 >> ss_ver; let hmask = 16 >> ss_hor; let vmax = (1 as c_uint) << vmask; let hmax = (1 as c_uint) << hmask; - let endy4 = (starty4 + cmp::min((*f).h4 - sby * sbsz, sbsz)) as c_uint; + let endy4 = (starty4 + cmp::min(f.h4 - sby * sbsz, sbsz)) as c_uint; let uv_endy4: c_uint = endy4.wrapping_add(ss_ver as c_uint) >> ss_ver; - let mut lpf_y: *const u8 = &mut *(*((*f).lf.tx_lpf_right_edge).as_ptr().offset(0)) + let mut lpf_y: *const u8 = &mut *(*(f.lf.tx_lpf_right_edge).as_ptr().offset(0)) .offset((sby << sbl2) as isize) as *mut u8; - let mut lpf_uv: *const u8 = &mut *(*((*f).lf.tx_lpf_right_edge).as_ptr().offset(1)) + let mut lpf_uv: *const u8 = &mut *(*(f.lf.tx_lpf_right_edge).as_ptr().offset(1)) .offset((sby << sbl2 - ss_ver) as isize) as *mut u8; - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); let mut tile_col = 1; loop { let mut x = frame_hdr.tiling.col_start_sb[tile_col as usize] as c_int; - if x << sbl2 >= (*f).bw { + if x << sbl2 >= f.bw { break; } let bx4: c_int = if x & is_sb64 != 0 { 16 } else { 0 }; @@ -598,7 +598,7 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( y = y.wrapping_add(1); mask <<= 1; } - if (*f).cur.p.layout != Rav1dPixelLayout::I400 { + if f.cur.p.layout != Rav1dPixelLayout::I400 { let uv_hmask: *mut [u16; 2] = ((*lflvl.offset(x as isize)).filter_uv[0][cbx4 as usize]).as_mut_ptr(); let mut y_0: c_uint = (starty4 >> ss_ver) as c_uint; @@ -628,12 +628,11 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( } if start_of_tile_row != 0 { let mut a: *const BlockContext; - a = &mut *((*f).a).offset(((*f).sb128w * (start_of_tile_row - 1)) as isize) - as *mut BlockContext; - for x in 0..(*f).sb128w { + a = &mut *(f.a).offset((f.sb128w * (start_of_tile_row - 1)) as isize) as *mut BlockContext; + for x in 0..f.sb128w { let y_vmask: *mut [u16; 2] = ((*lflvl.offset(x as isize)).filter_y[1][starty4 as usize]).as_mut_ptr(); - let w: c_uint = cmp::min(32 as c_int, (*f).w4 - (x << 5)) as c_uint; + let w: c_uint = cmp::min(32 as c_int, f.w4 - (x << 5)) as c_uint; let mut mask_0: c_uint = 1; let mut i: c_uint = 0; while i < w { @@ -655,7 +654,7 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( mask_0 <<= 1; i = i.wrapping_add(1); } - if (*f).cur.p.layout != Rav1dPixelLayout::I400 { + if f.cur.p.layout != Rav1dPixelLayout::I400 { let cw: c_uint = w.wrapping_add(ss_hor as c_uint) >> ss_hor; let uv_vmask: *mut [u16; 2] = ((*lflvl.offset(x as isize)).filter_uv[1] [(starty4 >> ss_ver) as usize]) @@ -683,19 +682,19 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( } } let mut ptr: *mut BD::Pixel; - let mut level_ptr = &(*f).lf.level[((*f).b4_stride * sby as isize * sbsz as isize) as usize..]; + let mut level_ptr = &f.lf.level[(f.b4_stride * sby as isize * sbsz as isize) as usize..]; ptr = p[0]; have_left = false; - for x in 0..(*f).sb128w { + for x in 0..f.sb128w { filter_plane_cols_y::( f, have_left, level_ptr, - (*f).b4_stride, + f.b4_stride, &(*lflvl.offset(x as isize)).filter_y[0], ptr, - (*f).cur.stride[0], - cmp::min(32 as c_int, (*f).w4 - x * 32), + f.cur.stride[0], + cmp::min(32 as c_int, f.w4 - x * 32), starty4, endy4 as c_int, ); @@ -707,20 +706,19 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( return; } let mut uv_off: ptrdiff_t = 0; - let mut level_ptr = - &(*f).lf.level[((*f).b4_stride * (sby * sbsz >> ss_ver) as isize) as usize..]; + let mut level_ptr = &f.lf.level[(f.b4_stride * (sby * sbsz >> ss_ver) as isize) as usize..]; have_left = false; - for x in 0..(*f).sb128w { + for x in 0..f.sb128w { filter_plane_cols_uv::( f, have_left, level_ptr, - (*f).b4_stride, + f.b4_stride, &(*lflvl.offset(x as isize)).filter_uv[0], &mut *p[1].offset(uv_off as isize), &mut *p[2].offset(uv_off as isize), - (*f).cur.stride[1], - cmp::min(32 as c_int, (*f).w4 - x * 32) + ss_hor >> ss_hor, + f.cur.stride[1], + cmp::min(32 as c_int, f.w4 - x * 32) + ss_hor >> ss_hor, starty4 >> ss_ver, uv_endy4 as c_int, ss_ver, @@ -732,35 +730,35 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_cols( } pub(crate) unsafe fn rav1d_loopfilter_sbrow_rows( - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, p: &[*mut BD::Pixel; 3], lflvl: *mut Av1Filter, sby: c_int, ) { // Don't filter outside the frame let have_top = sby > 0; - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); let is_sb64 = (seq_hdr.sb128 == 0) as c_int; let starty4 = (sby & is_sb64) << 4; let sbsz = 32 >> is_sb64; - let ss_ver = ((*f).cur.p.layout == Rav1dPixelLayout::I420) as c_int; - let ss_hor = ((*f).cur.p.layout != Rav1dPixelLayout::I444) as c_int; - let endy4: c_uint = (starty4 + cmp::min((*f).h4 - sby * sbsz, sbsz)) as c_uint; + let ss_ver = (f.cur.p.layout == Rav1dPixelLayout::I420) as c_int; + let ss_hor = (f.cur.p.layout != Rav1dPixelLayout::I444) as c_int; + let endy4: c_uint = (starty4 + cmp::min(f.h4 - sby * sbsz, sbsz)) as c_uint; let uv_endy4: c_uint = endy4.wrapping_add(ss_ver as c_uint) >> ss_ver; let mut ptr: *mut BD::Pixel; - let mut level_ptr = &(*f).lf.level[((*f).b4_stride * sby as isize * sbsz as isize) as usize..]; + let mut level_ptr = &f.lf.level[(f.b4_stride * sby as isize * sbsz as isize) as usize..]; ptr = p[0]; - for x in 0..(*f).sb128w { + for x in 0..f.sb128w { filter_plane_rows_y::( f, have_top, level_ptr, - (*f).b4_stride, + f.b4_stride, &(*lflvl.offset(x as isize)).filter_y[1], ptr, - (*f).cur.stride[0], - cmp::min(32, (*f).w4 - x * 32), + f.cur.stride[0], + cmp::min(32, f.w4 - x * 32), starty4, endy4 as c_int, ); @@ -768,25 +766,24 @@ pub(crate) unsafe fn rav1d_loopfilter_sbrow_rows( level_ptr = &level_ptr[32..]; } - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); if frame_hdr.loopfilter.level_u == 0 && frame_hdr.loopfilter.level_v == 0 { return; } let mut uv_off: ptrdiff_t = 0; - let mut level_ptr = - &(*f).lf.level[((*f).b4_stride * (sby * sbsz >> ss_ver) as isize) as usize..]; - for x in 0..(*f).sb128w { + let mut level_ptr = &f.lf.level[(f.b4_stride * (sby * sbsz >> ss_ver) as isize) as usize..]; + for x in 0..f.sb128w { filter_plane_rows_uv::( f, have_top, level_ptr, - (*f).b4_stride, + f.b4_stride, &(*lflvl.offset(x as isize)).filter_uv[1], &mut *p[1].offset(uv_off as isize), &mut *p[2].offset(uv_off as isize), - (*f).cur.stride[1], - cmp::min(32 as c_int, (*f).w4 - x * 32) + ss_hor >> ss_hor, + f.cur.stride[1], + cmp::min(32 as c_int, f.w4 - x * 32) + ss_hor >> ss_hor, starty4 >> ss_ver, uv_endy4 as c_int, ss_hor, diff --git a/src/lib.rs b/src/lib.rs index 6666f12ae..782ffc04c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -326,17 +326,15 @@ pub(crate) unsafe fn rav1d_open(c_out: &mut *mut Rav1dContext, s: &Rav1dSettings }); let mut n: c_uint = 0 as c_int as c_uint; while n < (*c).n_fc { - let f: *mut Rav1dFrameContext = - &mut *((*c).fc).offset(n as isize) as *mut Rav1dFrameContext; + let f: &mut Rav1dFrameContext = &mut *((*c).fc).offset(n as isize); if n_tc > 1 { - (*f).task_thread.lock = Mutex::new(()); - (*f).task_thread.cond = Condvar::new(); - (*f).task_thread.pending_tasks = Default::default(); + f.task_thread.lock = Mutex::new(()); + f.task_thread.cond = Condvar::new(); + f.task_thread.pending_tasks = Default::default(); } - (&mut (*f).task_thread.ttd as *mut Arc) - .write(Arc::clone(&(*c).task_thread)); - (*f).lf.last_sharpness = -(1 as c_int); - rav1d_refmvs_init(&mut (*f).rf); + (&mut f.task_thread.ttd as *mut Arc).write(Arc::clone(&(*c).task_thread)); + f.lf.last_sharpness = -(1 as c_int); + rav1d_refmvs_init(&mut f.rf); n = n.wrapping_add(1); } (*c).tc = (0..n_tc) @@ -531,15 +529,13 @@ unsafe fn drain_picture(c: &mut Rav1dContext, out: &mut Rav1dPicture) -> Rav1dRe let mut drained = 0; loop { let next: c_uint = c.frame_thread.next; - let f: *mut Rav1dFrameContext = - &mut *(c.fc).offset(next as isize) as *mut Rav1dFrameContext; + let f: &mut Rav1dFrameContext = &mut *(c.fc).offset(next as isize); let mut task_thread_lock = c.task_thread.delayed_fg.lock().unwrap(); - while !(*f).tiles.is_empty() { - task_thread_lock = (*f).task_thread.cond.wait(task_thread_lock).unwrap(); + while !f.tiles.is_empty() { + task_thread_lock = f.task_thread.cond.wait(task_thread_lock).unwrap(); } let out_delayed = &mut c.frame_thread.out_delayed[next as usize]; - if !out_delayed.p.data.data[0].is_null() - || (*f).task_thread.error.load(Ordering::SeqCst) != 0 + if !out_delayed.p.data.data[0].is_null() || f.task_thread.error.load(Ordering::SeqCst) != 0 { let first: c_uint = c.task_thread.first.load(Ordering::SeqCst); if first.wrapping_add(1 as c_uint) < c.n_fc { @@ -567,9 +563,9 @@ unsafe fn drain_picture(c: &mut Rav1dContext, out: &mut Rav1dPicture) -> Rav1dRe c.frame_thread.next = 0 as c_int as c_uint; } drop(task_thread_lock); - let error = (*f).task_thread.retval; + let error = f.task_thread.retval; if error.is_err() { - (*f).task_thread.retval = Ok(()); + f.task_thread.retval = Ok(()); *c.cached_error_props.get_mut().unwrap() = out_delayed.p.m.clone(); rav1d_thread_picture_unref(out_delayed); return error; @@ -831,10 +827,9 @@ pub(crate) unsafe fn rav1d_flush(c: *mut Rav1dContext) { if next == (*c).n_fc { next = 0 as c_int as c_uint; } - let f: *mut Rav1dFrameContext = - &mut *((*c).fc).offset(next as isize) as *mut Rav1dFrameContext; - rav1d_decode_frame_exit(&*c, &mut *f, Err(EGeneric)); - (*f).task_thread.retval = Ok(()); + let f: &mut Rav1dFrameContext = &mut *((*c).fc).offset(next as isize); + rav1d_decode_frame_exit(&*c, f, Err(EGeneric)); + f.task_thread.retval = Ok(()); let out_delayed = &mut (*c).frame_thread.out_delayed[next as usize]; if out_delayed.p.frame_hdr.is_some() { rav1d_thread_picture_unref(out_delayed); @@ -902,46 +897,43 @@ impl Drop for Rav1dContext { } let mut n_1: c_uint = 0 as c_int as c_uint; while !(self.fc).is_null() && n_1 < self.n_fc { - let f: *mut Rav1dFrameContext = - &mut *(self.fc).offset(n_1 as isize) as *mut Rav1dFrameContext; + let f: &mut Rav1dFrameContext = &mut *(self.fc).offset(n_1 as isize); if self.n_fc > 1 as c_uint { freep( - &mut (*f).tile_thread.lowest_pixel_mem as *mut *mut [[c_int; 2]; 7] + &mut f.tile_thread.lowest_pixel_mem as *mut *mut [[c_int; 2]; 7] as *mut c_void, ); - let _ = mem::take(&mut (*f).frame_thread.b); // TODO: remove when context is owned + let _ = mem::take(&mut f.frame_thread.b); // TODO: remove when context is owned + rav1d_freep_aligned(&mut f.frame_thread.pal_idx as *mut *mut u8 as *mut c_void); + rav1d_freep_aligned(&mut f.frame_thread.cf as *mut *mut DynCoef as *mut c_void); + freep(&mut f.frame_thread.tile_start_off as *mut *mut c_int as *mut c_void); rav1d_freep_aligned( - &mut (*f).frame_thread.pal_idx as *mut *mut u8 as *mut c_void, + &mut f.frame_thread.pal as *mut *mut [[u16; 8]; 3] as *mut c_void, ); - rav1d_freep_aligned( - &mut (*f).frame_thread.cf as *mut *mut DynCoef as *mut c_void, - ); - freep(&mut (*f).frame_thread.tile_start_off as *mut *mut c_int as *mut c_void); - rav1d_freep_aligned( - &mut (*f).frame_thread.pal as *mut *mut [[u16; 8]; 3] as *mut c_void, - ); - let _ = mem::take(&mut (*f).frame_thread.cbi); // TODO: remove when context is owned + let _ = mem::take(&mut f.frame_thread.cbi); // TODO: remove when context is owned } if self.tc.len() > 1 { - let _ = mem::take(&mut (*f).task_thread.pending_tasks); // TODO: remove when context is owned + let _ = mem::take(&mut f.task_thread.pending_tasks); // TODO: remove when context is owned } - mem::take(&mut (*f).frame_thread.frame_progress); // TODO: remove when context is owned - mem::take(&mut (*f).frame_thread.copy_lpf_progress); // TODO: remove when context is owned - freep(&mut (*f).task_thread.tasks as *mut *mut Rav1dTask as *mut c_void); - freep(&mut *((*f).task_thread.tile_tasks).as_mut_ptr().offset(0) - as *mut *mut Rav1dTask as *mut c_void); - rav1d_free_aligned((*f).ts as *mut c_void); - rav1d_free_aligned((*f).ipred_edge[0] as *mut c_void); - free((*f).a as *mut c_void); - let _ = mem::take(&mut (*f).tiles); - free((*f).lf.mask as *mut c_void); - free((*f).lf.lr_mask as *mut c_void); - let _ = mem::take(&mut (*f).lf.level); - free((*f).lf.tx_lpf_right_edge[0] as *mut c_void); - 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); - rav1d_free_aligned((*f).lf.lr_line_buf as *mut c_void); + mem::take(&mut f.frame_thread.frame_progress); // TODO: remove when context is owned + mem::take(&mut f.frame_thread.copy_lpf_progress); // TODO: remove when context is owned + freep(&mut f.task_thread.tasks as *mut *mut Rav1dTask as *mut c_void); + freep( + &mut *(f.task_thread.tile_tasks).as_mut_ptr().offset(0) as *mut *mut Rav1dTask + as *mut c_void, + ); + rav1d_free_aligned(f.ts as *mut c_void); + rav1d_free_aligned(f.ipred_edge[0] as *mut c_void); + free(f.a as *mut c_void); + let _ = mem::take(&mut f.tiles); + free(f.lf.mask as *mut c_void); + free(f.lf.lr_mask as *mut c_void); + let _ = mem::take(&mut f.lf.level); + free(f.lf.tx_lpf_right_edge[0] as *mut c_void); + 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); + rav1d_free_aligned(f.lf.lr_line_buf as *mut c_void); n_1 = n_1.wrapping_add(1); } rav1d_free_aligned(self.fc as *mut c_void); diff --git a/src/lr_apply.rs b/src/lr_apply.rs index 6b9351dcd..ffede2676 100644 --- a/src/lr_apply.rs +++ b/src/lr_apply.rs @@ -29,7 +29,7 @@ pub const LR_RESTORE_Y: LrRestorePlanes = 1; unsafe fn lr_stripe( c: &Rav1dContext, - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, mut p: *mut BD::Pixel, mut left: *const [BD::Pixel; 4], x: c_int, @@ -40,12 +40,12 @@ unsafe fn lr_stripe( lr: Av1RestorationUnit, mut edges: LrEdgeFlags, ) { - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); - let dsp: *const Rav1dDSPContext = (*f).dsp; + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); + let dsp: *const Rav1dDSPContext = f.dsp; let chroma = (plane != 0) as c_int; let ss_ver = chroma - & ((*f).sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; - let stride: ptrdiff_t = (*f).sr_cur.p.stride[chroma as usize]; + & (f.sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let stride: ptrdiff_t = f.sr_cur.p.stride[chroma as usize]; let sby = y + (if y != 0 { (8 as c_int) << ss_ver @@ -53,7 +53,7 @@ unsafe fn lr_stripe( 0 as c_int }) >> 6 - ss_ver + seq_hdr.sb128; let have_tt = (c.tc.len() > 1) as c_int; - let mut lpf: *const BD::Pixel = ((*f).lf.lr_lpf_line[plane as usize] as *mut BD::Pixel) + let mut lpf: *const BD::Pixel = (f.lf.lr_lpf_line[plane as usize] as *mut BD::Pixel) .offset( (have_tt * (sby * ((4 as c_int) << seq_hdr.sb128) - 4)) as isize * BD::pxstride(stride as usize) as isize, @@ -120,7 +120,7 @@ unsafe fn lr_stripe( // Change the HAVE_BOTTOM bit in edges to (sby + 1 != f->sbh || y + stripe_h != row_h) edges = ::core::mem::transmute::( edges as c_uint - ^ (-((sby + 1 != (*f).sbh || y + stripe_h != row_h) as c_int) as c_uint + ^ (-((sby + 1 != f.sbh || y + stripe_h != row_h) as c_int) as c_uint ^ edges as c_uint) & LR_HAVE_BOTTOM as c_int as c_uint, ); @@ -133,7 +133,7 @@ unsafe fn lr_stripe( stripe_h, &mut params, edges, - (*f).bitdepth_max, + f.bitdepth_max, ); left = left.offset(stripe_h as isize); y += stripe_h; @@ -169,7 +169,7 @@ unsafe fn backup4xU( unsafe fn lr_sbrow( c: &Rav1dContext, - f: *const Rav1dFrameContext, + f: &Rav1dFrameContext, mut p: *mut BD::Pixel, y: c_int, w: c_int, @@ -179,11 +179,11 @@ unsafe fn lr_sbrow( ) { let chroma = (plane != 0) as c_int; let ss_ver = chroma - & ((*f).sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + & (f.sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; let ss_hor = chroma - & ((*f).sr_cur.p.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; - let p_stride: ptrdiff_t = (*f).sr_cur.p.stride[chroma as usize]; - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + & (f.sr_cur.p.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + let p_stride: ptrdiff_t = f.sr_cur.p.stride[chroma as usize]; + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); let unit_size_log2 = frame_hdr.restoration.unit_size[(plane != 0) as c_int as usize]; let unit_size = (1 as c_int) << unit_size_log2; let half_unit_size = unit_size >> 1; @@ -202,16 +202,16 @@ unsafe fn lr_sbrow( aligned_unit_pos -= unit_size; } aligned_unit_pos <<= ss_ver; - let sb_idx = (aligned_unit_pos >> 7) * (*f).sr_sb128w; + let sb_idx = (aligned_unit_pos >> 7) * f.sr_sb128w; let unit_idx = (aligned_unit_pos >> 6 & 1) << 1; - lr[0] = (*((*f).lf.lr_mask).offset(sb_idx as isize)).lr[plane as usize][unit_idx as usize]; + lr[0] = (*(f.lf.lr_mask).offset(sb_idx as isize)).lr[plane as usize][unit_idx as usize]; let mut restore = (lr[0].r#type as c_int != RAV1D_RESTORATION_NONE as c_int) as c_int; let mut x = 0; let mut bit = 0; while x + max_unit_size <= w { let next_x = x + unit_size; let next_u_idx = unit_idx + (next_x >> shift_hor - 1 & 1); - lr[(bit == 0) as c_int as usize] = (*((*f).lf.lr_mask) + lr[(bit == 0) as c_int as usize] = (*(f.lf.lr_mask) .offset((sb_idx + (next_x >> shift_hor)) as isize)) .lr[plane as usize][next_u_idx as usize]; let restore_next = (lr[(bit == 0) as c_int as usize].r#type as c_int @@ -270,18 +270,18 @@ unsafe fn lr_sbrow( pub(crate) unsafe fn rav1d_lr_sbrow( c: &Rav1dContext, - f: *mut Rav1dFrameContext, + f: &mut Rav1dFrameContext, dst: *const *mut BD::Pixel, sby: c_int, ) { let offset_y = 8 * (sby != 0) as c_int; - let dst_stride: *const ptrdiff_t = ((*f).sr_cur.p.stride).as_mut_ptr(); - let restore_planes = (*f).lf.restore_planes; - let not_last = ((sby + 1) < (*f).sbh) as c_int; - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let dst_stride: *const ptrdiff_t = (f.sr_cur.p.stride).as_mut_ptr(); + let restore_planes = f.lf.restore_planes; + let not_last = ((sby + 1) < f.sbh) as c_int; + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); if restore_planes & LR_RESTORE_Y as c_int != 0 { - let h = (*f).sr_cur.p.p.h; - let w = (*f).sr_cur.p.p.w; + let h = f.sr_cur.p.p.h; + let w = f.sr_cur.p.p.w; let next_row_y = (sby + 1) << 6 + seq_hdr.sb128; let row_h = cmp::min(next_row_y - 8 * not_last, h); let y_stripe = (sby << 6 + seq_hdr.sb128) - offset_y; @@ -299,12 +299,12 @@ pub(crate) unsafe fn rav1d_lr_sbrow( ); } if restore_planes & (LR_RESTORE_U as c_int | LR_RESTORE_V as c_int) != 0 { - let ss_ver = ((*f).sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) - as c_int; - let ss_hor = ((*f).sr_cur.p.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) - as c_int; - let h_0 = (*f).sr_cur.p.p.h + ss_ver >> ss_ver; - let w_0 = (*f).sr_cur.p.p.w + ss_hor >> ss_hor; + let ss_ver = + (f.sr_cur.p.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = + (f.sr_cur.p.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + let h_0 = f.sr_cur.p.p.h + ss_ver >> ss_ver; + let w_0 = f.sr_cur.p.p.w + ss_hor >> ss_hor; let next_row_y_0 = (sby + 1) << 6 - ss_ver + seq_hdr.sb128; let row_h_0 = cmp::min(next_row_y_0 - (8 >> ss_ver) * not_last, h_0); let offset_uv = offset_y >> ss_ver; diff --git a/src/obu.rs b/src/obu.rs index 62e75af4e..1ede8a71f 100644 --- a/src/obu.rs +++ b/src/obu.rs @@ -2523,12 +2523,12 @@ unsafe fn parse_obus( } let f = &mut *c.fc.offset(next as isize); - while !(*f).tiles.is_empty() { - task_thread_lock = (*f).task_thread.cond.wait(task_thread_lock).unwrap(); + while !f.tiles.is_empty() { + task_thread_lock = f.task_thread.cond.wait(task_thread_lock).unwrap(); } let out_delayed = &mut c.frame_thread.out_delayed[next as usize]; if !out_delayed.p.data.data[0].is_null() - || (*f).task_thread.error.load(Ordering::SeqCst) != 0 + || f.task_thread.error.load(Ordering::SeqCst) != 0 { let first = c.task_thread.first.load(Ordering::SeqCst); if first + 1 < c.n_fc { @@ -2548,10 +2548,10 @@ unsafe fn parse_obus( c.task_thread.cur.fetch_sub(1, Ordering::Relaxed); } } - let error = (*f).task_thread.retval; + let error = f.task_thread.retval; if error.is_err() { c.cached_error = error; - (*f).task_thread.retval = Ok(()); + f.task_thread.retval = Ok(()); *c.cached_error_props.get_mut().unwrap() = out_delayed.p.m.clone(); rav1d_thread_picture_unref(out_delayed); } else if !(out_delayed.p.data.data[0]).is_null() { diff --git a/src/recon.rs b/src/recon.rs index 2d877109d..eb44d4bbf 100644 --- a/src/recon.rs +++ b/src/recon.rs @@ -1,6 +1,7 @@ use crate::include::common::bitdepth::AsPrimitive; use crate::include::common::bitdepth::BitDepth; use crate::include::common::bitdepth::DynCoef; +use crate::include::common::bitdepth::BPC; use crate::include::common::dump::ac_dump; use crate::include::common::dump::coef_dump; use crate::include::common::dump::hex_dump; @@ -466,18 +467,18 @@ unsafe fn decode_coefs( let current_block: u64; let ts: *mut Rav1dTileState = (*t).ts; let chroma = (plane != 0) as c_int; - let f: *const Rav1dFrameContext = (*t).f; - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + let f: &Rav1dFrameContext = &*(*t).f; + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); let lossless = frame_hdr.segmentation.lossless[b.seg_id as usize]; let t_dim = &dav1d_txfm_dimensions[tx as usize]; - let dbg = (debug_block_info!(&*f, &*t) && plane != 0 && false) as c_int; + let dbg = (debug_block_info!(f, &*t) && plane != 0 && false) as c_int; if dbg != 0 { printf( b"Start: r=%d\n\0" as *const u8 as *const c_char, (*ts).msac.rng, ); } - let sctx = get_skip_ctx(t_dim, bs, a, l, chroma, (*f).cur.p.layout) as c_int; + let sctx = get_skip_ctx(t_dim, bs, a, l, chroma, f.cur.p.layout) as c_int; let all_skip = rav1d_msac_decode_bool_adapt( &mut (*ts).msac, &mut (*ts).cdf.coef.skip[(*t_dim).ctx as usize][sctx as usize], @@ -1420,13 +1421,16 @@ unsafe fn decode_coefs( } let dq_tbl: *const u16 = ((*((*ts).dq).offset(b.seg_id as isize))[plane as usize]).as_ptr(); let qm_tbl: *const u8 = if (*txtp as c_uint) < IDTX as c_int as c_uint { - (*f).qm[tx as usize][plane as usize] + f.qm[tx as usize][plane as usize] } else { 0 as *const u8 }; let dq_shift = cmp::max(0 as c_int, (*t_dim).ctx as c_int - 2); - let cf_max = - !(!(127 as c_uint) << (if 16 == 8 { 8 as c_int } else { (*f).cur.p.bpc })) as c_int; + let cf_max = !(!(127 as c_uint) + << (match BD::BPC { + BPC::BPC8 => 8, + BPC::BPC16 => f.cur.p.bpc, + })) as c_int; let mut cul_level: c_uint; let dc_sign_level: c_uint; if dc_tok == 0 { @@ -1627,7 +1631,7 @@ unsafe fn read_coef_tree( ) { let f: &mut Rav1dFrameContext = &mut *(*t).f; let ts: *mut Rav1dTileState = (*t).ts; - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; let t_dim: *const TxfmInfo = &*dav1d_txfm_dimensions.as_ptr().offset(ytx as isize) as *const TxfmInfo; let txw = (*t_dim).w as c_int; @@ -1653,7 +1657,7 @@ unsafe fn read_coef_tree( dst, ); (*t).bx += txsw; - if txw >= txh && (*t).bx < (*f).bw { + if txw >= txh && (*t).bx < f.bw { read_coef_tree::( t, bs, @@ -1672,11 +1676,10 @@ unsafe fn read_coef_tree( } (*t).bx -= txsw; (*t).by += txsh; - if txh >= txw && (*t).by < (*f).bh { + if txh >= txw && (*t).by < f.bh { if !dst.is_null() { - dst = dst.offset( - (4 * txsh) as isize * BD::pxstride((*f).cur.stride[0] as usize) as isize, - ); + dst = dst + .offset((4 * txsh) as isize * BD::pxstride(f.cur.stride[0] as usize) as isize); } read_coef_tree::( t, @@ -1690,7 +1693,7 @@ unsafe fn read_coef_tree( dst, ); (*t).bx += txsw; - if txw >= txh && (*t).bx < (*f).bw { + if txw >= txh && (*t).bx < f.bw { read_coef_tree::( t, bs, @@ -1730,8 +1733,8 @@ unsafe fn read_coef_tree( * cmp::min((*t_dim).h as c_int, 8 as c_int) * 16) as isize, ) as *mut DynCoef; - cbi = &mut (*f).frame_thread.cbi - [((*t).by as isize * (*f).b4_stride + (*t).bx as isize) as usize]; + cbi = &mut f.frame_thread.cbi + [((*t).by as isize * f.b4_stride + (*t).bx as isize) as usize]; } else { cf = BD::select_mut(&mut (*t).cf).0.as_mut_ptr(); } @@ -1761,8 +1764,8 @@ unsafe fn read_coef_tree( CaseSet::<16, true>::many( [&mut (*t).l, &mut *(*t).a], [ - cmp::min(txh, (*f).bh - (*t).by) as usize, - cmp::min(txw, (*f).bw - (*t).bx) as usize, + cmp::min(txh, f.bh - (*t).by) as usize, + cmp::min(txw, f.bw - (*t).bx) as usize, ], [by4 as usize, bx4 as usize], |case, dir| { @@ -1800,15 +1803,15 @@ unsafe fn read_coef_tree( ((*dsp).itx.itxfm_add[ytx as usize][txtp as usize]) .expect("non-null function pointer")( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], cf.cast(), eob, - (*f).bitdepth_max, + f.bitdepth_max, ); if debug_block_info!(f, &*t) && 0 != 0 { hex_dump::( dst, - (*f).cur.stride[0] as usize, + f.cur.stride[0] as usize, (*t_dim).w as usize * 4, (*t_dim).h as usize * 4, "recon", @@ -1824,11 +1827,9 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( bs: BlockSize, b: &Av1Block, ) { - let f: *mut Rav1dFrameContext = t.f; - let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; - let ss_hor = - ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + let f: &mut Rav1dFrameContext = &mut *t.f; + let ss_ver = (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let bx4 = t.bx & 31; let by4 = t.by & 31; let cbx4 = bx4 >> ss_hor; @@ -1838,7 +1839,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( let bh4 = *b_dim.offset(1) as c_int; let cbw4 = bw4 + ss_hor >> ss_hor; let cbh4 = bh4 + ss_ver >> ss_ver; - let has_chroma = ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint + let has_chroma = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint && (bw4 > ss_hor || t.bx & 1 != 0) && (bh4 > ss_ver || t.by & 1 != 0)) as c_int; if b.skip != 0 { @@ -1864,8 +1865,8 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( return; } let ts: *mut Rav1dTileState = t.ts; - let w4 = cmp::min(bw4, (*f).bw - t.bx); - let h4 = cmp::min(bh4, (*f).bh - t.by); + let w4 = cmp::min(bw4, f.bw - t.bx); + let h4 = cmp::min(bh4, f.bh - t.by); let cw4 = w4 + ss_hor >> ss_hor; let ch4 = h4 + ss_ver >> ss_ver; if !(t.frame_thread.pass == 1) { @@ -1899,7 +1900,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( y = init_y; t.by += init_y; while y < sub_h4 { - let cbi = &mut (*f).frame_thread.cbi[(t.by as isize * (*f).b4_stride) as usize..]; + let cbi = &mut f.frame_thread.cbi[(t.by as isize * f.b4_stride) as usize..]; let mut x_off = (init_x != 0) as c_int; x = init_x; t.bx += init_x; @@ -1934,7 +1935,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( &mut cf_ctx, ) as i16; let eob = *fresh4 as c_int; - if debug_block_info!(&*f, t) { + if debug_block_info!(f, t) { printf( b"Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n\0" as *const u8 as *const c_char, @@ -1954,8 +1955,8 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( CaseSet::<16, true>::many( [&mut t.l, &mut *t.a], [ - cmp::min((*t_dim).h as i32, (*f).bh - t.by) as usize, - cmp::min((*t_dim).w as i32, (*f).bw - t.bx) as usize, + cmp::min((*t_dim).h as i32, f.bh - t.by) as usize, + cmp::min((*t_dim).w as i32, f.bw - t.bx) as usize, ], [(by4 + y) as usize, (bx4 + x) as usize], |case, dir| { @@ -1981,8 +1982,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( y = init_y >> ss_ver; t.by += init_y; while y < sub_ch4 { - let cbi = - &mut (*f).frame_thread.cbi[(t.by as isize * (*f).b4_stride) as usize..]; + let cbi = &mut f.frame_thread.cbi[(t.by as isize * f.b4_stride) as usize..]; x = init_x >> ss_hor; t.bx += init_x; while x < sub_cw4 { @@ -2008,7 +2008,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( &mut cf_ctx, ) as i16; let eob = *fresh5 as c_int; - if debug_block_info!(&*f, t) { + if debug_block_info!(f, t) { printf( b"Post-uv-cf-blk[pl=%d,tx=%d,txtp=%d,eob=%d]: r=%d\n\0" as *const u8 @@ -2028,14 +2028,10 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( CaseSet::<16, true>::many( [&mut t.l, &mut *t.a], [ - cmp::min( - (*uv_t_dim).h as i32, - (*f).bh - t.by + ss_ver >> ss_ver, - ) as usize, - cmp::min( - (*uv_t_dim).w as i32, - (*f).bw - t.bx + ss_hor >> ss_hor, - ) as usize, + cmp::min((*uv_t_dim).h as i32, f.bh - t.by + ss_ver >> ss_ver) + as usize, + cmp::min((*uv_t_dim).w as i32, f.bw - t.bx + ss_hor >> ss_hor) + as usize, ], [(cby4 + y) as usize, (cbx4 + x) as usize], |case, dir| { @@ -2080,13 +2076,11 @@ unsafe fn mc( { unreachable!(); } - let f: *const Rav1dFrameContext = (*t).f; - let ss_ver = (pl != 0 - && (*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) - as c_int; - let ss_hor = (pl != 0 - && (*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) - as c_int; + let f: &Rav1dFrameContext = &*(*t).f; + let ss_ver = + (pl != 0 && f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = + (pl != 0 && f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let h_mul = 4 >> ss_hor; let v_mul = 4 >> ss_ver; let mvx = mv.x as c_int; @@ -2095,17 +2089,17 @@ unsafe fn mc( let my = mvy & 15 >> (ss_ver == 0) as c_int; let mut ref_stride: ptrdiff_t = (*refp).p.stride[(pl != 0) as c_int as usize]; let r#ref: *const BD::Pixel; - if (*refp).p.p.w == (*f).cur.p.w && (*refp).p.p.h == (*f).cur.p.h { + if (*refp).p.p.w == f.cur.p.w && (*refp).p.p.h == f.cur.p.h { let dx = bx * h_mul + (mvx >> 3 + ss_hor); let dy = by * v_mul + (mvy >> 3 + ss_ver); let w; let h; - if (*refp).p.data.data[0] != (*f).cur.data.data[0] { - w = (*f).cur.p.w + ss_hor >> ss_hor; - h = (*f).cur.p.h + ss_ver >> ss_ver; + if (*refp).p.data.data[0] != f.cur.data.data[0] { + w = f.cur.p.w + ss_hor >> ss_hor; + h = f.cur.p.h + ss_ver >> ss_ver; } else { - w = (*f).bw * 4 >> ss_hor; - h = (*f).bh * 4 >> ss_ver; + w = f.bw * 4 >> ss_hor; + h = f.bh * 4 >> ss_ver; } if dx < (mx != 0) as c_int * 3 || dy < (my != 0) as c_int * 3 @@ -2114,7 +2108,7 @@ unsafe fn mc( { let emu_edge_buf = BD::select_mut(&mut (*t).scratch.c2rust_unnamed.emu_edge).as_mut_ptr(); - ((*(*f).dsp).mc.emu_edge)( + ((*f.dsp).mc.emu_edge)( (bw4 * h_mul + (mx != 0) as c_int * 7) as intptr_t, (bh4 * v_mul + (my != 0) as c_int * 7) as intptr_t, w as intptr_t, @@ -2140,7 +2134,7 @@ unsafe fn mc( .offset(dx as isize); } if !dst8.is_null() { - (*(*f).dsp).mc.mc[filter_2d as usize]( + (*f.dsp).mc.mc[filter_2d as usize]( dst8.cast(), dst_stride, r#ref.cast(), @@ -2149,10 +2143,10 @@ unsafe fn mc( bh4 * v_mul, mx << (ss_hor == 0) as c_int, my << (ss_ver == 0) as c_int, - (*f).bitdepth_max, + f.bitdepth_max, ); } else { - (*(*f).dsp).mc.mct[filter_2d as usize]( + (*f.dsp).mc.mct[filter_2d as usize]( dst16, r#ref.cast(), ref_stride, @@ -2160,25 +2154,25 @@ unsafe fn mc( bh4 * v_mul, mx << (ss_hor == 0) as c_int, my << (ss_ver == 0) as c_int, - (*f).bitdepth_max, + f.bitdepth_max, ); } } else { - if !(refp != &(*f).sr_cur as *const Rav1dThreadPicture) { + if !(refp != &f.sr_cur as *const Rav1dThreadPicture) { unreachable!(); } let orig_pos_y = (by * v_mul << 4) + mvy * ((1 as c_int) << (ss_ver == 0) as c_int); let orig_pos_x = (bx * h_mul << 4) + mvx * ((1 as c_int) << (ss_hor == 0) as c_int); let pos_y; let pos_x; - let tmp: i64 = orig_pos_x as i64 * (*f).svc[refidx as usize][0].scale as i64 - + (((*f).svc[refidx as usize][0].scale - 0x4000 as c_int) * 8) as i64; + let tmp: i64 = orig_pos_x as i64 * f.svc[refidx as usize][0].scale as i64 + + ((f.svc[refidx as usize][0].scale - 0x4000 as c_int) * 8) as i64; pos_x = apply_sign64( ((tmp as c_longlong).abs() + 128 as c_longlong >> 8) as c_int, tmp, ) + 32; - let tmp: i64 = orig_pos_y as i64 * (*f).svc[refidx as usize][1].scale as i64 - + (((*f).svc[refidx as usize][1].scale - 0x4000 as c_int) * 8) as i64; + let tmp: i64 = orig_pos_y as i64 * f.svc[refidx as usize][1].scale as i64 + + ((f.svc[refidx as usize][1].scale - 0x4000 as c_int) * 8) as i64; pos_y = apply_sign64( ((tmp as c_longlong).abs() + 128 as c_longlong >> 8) as c_int, tmp, @@ -2193,12 +2187,12 @@ unsafe fn mc( left, top, orig_pos_x, - (*f).svc[refidx as usize][0].scale, + f.svc[refidx as usize][0].scale, refidx, right - left, bottom - top, - (*f).svc[refidx as usize][0].step, - (*f).svc[refidx as usize][1].step, + f.svc[refidx as usize][0].step, + f.svc[refidx as usize][1].step, ); } let w = (*refp).p.p.w + ss_hor >> ss_hor; @@ -2206,7 +2200,7 @@ unsafe fn mc( if left < 3 || top < 3 || right + 4 > w || bottom + 4 > h { let emu_edge_buf = BD::select_mut(&mut (*t).scratch.c2rust_unnamed.emu_edge).as_mut_ptr(); - ((*(*f).dsp).mc.emu_edge)( + ((*f.dsp).mc.emu_edge)( (right - left + 7) as intptr_t, (bottom - top + 7) as intptr_t, w as intptr_t, @@ -2233,7 +2227,7 @@ unsafe fn mc( .offset(left as isize); } if !dst8.is_null() { - (*(*f).dsp).mc.mc_scaled[filter_2d as usize]( + (*f.dsp).mc.mc_scaled[filter_2d as usize]( dst8.cast(), dst_stride, r#ref.cast(), @@ -2242,12 +2236,12 @@ unsafe fn mc( bh4 * v_mul, pos_x & 0x3ff as c_int, pos_y & 0x3ff as c_int, - (*f).svc[refidx as usize][0].step, - (*f).svc[refidx as usize][1].step, - (*f).bitdepth_max, + f.svc[refidx as usize][0].step, + f.svc[refidx as usize][1].step, + f.bitdepth_max, ); } else { - (*(*f).dsp).mc.mct_scaled[filter_2d as usize]( + (*f.dsp).mc.mct_scaled[filter_2d as usize]( dst16, r#ref.cast(), ref_stride, @@ -2255,9 +2249,9 @@ unsafe fn mc( bh4 * v_mul, pos_x & 0x3ff as c_int, pos_y & 0x3ff as c_int, - (*f).svc[refidx as usize][0].step, - (*f).svc[refidx as usize][1].step, - (*f).bitdepth_max, + f.svc[refidx as usize][0].step, + f.svc[refidx as usize][1].step, + f.bitdepth_max, ); } } @@ -2278,18 +2272,16 @@ unsafe fn obmc( if !((*t).bx & 1 == 0 && (*t).by & 1 == 0) { unreachable!(); } - let f: *const Rav1dFrameContext = (*t).f; + let f: &Rav1dFrameContext = &*(*t).f; let r: *mut *mut refmvs_block = &mut *((*t).rt.r) .as_mut_ptr() .offset((((*t).by & 31) + 5) as isize) as *mut *mut refmvs_block; let lap = BD::select_mut(&mut (*t).scratch.c2rust_unnamed.c2rust_unnamed.lap).as_mut_ptr(); - let ss_ver = (pl != 0 - && (*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) - as c_int; - let ss_hor = (pl != 0 - && (*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) - as c_int; + let ss_ver = + (pl != 0 && f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = + (pl != 0 && f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let h_mul = 4 >> ss_hor; let v_mul = 4 >> ss_ver; let mut res; @@ -2320,7 +2312,7 @@ unsafe fn obmc( (*t).by, pl, (*a_r).0.mv.mv[0], - &*((*f).refp) + &*(f.refp) .as_ptr() .offset((*((*a_r).0.r#ref.r#ref).as_ptr().offset(0) as c_int - 1) as isize), (*a_r).0.r#ref.r#ref[0] as c_int - 1, @@ -2331,7 +2323,7 @@ unsafe fn obmc( if res != 0 { return res; } - ((*(*f).dsp).mc.blend_h)( + ((*f.dsp).mc.blend_h)( dst.offset((x * h_mul) as isize).cast(), dst_stride, lap.cast(), @@ -2368,7 +2360,7 @@ unsafe fn obmc( (*t).by + y, pl, (*l_r).0.mv.mv[0], - &*((*f).refp) + &*(f.refp) .as_ptr() .offset((*((*l_r).0.r#ref.r#ref).as_ptr().offset(0) as c_int - 1) as isize), (*l_r).0.r#ref.r#ref[0] as c_int - 1, @@ -2379,7 +2371,7 @@ unsafe fn obmc( if res != 0 { return res; } - ((*(*f).dsp).mc.blend_v)( + ((*f.dsp).mc.blend_v)( dst.offset((y * v_mul) as isize * BD::pxstride(dst_stride as usize) as isize) .cast(), dst_stride, @@ -2411,14 +2403,12 @@ unsafe fn warp_affine( { unreachable!(); } - let f: *const Rav1dFrameContext = (*t).f; - let dsp: *const Rav1dDSPContext = (*f).dsp; - let ss_ver = (pl != 0 - && (*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) - as c_int; - let ss_hor = (pl != 0 - && (*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) - as c_int; + let f: &Rav1dFrameContext = &*(*t).f; + let dsp: *const Rav1dDSPContext = f.dsp; + let ss_ver = + (pl != 0 && f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = + (pl != 0 && f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let h_mul = 4 >> ss_hor; let v_mul = 4 >> ss_ver; if !(*b_dim.offset(0) as c_int * h_mul & 7 == 0 && *b_dim.offset(1) as c_int * v_mul & 7 == 0) { @@ -2452,7 +2442,7 @@ unsafe fn warp_affine( if dx < 3 || dx + 8 + 4 > width || dy < 3 || dy + 8 + 4 > height { let emu_edge_buf = BD::select_mut(&mut (*t).scratch.c2rust_unnamed.emu_edge).as_mut_ptr(); - ((*(*f).dsp).mc.emu_edge)( + ((*f.dsp).mc.emu_edge)( 15 as c_int as intptr_t, 15 as c_int as intptr_t, width as intptr_t, @@ -2484,7 +2474,7 @@ unsafe fn warp_affine( (*wmp).abcd.get().as_ptr(), mx, my, - (*f).bitdepth_max, + f.bitdepth_max, ); } else { ((*dsp).mc.warp8x8)( @@ -2495,7 +2485,7 @@ unsafe fn warp_affine( (*wmp).abcd.get().as_ptr(), mx, my, - (*f).bitdepth_max, + f.bitdepth_max, ); } x += 8 as c_int; @@ -2517,25 +2507,23 @@ pub(crate) unsafe fn rav1d_recon_b_intra( b: &Av1Block, ) { let ts: *mut Rav1dTileState = t.ts; - let f: *mut Rav1dFrameContext = t.f; + let f: &mut Rav1dFrameContext = &mut *t.f; - let dsp: *const Rav1dDSPContext = (*f).dsp; + let dsp: *const Rav1dDSPContext = f.dsp; let bx4 = t.bx & 31; let by4 = t.by & 31; - let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; - let ss_hor = - ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + let ss_ver = (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let cbx4 = bx4 >> ss_hor; let cby4 = by4 >> ss_ver; let b_dim: *const u8 = (dav1d_block_dimensions[bs as usize]).as_ptr(); let bw4 = *b_dim.offset(0) as c_int; let bh4 = *b_dim.offset(1) as c_int; - let w4 = cmp::min(bw4, (*f).bw - t.bx); - let h4 = cmp::min(bh4, (*f).bh - t.by); + let w4 = cmp::min(bw4, f.bw - t.bx); + let h4 = cmp::min(bh4, f.bh - t.by); let cw4 = w4 + ss_hor >> ss_hor; let ch4 = h4 + ss_ver >> ss_ver; - let has_chroma = ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint + let has_chroma = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint && (bw4 > ss_hor || t.bx & 1 != 0) && (bh4 > ss_ver || t.by & 1 != 0)) as c_int; let t_dim: *const TxfmInfo = &*dav1d_txfm_dimensions @@ -2546,7 +2534,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( &*dav1d_txfm_dimensions.as_ptr().offset(b.uvtx as isize) as *const TxfmInfo; let cbw4 = bw4 + ss_hor >> ss_hor; let cbh4 = bh4 + ss_ver >> ss_ver; - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); let intra_edge_filter_flag = seq_hdr.intra_edge_filter << 10; let mut init_y = 0; while init_y < h4 { @@ -2555,8 +2543,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( let mut init_x = 0; while init_x < w4 { if b.c2rust_unnamed.c2rust_unnamed.pal_sz[0] != 0 { - let dst: *mut BD::Pixel = ((*f).cur.data.data[0] as *mut BD::Pixel).offset( - (4 * (t.by as isize * BD::pxstride((*f).cur.stride[0] as usize) as isize + let dst: *mut BD::Pixel = (f.cur.data.data[0] as *mut BD::Pixel).offset( + (4 * (t.by as isize * BD::pxstride(f.cur.stride[0] as usize) as isize + t.bx as isize)) as isize, ); let pal_idx: *const u8; @@ -2572,26 +2560,26 @@ pub(crate) unsafe fn rav1d_recon_b_intra( pal_idx = (t.scratch.c2rust_unnamed_0.pal_idx).as_mut_ptr(); } let pal: *const u16 = if t.frame_thread.pass != 0 { - ((*((*f).frame_thread.pal).offset( - (((t.by as isize >> 1) + (t.bx as isize & 1)) * ((*f).b4_stride >> 1) + ((*(f.frame_thread.pal).offset( + (((t.by as isize >> 1) + (t.bx as isize & 1)) * (f.b4_stride >> 1) + ((t.bx >> 1) + (t.by & 1)) as isize) as isize, ))[0]) .as_mut_ptr() } else { (t.scratch.c2rust_unnamed_0.pal[0]).as_mut_ptr() }; - (*(*f).dsp).ipred.pal_pred.call::( + (*f.dsp).ipred.pal_pred.call::( dst, - (*f).cur.stride[0], + f.cur.stride[0], pal, pal_idx, bw4 * 4, bh4 * 4, ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( dst, - BD::pxstride((*f).cur.stride[0] as usize), + BD::pxstride(f.cur.stride[0] as usize), bw4 as usize * 4, bh4 as usize * 4, "y-pal-pred", @@ -2621,8 +2609,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( y = init_y; t.by += init_y; while y < sub_h4 { - let mut dst: *mut BD::Pixel = ((*f).cur.data.data[0] as *mut BD::Pixel).offset( - (4 * (t.by as isize * BD::pxstride((*f).cur.stride[0] as usize) as isize + let mut dst: *mut BD::Pixel = (f.cur.data.data[0] as *mut BD::Pixel).offset( + (4 * (t.by as isize * BD::pxstride(f.cur.stride[0] as usize) as isize + t.bx as isize + init_x as isize)) as isize, ); @@ -2647,16 +2635,12 @@ pub(crate) unsafe fn rav1d_recon_b_intra( } else { EDGE_I444_LEFT_HAS_BOTTOM as c_int })) as EdgeFlags; - let top_sb_edge_slice = if t.by & (*f).sb_step - 1 == 0 { + let top_sb_edge_slice = if t.by & f.sb_step - 1 == 0 { let mut top_sb_edge: *const BD::Pixel = - (*f).ipred_edge[0] as *mut BD::Pixel; - let sby = t.by >> (*f).sb_shift; - top_sb_edge = - top_sb_edge.offset(((*f).sb128w * 128 * (sby - 1)) as isize); - Some(slice::from_raw_parts( - top_sb_edge, - (*f).sb128w as usize * 128, - )) + f.ipred_edge[0] as *mut BD::Pixel; + let sby = t.by >> f.sb_shift; + top_sb_edge = top_sb_edge.offset((f.sb128w * 128 * (sby - 1)) as isize); + Some(slice::from_raw_parts(top_sb_edge, f.sb128w as usize * 128)) } else { None }; @@ -2664,13 +2648,12 @@ pub(crate) unsafe fn rav1d_recon_b_intra( BD::select_mut(&mut t.scratch.c2rust_unnamed_0.interintra_edge); let edge_array = &mut interintra_edge.0.edge; let edge_offset = 128; - let data_stride = BD::pxstride((*f).cur.stride[0] as usize) as isize; + let data_stride = BD::pxstride(f.cur.stride[0] as usize) as isize; let data_width = 4 * (*ts).tiling.col_end; let data_height = 4 * (*ts).tiling.row_end; let data_diff = (data_height - 1) as isize * data_stride; let dst_slice = slice::from_raw_parts( - ((*f).cur.data.data[0] as *const BD::Pixel) - .offset(cmp::min(data_diff, 0)), + (f.cur.data.data[0] as *const BD::Pixel).offset(cmp::min(data_diff, 0)), data_diff.unsigned_abs() + data_width as usize, ); m = rav1d_prepare_intra_edges( @@ -2682,7 +2665,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( (*ts).tiling.row_end, edge_flags, dst_slice, - (*f).cur.stride[0], + f.cur.stride[0], top_sb_edge_slice, b.c2rust_unnamed.c2rust_unnamed.y_mode as IntraPredMode, &mut angle, @@ -2691,21 +2674,21 @@ pub(crate) unsafe fn rav1d_recon_b_intra( seq_hdr.intra_edge_filter, edge_array, edge_offset, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); let edge = edge_array.as_ptr().add(edge_offset); (*dsp).ipred.intra_pred[m as usize].call( dst, - (*f).cur.stride[0], + f.cur.stride[0], edge, (*t_dim).w as c_int * 4, (*t_dim).h as c_int * 4, angle | intra_flags, - 4 * (*f).bw - 4 * t.bx, - 4 * (*f).bh - 4 * t.by, - BD::from_c((*f).bitdepth_max), + 4 * f.bw - 4 * t.bx, + 4 * f.bh - 4 * t.by, + BD::from_c(f.bitdepth_max), ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( edge.offset(-(((*t_dim).h as c_int * 4) as isize)), (*t_dim).h as usize * 4, @@ -2723,7 +2706,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( ); hex_dump::( dst, - (*f).cur.stride[0] as usize, + f.cur.stride[0] as usize, (*t_dim).w as usize * 4, (*t_dim).h as usize * 4, "y-intra-pred", @@ -2743,8 +2726,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( * cmp::min((*t_dim).h as c_int, 8 as c_int) * 16) as isize, ) as *mut DynCoef; - let cbi = &mut (*f).frame_thread.cbi - [(t.by as isize * (*f).b4_stride + t.bx as isize) as usize]; + let cbi = &mut f.frame_thread.cbi + [(t.by as isize * f.b4_stride + t.bx as isize) as usize]; eob = cbi.eob[0] as c_int; txtp = cbi.txtp[0] as TxfmType; } else { @@ -2763,7 +2746,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( &mut txtp, &mut cf_ctx, ); - if debug_block_info!(&*f, t) { + if debug_block_info!(f, t) { printf( b"Post-y-cf-blk[tx=%d,txtp=%d,eob=%d]: r=%d\n\0" as *const u8 as *const c_char, @@ -2776,8 +2759,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( CaseSet::<16, true>::many( [&mut t.l, &mut *t.a], [ - cmp::min((*t_dim).h as i32, (*f).bh - t.by) as usize, - cmp::min((*t_dim).w as i32, (*f).bw - t.bx) as usize, + cmp::min((*t_dim).h as i32, f.bh - t.by) as usize, + cmp::min((*t_dim).w as i32, f.bw - t.bx) as usize, ], [(by4 + y) as usize, (bx4 + x) as usize], |case, dir| { @@ -2786,7 +2769,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( ); } if eob >= 0 { - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { coef_dump( cf, cmp::min((*t_dim).h as usize, 8) * 4, @@ -2799,15 +2782,15 @@ pub(crate) unsafe fn rav1d_recon_b_intra( [txtp as usize]) .expect("non-null function pointer")( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], cf.cast(), eob, - (*f).bitdepth_max, + f.bitdepth_max, ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( dst, - (*f).cur.stride[0] as usize, + f.cur.stride[0] as usize, (*t_dim).w as usize * 4, (*t_dim).h as usize * 4, "recon", @@ -2834,34 +2817,34 @@ pub(crate) unsafe fn rav1d_recon_b_intra( } t.by -= y; if !(has_chroma == 0) { - let stride: ptrdiff_t = (*f).cur.stride[1]; + let stride: ptrdiff_t = f.cur.stride[1]; if b.c2rust_unnamed.c2rust_unnamed.uv_mode as c_int == CFL_PRED as c_int { if !(init_x == 0 && init_y == 0) { unreachable!(); } let ac = &mut t.scratch.c2rust_unnamed_0.ac; - let y_src: *mut BD::Pixel = ((*f).cur.data.data[0] as *mut BD::Pixel) + let y_src: *mut BD::Pixel = (f.cur.data.data[0] as *mut BD::Pixel) .offset((4 * (t.bx & !ss_hor)) as isize) .offset( ((4 * (t.by & !ss_ver)) as isize - * BD::pxstride((*f).cur.stride[0] as usize) as isize) + * BD::pxstride(f.cur.stride[0] as usize) as isize) as isize, ); let uv_off: ptrdiff_t = 4 * ((t.bx >> ss_hor) as isize + (t.by >> ss_ver) as isize * BD::pxstride(stride as usize) as isize); let uv_dst: [*mut BD::Pixel; 2] = [ - ((*f).cur.data.data[1] as *mut BD::Pixel).offset(uv_off as isize), - ((*f).cur.data.data[2] as *mut BD::Pixel).offset(uv_off as isize), + (f.cur.data.data[1] as *mut BD::Pixel).offset(uv_off as isize), + (f.cur.data.data[2] as *mut BD::Pixel).offset(uv_off as isize), ]; let furthest_r = (cw4 << ss_hor) + (*t_dim).w as c_int - 1 & !((*t_dim).w as c_int - 1); let furthest_b = (ch4 << ss_ver) + (*t_dim).h as c_int - 1 & !((*t_dim).h as c_int - 1); - (*dsp).ipred.cfl_ac[(*f).cur.p.layout.try_into().unwrap()].call::( + (*dsp).ipred.cfl_ac[f.cur.p.layout.try_into().unwrap()].call::( ac.as_mut_ptr(), y_src, - (*f).cur.stride[0], + f.cur.stride[0], cbw4 - (furthest_r >> ss_hor), cbh4 - (furthest_b >> ss_ver), cbw4 * 4, @@ -2871,16 +2854,13 @@ pub(crate) unsafe fn rav1d_recon_b_intra( while pl < 2 { if !(b.c2rust_unnamed.c2rust_unnamed.cfl_alpha[pl as usize] == 0) { let mut angle = 0; - let top_sb_edge_slice = if t.by & !ss_ver & (*f).sb_step - 1 == 0 { + let top_sb_edge_slice = if t.by & !ss_ver & f.sb_step - 1 == 0 { let mut top_sb_edge: *const BD::Pixel = - (*f).ipred_edge[(pl + 1) as usize] as *mut BD::Pixel; - let sby = t.by >> (*f).sb_shift; + f.ipred_edge[(pl + 1) as usize] as *mut BD::Pixel; + let sby = t.by >> f.sb_shift; top_sb_edge = - top_sb_edge.offset(((*f).sb128w * 128 * (sby - 1)) as isize); - Some(slice::from_raw_parts( - top_sb_edge, - (*f).sb128w as usize * 128, - )) + top_sb_edge.offset((f.sb128w * 128 * (sby - 1)) as isize); + Some(slice::from_raw_parts(top_sb_edge, f.sb128w as usize * 128)) } else { None }; @@ -2892,12 +2872,12 @@ pub(crate) unsafe fn rav1d_recon_b_intra( BD::select_mut(&mut t.scratch.c2rust_unnamed_0.interintra_edge); let edge_array = &mut interintra_edge.0.edge; let edge_offset = 128; - let data_stride = BD::pxstride((*f).cur.stride[1] as usize) as isize; + let data_stride = BD::pxstride(f.cur.stride[1] as usize) as isize; let data_width = 4 * (*ts).tiling.col_end >> ss_hor; let data_height = 4 * (*ts).tiling.row_end >> ss_ver; let data_diff = (data_height - 1) as isize * data_stride; let uvdst_slice = slice::from_raw_parts( - ((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel) + (f.cur.data.data[1 + pl as usize] as *const BD::Pixel) .offset(cmp::min(data_diff, 0)), data_diff.unsigned_abs() + data_width as usize, ); @@ -2919,7 +2899,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( 0 as c_int, edge_array, edge_offset, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); let edge = edge_array.as_ptr().add(edge_offset); (*dsp).ipred.cfl_pred[m as usize].call( @@ -2930,7 +2910,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( (*uv_t_dim).h as c_int * 4, ac.as_mut_ptr(), b.c2rust_unnamed.c2rust_unnamed.cfl_alpha[pl as usize] as c_int, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); } pl += 1; @@ -2956,7 +2936,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( let uv_dstoff: ptrdiff_t = 4 * ((t.bx >> ss_hor) as isize + (t.by >> ss_ver) as isize - * BD::pxstride((*f).cur.stride[1] as usize) as isize); + * BD::pxstride(f.cur.stride[1] as usize) as isize); let pal: *const [u16; 8]; let pal_idx: *const u8; if t.frame_thread.pass != 0 { @@ -2964,8 +2944,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( if ((*ts).frame_thread[p as usize].pal_idx).is_null() { unreachable!(); } - pal = (*((*f).frame_thread.pal).offset( - (((t.by >> 1) + (t.bx & 1)) as isize * ((*f).b4_stride >> 1) + pal = (*(f.frame_thread.pal).offset( + (((t.by >> 1) + (t.bx & 1)) as isize * (f.b4_stride >> 1) + ((t.bx as isize >> 1) as isize + (t.by as isize & 1)) as isize) as isize, )) @@ -2981,33 +2961,33 @@ pub(crate) unsafe fn rav1d_recon_b_intra( .offset((bw4 * bh4 * 16) as isize) as *mut u8; } - (*(*f).dsp).ipred.pal_pred.call::( - ((*f).cur.data.data[1] as *mut BD::Pixel).offset(uv_dstoff as isize), - (*f).cur.stride[1], + (*f.dsp).ipred.pal_pred.call::( + (f.cur.data.data[1] as *mut BD::Pixel).offset(uv_dstoff as isize), + f.cur.stride[1], (*pal.offset(1)).as_ptr(), pal_idx, cbw4 * 4, cbh4 * 4, ); - (*(*f).dsp).ipred.pal_pred.call::( - ((*f).cur.data.data[2] as *mut BD::Pixel).offset(uv_dstoff as isize), - (*f).cur.stride[1], + (*f.dsp).ipred.pal_pred.call::( + (f.cur.data.data[2] as *mut BD::Pixel).offset(uv_dstoff as isize), + f.cur.stride[1], (*pal.offset(2)).as_ptr(), pal_idx, cbw4 * 4, cbh4 * 4, ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( - ((*f).cur.data.data[1] as *mut BD::Pixel).offset(uv_dstoff as isize), - BD::pxstride((*f).cur.stride[1] as usize), + (f.cur.data.data[1] as *mut BD::Pixel).offset(uv_dstoff as isize), + BD::pxstride(f.cur.stride[1] as usize), cbw4 as usize * 4, cbh4 as usize * 4, "u-pal-pred", ); hex_dump::( - ((*f).cur.data.data[2] as *mut BD::Pixel).offset(uv_dstoff as isize), - BD::pxstride((*f).cur.stride[1] as usize), + (f.cur.data.data[2] as *mut BD::Pixel).offset(uv_dstoff as isize), + BD::pxstride(f.cur.stride[1] as usize), cbw4 as usize * 4, cbh4 as usize * 4, "v-pal-pred", @@ -3023,7 +3003,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( } else { intra_edge_flags as c_uint & (EDGE_I420_TOP_HAS_RIGHT as c_int - >> ((*f).cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint)) + >> (f.cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint)) as c_uint }) as c_int; let uv_sb_has_bl = (if init_x != 0 { @@ -3033,7 +3013,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( } else { intra_edge_flags as c_uint & (EDGE_I420_LEFT_HAS_BOTTOM as c_int - >> ((*f).cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint)) + >> (f.cur.p.layout as c_uint).wrapping_sub(1 as c_int as c_uint)) as c_uint }) as c_int; let sub_cw4 = cmp::min(cw4, init_x + 16 >> ss_hor); @@ -3043,7 +3023,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( t.by += init_y; while y < sub_ch4 { let mut dst: *mut BD::Pixel = - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel).offset( + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel).offset( (4 * ((t.by >> ss_ver) as isize * BD::pxstride(stride as usize) as isize + (t.bx + init_x >> ss_hor) as isize)) @@ -3080,15 +3060,15 @@ pub(crate) unsafe fn rav1d_recon_b_intra( } else { EDGE_I444_LEFT_HAS_BOTTOM as c_int })) as EdgeFlags; - let top_sb_edge_slice = if t.by & !ss_ver & (*f).sb_step - 1 == 0 { + let top_sb_edge_slice = if t.by & !ss_ver & f.sb_step - 1 == 0 { let mut top_sb_edge: *const BD::Pixel = - (*f).ipred_edge[(1 + pl) as usize] as *const BD::Pixel; - let sby = t.by >> (*f).sb_shift; - top_sb_edge = top_sb_edge - .offset(((*f).sb128w * 128 * (sby - 1)) as isize); + f.ipred_edge[(1 + pl) as usize] as *const BD::Pixel; + let sby = t.by >> f.sb_shift; + top_sb_edge = + top_sb_edge.offset((f.sb128w * 128 * (sby - 1)) as isize); Some(slice::from_raw_parts( top_sb_edge, - (*f).sb128w as usize * 128, + f.sb128w as usize * 128, )) } else { None @@ -3108,13 +3088,12 @@ pub(crate) unsafe fn rav1d_recon_b_intra( BD::select_mut(&mut t.scratch.c2rust_unnamed_0.interintra_edge); let edge_array = &mut interintra_edge.0.edge; let edge_offset = 128; - let data_stride = - BD::pxstride((*f).cur.stride[1] as usize) as isize; + let data_stride = BD::pxstride(f.cur.stride[1] as usize) as isize; let data_width = 4 * (*ts).tiling.col_end >> ss_hor; let data_height = 4 * (*ts).tiling.row_end >> ss_ver; let data_diff = (data_height - 1) as isize * data_stride; let dstuv_slice = slice::from_raw_parts( - ((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel) + (f.cur.data.data[1 + pl as usize] as *const BD::Pixel) .offset(cmp::min(data_diff, 0)), data_diff.unsigned_abs() + data_width as usize, ); @@ -3136,7 +3115,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( seq_hdr.intra_edge_filter, edge_array, edge_offset, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); angle |= intra_edge_filter_flag; let edge = edge_array.as_ptr().add(edge_offset); @@ -3147,11 +3126,11 @@ pub(crate) unsafe fn rav1d_recon_b_intra( (*uv_t_dim).w as c_int * 4, (*uv_t_dim).h as c_int * 4, angle | sm_uv_fl, - 4 * (*f).bw + ss_hor - 4 * (t.bx & !ss_hor) >> ss_hor, - 4 * (*f).bh + ss_ver - 4 * (t.by & !ss_ver) >> ss_ver, - BD::from_c((*f).bitdepth_max), + 4 * f.bw + ss_hor - 4 * (t.bx & !ss_hor) >> ss_hor, + 4 * f.bh + ss_ver - 4 * (t.by & !ss_ver) >> ss_ver, + BD::from_c(f.bitdepth_max), ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( edge.offset(-(((*uv_t_dim).h as c_int * 4) as isize)), (*uv_t_dim).h as usize * 4, @@ -3196,8 +3175,8 @@ pub(crate) unsafe fn rav1d_recon_b_intra( as isize, ) as *mut DynCoef; - let cbi = &mut (*f).frame_thread.cbi - [(t.by as isize * (*f).b4_stride + t.bx as isize) as usize]; + let cbi = &f.frame_thread.cbi + [(t.by as isize * f.b4_stride + t.bx as isize) as usize]; eob = cbi.eob[(pl + 1) as usize] as c_int; txtp = cbi.txtp[(pl + 1) as usize] as TxfmType; } else { @@ -3216,7 +3195,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( &mut txtp, &mut cf_ctx, ); - if debug_block_info!(&*f, t) { + if debug_block_info!(f, t) { printf( b"Post-uv-cf-blk[pl=%d,tx=%d,txtp=%d,eob=%d]: r=%d [x=%d,cbx4=%d]\n\0" as *const u8 as *const c_char, @@ -3234,11 +3213,11 @@ pub(crate) unsafe fn rav1d_recon_b_intra( [ cmp::min( (*uv_t_dim).h as i32, - (*f).bh - t.by + ss_ver >> ss_ver, + f.bh - t.by + ss_ver >> ss_ver, ) as usize, cmp::min( (*uv_t_dim).w as i32, - (*f).bw - t.bx + ss_hor >> ss_hor, + f.bw - t.bx + ss_hor >> ss_hor, ) as usize, ], [(cby4 + y) as usize, (cbx4 + x) as usize], @@ -3248,7 +3227,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra( ); } if eob >= 0 { - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { coef_dump( cf, (*uv_t_dim).h as usize * 4, @@ -3263,9 +3242,9 @@ pub(crate) unsafe fn rav1d_recon_b_intra( stride, cf.cast(), eob, - (*f).bitdepth_max, + f.bitdepth_max, ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( dst, stride as usize, @@ -3309,41 +3288,38 @@ pub(crate) unsafe fn rav1d_recon_b_inter( b: &Av1Block, ) -> c_int { let ts: *mut Rav1dTileState = t.ts; - let f: *mut Rav1dFrameContext = t.f; - let dsp: *const Rav1dDSPContext = (*f).dsp; + let f: &mut Rav1dFrameContext = &mut *t.f; + let dsp: *const Rav1dDSPContext = f.dsp; let bx4 = t.bx & 31; let by4 = t.by & 31; - let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; - let ss_hor = - ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + let ss_ver = (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_hor = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let cbx4 = bx4 >> ss_hor; let cby4 = by4 >> ss_ver; let b_dim: *const u8 = (dav1d_block_dimensions[bs as usize]).as_ptr(); let bw4 = *b_dim.offset(0) as c_int; let bh4 = *b_dim.offset(1) as c_int; - let w4 = cmp::min(bw4, (*f).bw - t.bx); - let h4 = cmp::min(bh4, (*f).bh - t.by); - let has_chroma = ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint + let w4 = cmp::min(bw4, f.bw - t.bx); + let h4 = cmp::min(bh4, f.bh - t.by); + let has_chroma = (f.cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint && (bw4 > ss_hor || t.bx & 1 != 0) && (bh4 > ss_ver || t.by & 1 != 0)) as c_int; - let chr_layout_idx = - (if (*f).cur.p.layout as c_uint == Rav1dPixelLayout::I400 as c_int as c_uint { - 0 as c_int as c_uint - } else { - (Rav1dPixelLayout::I444 as c_int as c_uint).wrapping_sub((*f).cur.p.layout as c_uint) - }) as c_int; + let chr_layout_idx = (if f.cur.p.layout as c_uint == Rav1dPixelLayout::I400 as c_int as c_uint { + 0 as c_int as c_uint + } else { + (Rav1dPixelLayout::I444 as c_int as c_uint).wrapping_sub(f.cur.p.layout as c_uint) + }) as c_int; let mut res; let cbh4 = bh4 + ss_ver >> ss_ver; let cbw4 = bw4 + ss_hor >> ss_hor; - let mut dst: *mut BD::Pixel = ((*f).cur.data.data[0] as *mut BD::Pixel).offset( - (4 * (t.by as isize * BD::pxstride((*f).cur.stride[0] as usize) as isize + t.bx as isize)) + let mut dst: *mut BD::Pixel = (f.cur.data.data[0] as *mut BD::Pixel).offset( + (4 * (t.by as isize * BD::pxstride(f.cur.stride[0] as usize) as isize + t.bx as isize)) as isize, ); let uvdstoff: ptrdiff_t = 4 * ((t.bx >> ss_hor) as isize - + (t.by >> ss_ver) as isize * BD::pxstride((*f).cur.stride[1] as usize) as isize); - let frame_hdr = &***(*f).frame_hdr.as_ref().unwrap(); + + (t.by >> ss_ver) as isize * BD::pxstride(f.cur.stride[1] as usize) as isize); + let frame_hdr = &***f.frame_hdr.as_ref().unwrap(); if frame_hdr.frame_type.is_key_or_intra() { if frame_hdr.size.super_res.enabled != 0 { unreachable!(); @@ -3352,7 +3328,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( t, dst, 0 as *mut i16, - (*f).cur.stride[0], + f.cur.stride[0], bw4, bh4, t.bx, @@ -3363,7 +3339,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .c2rust_unnamed .c2rust_unnamed .mv[0], - &(*f).sr_cur, + &f.sr_cur, 0 as c_int, FILTER_2D_BILINEAR, ); @@ -3375,9 +3351,9 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 3 { res = mc::( t, - ((*f).cur.data.data[pl as usize] as *mut BD::Pixel).offset(uvdstoff as isize), + (f.cur.data.data[pl as usize] as *mut BD::Pixel).offset(uvdstoff as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4 << (bw4 == ss_hor) as c_int, bh4 << (bh4 == ss_ver) as c_int, t.bx & !ss_hor, @@ -3388,7 +3364,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .c2rust_unnamed .c2rust_unnamed .mv[0], - &(*f).sr_cur, + &f.sr_cur, 0 as c_int, FILTER_2D_BILINEAR, ); @@ -3401,15 +3377,14 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } else if b.c2rust_unnamed.c2rust_unnamed_0.comp_type as c_int == COMP_INTER_NONE as c_int { let mut is_sub8x8; let mut r: *const *mut refmvs_block; - let refp: *const Rav1dThreadPicture = &*((*f).refp) + let refp: *const Rav1dThreadPicture = &*(f.refp) .as_ptr() .offset(*(b.c2rust_unnamed.c2rust_unnamed_0.r#ref).as_ptr().offset(0) as isize) as *const Rav1dThreadPicture; let filter_2d: Filter2d = b.c2rust_unnamed.c2rust_unnamed_0.filter2d as Filter2d; if cmp::min(bw4, bh4) > 1 && (b.c2rust_unnamed.c2rust_unnamed_0.inter_mode as c_int == GLOBALMV as c_int - && (*f).gmv_warp_allowed[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] - as c_int + && f.gmv_warp_allowed[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] as c_int != 0 || b.c2rust_unnamed.c2rust_unnamed_0.motion_mode as c_int == MM_WARP as c_int && t.warpmv.r#type as c_uint > RAV1D_WM_TYPE_TRANSLATION as c_int as c_uint) @@ -3418,7 +3393,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( t, dst, 0 as *mut i16, - (*f).cur.stride[0], + f.cur.stride[0], b_dim, 0 as c_int, refp, @@ -3436,7 +3411,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( t, dst, 0 as *mut i16, - (*f).cur.stride[0], + f.cur.stride[0], bw4, bh4, t.bx, @@ -3455,17 +3430,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( return res; } if b.c2rust_unnamed.c2rust_unnamed_0.motion_mode as c_int == MM_OBMC as c_int { - res = obmc::( - t, - dst, - (*f).cur.stride[0], - b_dim, - 0 as c_int, - bx4, - by4, - w4, - h4, - ); + res = obmc::(t, dst, f.cur.stride[0], b_dim, 0 as c_int, bx4, by4, w4, h4); if res != 0 { return res; } @@ -3492,23 +3457,20 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .interintra_mode as c_int }) as IntraPredMode; let mut angle = 0; - let top_sb_edge_slice = if t.by & (*f).sb_step - 1 == 0 { - let mut top_sb_edge: *const BD::Pixel = (*f).ipred_edge[0] as *const BD::Pixel; - let sby = t.by >> (*f).sb_shift; - top_sb_edge = top_sb_edge.offset(((*f).sb128w * 128 * (sby - 1)) as isize); - Some(slice::from_raw_parts( - top_sb_edge, - (*f).sb128w as usize * 128, - )) + let top_sb_edge_slice = if t.by & f.sb_step - 1 == 0 { + let mut top_sb_edge: *const BD::Pixel = f.ipred_edge[0] as *const BD::Pixel; + let sby = t.by >> f.sb_shift; + top_sb_edge = top_sb_edge.offset((f.sb128w * 128 * (sby - 1)) as isize); + Some(slice::from_raw_parts(top_sb_edge, f.sb128w as usize * 128)) } else { None }; - let data_stride = BD::pxstride((*f).cur.stride[0] as usize) as isize; + let data_stride = BD::pxstride(f.cur.stride[0] as usize) as isize; let data_width = 4 * (*ts).tiling.col_end; let data_height = 4 * (*ts).tiling.row_end; let data_diff = (data_height - 1) as isize * data_stride; let dst_slice = slice::from_raw_parts( - ((*f).cur.data.data[0] as *const BD::Pixel).offset(cmp::min(data_diff, 0)), + (f.cur.data.data[0] as *const BD::Pixel).offset(cmp::min(data_diff, 0)), data_diff.unsigned_abs() + data_width as usize, ); m = rav1d_prepare_intra_edges( @@ -3520,7 +3482,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( (*ts).tiling.row_end, 0 as EdgeFlags, dst_slice, - (*f).cur.stride[0], + f.cur.stride[0], top_sb_edge_slice, m, &mut angle, @@ -3529,7 +3491,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( 0 as c_int, tl_edge_array, tl_edge_offset, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); let tl_edge = tl_edge_array[tl_edge_offset..].as_ptr(); let tmp = interintra_edge.0.interintra.as_mut_ptr(); @@ -3543,7 +3505,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( 0 as c_int, 0 as c_int, 0 as c_int, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); let ii_mask = if b.c2rust_unnamed.c2rust_unnamed_0.interintra_type as c_int == INTER_INTRA_BLEND as c_int @@ -3564,7 +3526,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( }; ((*dsp).mc.blend)( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], tmp.cast(), bw4 * 4, bh4 * 4, @@ -3611,10 +3573,10 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { res = mc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4, bh4, t.bx - 1, @@ -3624,7 +3586,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .0 .mv .mv[0], - &*((*f).refp).as_ptr().offset( + &*(f.refp).as_ptr().offset( (*((*(*r.offset(-(1 as c_int) as isize)) .offset((t.bx - 1) as isize)) .0 @@ -3642,10 +3604,8 @@ pub(crate) unsafe fn rav1d_recon_b_inter( (if t.frame_thread.pass != 2 as c_int { t.tl_4x4_filter as c_uint } else { - (*f).frame_thread.b[((t.by - 1) as isize * (*f).b4_stride - + t.bx as isize - - 1) - as usize] + f.frame_thread.b[((t.by - 1) as isize * f.b4_stride + t.bx as isize + - 1) as usize] .c2rust_unnamed .c2rust_unnamed_0 .filter2d as c_uint @@ -3656,7 +3616,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } pl += 1; } - v_off = 2 * BD::pxstride((*f).cur.stride[1] as usize) as isize; + v_off = 2 * BD::pxstride(f.cur.stride[1] as usize) as isize; h_off = 2 as c_int as ptrdiff_t; } if bw4 == 1 { @@ -3668,18 +3628,18 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { res = mc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize) .offset(v_off as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4, bh4, t.bx - 1, t.by, 1 + pl, (*(*r.offset(0)).offset((t.bx - 1) as isize)).0.mv.mv[0], - &*((*f).refp).as_ptr().offset( + &*(f.refp).as_ptr().offset( (*((*(*r.offset(0)).offset((t.bx - 1) as isize)).0.r#ref.r#ref) .as_mut_ptr() .offset(0) as c_int @@ -3690,8 +3650,8 @@ pub(crate) unsafe fn rav1d_recon_b_inter( (if t.frame_thread.pass != 2 as c_int { left_filter_2d as c_uint } else { - (*f).frame_thread.b - [(t.by as isize * (*f).b4_stride + t.bx as isize - 1) as usize] + f.frame_thread.b + [(t.by as isize * f.b4_stride + t.bx as isize - 1) as usize] .c2rust_unnamed .c2rust_unnamed_0 .filter2d as c_uint @@ -3713,11 +3673,11 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { res = mc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize) .offset(h_off as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4, bh4, t.bx, @@ -3727,7 +3687,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .0 .mv .mv[0], - &*((*f).refp).as_ptr().offset( + &*(f.refp).as_ptr().offset( (*((*(*r.offset(-(1 as c_int) as isize)).offset(t.bx as isize)) .0 .r#ref @@ -3744,9 +3704,8 @@ pub(crate) unsafe fn rav1d_recon_b_inter( (if t.frame_thread.pass != 2 as c_int { top_filter_2d as c_uint } else { - (*f).frame_thread.b[((t.by - 1) as isize * (*f).b4_stride - + t.bx as isize) - as usize] + f.frame_thread.b + [((t.by - 1) as isize * f.b4_stride + t.bx as isize) as usize] .c2rust_unnamed .c2rust_unnamed_0 .filter2d as c_uint @@ -3757,18 +3716,18 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } pl += 1; } - v_off = 2 * BD::pxstride((*f).cur.stride[1] as usize) as isize; + v_off = 2 * BD::pxstride(f.cur.stride[1] as usize) as isize; } let mut pl = 0; while pl < 2 { res = mc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize) .offset(h_off as isize) .offset(v_off as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4, bh4, t.bx, @@ -3791,8 +3750,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } else { if cmp::min(cbw4, cbh4) > 1 && (b.c2rust_unnamed.c2rust_unnamed_0.inter_mode as c_int == GLOBALMV as c_int - && (*f).gmv_warp_allowed - [b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] + && f.gmv_warp_allowed[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] as c_int != 0 || b.c2rust_unnamed.c2rust_unnamed_0.motion_mode as c_int @@ -3804,10 +3762,10 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { res = warp_affine::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], b_dim, 1 + pl, refp, @@ -3829,10 +3787,10 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { res = mc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize), 0 as *mut i16, - (*f).cur.stride[1], + f.cur.stride[1], bw4 << (bw4 == ss_hor) as c_int, bh4 << (bh4 == ss_ver) as c_int, t.bx & !ss_hor, @@ -3855,9 +3813,9 @@ pub(crate) unsafe fn rav1d_recon_b_inter( { res = obmc::( t, - ((*f).cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) + (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize), - (*f).cur.stride[1], + f.cur.stride[1], b_dim, 1 + pl, bx4, @@ -3916,28 +3874,24 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .interintra_mode as c_int }) as IntraPredMode; let mut angle = 0; - let uvdst: *mut BD::Pixel = ((*f).cur.data.data[(1 + pl) as usize] + let uvdst: *mut BD::Pixel = (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize); - let top_sb_edge_slice = if t.by & (*f).sb_step - 1 == 0 { + let top_sb_edge_slice = if t.by & f.sb_step - 1 == 0 { let mut top_sb_edge: *const BD::Pixel = - (*f).ipred_edge[(pl + 1) as usize] as *const BD::Pixel; - let sby = t.by >> (*f).sb_shift; - top_sb_edge = - top_sb_edge.offset(((*f).sb128w * 128 * (sby - 1)) as isize); - Some(slice::from_raw_parts( - top_sb_edge, - (*f).sb128w as usize * 128, - )) + f.ipred_edge[(pl + 1) as usize] as *const BD::Pixel; + let sby = t.by >> f.sb_shift; + top_sb_edge = top_sb_edge.offset((f.sb128w * 128 * (sby - 1)) as isize); + Some(slice::from_raw_parts(top_sb_edge, f.sb128w as usize * 128)) } else { None }; - let data_stride = BD::pxstride((*f).cur.stride[1] as usize) as isize; + let data_stride = BD::pxstride(f.cur.stride[1] as usize) as isize; let data_width = 4 * (*ts).tiling.col_end >> ss_hor; let data_height = 4 * (*ts).tiling.row_end >> ss_ver; let data_diff = (data_height - 1) as isize * data_stride; let dstuv_slice = slice::from_raw_parts( - ((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel) + (f.cur.data.data[1 + pl as usize] as *const BD::Pixel) .offset(cmp::min(data_diff, 0)), data_diff.unsigned_abs() + data_width as usize, ); @@ -3950,7 +3904,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( (*ts).tiling.row_end >> ss_ver, 0 as EdgeFlags, dstuv_slice, - (*f).cur.stride[1], + f.cur.stride[1], top_sb_edge_slice, m, &mut angle, @@ -3959,7 +3913,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( 0 as c_int, tl_edge_array, tl_edge_offset, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); let tl_edge = tl_edge_array[tl_edge_offset..].as_ptr(); let tmp = interintra_edge.0.interintra.as_mut_ptr(); @@ -3974,11 +3928,11 @@ pub(crate) unsafe fn rav1d_recon_b_inter( 0 as c_int, 0 as c_int, 0 as c_int, - BD::from_c((*f).bitdepth_max), + BD::from_c(f.bitdepth_max), ); ((*dsp).mc.blend)( uvdst.cast(), - (*f).cur.stride[1], + f.cur.stride[1], tmp.cast(), cbw4 * 4, cbh4 * 4, @@ -4010,14 +3964,13 @@ pub(crate) unsafe fn rav1d_recon_b_inter( let mut mask: *const u8 = 0 as *const u8; let mut i = 0; while i < 2 { - let refp: *const Rav1dThreadPicture = &*((*f).refp).as_ptr().offset( + let refp: *const Rav1dThreadPicture = &*(f.refp).as_ptr().offset( *(b.c2rust_unnamed.c2rust_unnamed_0.r#ref) .as_ptr() .offset(i as isize) as isize, ) as *const Rav1dThreadPicture; if b.c2rust_unnamed.c2rust_unnamed_0.inter_mode as c_int == GLOBALMV_GLOBALMV as c_int - && (*f).gmv_warp_allowed - [b.c2rust_unnamed.c2rust_unnamed_0.r#ref[i as usize] as usize] + && f.gmv_warp_allowed[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[i as usize] as usize] as c_int != 0 { @@ -4064,33 +4017,33 @@ pub(crate) unsafe fn rav1d_recon_b_inter( 2 => { ((*dsp).mc.avg)( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], (*tmp.offset(0)).as_mut_ptr(), (*tmp.offset(1)).as_mut_ptr(), bw4 * 4, bh4 * 4, - (*f).bitdepth_max, + f.bitdepth_max, ); } 1 => { - jnt_weight = (*f).jnt_weights[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] + jnt_weight = f.jnt_weights[b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as usize] [b.c2rust_unnamed.c2rust_unnamed_0.r#ref[1] as usize] as c_int; ((*dsp).mc.w_avg)( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], (*tmp.offset(0)).as_mut_ptr(), (*tmp.offset(1)).as_mut_ptr(), bw4 * 4, bh4 * 4, jnt_weight, - (*f).bitdepth_max, + f.bitdepth_max, ); } 3 => { (*dsp).mc.w_mask[chr_layout_idx as usize]( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], (*tmp.offset( b.c2rust_unnamed .c2rust_unnamed_0 @@ -4116,7 +4069,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .c2rust_unnamed .c2rust_unnamed .mask_sign as c_int, - (*f).bitdepth_max, + f.bitdepth_max, ); mask = seg_mask; } @@ -4131,7 +4084,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( .as_ptr(); ((*dsp).mc.mask)( dst.cast(), - (*f).cur.stride[0], + f.cur.stride[0], (*tmp.offset( b.c2rust_unnamed .c2rust_unnamed_0 @@ -4152,7 +4105,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( bw4 * 4, bh4 * 4, mask, - (*f).bitdepth_max, + f.bitdepth_max, ); if has_chroma != 0 { mask = dav1d_wedge_masks[bs as usize][chr_layout_idx as usize][b @@ -4177,7 +4130,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( while pl < 2 { let mut i = 0; while i < 2 { - let refp: *const Rav1dThreadPicture = &*((*f).refp).as_ptr().offset( + let refp: *const Rav1dThreadPicture = &*(f.refp).as_ptr().offset( *(b.c2rust_unnamed.c2rust_unnamed_0.r#ref) .as_ptr() .offset(i as isize) as isize, @@ -4186,7 +4139,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( if b.c2rust_unnamed.c2rust_unnamed_0.inter_mode as c_int == GLOBALMV_GLOBALMV as c_int && cmp::min(cbw4, cbh4) > 1 - && (*f).gmv_warp_allowed + && f.gmv_warp_allowed [b.c2rust_unnamed.c2rust_unnamed_0.r#ref[i as usize] as usize] as c_int != 0 @@ -4231,37 +4184,36 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } i += 1; } - let uvdst: *mut BD::Pixel = ((*f).cur.data.data[(1 + pl) as usize] - as *mut BD::Pixel) + let uvdst: *mut BD::Pixel = (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize); match b.c2rust_unnamed.c2rust_unnamed_0.comp_type as c_int { 2 => { ((*dsp).mc.avg)( uvdst.cast(), - (*f).cur.stride[1], + f.cur.stride[1], (*tmp.offset(0)).as_mut_ptr(), (*tmp.offset(1)).as_mut_ptr(), bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, - (*f).bitdepth_max, + f.bitdepth_max, ); } 1 => { ((*dsp).mc.w_avg)( uvdst.cast(), - (*f).cur.stride[1], + f.cur.stride[1], (*tmp.offset(0)).as_mut_ptr(), (*tmp.offset(1)).as_mut_ptr(), bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, jnt_weight, - (*f).bitdepth_max, + f.bitdepth_max, ); } 4 | 3 => { ((*dsp).mc.mask)( uvdst.cast(), - (*f).cur.stride[1], + f.cur.stride[1], (*tmp.offset( b.c2rust_unnamed .c2rust_unnamed_0 @@ -4282,7 +4234,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( bw4 * 4 >> ss_hor, bh4 * 4 >> ss_ver, mask, - (*f).bitdepth_max, + f.bitdepth_max, ); } _ => {} @@ -4291,27 +4243,27 @@ pub(crate) unsafe fn rav1d_recon_b_inter( } } } - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( dst, - (*f).cur.stride[0] as usize, + f.cur.stride[0] as usize, *b_dim.offset(0) as usize * 4, *b_dim.offset(1) as usize * 4, "y-pred", ); if has_chroma != 0 { hex_dump::( - &mut *(*((*f).cur.data.data).as_ptr().offset(1) as *mut BD::Pixel) + &mut *(*(f.cur.data.data).as_ptr().offset(1) as *mut BD::Pixel) .offset(uvdstoff as isize), - (*f).cur.stride[1] as usize, + f.cur.stride[1] as usize, cbw4 as usize * 4, cbh4 as usize * 4, "u-pred", ); hex_dump::( - &mut *(*((*f).cur.data.data).as_ptr().offset(2) as *mut BD::Pixel) + &mut *(*(f.cur.data.data).as_ptr().offset(2) as *mut BD::Pixel) .offset(uvdstoff as isize), - (*f).cur.stride[1] as usize, + f.cur.stride[1] as usize, cbw4 as usize * 4, cbh4 as usize * 4, "v-pred", @@ -4359,7 +4311,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( let mut y_off = (init_y != 0) as c_int; let mut y; dst = dst.offset( - (BD::pxstride((*f).cur.stride[0] as usize) as isize * 4 * init_y as isize) as isize, + (BD::pxstride(f.cur.stride[0] as usize) as isize * 4 * init_y as isize) as isize, ); y = init_y; t.by += init_y; @@ -4385,7 +4337,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( x_off += 1; } dst = dst.offset( - (BD::pxstride((*f).cur.stride[0] as usize) as isize * 4 * (*ytx).h as isize) + (BD::pxstride(f.cur.stride[0] as usize) as isize * 4 * (*ytx).h as isize) as isize, ); t.bx -= x; @@ -4394,19 +4346,17 @@ pub(crate) unsafe fn rav1d_recon_b_inter( y_off += 1; } dst = dst.offset( - -((BD::pxstride((*f).cur.stride[0] as usize) as isize * 4 * y as isize) as isize), + -((BD::pxstride(f.cur.stride[0] as usize) as isize * 4 * y as isize) as isize), ); t.by -= y; if has_chroma != 0 { let mut pl = 0; while pl < 2 { - let mut uvdst: *mut BD::Pixel = ((*f).cur.data.data[(1 + pl) as usize] + let mut uvdst: *mut BD::Pixel = (f.cur.data.data[(1 + pl) as usize] as *mut BD::Pixel) .offset(uvdstoff as isize) .offset( - (BD::pxstride((*f).cur.stride[1] as usize) as isize - * init_y as isize - * 4 + (BD::pxstride(f.cur.stride[1] as usize) as isize * init_y as isize * 4 >> ss_ver) as isize, ); y = init_y >> ss_ver; @@ -4426,8 +4376,8 @@ pub(crate) unsafe fn rav1d_recon_b_inter( ((*ts).frame_thread[p as usize].cf as *mut BD::Coef).offset( ((*uvtx).w as c_int * (*uvtx).h as c_int * 16) as isize, ) as *mut DynCoef; - let cbi = &mut (*f).frame_thread.cbi - [(t.by as isize * (*f).b4_stride + t.bx as isize) as usize]; + let cbi = &f.frame_thread.cbi + [(t.by as isize * f.b4_stride + t.bx as isize) as usize]; eob = cbi.eob[(1 + pl) as usize] as c_int; txtp = cbi.txtp[(1 + pl) as usize] as TxfmType; } else { @@ -4449,7 +4399,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( &mut txtp, &mut cf_ctx, ); - if debug_block_info!(&*f, t) { + if debug_block_info!(f, t) { printf( b"Post-uv-cf-blk[pl=%d,tx=%d,txtp=%d,eob=%d]: r=%d\n\0" as *const u8 @@ -4464,14 +4414,10 @@ pub(crate) unsafe fn rav1d_recon_b_inter( CaseSet::<16, true>::many( [&mut t.l, &mut *t.a], [ - cmp::min( - (*uvtx).h as i32, - (*f).bh - t.by + ss_ver >> ss_ver, - ) as usize, - cmp::min( - (*uvtx).w as i32, - (*f).bw - t.bx + ss_hor >> ss_hor, - ) as usize, + cmp::min((*uvtx).h as i32, f.bh - t.by + ss_ver >> ss_ver) + as usize, + cmp::min((*uvtx).w as i32, f.bw - t.bx + ss_hor >> ss_hor) + as usize, ], [(cby4 + y) as usize, (cbx4 + x) as usize], |case, dir| { @@ -4480,7 +4426,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( ); } if eob >= 0 { - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { coef_dump( cf, (*uvtx).h as usize * 4, @@ -4492,15 +4438,15 @@ pub(crate) unsafe fn rav1d_recon_b_inter( ((*dsp).itx.itxfm_add[b.uvtx as usize][txtp as usize]) .expect("non-null function pointer")( uvdst.offset((4 * x) as isize).cast(), - (*f).cur.stride[1], + f.cur.stride[1], cf.cast(), eob, - (*f).bitdepth_max, + f.bitdepth_max, ); - if debug_block_info!(&*f, t) && 0 != 0 { + if debug_block_info!(f, t) && 0 != 0 { hex_dump::( &mut *uvdst.offset((4 * x) as isize), - (*f).cur.stride[1] as usize, + f.cur.stride[1] as usize, (*uvtx).w as usize * 4, (*uvtx).h as usize * 4, "recon", @@ -4511,7 +4457,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter( x += (*uvtx).w as c_int; } uvdst = uvdst.offset( - (BD::pxstride((*f).cur.stride[1] as usize) as isize + (BD::pxstride(f.cur.stride[1] as usize) as isize * 4 * (*uvtx).h as isize) as isize, ); @@ -4603,46 +4549,45 @@ pub(crate) unsafe fn rav1d_filter_sbrow_cdef( tc: &mut Rav1dTaskContext, sby: c_int, ) { - let f: *const Rav1dFrameContext = tc.f; + let f: &Rav1dFrameContext = &*tc.f; if c.inloop_filters as c_uint & RAV1D_INLOOPFILTER_CDEF as c_int as c_uint == 0 { return; } - let sbsz = (*f).sb_step; + let sbsz = f.sb_step; let y = sby * sbsz * 4; - let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + let ss_ver = (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; let p: [*mut BD::Pixel; 3] = [ - ((*f).lf.p[0] as *mut BD::Pixel) - .offset((y as isize * BD::pxstride((*f).cur.stride[0] as usize) as isize) as isize), - ((*f).lf.p[1] as *mut BD::Pixel).offset( - (y as isize * BD::pxstride((*f).cur.stride[1] as usize) as isize >> ss_ver) as isize, + (f.lf.p[0] as *mut BD::Pixel) + .offset((y as isize * BD::pxstride(f.cur.stride[0] as usize) as isize) as isize), + (f.lf.p[1] as *mut BD::Pixel).offset( + (y as isize * BD::pxstride(f.cur.stride[1] as usize) as isize >> ss_ver) as isize, ), - ((*f).lf.p[2] as *mut BD::Pixel).offset( - (y as isize * BD::pxstride((*f).cur.stride[1] as usize) as isize >> ss_ver) as isize, + (f.lf.p[2] as *mut BD::Pixel).offset( + (y as isize * BD::pxstride(f.cur.stride[1] as usize) as isize >> ss_ver) as isize, ), ]; - let seq_hdr = &***(*f).seq_hdr.as_ref().unwrap(); + let seq_hdr = &***f.seq_hdr.as_ref().unwrap(); let prev_mask: *mut Av1Filter = - ((*f).lf.mask).offset(((sby - 1 >> (seq_hdr.sb128 == 0) as c_int) * (*f).sb128w) as isize); + (f.lf.mask).offset(((sby - 1 >> (seq_hdr.sb128 == 0) as c_int) * f.sb128w) as isize); let mask: *mut Av1Filter = - ((*f).lf.mask).offset(((sby >> (seq_hdr.sb128 == 0) as c_int) * (*f).sb128w) as isize); + (f.lf.mask).offset(((sby >> (seq_hdr.sb128 == 0) as c_int) * f.sb128w) as isize); let start = sby * sbsz; if sby != 0 { let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; let p_up: [*mut BD::Pixel; 3] = [ - (p[0]).offset(-((8 * BD::pxstride((*f).cur.stride[0] as usize) as isize) as isize)), + (p[0]).offset(-((8 * BD::pxstride(f.cur.stride[0] as usize) as isize) as isize)), (p[1]).offset( - -((8 * BD::pxstride((*f).cur.stride[1] as usize) as isize >> ss_ver) as isize), + -((8 * BD::pxstride(f.cur.stride[1] as usize) as isize >> ss_ver) as isize), ), (p[2]).offset( - -((8 * BD::pxstride((*f).cur.stride[1] as usize) as isize >> ss_ver) as isize), + -((8 * BD::pxstride(f.cur.stride[1] as usize) as isize >> ss_ver) as isize), ), ]; rav1d_cdef_brow::(c, tc, &p_up, prev_mask, start - 2, start, true, sby); } - let n_blks = sbsz - 2 * ((sby + 1) < (*f).sbh) as c_int; - let end = cmp::min(start + n_blks, (*f).bh); + let n_blks = sbsz - 2 * ((sby + 1) < f.sbh) as c_int; + let end = cmp::min(start + n_blks, f.bh); rav1d_cdef_brow::(c, tc, &p, mask, start, end, false, sby); } @@ -4757,20 +4702,20 @@ pub(crate) unsafe fn rav1d_filter_sbrow( } pub(crate) unsafe fn rav1d_backup_ipred_edge(t: &mut Rav1dTaskContext) { - let f: *const Rav1dFrameContext = t.f; + let f: &Rav1dFrameContext = &*t.f; let ts: *mut Rav1dTileState = t.ts; - let sby = t.by >> (*f).sb_shift; - let sby_off = (*f).sb128w * 128 * sby; + let sby = t.by >> f.sb_shift; + let sby_off = f.sb128w * 128 * sby; let x_off = (*ts).tiling.col_start; - let y: *const BD::Pixel = ((*f).cur.data.data[0] as *const BD::Pixel) + let y: *const BD::Pixel = (f.cur.data.data[0] as *const BD::Pixel) .offset((x_off * 4) as isize) .offset( - (((t.by + (*f).sb_step) * 4 - 1) as isize - * BD::pxstride((*f).cur.stride[0] as usize) as isize) as isize, + (((t.by + f.sb_step) * 4 - 1) as isize + * BD::pxstride(f.cur.stride[0] as usize) as isize) as isize, ); BD::pixel_copy( &mut slice::from_raw_parts_mut( - (*f).ipred_edge[0].cast(), + f.ipred_edge[0].cast(), (sby_off + x_off * 4 + (4 * ((*ts).tiling.col_end - x_off))) .try_into() .unwrap(), @@ -4778,19 +4723,19 @@ pub(crate) unsafe fn rav1d_backup_ipred_edge(t: &mut Rav1dTaskCont slice::from_raw_parts(y, (4 * ((*ts).tiling.col_end - x_off)).try_into().unwrap()), (4 * ((*ts).tiling.col_end - x_off)).try_into().unwrap(), ); - if (*f).cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint { + if f.cur.p.layout as c_uint != Rav1dPixelLayout::I400 as c_int as c_uint { let ss_ver = - ((*f).cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; + (f.cur.p.layout as c_uint == Rav1dPixelLayout::I420 as c_int as c_uint) as c_int; let ss_hor = - ((*f).cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; + (f.cur.p.layout as c_uint != Rav1dPixelLayout::I444 as c_int as c_uint) as c_int; let uv_off: ptrdiff_t = (x_off * 4 >> ss_hor) as isize - + (((t.by + (*f).sb_step) * 4 >> ss_ver) - 1) as isize - * BD::pxstride((*f).cur.stride[1] as usize) as isize; + + (((t.by + f.sb_step) * 4 >> ss_ver) - 1) as isize + * BD::pxstride(f.cur.stride[1] as usize) as isize; let mut pl = 1; while pl <= 2 { BD::pixel_copy( &mut slice::from_raw_parts_mut( - (*f).ipred_edge[pl as usize].cast(), + f.ipred_edge[pl as usize].cast(), (sby_off + (x_off * 4 >> ss_hor) + (4 * ((*ts).tiling.col_end - x_off) >> ss_hor)) @@ -4798,7 +4743,7 @@ pub(crate) unsafe fn rav1d_backup_ipred_edge(t: &mut Rav1dTaskCont .unwrap(), )[(sby_off + (x_off * 4 >> ss_hor)).try_into().unwrap()..], &slice::from_raw_parts( - (*f).cur.data.data[pl as usize].cast(), + f.cur.data.data[pl as usize].cast(), (uv_off + (4 * ((*ts).tiling.col_end - x_off) >> ss_hor) as isize) .try_into() .unwrap(), diff --git a/src/thread_task.rs b/src/thread_task.rs index ebcfec3e4..7ce1772dd 100644 --- a/src/thread_task.rs +++ b/src/thread_task.rs @@ -315,7 +315,7 @@ unsafe fn insert_task( } #[inline] -unsafe fn add_pending(f: &mut Rav1dFrameContext, t: *mut Rav1dTask) { +unsafe fn add_pending(f: &Rav1dFrameContext, t: *mut Rav1dTask) { let mut pending_tasks = f.task_thread.pending_tasks.lock().unwrap(); (*t).next = 0 as *mut Rav1dTask; if pending_tasks.head.is_null() { @@ -529,7 +529,7 @@ pub(crate) unsafe fn rav1d_task_delayed_fg( #[inline] unsafe fn ensure_progress<'l, 'ttd: 'l>( ttd: &'ttd TaskThreadData, - f: *mut Rav1dFrameContext, + f: &Rav1dFrameContext, t: *mut Rav1dTask, type_0: TaskType, state: &AtomicI32, @@ -542,7 +542,7 @@ unsafe fn ensure_progress<'l, 'ttd: 'l>( (*t).deblock_progress = 0 as c_int; (*t).recon_progress = (*t).deblock_progress; *target = (*t).sby; - add_pending(&mut *f, t); + add_pending(f, t); *task_thread_lock = Some(ttd.delayed_fg.lock().unwrap()); return 1 as c_int; } @@ -668,7 +668,7 @@ unsafe fn abort_frame(c: &Rav1dContext, f: &mut Rav1dFrameContext, error: Rav1dR let progress = &**f.sr_cur.progress.as_ref().unwrap(); progress[0].store(FRAME_ERROR, Ordering::SeqCst); progress[1].store(FRAME_ERROR, Ordering::SeqCst); - rav1d_decode_frame_exit(c, &mut *f, error); + rav1d_decode_frame_exit(c, f, error); f.task_thread.cond.notify_one(); } @@ -1099,7 +1099,7 @@ pub unsafe fn rav1d_worker_task(c: &Rav1dContext, task_thread: Arc