Skip to content

Commit

Permalink
Define intermediate variables to minimize "distance" from existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Bossen committed Feb 5, 2024
1 parent 0a3c9a1 commit cf2527f
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/recon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,11 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
let data_width = 4 * (*ts).tiling.col_end;
let data_height = 4 * (*ts).tiling.row_end;
let data_diff = (data_height - 1) as isize * data_stride;
let dst_slice = slice::from_raw_parts(
((*f).cur.data.data[0] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
);
m = rav1d_prepare_intra_edges(
t.bx,
t.bx > (*ts).tiling.col_start,
Expand All @@ -2674,11 +2679,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
(*ts).tiling.col_end,
(*ts).tiling.row_end,
edge_flags,
slice::from_raw_parts(
((*f).cur.data.data[0] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
),
dst_slice,
(*f).cur.stride[0],
top_sb_edge_slice,
b.c2rust_unnamed.c2rust_unnamed.y_mode as IntraPredMode,
Expand Down Expand Up @@ -2894,6 +2895,11 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
let data_width = 4 * (*ts).tiling.col_end >> ss_ver;
let data_height = 4 * (*ts).tiling.row_end >> ss_ver;
let data_diff = (data_height - 1) as isize * data_stride;
let uvdst_slice = slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
);
let m: IntraPredMode = rav1d_prepare_intra_edges(
xpos,
xpos > xstart,
Expand All @@ -2902,11 +2908,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
(*ts).tiling.col_end >> ss_hor,
(*ts).tiling.row_end >> ss_ver,
0 as EdgeFlags,
slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
),
uvdst_slice,
stride,
top_sb_edge_slice,
DC_PRED,
Expand Down Expand Up @@ -3110,6 +3112,11 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
let data_width = 4 * (*ts).tiling.col_end >> ss_ver;
let data_height = 4 * (*ts).tiling.row_end >> ss_ver;
let data_diff = (data_height - 1) as isize * data_stride;
let dstuv_slice = slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
);
m = rav1d_prepare_intra_edges(
xpos,
xpos > xstart,
Expand All @@ -3118,11 +3125,7 @@ pub(crate) unsafe fn rav1d_recon_b_intra<BD: BitDepth>(
(*ts).tiling.col_end >> ss_hor,
(*ts).tiling.row_end >> ss_ver,
edge_flags,
slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
),
dstuv_slice,
stride,
top_sb_edge_slice,
uv_mode,
Expand Down Expand Up @@ -3507,6 +3510,10 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
let data_width = 4 * (*ts).tiling.col_end;
let data_height = 4 * (*ts).tiling.row_end;
let data_diff = (data_height - 1) as isize * data_stride;
let dst_slice = slice::from_raw_parts(
((*f).cur.data.data[0] as *const BD::Pixel).offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
);
m = rav1d_prepare_intra_edges(
t.bx,
t.bx > (*ts).tiling.col_start,
Expand All @@ -3515,10 +3522,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
(*ts).tiling.col_end,
(*ts).tiling.row_end,
0 as EdgeFlags,
slice::from_raw_parts(
((*f).cur.data.data[0] as *const BD::Pixel).offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
),
dst_slice,
(*f).cur.stride[0],
top_sb_edge_slice,
m,
Expand Down Expand Up @@ -3936,6 +3940,11 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
let data_width = 4 * (*ts).tiling.col_end >> ss_hor;
let data_height = 4 * (*ts).tiling.row_end >> ss_ver;
let data_diff = (data_height - 1) as isize * data_stride;
let dstuv_slice = slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
);
m = rav1d_prepare_intra_edges(
t.bx >> ss_hor,
t.bx >> ss_hor > (*ts).tiling.col_start >> ss_hor,
Expand All @@ -3944,11 +3953,7 @@ pub(crate) unsafe fn rav1d_recon_b_inter<BD: BitDepth>(
(*ts).tiling.col_end >> ss_hor,
(*ts).tiling.row_end >> ss_ver,
0 as EdgeFlags,
slice::from_raw_parts(
((*f).cur.data.data[1 + pl as usize] as *const BD::Pixel)
.offset(cmp::min(data_diff, 0)),
data_diff.unsigned_abs() + data_width as usize,
),
dstuv_slice,
(*f).cur.stride[1],
top_sb_edge_slice,
m,
Expand Down

0 comments on commit cf2527f

Please sign in to comment.