Use millisecond in Make Adjacent step in Timing Post-Processor

Fix wangqr/Aegisub#57
This commit is contained in:
wangqr 2020-07-04 05:22:14 -04:00
parent 1e3e478f5f
commit 8dececc3cb
2 changed files with 8 additions and 2 deletions

View File

@ -31,6 +31,9 @@ public:
// Always round up for 5ms because the range is [start, stop) // Always round up for 5ms because the range is [start, stop)
operator int() const { return (time + 5) - (time + 5) % 10; } operator int() const { return (time + 5) - (time + 5) % 10; }
/// Get millisecond, without centisecond round
int GetMillisecond() const noexcept { return time; }
/// Return the time as a string /// Return the time as a string
/// @param ms Use milliseconds precision, for non-ASS formats /// @param ms Use milliseconds precision, for non-ASS formats
std::string GetAssFormatted(bool ms=false) const; std::string GetAssFormatted(bool ms=false) const;

View File

@ -407,9 +407,12 @@ void DialogTimingProcessor::Process() {
AssDialogue *prev = sorted[i - 1]; AssDialogue *prev = sorted[i - 1];
AssDialogue *cur = sorted[i]; AssDialogue *cur = sorted[i];
int dist = cur->Start - prev->End; // Raw millisecond values are used in this step instead of the typical centisecond.
// In this step, we need to distinguish between gap and overlap, as they have different thresholds.
// A small gap / overlap less than 1 centisecond may not be distinguishable using rounded centisecond values.
int dist = cur->Start.GetMillisecond() - prev->End.GetMillisecond();
if ((dist < 0 && -dist <= adjOverlap) || (dist > 0 && dist <= adjGap)) { if ((dist < 0 && -dist <= adjOverlap) || (dist > 0 && dist <= adjGap)) {
int setPos = prev->End + int(dist * bias); int setPos = prev->End.GetMillisecond() + int(dist * bias + 0.5);
cur->Start = setPos; cur->Start = setPos;
prev->End = setPos; prev->End = setPos;
} }