0.2.69 - Homepage loading improvements pass

This commit is contained in:
ponzischeme89
2026-08-16 21:20:55 +12:00
parent b9374baaf1
commit 845fa349e4
23 changed files with 663 additions and 262 deletions
+75
View File
@@ -49,6 +49,19 @@ func darkSceneFrame(position time.Duration) frameStats {
}
}
// A dim, textured final scene: close enough to the roll's structural score that what comes
// after it could lift the sustain average, but visibly still programme.
func dimTexturedSceneFrame(position time.Duration) frameStats {
return frameStats{
PositionMs: position.Milliseconds(),
Mean: 0.13,
Variance: 0.006,
DarkFraction: 0.78,
EdgeDensity: 0.015,
Diff: 0.08,
}
}
func window(start time.Duration, kinds ...func(time.Duration) frameStats) []frameStats {
frames := make([]frameStats, 0, len(kinds))
for index, build := range kinds {
@@ -85,6 +98,32 @@ func TestFindsACleanTransition(t *testing.T) {
}
}
// Television rolls are commonly only half a minute long. This is also the amount of media
// available after a correctly centred transition in the fine pass, so requiring more would
// make the refinement structurally unable to confirm the coarse answer.
func TestFindsACompactTelevisionCreditsRoll(t *testing.T) {
kinds := append(repeatFrames(20, programmeFrame), repeatFrames(8, creditsFrame)...)
frames := window(20*time.Minute, kinds...)
if index, _, found := findTransition(frames, coarseInterval); !found || index != 20 {
t.Fatalf("compact credits transition = %d, found %t; want frame 20", index, found)
}
}
func TestFinePassCanConfirmACentredTransition(t *testing.T) {
frames := make([]frameStats, 0, 80)
for index := 0; index < 40; index++ {
frames = append(frames, programmeFrame(time.Duration(index)*fineInterval))
}
for index := 40; index < 80; index++ {
frames = append(frames, creditsFrame(time.Duration(index)*fineInterval))
}
if index, _, found := findTransition(frames, fineInterval); !found || index != 40 {
t.Fatalf("fine transition = %d, found %t; want frame 40", index, found)
}
}
// The whole point of not answering on darkness alone.
func TestDarkSceneIsNotCredits(t *testing.T) {
kinds := append(repeatFrames(30, programmeFrame), repeatFrames(30, darkSceneFrame)...)
@@ -122,6 +161,34 @@ func TestBriefDarkBeatIsIgnored(t *testing.T) {
}
}
// A locally convincing title-like sequence in the middle of the tail is not closing
// credits when ordinary programme resumes after it. This is the real-media failure shape:
// looking only at the immediate sustain window marked Westworld and Blue Bloods several
// minutes before their genuine rolls.
func TestCreditLikeSequenceThatDoesNotReachTheEndIsIgnored(t *testing.T) {
kinds := append(repeatFrames(20, programmeFrame), repeatFrames(8, creditsFrame)...)
kinds = append(kinds, repeatFrames(20, programmeFrame)...)
frames := window(35*time.Minute, kinds...)
if _, _, found := findTransition(frames, coarseInterval); found {
t.Fatal("a temporary credit-like sequence was reported as closing credits")
}
}
func TestDimFinalSceneBeforeCreditsDoesNotMoveTheMarkerEarly(t *testing.T) {
kinds := append(repeatFrames(20, programmeFrame), repeatFrames(8, dimTexturedSceneFrame)...)
kinds = append(kinds, repeatFrames(12, creditsFrame)...)
frames := window(35*time.Minute, kinds...)
index, _, found := findTransition(frames, coarseInterval)
if !found {
t.Fatal("the genuine credits after the dim scene were not found")
}
if index != 28 {
t.Fatalf("transition at frame %d, want the credits at frame 28", index)
}
}
func TestTooFewFramesAnswerNothing(t *testing.T) {
frames := window(41*time.Minute, repeatFrames(4, creditsFrame)...)
if _, _, found := findTransition(frames, coarseInterval); found {
@@ -151,6 +218,14 @@ func TestCreditScoreSeparatesTheThreeCases(t *testing.T) {
}
}
func TestDenseCreditsStillLookLikeCredits(t *testing.T) {
frame := creditsFrame(0)
frame.EdgeDensity = 0.075
if score := creditScore(frame); score < creditLikeFloor {
t.Fatalf("dense credits scored %.2f, below the floor %.2f", score, creditLikeFloor)
}
}
// Confidence from one detector agreeing with itself is not corroboration.
func TestVisualConfidenceIsCapped(t *testing.T) {
if score := visualConfidence(10); score >= 1 {