Skip to content

Commit

Permalink
fn mem::zeroed: Replace most uses with Default::default() (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen authored Apr 23, 2024
2 parents be8c0e6 + 73336f1 commit b27620a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
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

0 comments on commit b27620a

Please sign in to comment.