Commit 7a35ca8f for libheif
commit 7a35ca8f921f7739131d841b22cd9972364d0156
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu Oct 15 20:36:40 2026 +0200
heif-enc: report WebVMT timestamps that the pattern rejects
With the stricter timestamp pattern, malformed timestamps such as
00:01.12 or 00:01.1234 no longer reach the fraction-length check. They
take the no-match branch instead, which returned 0. A zero start time
was then silently merged into the time-zero packet, or reported as a
timestamp order error, which points at the wrong defect.
Return BAD_VMT_TIMESTAMP on no-match so that such cues are reported and
skipped. An empty cue start time is now reported as well. The
fraction-length check is dead since the pattern requires exactly three
digits, so remove it.
diff --git a/examples/vmt.cc b/examples/vmt.cc
index 689472ac..89d0d395 100644
--- a/examples/vmt.cc
+++ b/examples/vmt.cc
@@ -167,28 +167,19 @@ static uint32_t parse_vmt_timestamp(const std::string& vmt_time)
std::smatch match;
if (!std::regex_match(vmt_time, match, pattern)) {
- return 0; // no match
+ return BAD_VMT_TIMESTAMP; // no match
}
std::string hh = match[2]; // optional
std::string mm = match[3];
std::string ss = match[4];
- std::string fs = match[6]; // optional
+ std::string fs = match[6];
if (vmt_time.find('-') != std::string::npos) {
return 0; // negative time not supported
}
- uint32_t ms = 0;
-
- if (fs != "") {
- if (fs.length() == 3) {
- ms = std::stoi(fs);
- }
- else {
- return BAD_VMT_TIMESTAMP; // invalid
- }
- }
+ uint32_t ms = std::stoi(fs); // the pattern guarantees exactly three digits
uint32_t ts = ((hh != "" ? std::stoi(hh) : 0) * 3600 * 1000 +
std::stoi(mm) * 60 * 1000 +