Skip to content

Commit a22c5a7

Browse files
committed
mod recon: Mark #![deny(unsafe_op_in_unsafe_fn)].
`rav1d_cdef_brow` is wrapped in TODO `unsafe` blocks since #1239 fixes that already (not merged yet).
1 parent cbe24ab commit a22c5a7

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

src/decode.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,9 +4756,7 @@ fn rav1d_decode_frame_main(c: &Rav1dContext, f: &mut Rav1dFrameData) -> Rav1dRes
47564756
}
47574757

47584758
// loopfilter + cdef + restoration
4759-
//
4760-
// SAFETY: Function call with all safe args, will be marked safe.
4761-
unsafe { (f.bd_fn().filter_sbrow)(c, f, &mut t, sby) };
4759+
(f.bd_fn().filter_sbrow)(c, f, &mut t, sby);
47624760
}
47634761
}
47644762

src/recon.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(unsafe_op_in_unsafe_fn)]
2+
13
use crate::include::common::bitdepth::AsPrimitive;
24
use crate::include::common::bitdepth::BitDepth;
35
use crate::include::common::bitdepth::BPC;
@@ -142,7 +144,7 @@ pub(crate) type recon_b_inter_fn = fn(
142144
) -> Result<(), ()>;
143145

144146
pub(crate) type filter_sbrow_fn =
145-
unsafe fn(&Rav1dContext, &Rav1dFrameData, &mut Rav1dTaskContext, c_int) -> ();
147+
fn(&Rav1dContext, &Rav1dFrameData, &mut Rav1dTaskContext, c_int) -> ();
146148

147149
pub(crate) type backup_ipred_edge_fn = fn(&Rav1dFrameData, &mut Rav1dTaskContext) -> ();
148150

@@ -4015,7 +4017,7 @@ pub(crate) fn rav1d_filter_sbrow_deblock_rows<BD: BitDepth>(
40154017
}
40164018
}
40174019

4018-
pub(crate) unsafe fn rav1d_filter_sbrow_cdef<BD: BitDepth>(
4020+
pub(crate) fn rav1d_filter_sbrow_cdef<BD: BitDepth>(
40194021
c: &Rav1dContext,
40204022
f: &Rav1dFrameData,
40214023
tc: &mut Rav1dTaskContext,
@@ -4037,12 +4039,14 @@ pub(crate) unsafe fn rav1d_filter_sbrow_cdef<BD: BitDepth>(
40374039
let ss_ver = f.cur.p.layout == Rav1dPixelLayout::I420 && i != 0;
40384040
p[i] - ((8 * p[i].pixel_stride::<BD>()) >> ss_ver as u8)
40394041
});
4040-
rav1d_cdef_brow::<BD>(c, tc, f, p_up, prev_mask, start - 2, start, true, sby);
4042+
// TODO make safe
4043+
unsafe { rav1d_cdef_brow::<BD>(c, tc, f, p_up, prev_mask, start - 2, start, true, sby) };
40414044
}
40424045

40434046
let n_blks = sbsz - 2 * ((sby + 1) < f.sbh) as c_int;
40444047
let end = cmp::min(start + n_blks, f.bh);
4045-
rav1d_cdef_brow::<BD>(c, tc, f, p, mask_offset, start, end, false, sby);
4048+
// TODO make safe
4049+
unsafe { rav1d_cdef_brow::<BD>(c, tc, f, p, mask_offset, start, end, false, sby) };
40464050
}
40474051

40484052
pub(crate) fn rav1d_filter_sbrow_resize<BD: BitDepth>(
@@ -4101,7 +4105,7 @@ pub(crate) fn rav1d_filter_sbrow_lr<BD: BitDepth>(
41014105
rav1d_lr_sbrow::<BD>(c, f, sr_p, sby);
41024106
}
41034107

4104-
pub(crate) unsafe fn rav1d_filter_sbrow<BD: BitDepth>(
4108+
pub(crate) fn rav1d_filter_sbrow<BD: BitDepth>(
41054109
c: &Rav1dContext,
41064110
f: &Rav1dFrameData,
41074111
t: &mut Rav1dTaskContext,

src/thread_task.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,10 +1206,7 @@ pub fn rav1d_worker_task(task_thread: Arc<Rav1dTaskContext_task_thread>) {
12061206
{
12071207
let f = fc.data.try_read().unwrap();
12081208
if fc.task_thread.error.load(Ordering::SeqCst) == 0 {
1209-
// SAFETY: TODO make safe
1210-
unsafe {
1211-
(f.bd_fn().filter_sbrow_deblock_cols)(c, &f, &mut tc, sby);
1212-
}
1209+
(f.bd_fn().filter_sbrow_deblock_cols)(c, &f, &mut tc, sby);
12131210
}
12141211
}
12151212
if ensure_progress(
@@ -1229,10 +1226,7 @@ pub fn rav1d_worker_task(task_thread: Arc<Rav1dTaskContext_task_thread>) {
12291226
TaskType::DeblockRows => {
12301227
let f = fc.data.try_read().unwrap();
12311228
if fc.task_thread.error.load(Ordering::SeqCst) == 0 {
1232-
// SAFETY: TODO make safe
1233-
unsafe {
1234-
(f.bd_fn().filter_sbrow_deblock_rows)(c, &f, &mut tc, sby);
1235-
}
1229+
(f.bd_fn().filter_sbrow_deblock_rows)(c, &f, &mut tc, sby);
12361230
}
12371231
// signal deblock progress
12381232
let seq_hdr = &***f.seq_hdr.as_ref().unwrap();
@@ -1299,10 +1293,7 @@ pub fn rav1d_worker_task(task_thread: Arc<Rav1dTaskContext_task_thread>) {
12991293
let frame_hdr = &***f.frame_hdr.as_ref().unwrap();
13001294
if frame_hdr.size.width[0] != frame_hdr.size.width[1] {
13011295
if fc.task_thread.error.load(Ordering::SeqCst) == 0 {
1302-
// SAFETY: TODO make safe
1303-
unsafe {
1304-
(f.bd_fn().filter_sbrow_resize)(c, &f, &mut tc, sby);
1305-
}
1296+
(f.bd_fn().filter_sbrow_resize)(c, &f, &mut tc, sby);
13061297
}
13071298
}
13081299
task_type = TaskType::LoopRestoration;
@@ -1313,10 +1304,7 @@ pub fn rav1d_worker_task(task_thread: Arc<Rav1dTaskContext_task_thread>) {
13131304
if fc.task_thread.error.load(Ordering::SeqCst) == 0
13141305
&& f.lf.restore_planes != 0
13151306
{
1316-
// SAFETY: TODO make safe
1317-
unsafe {
1318-
(f.bd_fn().filter_sbrow_lr)(c, &f, &mut tc, sby);
1319-
}
1307+
(f.bd_fn().filter_sbrow_lr)(c, &f, &mut tc, sby);
13201308
}
13211309
task_type = TaskType::ReconstructionProgress;
13221310
continue 'fallthrough;

0 commit comments

Comments
 (0)