aboutsummaryrefslogtreecommitdiff
path: root/old/evc/src/format/header.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-05-05 15:09:54 +0200
committermetamuffin <metamuffin@disroot.org>2025-05-05 15:09:54 +0200
commit306f96164784a8cbf405e72fa4364d6523366e95 (patch)
tree51717fc139871baa438aad806f4923669ae0896c /old/evc/src/format/header.rs
parent9cc089e2d6e841879e430b01d2f3d92c8820523e (diff)
downloadvideo-codec-experiments-306f96164784a8cbf405e72fa4364d6523366e95.tar
video-codec-experiments-306f96164784a8cbf405e72fa4364d6523366e95.tar.bz2
video-codec-experiments-306f96164784a8cbf405e72fa4364d6523366e95.tar.zst
old dir
Diffstat (limited to 'old/evc/src/format/header.rs')
-rw-r--r--old/evc/src/format/header.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/old/evc/src/format/header.rs b/old/evc/src/format/header.rs
new file mode 100644
index 0000000..ecbae89
--- /dev/null
+++ b/old/evc/src/format/header.rs
@@ -0,0 +1,29 @@
+use crate::{
+ format::ser::{Ser, Sink, Source},
+ helpers::vector::Vec2,
+};
+
+#[derive(Debug, Clone, PartialEq, Copy)]
+pub struct Header {
+ pub resolution: Vec2<isize>,
+ pub frame_count: usize,
+}
+
+pub const MAGIC: [u8; 4] = [0x5eu8, 0xb1u8, 0xc3u8, 0x08u8];
+
+impl Ser for Header {
+ fn write(&self, sink: &mut impl std::io::Write) -> anyhow::Result<()> {
+ sink.put(MAGIC)?;
+ sink.put((Into::<Vec2<u16>>::into(self.resolution), self.frame_count))?;
+ Ok(())
+ }
+
+ fn read(source: &mut impl std::io::Read) -> anyhow::Result<Self> {
+ assert_eq!(source.get::<[u8; 4]>()?, MAGIC);
+ let (resolution, frame_count): (Vec2<u16>, usize) = source.get()?;
+ Ok(Self {
+ resolution: resolution.into(),
+ frame_count,
+ })
+ }
+}