Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions se5/ArteCheck.Tests/ArteCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,18 @@ public void MinimumGap_SharedBetweenOutAndInTime()
var fix = Assert.Single(ArteChecker.Analyze(source, ArteHeader(), Options(ArteCheckType.MinimumGaps)));
Assert.True(fix.CanBeFixed);
var result = ArteChecker.Apply(source, ArteHeader(), new[] { fix }, Options());
Assert.Equal(Hour10 + 4000 - 2 * 40, result.Paragraphs[0].EndMs);
Assert.Equal(Hour10 + 4000 + 3 * 40, result.Paragraphs[1].StartMs);
Assert.Equal(Hour10 + 4000 - 3 * 40, result.Paragraphs[0].EndMs);
Assert.Equal(Hour10 + 4000 + 2 * 40, result.Paragraphs[1].StartMs);
}

[Fact]
public void MinimumGap_OneMissingFrameComesOffThePreviousOutTime()
{
var source = new[] { P(Hour10, Hour10 + 4000, "Eins"), P(Hour10 + 4000 + 4 * 40, Hour10 + 8000, "Zwei") };
var fix = Assert.Single(ArteChecker.Analyze(source, ArteHeader(), Options(ArteCheckType.MinimumGaps)));
var result = ArteChecker.Apply(source, ArteHeader(), new[] { fix }, Options());
Assert.Equal(Hour10 + 4000 - 40, result.Paragraphs[0].EndMs);
Assert.Equal(Hour10 + 4000 + 4 * 40, result.Paragraphs[1].StartMs);
}

[Fact]
Expand Down
5 changes: 3 additions & 2 deletions se5/ArteCheck/ArteChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,9 @@ private void AnalyzeMinimumGaps(List<PluginParagraph> subtitle)
continue;
}

// Share the missing frames: half from the previous out time, half from the next in time.
var previousShift = Math.Min(previousCapacity, missing / 2);
// Share the missing frames between the previous out time and the next in time; an odd
// frame comes off the previous out time, so a 4-frame gap keeps the next in time.
var previousShift = Math.Min(previousCapacity, (missing + 1) / 2);
var currentShift = Math.Min(currentCapacity, missing - previousShift);
var remaining = missing - previousShift - currentShift;
var addPrevious = Math.Min(previousCapacity - previousShift, remaining);
Expand Down
2 changes: 1 addition & 1 deletion se5/ArteCheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Needs a Subtitle Edit build whose plugin contract includes `subtitle.header` and
| Teletext row | Double height: one line on row 22, two lines on row 20. Moves a whole file down one row if it sits one row too high. Rows higher up the screen are left alone. |
| Teletext colors | Normal subtitles are all yellow or uncolored, with no boxing. SDH colors map to the eight teletext colors. |
| No italics, unneeded spaces | Teletext has no italics; leading and trailing spaces use cells. |
| Minimum gaps | Shares the missing frames between the previous out time and the next in time, without going under the minimum durations. |
| Minimum gaps | Shares the missing frames between the previous out time and the next in time (an odd frame comes off the previous out time), without going under the minimum durations. |

## UI

Expand Down
Loading