Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ numer = "numer"
trak = "trak"
trun = "trun"
truns = "truns"
typ = "typ"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 0.3.0 - 2024-11-13 - Handle time shifts
* Account for video with DTS shift and resulting negative dts values [#16](https://github.com/rerun-io/re_mp4/pull/16) by [@Wumpf](https://github.com/Wumpf)
* Shift DTS & CTS by minimum CTS to mimick `ffprobe`'s behavior [#17](https://github.com/rerun-io/re_mp4/pull/17) by [@Wumpf](https://github.com/Wumpf)
* Shift DTS & CTS by minimum CTS to mimic `ffprobe`'s behavior [#17](https://github.com/rerun-io/re_mp4/pull/17) by [@Wumpf](https://github.com/Wumpf)


## 0.2.1 - 2024-11-12 - Bug fixes
Expand Down
11 changes: 9 additions & 2 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ impl Mp4 {
let stsz = &stbl.stsz;
let stts = &stbl.stts;

while sample_n < stsz.sample_sizes.len() {
// Could probably just always use sample count
while (sample_n < stsz.sample_sizes.len() && sample_n == 0)
|| sample_n < stsz.sample_count as usize
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit weird 👀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be && stsz. sample_size == 0 oops

Either sample_sizes should exist as a non-empty vector and sample_size is 0 (showing unused) or sample_size is a constant across all samples. I think we can just always use sample_count but I couldn't find a sufficiently convincing spec to reference (didn't look that hard)

// compute offset
if sample_n == 0 {
chunk_index = 1;
Expand Down Expand Up @@ -208,7 +211,11 @@ impl Mp4 {
}

let timescale = trak.mdia.mdhd.timescale as u64;
let size = stsz.sample_sizes[sample_n] as u64;
let size = if stsz.sample_size != 0 {
stsz.sample_size as u64
} else {
stsz.sample_sizes[sample_n] as u64
};
let offset = get_sample_chunk_offset(stbl, chunk_index) + offset_in_chunk;
offset_in_chunk += size;

Expand Down
Loading