-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
struct Rav1dFrameContext_lf::lr_lpf_line
: Convert to offsets
#793
Conversation
879f132
to
3849584
Compare
src/lf_apply.rs
Outdated
let dst: [&mut [BD::Pixel]; 3] = [ | ||
slice::from_raw_parts_mut( | ||
(f.lf.lr_lpf_line[0] as *mut BD::Pixel).offset(cmp::min(y_span, 0)), | ||
lr_plane_sz[0] as usize, | ||
), | ||
slice::from_raw_parts_mut( | ||
(f.lf.lr_lpf_line[1] as *mut BD::Pixel).offset(cmp::min(uv_span, 0)), | ||
lr_plane_sz[1] as usize / 2, | ||
), | ||
slice::from_raw_parts_mut( | ||
(f.lf.lr_lpf_line[2] as *mut BD::Pixel).offset(cmp::min(uv_span, 0)), | ||
lr_plane_sz[1] as usize / 2, | ||
), | ||
]; | ||
let dst_offset: [usize; 2] = [ | ||
let yuv_offset: [usize; 2] = [ | ||
(tt_off as isize * y_stride - cmp::min(y_span, 0)) as usize, | ||
(tt_off as isize * uv_stride - cmp::min(uv_span, 0)) as usize, | ||
]; | ||
let dst_offset = [ | ||
f.lf.lr_lpf_line[0].wrapping_add_signed(cmp::min(y_span, 0)) + yuv_offset[0], | ||
f.lf.lr_lpf_line[1].wrapping_add_signed(cmp::min(uv_span, 0)) + yuv_offset[1], | ||
f.lf.lr_lpf_line[2].wrapping_add_signed(cmp::min(uv_span, 0)) + yuv_offset[1], | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we keep the original dst
as an array of &mut [_]
s? They don't overlap, so we should be able to split up lr_line_buf
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splitting up lr_line_buf
into separate slices isn't necessary here. We were passing dst[i]
plus an offset into backup_lpf
, so the most straightforward thing to do is combine the offsets and pass all of lr_line_buf
in along with the calculated offset. I don't see any reason to go through the extra steps of split_at_mut
ing the slice only to still pass in a buffer+offset pair.
Rav1dFrameContext_lf::lr_lpf_line
: Convert to offsetsstruct Rav1dFrameContext_lf::lr_lpf_line
: Convert to offsets
This is blocked on #801. The test failures we're seeing originate from the out-of-bounds pointer access that is already present on |
3849584
to
21f7300
Compare
let lpf_plane_sz = BD::pxstride(f.lf.lr_buf_plane_sz[(plane != 0) as usize] as isize); | ||
let mut lpf_offset = cmp::max(lpf_stride - lpf_plane_sz, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fbossen I ended up removing lpf_plane_sz
and lpf_offset
in order to make the calculation here the same as the original C. You had added those in #746 to handle negative strides I think. Do we still need those with the fixed pxstride
? Was there a reason why we needed those values in Rust but not in the original C?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I added lpf_plane_sz
and lpf_offset
is that I defined lpf
as a slice that begins at the memory section being effectively used and needed the compute the memory location of the beginning of the slice (and cover the case of a negative stride). If, instead of defining a new slice lpf
, you use lr_line_buf
, then removing lpf_plane_sz
and lpf_offset
looks appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further testing, it looks like I am hitting an error on one of the test bitstreams. Let me look into it and report more details later.
src/lf_apply.rs
Outdated
@@ -161,29 +161,21 @@ pub(crate) unsafe fn rav1d_copy_lpf<BD: BitDepth>( | |||
let y_span = lr_plane_sz[0] as isize - y_stride; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to remove y_span
and uv_span
here as well. They were used to compute the base address of the slice. It seems superfluous to subtract y_span
in yuv_offset[0]
and add it back in dst_offset[0]
The issues boils down to the following: in |
Huh, is that being caused by the changes in this PR? I haven't changed anything related to when we do the re-allocation and update |
21f7300
to
68fda0e
Compare
Yes. Changes in this PR cause the issue. If |
68fda0e
to
b637376
Compare
Okay, thanks for confirming! I've removed the conditional logic for initializing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.