Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fn mem::zeroed: Replace most uses with Default::default() #994

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/cdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ use crate::src::tables::dav1d_partition_type_count;
use std::cmp;
use std::ffi::c_int;
use std::ffi::c_uint;
use std::mem;
use std::sync::atomic::AtomicU32;
use std::sync::Arc;
use std::sync::RwLock;
use std::sync::RwLockWriteGuard;
use strum::EnumCount;

#[derive(Clone)]
#[derive(Clone, Default)]
#[repr(C)]
pub struct CdfContext {
pub m: CdfModeContext,
Expand All @@ -36,14 +35,14 @@ pub struct CdfContext {
pub dmv: CdfMvContext,
}

#[derive(Clone)]
#[derive(Clone, Default)]
#[repr(C)]
pub struct CdfMvContext {
pub comp: [CdfMvComponent; 2],
pub joint: Align8<[u16; 4]>,
}

#[derive(Clone)]
#[derive(Clone, Default)]
#[repr(C)]
pub struct CdfMvComponent {
pub classes: Align32<[u16; 16]>,
Expand All @@ -56,7 +55,7 @@ pub struct CdfMvComponent {
pub sign: Align4<[u16; 2]>,
}

#[derive(Clone)]
#[derive(Clone, Default)]
#[repr(C)]
pub struct CdfCoefContext {
pub eob_bin_16: Align16<[[[u16; 8]; 2]; 2]>,
Expand All @@ -74,7 +73,7 @@ pub struct CdfCoefContext {
pub dc_sign: Align4<[[[u16; 2]; 3]; 2]>,
}

#[derive(Clone)]
#[derive(Clone, Default)]
#[repr(C)]
pub struct CdfModeContext {
pub y_mode: Align32<[[u16; N_INTRA_PRED_MODES + 3]; 4]>,
Expand Down Expand Up @@ -5127,7 +5126,7 @@ pub unsafe fn rav1d_cdf_thread_alloc(
None
};
Ok(CdfThreadContext::Cdf(Arc::new(CdfThreadContext_data {
cdf: mem::zeroed(),
cdf: Default::default(),
progress,
})))
}
11 changes: 5 additions & 6 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ use std::ops::Index;
use std::ops::IndexMut;
use std::ops::Range;
use std::ops::Sub;
use std::ptr;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::AtomicU32;
Expand Down Expand Up @@ -1070,22 +1069,22 @@ pub(crate) struct Rav1dTaskContext {
}

impl Rav1dTaskContext {
pub(crate) unsafe fn new(task_thread: Arc<Rav1dTaskContext_task_thread>) -> Self {
pub(crate) fn new(task_thread: Arc<Rav1dTaskContext_task_thread>) -> Self {
Self {
ts: 0,
b: Default::default(),
l: Default::default(),
a: 0,
rt: mem::zeroed(),
rt: Default::default(),
cf: Default::default(),
al_pal: Default::default(),
pal_sz_uv: Default::default(),
scratch: mem::zeroed(),
warpmv: mem::zeroed(),
scratch: unsafe { mem::zeroed() },
warpmv: Default::default(),
lf_mask: None,
top_pre_cdef_toggle: 0,
cur_sb_cdef_idx: 0,
tl_4x4_filter: mem::zeroed(),
tl_4x4_filter: Filter2d::Regular8Tap, // 0
frame_thread: Rav1dTaskContext_frame_thread { pass: 0 },
task_thread,
}
Expand Down
12 changes: 12 additions & 0 deletions src/refmvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ pub(crate) struct RefMvsFrame {
pub n_frame_threads: u32,
}

#[derive(Default)]
#[repr(C)]
pub struct refmvs_tile_range {
pub start: c_int,
Expand All @@ -246,6 +247,17 @@ pub(crate) struct refmvs_tile {
pub tile_row: refmvs_tile_range,
}

impl Default for refmvs_tile {
fn default() -> Self {
Self {
r: [Default::default(); 37],
rp_proj: Default::default(),
tile_col: Default::default(),
tile_row: Default::default(),
}
}
}

#[derive(Copy, Clone, Default)]
#[repr(C)]
pub struct refmvs_candidate {
Expand Down
Loading