diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7ce24e712..3e0023626 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,9 @@ [toolchain] -channel = "nightly-2022-08-08" +channel = "nightly-2023-05-10" +targets = [ + "x86_64-unknown-linux-gnu", + "i686-unknown-linux-gnu", + "aarch64-unknown-linux-gnu", + "armv7-unknown-linux-gnueabihf", +] components = ["rustfmt"] diff --git a/src/cdef_apply_tmpl_16.rs b/src/cdef_apply_tmpl_16.rs index b7839718e..725ef9a00 100644 --- a/src/cdef_apply_tmpl_16.rs +++ b/src/cdef_apply_tmpl_16.rs @@ -929,7 +929,7 @@ pub unsafe extern "C" fn dav1d_cdef_brow_16bpc( layout, ); } - let mut lr_bak: [[[[pixel; 2]; 8]; 3]; 2] = [[[[0; 2]; 8]; 3]; 2]; + let mut lr_bak: Align16<[[[[pixel; 2]; 8]; 3]; 2]> = Align16([[[[0; 2]; 8]; 3]; 2]); let mut iptrs: [*mut pixel; 3] = [ptrs[0], ptrs[1], ptrs[2]]; edges = ::core::mem::transmute::( edges as libc::c_uint & !(CDEF_HAVE_LEFT as libc::c_int) as libc::c_uint, diff --git a/src/cdef_apply_tmpl_8.rs b/src/cdef_apply_tmpl_8.rs index eb2e077f7..9d72d7a10 100644 --- a/src/cdef_apply_tmpl_8.rs +++ b/src/cdef_apply_tmpl_8.rs @@ -902,7 +902,7 @@ pub unsafe extern "C" fn dav1d_cdef_brow_8bpc( layout, ); } - let mut lr_bak: [[[[pixel; 2]; 8]; 3]; 2] = [[[[0; 2]; 8]; 3]; 2]; + let mut lr_bak: Align16<[[[[pixel; 2]; 8]; 3]; 2]> = Align16([[[[0; 2]; 8]; 3]; 2]); let mut iptrs: [*mut pixel; 3] = [ptrs[0], ptrs[1], ptrs[2]]; edges = ::core::mem::transmute::( edges as libc::c_uint & !(CDEF_HAVE_LEFT as libc::c_int) as libc::c_uint, diff --git a/src/cdef_tmpl_8.rs b/src/cdef_tmpl_8.rs index 9a0507b00..ead658f1d 100644 --- a/src/cdef_tmpl_8.rs +++ b/src/cdef_tmpl_8.rs @@ -845,8 +845,8 @@ unsafe extern "C" fn cdef_filter_4x4_neon( damping: libc::c_int, edges: CdefEdgeFlags, ) { - let mut tmp_buf = [0; 104]; - let mut tmp = tmp_buf.as_mut_ptr().offset(2 * 8).offset(8); + let mut tmp_buf = Align16([0; 104]); + let mut tmp = tmp_buf.0.as_mut_ptr().offset(2 * 8).offset(8); dav1d_cdef_padding4_8bpc_neon(tmp, dst, stride, left, top, bottom, 4, edges); dav1d_cdef_filter4_8bpc_neon( dst, @@ -875,8 +875,8 @@ unsafe extern "C" fn cdef_filter_4x8_neon( damping: libc::c_int, edges: CdefEdgeFlags, ) { - let mut tmp_buf = [0; 104]; - let mut tmp = tmp_buf.as_mut_ptr().offset(2 * 8).offset(8); + let mut tmp_buf = Align16([0; 104]); + let mut tmp = tmp_buf.0.as_mut_ptr().offset(2 * 8).offset(8); dav1d_cdef_padding4_8bpc_neon(tmp, dst, stride, left, top, bottom, 8, edges); dav1d_cdef_filter4_8bpc_neon( dst, diff --git a/src/decode.rs b/src/decode.rs index 65e14f14c..b22fd4445 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -3335,14 +3335,13 @@ unsafe fn decode_b( if b.skip_mode != 0 { b.intra = 0; } else if is_inter_or_switch(frame_hdr) { - if let Some(seg) = seg && (seg.r#ref >= 0 || seg.globalmv != 0) { + if let Some(seg) = seg.filter(|seg| seg.r#ref >= 0 || seg.globalmv != 0) { b.intra = (seg.r#ref == 0) as uint8_t; } else { let ictx = get_intra_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); - b.intra = (!dav1d_msac_decode_bool_adapt( - &mut ts.msac, - &mut ts.cdf.m.intra[ictx.into()], - )) as uint8_t; + b.intra = + (!dav1d_msac_decode_bool_adapt(&mut ts.msac, &mut ts.cdf.m.intra[ictx.into()])) + as uint8_t; if DEBUG_BLOCK_INFO(f, t) { println!("Post-intra[{}]: r={}", b.intra, ts.msac.rng); @@ -4266,139 +4265,64 @@ unsafe fn decode_b( } } else { b.c2rust_unnamed.c2rust_unnamed_0.comp_type = COMP_INTER_NONE as libc::c_int as uint8_t; - if let Some(seg) = seg && seg.r#ref > 0 { - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0 as libc::c_int - as usize] = seg.r#ref as i8 - 1; - } else if let Some(seg) = seg && (seg.globalmv != 0 || seg.skip != 0) { - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0] = 0 as libc::c_int as int8_t; + if let Some(seg) = seg.filter(|seg| seg.r#ref > 0) { + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0 as libc::c_int as usize] = + seg.r#ref as i8 - 1; + } else if let Some(_) = seg.filter(|seg| seg.globalmv != 0 || seg.skip != 0) { + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] = 0 as libc::c_int as int8_t; } else { - let ctx1_0 = av1_get_ref_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); + let ctx1_0 = av1_get_ref_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); if dav1d_msac_decode_bool_adapt( &mut ts.msac, &mut ts.cdf.m.r#ref[0][ctx1_0 as usize], - ) - { - let ctx2_1 = av1_get_bwd_ref_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); + ) { + let ctx2_1 = av1_get_bwd_ref_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); if dav1d_msac_decode_bool_adapt( &mut ts.msac, &mut ts.cdf.m.r#ref[1][ctx2_1 as usize], - ) - { - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0 as libc::c_int - as usize] = 6 as libc::c_int as int8_t; + ) { + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0 as libc::c_int as usize] = + 6 as libc::c_int as int8_t; } else { - let ctx3_0 = av1_get_bwd_ref_1_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0 as libc::c_int - as usize] = (4 as libc::c_int as libc::c_uint) - .wrapping_add( + let ctx3_0 = + av1_get_bwd_ref_1_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0 as libc::c_int as usize] = + (4 as libc::c_int as libc::c_uint).wrapping_add( dav1d_msac_decode_bool_adapt( &mut ts.msac, - &mut ts - .cdf - .m - .r#ref[5][ctx3_0 as usize], + &mut ts.cdf.m.r#ref[5][ctx3_0 as usize], ) as libc::c_uint, ) as int8_t; } } else { - let ctx2_2 = av1_get_fwd_ref_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); + let ctx2_2 = av1_get_fwd_ref_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); if dav1d_msac_decode_bool_adapt( &mut ts.msac, &mut ts.cdf.m.r#ref[2][ctx2_2 as usize], - ) - { - let ctx3_1 = av1_get_fwd_ref_2_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0 as libc::c_int - as usize] = (2 as libc::c_int as libc::c_uint) - .wrapping_add( + ) { + let ctx3_1 = + av1_get_fwd_ref_2_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0 as libc::c_int as usize] = + (2 as libc::c_int as libc::c_uint).wrapping_add( dav1d_msac_decode_bool_adapt( &mut ts.msac, - &mut ts - .cdf - .m - .r#ref[4][ctx3_1 as usize], + &mut ts.cdf.m.r#ref[4][ctx3_1 as usize], ) as libc::c_uint, ) as int8_t; } else { - let ctx3_2 = av1_get_fwd_ref_1_ctx( - &*t.a, - &t.l, - by4, - bx4, - have_top, - have_left, - ); - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0 as libc::c_int - as usize] = dav1d_msac_decode_bool_adapt( - &mut ts.msac, - &mut ts - .cdf - .m - .r#ref[3][ctx3_2 as usize], - ) as int8_t; + let ctx3_2 = + av1_get_fwd_ref_1_ctx(&*t.a, &t.l, by4, bx4, have_top, have_left); + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0 as libc::c_int as usize] = + dav1d_msac_decode_bool_adapt( + &mut ts.msac, + &mut ts.cdf.m.r#ref[3][ctx3_2 as usize], + ) as int8_t; } } - if DEBUG_BLOCK_INFO(f, t) - { + if DEBUG_BLOCK_INFO(f, t) { printf( b"Post-ref[%d]: r=%d\n\0" as *const u8 as *const libc::c_char, - b - .c2rust_unnamed - .c2rust_unnamed_0 - .r#ref[0] as libc::c_int, + b.c2rust_unnamed.c2rust_unnamed_0.r#ref[0] as libc::c_int, ts.msac.rng, ); } diff --git a/src/env.rs b/src/env.rs index 5dc7b164d..57778faa1 100644 --- a/src/env.rs +++ b/src/env.rs @@ -578,9 +578,10 @@ pub fn av1_get_uni_p1_ctx( if let Some(cnt) = cnt.get_mut((a.r#ref[0][xb4 as usize] - 1) as usize) { *cnt += 1; } - if a.comp_type[xb4 as usize] != 0 - && let Some(cnt) = cnt.get_mut((a.r#ref[1][xb4 as usize] - 1) as usize) { - *cnt += 1; + if a.comp_type[xb4 as usize] != 0 { + if let Some(cnt) = cnt.get_mut((a.r#ref[1][xb4 as usize] - 1) as usize) { + *cnt += 1; + } } } @@ -588,9 +589,10 @@ pub fn av1_get_uni_p1_ctx( if let Some(cnt) = cnt.get_mut((l.r#ref[0][yb4 as usize] - 1) as usize) { *cnt += 1; } - if l.comp_type[yb4 as usize] != 0 - && let Some(cnt) = cnt.get_mut((l.r#ref[1][yb4 as usize] - 1) as usize) { - *cnt += 1; + if l.comp_type[yb4 as usize] != 0 { + if let Some(cnt) = cnt.get_mut((l.r#ref[1][yb4 as usize] - 1) as usize) { + *cnt += 1; + } } } diff --git a/src/fg_apply_tmpl_16.rs b/src/fg_apply_tmpl_16.rs index aaba86941..60278a5ed 100644 --- a/src/fg_apply_tmpl_16.rs +++ b/src/fg_apply_tmpl_16.rs @@ -1,6 +1,6 @@ use crate::include::stddef::*; use crate::include::stdint::*; -use crate::src::align::{Align16, Align64}; +use crate::src::align::{Align1, Align16}; use ::libc; extern "C" { pub type Dav1dRef; @@ -392,7 +392,7 @@ pub unsafe extern "C" fn dav1d_apply_grain_16bpc( in_0: *const Dav1dPicture, ) { let mut grain_lut = Align16([[[0; 82]; 74]; 3]); - let mut scaling = Align64([[0; 4096]; 3]); + let mut scaling = Align1([[0; 4096]; 3]); let rows = (*out).p.h + 31 >> 5; dav1d_prep_grain_16bpc( dsp, diff --git a/src/fg_apply_tmpl_8.rs b/src/fg_apply_tmpl_8.rs index 4deec89c1..c2619b763 100644 --- a/src/fg_apply_tmpl_8.rs +++ b/src/fg_apply_tmpl_8.rs @@ -1,7 +1,8 @@ use crate::include::stddef::*; use crate::include::stdint::*; -use crate::src::align::{Align16, Align64}; +use crate::src::align::Align16; use ::libc; +use cfg_if::cfg_if; extern "C" { pub type Dav1dRef; fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: libc::c_ulong) -> *mut libc::c_void; @@ -348,7 +349,17 @@ pub unsafe extern "C" fn dav1d_apply_grain_8bpc( in_0: *const Dav1dPicture, ) { let mut grain_lut = Align16([[[0; 82]; 74]; 3]); - let mut scaling = Align64([[0; 256]; 3]); + cfg_if! { + if #[cfg(target_arch = "x86_64")] { + use crate::src::align::Align64; + + let mut scaling = Align64([[0; 256]; 3]); + } else { + use crate::src::align::Align1; + + let mut scaling = Align1([[0; 256]; 3]); + } + } let rows = (*out).p.h + 31 >> 5; dav1d_prep_grain_8bpc( dsp, diff --git a/src/lf_mask.rs b/src/lf_mask.rs index ea6826719..829e75e4d 100644 --- a/src/lf_mask.rs +++ b/src/lf_mask.rs @@ -60,6 +60,9 @@ use crate::include::common::intops::iclip; use crate::include::common::intops::imax; use crate::include::common::intops::imin; use crate::src::tables::TxfmInfo; + +use crate::src::align::Align16; + unsafe extern "C" fn decomp_tx( txa: *mut [[[uint8_t; 32]; 32]; 2], from: RectTxfmSize, @@ -324,7 +327,7 @@ unsafe extern "C" fn mask_edges_inter( &*dav1d_txfm_dimensions.as_ptr().offset(max_tx as isize) as *const TxfmInfo; let mut y = 0; let mut x = 0; - let mut txa: [[[[uint8_t; 32]; 32]; 2]; 2] = [[[[0; 32]; 32]; 2]; 2]; + let mut txa: Align16<[[[[uint8_t; 32]; 32]; 2]; 2]> = Align16([[[[0; 32]; 32]; 2]; 2]); let mut y_off = 0; let mut y_0 = 0; while y_0 < h4 { @@ -332,7 +335,7 @@ unsafe extern "C" fn mask_edges_inter( let mut x_0 = 0; while x_0 < w4 { decomp_tx( - &mut *(*(*(*txa.as_mut_ptr().offset(0)).as_mut_ptr().offset(0)) + &mut *(*(*(*txa.0.as_mut_ptr().offset(0)).as_mut_ptr().offset(0)) .as_mut_ptr() .offset(y_0 as isize)) .as_mut_ptr() diff --git a/src/lr_apply_tmpl_16.rs b/src/lr_apply_tmpl_16.rs index bef395e21..073e3b029 100644 --- a/src/lr_apply_tmpl_16.rs +++ b/src/lr_apply_tmpl_16.rs @@ -869,7 +869,7 @@ unsafe extern "C" fn lr_sbrow( let max_unit_size = unit_size + half_unit_size; let row_y = y + (8 >> ss_ver) * (y != 0) as libc::c_int; let shift_hor = 7 - ss_hor; - let mut pre_lr_border: [[[pixel; 4]; 136]; 2] = [[[0; 4]; 136]; 2]; + let mut pre_lr_border: Align16<[[[pixel; 4]; 136]; 2]> = Align16([[[0; 4]; 136]; 2]); let mut lr: [*const Av1RestorationUnit; 2] = [0 as *const Av1RestorationUnit; 2]; let mut edges: LrEdgeFlags = ((if y > 0 { LR_HAVE_TOP as libc::c_int diff --git a/src/lr_apply_tmpl_8.rs b/src/lr_apply_tmpl_8.rs index f55055f01..56d53077d 100644 --- a/src/lr_apply_tmpl_8.rs +++ b/src/lr_apply_tmpl_8.rs @@ -840,7 +840,7 @@ unsafe extern "C" fn lr_sbrow( let max_unit_size = unit_size + half_unit_size; let row_y = y + (8 >> ss_ver) * (y != 0) as libc::c_int; let shift_hor = 7 - ss_hor; - let mut pre_lr_border: [[[pixel; 4]; 136]; 2] = [[[0; 4]; 136]; 2]; + let mut pre_lr_border: Align16<[[[pixel; 4]; 136]; 2]> = Align16([[[0; 4]; 136]; 2]); let mut lr: [*const Av1RestorationUnit; 2] = [0 as *const Av1RestorationUnit; 2]; let mut edges: LrEdgeFlags = ((if y > 0 { LR_HAVE_TOP as libc::c_int