From 29a9aae87d0455054867b20f028fadf3a232c0a1 Mon Sep 17 00:00:00 2001 From: niksedk Date: Tue, 6 Oct 2026 21:53:48 +0200 Subject: [PATCH] ArteCheck: take an odd missing gap frame off the previous out time A 4-frame gap (1 frame short of ARTE's 5) moved the next in time one frame later. Take that frame off the previous out time instead, like ARTE's own tooling does; larger shortfalls are still shared, with the odd frame on the out time. Co-Authored-By: Claude Opus 5.5 --- se5/ArteCheck.Tests/ArteCheckerTests.cs | 14 ++++++++++++-- se5/ArteCheck/ArteChecker.cs | 5 +++-- se5/ArteCheck/README.md | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/se5/ArteCheck.Tests/ArteCheckerTests.cs b/se5/ArteCheck.Tests/ArteCheckerTests.cs index ba4da44a..9fb2c9ef 100644 --- a/se5/ArteCheck.Tests/ArteCheckerTests.cs +++ b/se5/ArteCheck.Tests/ArteCheckerTests.cs @@ -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] diff --git a/se5/ArteCheck/ArteChecker.cs b/se5/ArteCheck/ArteChecker.cs index 9e39bc74..d2a02caa 100644 --- a/se5/ArteCheck/ArteChecker.cs +++ b/se5/ArteCheck/ArteChecker.cs @@ -767,8 +767,9 @@ private void AnalyzeMinimumGaps(List 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); diff --git a/se5/ArteCheck/README.md b/se5/ArteCheck/README.md index 8ab77220..a0733fe6 100644 --- a/se5/ArteCheck/README.md +++ b/se5/ArteCheck/README.md @@ -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