Commit c0e970f3 authored by Romain Vimont's avatar Romain Vimont Committed by Thomas Daede

Expose separate rows from 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 <https://github.com/xiph/rav1e/issues/631#issuecomment-456088577>.
parent 954df861
......@@ -444,6 +444,24 @@ pub struct PlaneMutSlice<'a, T: Pixel> {
}
impl<'a, T: Pixel> PlaneMutSlice<'a, T> {
pub fn row(&self, y: usize) -> &[T] {
let range = self.plane.row_range(self.x, self.y + y as isize);
&self.plane.data[range]
}
pub fn row_mut(&mut self, y: usize) -> &mut [T] {
let range = self.plane.row_range(self.x, self.y + y as isize);
&mut self.plane.data[range]
}
pub fn as_ptr(&self) -> *const T {
self.row(0).as_ptr()
}
pub fn as_mut_ptr(&mut self) -> *mut T {
self.row_mut(0).as_mut_ptr()
}
pub fn as_mut_slice(&mut self) -> &mut [T] {
let stride = self.plane.cfg.stride;
let base = (self.y + self.plane.cfg.yorigin as isize) as usize * stride
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment