diff --git a/src/internal.rs b/src/internal.rs index 21dc5d9a7..24fadeae6 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -939,6 +939,7 @@ pub struct ScratchCompinter { pub seg_mask: [u8; 16384], } +// Larger of the two between `ScratchCompinter` and `[BD::Pixel; 128 * 32]`. const SCRATCH_COMPINTER_SIZE: usize = mem::size_of::(); #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] @@ -955,15 +956,14 @@ impl ScratchLapInter { } } -const EMU_EDGE_SIZE: usize = 320 * (256 + 7); +const EMU_EDGE_LEN: usize = 320 * (256 + 7); // stride=192 for non-SVC, or 320 for SVC -// Contains `320 * (256 + 7)` elements of either `u8` or `u16` depending on bitdepth. #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C, align(32))] -pub struct EmuEdge([u8; EMU_EDGE_SIZE * 2]); +pub struct ScratchEmuEdge([u8; EMU_EDGE_LEN * 2]); -impl EmuEdge { - pub fn buf_mut(&mut self) -> &mut [BD::Pixel; EMU_EDGE_SIZE] { +impl ScratchEmuEdge { + pub fn buf_mut(&mut self) -> &mut [BD::Pixel; EMU_EDGE_LEN] { FromBytes::mut_from_prefix(&mut self.0).unwrap() } } @@ -972,7 +972,7 @@ impl EmuEdge { #[repr(C)] pub struct ScratchInter { pub lap_inter: ScratchLapInter, - pub emu_edge: EmuEdge, + pub emu_edge: ScratchEmuEdge, } #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] @@ -982,25 +982,10 @@ pub struct ScratchPal { pub pal_ctx: [u8; 64], } -impl Default for ScratchPal { - fn default() -> Self { - Self { - pal_order: [[0; 8]; 64], - pal_ctx: [0; 64], - } - } -} - #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C, align(64))] pub struct ScratchLevelsPal([u8; 1088]); -impl Default for ScratchLevelsPal { - fn default() -> Self { - Self([0; 1088]) - } -} - impl ScratchLevelsPal { pub fn levels_mut(&mut self) -> &mut [u8; 1088] { &mut self.0 @@ -1013,9 +998,9 @@ impl ScratchLevelsPal { #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C, align(64))] -pub struct InterIntraEdgePalInterintra([u8; 64 * 64 * 2]); +pub struct ScratchInterintraBuf([u8; 64 * 64 * 2]); -impl InterIntraEdgePalInterintra { +impl ScratchInterintraBuf { pub fn buf_mut(&mut self) -> &mut [BD::Pixel; 64 * 64] { FromBytes::mut_from_prefix(&mut self.0).unwrap() } @@ -1023,9 +1008,9 @@ impl InterIntraEdgePalInterintra { #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C, align(32))] -pub struct InterIntraEdgePalEdge([u8; 257 * 2 + 30]); // 257 Pixel elements + 30 padding bytes +pub struct ScratchEdgeBuf([u8; 257 * 2 + 30]); // 257 Pixel elements + 30 padding bytes -impl InterIntraEdgePalEdge { +impl ScratchEdgeBuf { pub fn buf_mut(&mut self) -> &mut [BD::Pixel; 257] { FromBytes::mut_from_prefix(&mut self.0).unwrap() } @@ -1033,10 +1018,9 @@ impl InterIntraEdgePalEdge { #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C, align(16))] -pub struct InterIntraEdgePalPal([u8; 8 * 3 * 2]); /* [3 plane][8 palette_idx] */ - +pub struct ScratchPalBuf([u8; 8 * 3 * 2]); /* [3 plane][8 palette_idx] */ -impl InterIntraEdgePalPal { +impl ScratchPalBuf { pub fn buf(&self) -> &[[BD::Pixel; 8]; 3] { FromBytes::ref_from_prefix(&self.0).unwrap() } @@ -1048,10 +1032,10 @@ impl InterIntraEdgePalPal { #[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)] #[repr(C)] -pub struct InterIntraEdgePal { - pub interintra: InterIntraEdgePalInterintra, - pub edge: InterIntraEdgePalEdge, - pub pal: InterIntraEdgePalPal, +pub struct ScratchInterintraEdgePal { + pub interintra: ScratchInterintraBuf, + pub edge: ScratchEdgeBuf, + pub pal: ScratchPalBuf, _padding: [u8; 48], } @@ -1070,7 +1054,6 @@ impl ScratchAcTxtpMap { FromBytes::mut_from_prefix(&mut self.0).unwrap() } - #[track_caller] pub fn txtp_map(&self) -> &[TxfmType; 1024] { FromBytes::ref_from_prefix(&self.0).unwrap() } @@ -1086,7 +1069,7 @@ pub struct ScratchInterIntra { pub levels_pal: ScratchLevelsPal, pub ac_txtp_map: ScratchAcTxtpMap, pub pal_idx: [u8; 8192], - pub interintra_edge_pal: InterIntraEdgePal, + pub interintra_edge_pal: ScratchInterintraEdgePal, } // Larger of the two between `ScratchInter` and `ScratchInterIntra`. @@ -1100,7 +1083,6 @@ impl TaskContextScratch { FromBytes::mut_from_prefix(&mut self.0).unwrap() } - #[track_caller] pub fn inter_intra(&self) -> &ScratchInterIntra { FromBytes::ref_from_prefix(&self.0).unwrap() } diff --git a/src/recon.rs b/src/recon.rs index 9eb6e2b06..1a9f6e837 100644 --- a/src/recon.rs +++ b/src/recon.rs @@ -19,11 +19,11 @@ use crate::src::ctx::CaseSet; use crate::src::env::get_uv_inter_txtp; use crate::src::internal::Bxy; use crate::src::internal::CodedBlockInfo; -use crate::src::internal::EmuEdge; use crate::src::internal::Rav1dContext; use crate::src::internal::Rav1dDSPContext; use crate::src::internal::Rav1dFrameData; use crate::src::internal::Rav1dTaskContext; +use crate::src::internal::ScratchEmuEdge; use crate::src::internal::TileStateRef; use crate::src::intra_edge::EdgeFlags; use crate::src::ipred_prepare::rav1d_prepare_intra_edges; @@ -2024,7 +2024,7 @@ pub(crate) unsafe fn rav1d_read_coef_blocks( unsafe fn mc( f: &Rav1dFrameData, - emu_edge: &mut EmuEdge, + emu_edge: &mut ScratchEmuEdge, b: Bxy, dst8: *mut BD::Pixel, dst16: *mut i16, @@ -2311,7 +2311,7 @@ unsafe fn obmc( unsafe fn warp_affine( f: &Rav1dFrameData, - emu_edge: &mut EmuEdge, + emu_edge: &mut ScratchEmuEdge, b: Bxy, mut dst8: *mut BD::Pixel, mut dst16: *mut i16,