Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
Use millisecond in Make Adjacent step in Timing Post-Processor
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed Jul 4, 2020
1 parent ba649b4 commit 4be13a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions libaegisub/include/libaegisub/ass/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Time {
// Always round up for 5ms because the range is [start, stop)
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
/// @param ms Use milliseconds precision, for non-ASS formats
std::string GetAssFormatted(bool ms=false) const;
Expand Down
7 changes: 5 additions & 2 deletions src/dialog_timing_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,12 @@ void DialogTimingProcessor::Process() {
AssDialogue *prev = sorted[i - 1];
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)) {
int setPos = prev->End + int(dist * bias);
int setPos = prev->End.GetMillisecond() + int(dist * bias + 0.5);
cur->Start = setPos;
prev->End = setPos;
}
Expand Down

0 comments on commit 4be13a3

Please sign in to comment.