From 0ad6e3abde97331f96cc1656bc1ba31a4efc1446 Mon Sep 17 00:00:00 2001 From: Rebuild Date: Sun, 19 May 2024 10:55:04 -0400 Subject: [PATCH] patterns/mp4: Use FixedPoint32 instead of u32 for width and height (#248) Update mp4.hexpat * Use FixedPoint32 instead of u32 for width and height * Add formatting for displaying fixed point 16.16 and 8.8 numbers --- patterns/mp4.hexpat | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/patterns/mp4.hexpat b/patterns/mp4.hexpat index 07f99ed..3ebd6fc 100644 --- a/patterns/mp4.hexpat +++ b/patterns/mp4.hexpat @@ -18,15 +18,23 @@ fn format_string(auto string) { return string.value; }; +fn format_fixed32(auto fp32) { + return fp32.integer + fp32.fraction / 65536.0; +}; + +fn format_fixed16(auto fp16) { + return fp16.integer + fp16.fraction / 256.0; +}; + struct FixedPoint16 { u8 integer; u8 fraction; -}; +} [[format("format_fixed16")]]; struct FixedPoint32 { u16 integer; u16 fraction; -}; +} [[format("format_fixed32")]]; struct string { char value[std::mem::find_sequence_in_range(0, $, std::mem::size(), 0x00) - $]; @@ -122,8 +130,8 @@ struct TrackHeaderBox : FullBox { s16 volume; u16 reserved_3; s32 matrix[9]; - u32 width; - u32 height; + FixedPoint32 width; + FixedPoint32 height; }; struct DataEntryBox : FullBox {