Skip to content

fix(disc): defeat repeated-clip decoy playlists in BD title selection (#105) - #108

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/bd-decoy-playlist
Jul 6, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/bd-decoy-playlist

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Problem

Issue #105: the generated snapshot is a blank image. Reporter's log + screenshots show a Blu-ray ISO (TRON: Legacy 4K, 16 titles):

[disc] Blu-ray recognized: 16 titles, selected 0 clips=["00046","00038" x252] m2ts-extents=253
[Demuxer] Opened: 3 streams, duration=76640000 us          <- 76.64s
[FrameExtractor] miss mode=snapshot t=611.25s ... image=ok bytes=0   <- blank

The disc's longest-duration .mpls references one ~76s menu/loop clip (00038) 252 times, inflating its declared duration to 5:23:17 while the demuxer only ever probes the first clip's PTS (76.64s). BDTitleSelector ranked titles purely by durationTicks, so this decoy crowned the real 2:05 feature (single clip 00070) as the main/default title. Scrubbing or snapshotting past 76s then seeked past the demuxer's EOF and decoded a blank garbage frame that still reported image=ok.

This is not the tone-map path and not the #106 single-connection second-demuxer class.

Fix

  • BDTitleSelector: isRepeatedClipDecoy flags a playlist dominated by one repeated clip (repeats past a floor and supplying more than half its PlayItems). selectMainTitle and enumerateTitles drop decoys before the duration-max sort, keeping the existing never-leave-zero-titles fallback. Light legitimate clip reuse (seamless branching, multi-angle) is preserved.
  • FrameDecodeContext: clampSeekSeconds clamps a still requested past the demuxer's known duration to the last decodable frame instead of seeking past EOF into a blank frame (defense-in-depth behind the selector fix). Both the seek and the snapshot forward-decode target use the clamped value.

Tests

  • BDTitleSelectorTests: decoy demotion (real feature becomes the main title), only-decoy fallback, light clip-reuse tolerance.
  • FrameDecodeContextClampTests: the pure clamp arithmetic (in-range passthrough, past-EOF clamp, unknown-duration passthrough, end-scrub tolerance).

Verification

  • Full suite: 431 tests, 0 failures
  • swift build -Xswiftc -strict-concurrency=complete: clean
  • tvOS Simulator (xcodebuild -scheme AetherEngine): BUILD SUCCEEDED

🤖 Generated with Claude Code

https://claude.ai/code/session_01HFZVoTDayyEfpqrY8ohNyg

…#105)

Anti-rip Blu-rays (e.g. TRON: Legacy 4K) pad PLAYLIST with a decoy .mpls that
references one short menu/loop clip hundreds of times, inflating its declared
duration to 5+ hours while the demuxer only ever probes the first clip's ~76s of
PTS. BDTitleSelector ranked titles purely by durationTicks, so the decoy (5:23:17)
crowned the real 2:05 feature as the main/default title. Scrubbing or snapshotting
past 76s then seeked past the demuxer's EOF and decoded a blank garbage frame that
still reported image=ok, which surfaced as issue #105 (blank generated snapshot).

- BDTitleSelector: isRepeatedClipDecoy flags a playlist dominated by one repeated
  clip (repeats past a floor and supplying >half its PlayItems); selectMainTitle and
  enumerateTitles drop decoys before the duration-max sort, with the existing
  never-leave-zero-titles fallback. Light legitimate clip reuse (seamless branching,
  multi-angle) is preserved.
- FrameDecodeContext: clampSeekSeconds clamps a still requested past the demuxer's
  known duration to the last decodable frame instead of seeking past EOF into a blank
  frame (defense-in-depth behind the selector fix). Both the seek and the snapshot
  forward-decode target use the clamped value.

Tests: BDTitleSelectorTests covers decoy demotion, the only-decoy fallback, and light
clip-reuse tolerance; FrameDecodeContextClampTests covers the pure clamp arithmetic.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HFZVoTDayyEfpqrY8ohNyg
@superuser404notfound
superuser404notfound merged commit ee34723 into main Jul 6, 2026
3 checks passed
@superuser404notfound
superuser404notfound deleted the fix/bd-decoy-playlist branch July 7, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant