Skip to content

Commit

Permalink
Code review cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Apr 24, 2024
1 parent e02d0cb commit 24d4c69
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ impl BitDepthDependentType for AlPal {
type T<BD: BitDepth> = [[[[BD::Pixel; 8]; 3]; 32]; 2]; /* [2 a/l][32 bx/y4][3 plane][8 palette_idx] */
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(64))]
pub struct ScratchCompinter {
pub compinter: [[i16; 16384]; 2],
Expand All @@ -941,7 +941,7 @@ pub struct ScratchCompinter {
// Larger of the two between `ScratchCompinter` and `[BD::Pixel; 128 * 32]`.
const SCRATCH_COMPINTER_SIZE: usize = mem::size_of::<ScratchCompinter>();

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(64))]
pub struct ScratchLapInter([u8; SCRATCH_COMPINTER_SIZE]);

Expand All @@ -957,7 +957,7 @@ impl ScratchLapInter {

const EMU_EDGE_LEN: usize = 320 * (256 + 7);
// stride=192 for non-SVC, or 320 for SVC
#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(32))]
pub struct ScratchEmuEdge([u8; EMU_EDGE_LEN * 2]);

Expand All @@ -967,21 +967,21 @@ impl ScratchEmuEdge {
}
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C)]
pub struct ScratchInter {
pub lap_inter: ScratchLapInter,
pub emu_edge: ScratchEmuEdge,
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(64))]
pub struct ScratchPal {
pub pal_order: [[u8; 8]; 64],
pub pal_ctx: [u8; 64],
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(64))]
pub struct ScratchLevelsPal([u8; 1088]);

Expand All @@ -991,7 +991,7 @@ impl ScratchLevelsPal {
}

pub fn pal_mut(&mut self) -> &mut ScratchPal {
ScratchPal::mut_from_prefix(&mut self.0).unwrap()
FromBytes::mut_from_prefix(&mut self.0).unwrap()
}
}

Expand All @@ -1016,7 +1016,7 @@ impl ScratchEdgeBuf {
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[repr(C, align(16))]
#[repr(C, align(16))] // Over-aligned for 8bpc (needs to be `align(8)` for 8bpc, `align(16)` for 16bpc).
pub struct ScratchPalBuf([u8; 8 * 3 * 2]); /* [3 plane][8 palette_idx] */

impl ScratchPalBuf {
Expand All @@ -1035,6 +1035,8 @@ pub struct ScratchInterintraEdgePal {
pub interintra: ScratchInterintraBuf,
pub edge: ScratchEdgeBuf,
pub pal: ScratchPalBuf,

/// For `AsBytes`, so there's no implicit padding.
_padding: [u8; 48],
}

Expand All @@ -1056,7 +1058,7 @@ impl ScratchAcTxtpMap {
}
}

#[derive(Clone, Copy, FromZeroes, FromBytes, AsBytes)]
#[derive(FromZeroes, FromBytes, AsBytes)]
#[repr(C)]
pub struct ScratchInterIntra {
pub levels_pal: ScratchLevelsPal,
Expand Down

0 comments on commit 24d4c69

Please sign in to comment.