1use fixed::types::{I16F16, I2F30};
2use fixed_macro::fixed;
3use crate::mp4_data;
4
5mp4_data! {
6 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
7 pub struct MP4Matrix {
8 pub a: I16F16,
9 pub b: I16F16,
10 pub u: I2F30,
11 pub c: I16F16,
12 pub d: I16F16,
13 pub v: I2F30,
14 pub x: I16F16,
15 pub y: I16F16,
16 pub w: I2F30,
17 }
18}
19
20impl MP4Matrix {
21 pub fn byte_size() -> usize {
22 4 * 9
23 }
24
25 pub fn unity() -> MP4Matrix {
26 Self {
27 a: fixed!(1: I16F16),
28 b: fixed!(0: I16F16),
29 u: fixed!(0: I2F30),
30 c: fixed!(0: I16F16),
31 d: fixed!(1: I16F16),
32 v: fixed!(0: I2F30),
33 x: fixed!(0: I16F16),
34 y: fixed!(0: I16F16),
35 w: fixed!(1: I2F30),
36 }
37 }
38}
39
40impl Default for MP4Matrix {
41 fn default() -> Self {
42 Self::unity()
43 }
44}