rav1e
rav1e copied to clipboard
Use MaybeUninit properly
Now that we switched to MaybeUninit in #1292 we might as well start using it properly; right now as far as I can tell it's equivalent to mem::uninitialized() in our usage. See the MaybeUninit docs.
In particular, instead of doing MaybeUninit::uninit().assume_init() we should be doing MaybeUninit::uninit(), then initializing the value using .as_mut_ptr().write(...) and only then doing .assume_init().
It appears the only remaining place where this needs to be fixed is in AlignedArray::uninitialized.
How to handle PlaneRegionMut? It's used in lots of places for dst: &mut PlaneRegionMut<T>.
It's relatively easy to remove T: Pixel bound on it, and make PlaneRegionMut<MaybeUninit<T>> work.
Alternatively, maybe there could be a simpler type that is purely {width, height, stride} that could be created ad-hoc from PlaneRegionMut and slices? It seems that many places that take PlaneRegionMut don't actually use all of the plane config complexity, and just redundantly compute things like let xsize = (8 >> xdec) as isize; to reduce it to back basic width/height/stride.
When do we have a PlaneRegion that is pointing to something not initialized though?
subpel_diamond_search makes PlaneRegionMut from let mut buf: Aligned<[T; 128 * 128]> = unsafe { Aligned::uninitialized() } and then hopes get_subpel_mv_rd is initializing it.