Skip to content

Commit 73336f1

Browse files
committed
struct Rav1dTaskContext: Initialize fields with Default::default() except for scratch, which is a union and a WIP to make safe.
1 parent a5739a5 commit 73336f1

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/internal.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ use std::ops::Index;
9898
use std::ops::IndexMut;
9999
use std::ops::Range;
100100
use std::ops::Sub;
101-
use std::ptr;
102101
use std::sync::atomic::AtomicBool;
103102
use std::sync::atomic::AtomicI32;
104103
use std::sync::atomic::AtomicU32;
@@ -1070,22 +1069,22 @@ pub(crate) struct Rav1dTaskContext {
10701069
}
10711070

10721071
impl Rav1dTaskContext {
1073-
pub(crate) unsafe fn new(task_thread: Arc<Rav1dTaskContext_task_thread>) -> Self {
1072+
pub(crate) fn new(task_thread: Arc<Rav1dTaskContext_task_thread>) -> Self {
10741073
Self {
10751074
ts: 0,
10761075
b: Default::default(),
10771076
l: Default::default(),
10781077
a: 0,
1079-
rt: mem::zeroed(),
1078+
rt: Default::default(),
10801079
cf: Default::default(),
10811080
al_pal: Default::default(),
10821081
pal_sz_uv: Default::default(),
1083-
scratch: mem::zeroed(),
1084-
warpmv: mem::zeroed(),
1082+
scratch: unsafe { mem::zeroed() },
1083+
warpmv: Default::default(),
10851084
lf_mask: None,
10861085
top_pre_cdef_toggle: 0,
10871086
cur_sb_cdef_idx: 0,
1088-
tl_4x4_filter: mem::zeroed(),
1087+
tl_4x4_filter: Filter2d::Regular8Tap, // 0
10891088
frame_thread: Rav1dTaskContext_frame_thread { pass: 0 },
10901089
task_thread,
10911090
}

src/refmvs.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub(crate) struct RefMvsFrame {
224224
pub n_frame_threads: u32,
225225
}
226226

227+
#[derive(Default)]
227228
#[repr(C)]
228229
pub struct refmvs_tile_range {
229230
pub start: c_int,
@@ -246,6 +247,17 @@ pub(crate) struct refmvs_tile {
246247
pub tile_row: refmvs_tile_range,
247248
}
248249

250+
impl Default for refmvs_tile {
251+
fn default() -> Self {
252+
Self {
253+
r: [Default::default(); 37],
254+
rp_proj: Default::default(),
255+
tile_col: Default::default(),
256+
tile_row: Default::default(),
257+
}
258+
}
259+
}
260+
249261
#[derive(Copy, Clone, Default)]
250262
#[repr(C)]
251263
pub struct refmvs_candidate {

0 commit comments

Comments
 (0)