-
Notifications
You must be signed in to change notification settings - Fork 280
Expose separate rows from PlaneMutSlice #1043
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
Conversation
4d940ba to
633fe00
Compare
|
Landed the cdef fix, needs one more rebase sorry ;_; |
b05dc55 to
db53522
Compare
src/plane.rs
Outdated
| // cannot directly return self.ps.row(row) due to lifetime issue | ||
| let range = self.ps.slice_range(row); | ||
| Some(&self.ps.plane.data[range]) | ||
| let range = PlaneSlice::slice_range(&self.plane, self.x, self.y); |
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.
Would it make more sense for slice_range to be a method on plane?
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.
Yes, you're right. Now that it is refactored that way, it is not related to PlaneSlice anymore.
| assert!(dst.len() >= (ysize - 1) * out_stride + xsize); | ||
| assert!(input.len() >= ((ysize + 3) * in_stride + xsize + 4) as usize); | ||
| cdef_filter_block(dst.as_mut_ptr(), | ||
| assert!(out_slice.rows_iter().len() >= (8 * by >> ydec) + ysize); |
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.
Is there a more direct way to get len() than producing an iterator first?
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.
Currently, no, but we can add rows_count() (or similar) on PlaneMutSlice.
I did not do that because it's only used in assert!().
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.
OK, we can skip it.
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 assert could be a debug_assert!() in case.
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.
When should we call assert!() vs debug_assert!() in rav1e?
Here, we call an unsafe code using raw pointers, which is undefined if this assertion fails.
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.
Ideally we can move to debug_assert!() all the cases in which:
- We want to document the behavior, but
- We have tests to make sure we do not break it
- The code isn't user-facing. When it is, I'd keep the assert and document when it could panic.
Make RowsIter depend on Plane instead of PlaneSlice, so that we can reuse it for PlaneMutSlice.
Currently, many functions access rectangular regions of planes (spanning multiple rows) via a primitive slice to the whole plane along with the stride information. This strategy is not compatible with tiling, since this borrows the memory belonging to other tiles. Like for PlaneSlice, add methods to PlaneMutSlice to access rows separately. See <xiph#631 (comment)>.
Implement traits Index and IndexMut to access PlaneMutSlice rows as if
it was a two-dimensional array.
Thay way, we can write:
plane_slice[8][8] = 1;
let row = &mut plane_slice[5];
row[3] = 42;
Add rows_iter() and rows_iter_mut() to iterate over PlaneMutSlice rows.
This will help to use Plane and PlaneSlice in tests.
The function required a multirows slice with stride information, which will become incompatible with PlaneMutSlice. It was already unsafe, so just replace the slice parameter by a raw pointer.
The number of rows to copy in the bottom was incorrect (it used yorigin, which is the number of rows in the "top padding").
Add unit test to make sure we will not break Plane::pad() when we change its implementation not to use PlaneMutSlice.
We have access to the whole underlying buffer from there. This avoids to call methods returning multirows mutable slices from the PlaneMutslice, so we can then remove these methods.
Remove as_mut_slice() and similar methods from PlaneMutSlice which expose slices spanning multiple rows.
lu-zero
left a comment
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.
Let's land it!
This PR is to
PlaneMutSlicewhat #1035 was toPlaneSlice.It is written over #1040 (so ignore the first commit).