Skip to content

Commit

Permalink
struct Rav1dTaskContext: Initialize fields with `Default::default()…
Browse files Browse the repository at this point in the history
…` except for `scratch`, which is a `union` and a WIP to make safe.
  • Loading branch information
kkysen committed Apr 23, 2024
1 parent a5739a5 commit 73336f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
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 73336f1

Please sign in to comment.