Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/moov/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ mod test {
modification_time: 3773812694,
track_id: 1,
enabled: true,
in_movie: true,
width: 1920.into(),
height: 1080.into(),
..Default::default()
Expand Down
19 changes: 18 additions & 1 deletion src/moov/trak/tkhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ext! {
track_enabled = 0,
track_in_movie = 1,
track_in_preview = 2,
track_size_is_aspect_ratio = 3,
}
}

Expand All @@ -20,6 +21,10 @@ pub struct Tkhd {
pub layer: u16,
pub alternate_group: u16,
pub enabled: bool,
pub in_movie: bool,
/// When set, `width`/`height` express the track's suggested aspect ratio
/// rather than pixel dimensions (ISO/IEC 14496-12:2022 §8.3.2.3).
pub size_is_aspect_ratio: bool,

pub volume: FixedPoint<u8>,
pub matrix: Matrix,
Expand Down Expand Up @@ -73,6 +78,10 @@ impl AtomExt for Tkhd {
width,
height,
enabled: ext.track_enabled,
in_movie: ext.track_in_movie,
size_is_aspect_ratio: ext.track_size_is_aspect_ratio,
// track_in_preview has no assigned meaning and is ignored on read
// per ISO/IEC 14496-12:2022 §8.3.2.3.
})
}

Expand All @@ -96,7 +105,11 @@ impl AtomExt for Tkhd {
Ok(TkhdExt {
version: TkhdVersion::V1,
track_enabled: self.enabled,
..Default::default()
track_in_movie: self.in_movie,
// track_in_preview has no assigned meaning; per ISO/IEC
// 14496-12:2022 §8.3.2.3 writers should mirror track_in_movie.
track_in_preview: self.in_movie,
track_size_is_aspect_ratio: self.size_is_aspect_ratio,
})
}
}
Expand Down Expand Up @@ -190,6 +203,8 @@ mod tests {
width: 512.into(),
height: 288.into(),
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
};
let mut buf = Vec::new();
expected.encode(&mut buf).unwrap();
Expand All @@ -213,6 +228,8 @@ mod tests {
width: 512.into(),
height: 288.into(),
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
};
let mut buf = Vec::new();
expected.encode(&mut buf).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions src/test/av1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ fn av1() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down
2 changes: 2 additions & 0 deletions src/test/bbb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn bbb() {
tkhd: Tkhd {
track_id: 1,
enabled: true,
in_movie: true,
width: 1280.into(),
height: 720.into(),
..Default::default()
Expand Down Expand Up @@ -129,6 +130,7 @@ fn bbb() {
track_id: 2,
alternate_group: 1,
enabled: true,
in_movie: true,
volume: 1.into(),
..Default::default()
},
Expand Down
2 changes: 2 additions & 0 deletions src/test/esds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fn esds() {
tkhd: Tkhd {
track_id: 1,
enabled: true,
in_movie: true,
width: 1280.into(),
height: 720.into(),
..Default::default()
Expand Down Expand Up @@ -129,6 +130,7 @@ fn esds() {
track_id: 2,
alternate_group: 1,
enabled: true,
in_movie: true,
volume: 1.into(),
..Default::default()
},
Expand Down
2 changes: 2 additions & 0 deletions src/test/flac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ fn flac() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 1.into(),
matrix: Matrix {
a: 65536,
Expand Down
4 changes: 4 additions & 0 deletions src/test/h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ fn avcc_ext() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down Expand Up @@ -189,6 +191,8 @@ fn avcc_ext() {
layer: 0,
alternate_group: 1,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 1.into(),
matrix: Matrix {
a: 65536,
Expand Down
2 changes: 2 additions & 0 deletions src/test/hevc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ fn hevc() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down
2 changes: 2 additions & 0 deletions src/test/libavif_anim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ fn av1_anim() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: false,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down
2 changes: 2 additions & 0 deletions src/test/uncompressed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ fn uncompressed() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down
2 changes: 2 additions & 0 deletions src/test/vp9.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ fn vp9() {
layer: 0,
alternate_group: 0,
enabled: true,
in_movie: true,
size_is_aspect_ratio: false,
volume: 0.into(),
matrix: Matrix {
a: 65536,
Expand Down
Loading