Fix NTSC chapter/duration drift: dvd_time_t is a timecode, not seconds

`dvd_time_t` stores H:M:S:F as non-drop-frame timecode with a rate flag,
not elapsed wall-clock time. On NTSC the seconds field advances every 30
frames, but a frame lasts 1001/30000 s, so 30 frames occupy 1.001 s of
real time. Reading H:M:S as literal seconds under-reports real time by
exactly 0.1% — 3.6 s per hour, growing with elapsed time, which is what
made chapter marks drift ~4 s by the 67-minute mark.

Convert the whole timecode through an integer frame count and apply the
exact 1001/30000 fraction once, instead of reading H:M:S literally and
dividing only the frame remainder by a decimal 29.97. Chapter marks sum
per-cell frame counts as integers and convert once per chapter, so every
mark lands on an exact frame boundary instead of accumulating f64
rounding across a long title.

PAL is arithmetically unaffected: 25 frames = 1.000 s exactly, so the
old and new paths agree to within one ULP. Sweeping all 900k H:M:S:F
combinations under 10 hours, 12 differ, by at most 8.9e-16 s — the new
path divides one exact integer instead of adding a rounded fraction to a
large one, so where they differ it is the more accurate of the two.

Five existing NTSC fixtures asserted the old literal-seconds values and
were updated to real seconds (each is exactly 1.001x its old figure);
`bcd_secs` now documents that its argument is timecode, not real time.

Fixes #1
Reported-by: AnimeFN <admin@animefn.com>
This commit is contained in:
AnimeFN
2026-08-05 13:48:11 -07:00
committed by Matthew Jackson
parent 4ab8303a65
commit cfce270186
2 changed files with 304 additions and 56 deletions
+19
View File
@@ -1,5 +1,24 @@
# Changelog
## [1.6.1]
### Fixed
- Chapter marks and title durations on NTSC DVDs ran roughly 0.1% short —
about 3.6 seconds per hour — so a mark near the end of a feature could
land several seconds before the scene it names. On a 67-minute title the
drift reached about 4 seconds. The playback times a DVD stores are
timecode, and on an NTSC disc the timecode runs slightly slow against the
clock: its seconds field ticks every 30 frames while the video actually
runs at 30000/1001 frames per second, so 30 frames take 1.001 real
seconds, not 1.000. Those times were being read as if they were plain
seconds, which is where the missing 0.1% went. They are now converted
through an exact frame count, so every mark lands on a real frame
boundary no matter how long the title runs. PAL discs were never affected
and their timings are unchanged.
Reported and fixed by AnimeFN (freemkv#25, libfreemkv#1).
## [1.6.0] — 2026-08-03
### Fixed