Skip to content

fix(disc): a DVD title declares its subpicture streams and probes briefly (AE#651) - #652

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/mpegps-probe-budget
Sep 26, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/mpegps-probe-budget

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Refs #651.

Problem

mpegps sets AVFMTCTX_NOHEADER and never clears it, so avformat_find_stream_info never takes its "All info found" exit. Every DVD open therefore read the full playback budget (probesize 50 MB, max_analyze_duration 60 s). That window exists to discover streams that start late, and it still missed any subtitle whose first packet arrived after it.

Change

  • DVDIFOParser.parseSubpictureStreamIDs returns every subpicture substream id the VTS IFO declares, with or without a language, using the same PGC control reading as the language parser. It returns nil for an unreadable IFO, which is a different answer from a title with no subpictures. The result is carried as DiscTitle.dvdSubpictureStreamIDs.
  • Demuxer creates those streams right after avformat_open_input. mpegps looks a packet's stream up by AVStream.id before creating one, so their packets land there.
  • libavformat attaches its dvdsub parser only to streams the demuxer created itself (need_parsing is internal). Without the parser, a subpicture larger than one pack reaches the decoder as its first fragment and does not decode (measured, outcome=undecodable). DVDSubpictureAssembler joins the fragments in readPacketLocked using the rule from dvdsub_parser.c: the size comes from the first 16 bits, or from the 32 bits after a zero; the unit keeps the first fragment's timing; an overrun drops the unit. The assembler is reset at every avformat_flush.
  • A title with a readable IFO probes 8 MB / 5 s. This never raises a budget, so a tighter caller budget (Let callers bound the demux probe budget (probesize / analyze duration) per load #68) still wins. Discs without a readable VTS IFO, and plain .mpg / .vob URLs, keep the old budget.

Side effect: on such a title the declared subpicture streams come first in the stream indices. The forward prefetcher and the side readers now see these streams from the open (with skipStreamInfo they used to see none). In the measurement below the prefetcher delivered the first cue at playhead 5.3 s instead of 16.6 s.

Measured

aetherctl against dvdauthor-built DVD ISOs, served by a logging range origin at 20 Mbit/s with 100 ms per response:

first frame
main, cold 29.6 s
this branch, cold 6.5 s
this branch, --prewarm (with #647) 0.54 s

Subtitle discovery, on a disc whose IFO declares en (first packet at 20 s) and de (first packet at 100 s, an 8 KB unit spread over several packets):

  • main lists only en.
  • This branch lists both from the open, and --subs de produces CUE #0 100.53 (published).
  • A large multi-packet en unit decodes the same cue as on main.

Tests

Issue651DeclaredSubpictureTests:

  • six assembler cases: single fragment, join, 32-bit size, overrun, reset, too-short header
  • IFO id parsing, including the unreadable-IFO case
  • a Demuxer run over an ISO fixture with a hand-built VOB. The declared stream 0x21, which never carries a packet, is still a track, and a subpicture split across three PES packets arrives as one packet with the first fragment's PTS. This test fails when the assembler hook is bypassed.

Full suite green locally: 3531 swift-testing tests + 17 XCTest. Issue281ColdStartRoundTripTests failed once under full-suite load and passed when run alone and on a full rerun.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mf4MXgM9bqugHoe5TW4BYf

…efly (AE#651)

mpegps sets AVFMTCTX_NOHEADER and never clears it, so find_stream_info
never takes its "all info found" exit and every DVD open read the full
playback budget (50 MB / 60 s). The window existed to discover streams
that start late, and it still missed any subtitle whose first packet
came after it.

The VTS IFO already declares the title's subpicture streams. They are
now created before the probe; mpegps routes packets to an existing
stream by id. libavformat attaches its dvdsub parser only to streams the
demuxer created (need_parsing is internal), so DVDSubpictureAssembler
joins the PES fragments in readPacketLocked under the parser's rule and
is reset at every flush. A title with a readable IFO then probes
8 MB / 5 s; a disc without one keeps the old budget.

Measured with aetherctl on an authored DVD over a 20 Mbit/s, 100 ms
origin: first frame at 6.5 s instead of 29.6 s, 0.5 s after a prewarm.
A subtitle first shown at 100 s is a track from the first frame and its
8 KB, multi-packet unit decodes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mf4MXgM9bqugHoe5TW4BYf
@superuser404notfound
superuser404notfound merged commit 22043b8 into main Sep 26, 2026
7 checks passed
@superuser404notfound
superuser404notfound deleted the fix/mpegps-probe-budget branch September 26, 2026 14:51
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