Skip to content

Conversation

@rjksmith
Copy link

Updated VMT timestamp parser

Updated VMT timestamp parser
Comment on lines 2209 to 2219
if (fs.length() == 3) { // ms
ms = std::stoi(fs);
}
else if (fs.length() < 3) { // scale integer up
uint32_t scale = pow(10.0, 3 - fs.length());
ms = std::stoi(fs) * scale;
}
else { // scale integer down
uint32_t scale = pow(10.0, fs.length() - 3);
ms = std::stoi(fs) / scale;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You could either use std::pow(10, ... to keep all calculations integer, or use double scale = pow(10.0, ...). Then everything is subsumed in one case instead of three.

Copy link
Author

@rjksmith rjksmith Feb 3, 2026

Choose a reason for hiding this comment

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

Thanks for your feedback @farindk

I've identified a mistake with my millisecond parser and the refactored code will not need to call pow at all or have multiple cases.

Refactored VMT timestamp parser
heif_raw_sequence_sample_set_duration(sample, ts - *prev_ts);
heif_track_add_raw_sequence_sample(track, sample);
}
else if (ts == *prev_ts) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it legal input to have similar timestamps following each other?

Copy link
Author

Choose a reason for hiding this comment

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

Yes - for several reasons, including:

  • two VMT cues may share the same start time and have different end times
  • two VMT cues that share the same start times and end times may have different cue ids or carry different payloads that are agnostic of each other
  • where negative cue times are not supported, a simple workaround is to set those negative values to zero (destructively) which may produce unexpected duplicate times

@farindk farindk merged commit 8a4b56a into strukturag:vmt Feb 5, 2026
6 of 7 checks passed
@farindk
Copy link
Contributor

farindk commented Feb 5, 2026

Thanks, I have merged it.

@rjksmith
Copy link
Author

rjksmith commented Feb 5, 2026

These changes add the following features:

  • optional hours in VMT timestamps
  • optional milliseconds in VMT timestamps
  • optional end times in VMT cues
  • negative cue times are set to zero
  • VMT cues with identical start times are appended to the previous metadata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants