Skip to content

Image subtitles: build the bundled FFmpeg with zlib so compressed Matroska subtitle tracks decode - #235

Merged
GLinnik21 merged 2 commits into
mainfrom
worktree-agent-a3dc7dff778fa7441
Sep 25, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
worktree-agent-a3dc7dff778fa7441

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Problem

Image subtitles (PGS, VobSub) never showed during direct play. Video played normally and picking a track from the menu worked, but no bitmap cue was ever decoded (image cue never appears in the log). The subtitle_image_pgs harness case has failed like this in the v0.6.0 and v0.7.0 audits. A field report then showed the same thing on a different library.

Root cause

ci/build-ffmpeg.sh configures the bundled FFmpeg with --disable-autodetect, and that flag also drops zlib. libavformat's Matroska demuxer only inflates a track's ContentCompression when it is built with zlib. Without it, the demuxer logs Unsupported encoding type and passes the packets on still compressed. mkvmerge zlib-compresses every PGS and VobSub track by default, so for almost every disc remux the decoder received 78 da …, found no display set, and returned nothing. The selection path (track menu → sub_render_ordinal → request_subtitle → desired_sub_idx → decode_bitmap_cue) was traced and is correct.

The synthetic harness media never caught this because ffmpeg's own muxer writes these tracks uncompressed.

Fix

  • --enable-zlib in the shared configure line. It is named explicitly, so configure fails if zlib is missing instead of silently building the old behaviour. The only change to the shipped libraries: libavformat-plx.so.63 gains DT_NEEDED libz.so.1 and imports four unversioned symbols (inflate, inflateInit_, inflateEnd, uncompress). All four are present in all 14 firmware inventories (zlib 1.2.7 to 1.3.1). The firmware-compatibility review passed: no VERNEED entry, and plxnative's own DT_NEEDED is unchanged.
  • The host FFmpeg rule now depends on ci/build-ffmpeg.sh, as the cross rule already did, so a flag change rebuilds it.
  • THIRD-PARTY-NOTICES.md lists the television's zlib. The v0.7.0 audit records the root cause; the audited item's compression is inferred, not read.

Consumers: the fix is in the demuxer, so it applies to every compressed Matroska track, not just one call site. The test covers PGS, VobSub and a compressed text (SRT) track, each against an uncompressed control. The demuxer's zlib support also enables compressed-moov MP4 and compressed ID3 tags; those are newly supported, not changed.

Tests (RED → GREEN)

New ff_image_subtitle_tests.rs loads the host build of the same FFmpeg (same component list) and runs the app's own decode path (open_sub_decoder → decode_bitmap_cue → push_subtitle_bitmap) over tests/fixtures/mkv_zlib_subs.mkv (13 KB, made by mkvmerge). make check has no FFmpeg, so the test is #[ignore]d there and runs under the new make check-ffmpeg, which the macOS simulator CI job now runs.

  • RED (without --enable-zlib): Unsupported encoding type ×3; left: [] right: [(0, 8000000000, 1)]; test result: FAILED. 0 passed; 1 failed
  • GREEN: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 4353 filtered out

Gates (on the committed tree)

  • make check (RUST_TEST_THREADS=4; on an overloaded host, the three unthrottled runs each hit a different unrelated loopback-fixture WouldBlock flake, and each failing test passes alone):
    • test result: ok. 4352 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
    • test result: ok. 4405 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
    • test result: ok. 101 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  • cargo +nightly check --lib --no-default-features: clean
  • make (ARM cross-build, including the zlib-enabled FFmpeg): success
  • Codex adversarial review (systematic-fix focus) against origin/main: approve, no findings. An earlier run against a stale local main flagged route/plan.rs sidecar selection, which this branch does not touch.

Still pending

TV verification: subtitle_image_pgs plus a mid-playback image-subtitle pick on an mkvmerge-muxed remux, expecting image cue […] lines.

🤖 Generated with Claude Code

Image subtitles never rendered in direct play: playback was fine, the
track menu selection landed, and not one `image cue` was ever decoded.
The bundled FFmpeg is configured with `--disable-autodetect`, which also
dropped zlib, and libavformat's Matroska demuxer only inflates a track's
ContentCompression when built with it. Without it the demuxer logs
"Unsupported encoding type" and passes the packets through still
compressed. mkvmerge zlib-compresses every PGS and VobSub track by
default, so on nearly every disc remux pgssubdec was handed `78 da ...`,
found no display set and produced nothing. The synthetic harness media
never showed it because ffmpeg's own muxer writes those tracks
uncompressed.

`--enable-zlib` is named explicitly, so configure fails if the library is
absent rather than quietly rebuilding the old behaviour. It links the
system libz.so.1, present on every firmware inventory (zlib 1.2.7 to
1.3.1) and on macOS.

The regression test loads the host build of the same FFmpeg and runs the
app's own decode path over an mkvmerge fixture carrying compressed and
uncompressed PGS and VobSub tracks plus a compressed SRT. It needs that
FFmpeg, so it is #[ignore]d in `make check` and run by the new
`make check-ffmpeg`, which the macOS simulator CI job now runs. The host
FFmpeg rule now depends on ci/build-ffmpeg.sh, as the cross rule already
did, so a flag change rebuilds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T01:40:24.265459Z c409d58 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

rust-modules/.cargo/config.toml sets [unstable] build-std for every nightly
cargo invocation, so the host test build needs rust-src exactly as ci.yml's
host checks do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 20518dc into main Sep 25, 2026
10 checks passed
@GLinnik21
GLinnik21 deleted the worktree-agent-a3dc7dff778fa7441 branch September 25, 2026 02:10
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
ci/build-ffmpeg.sh: the firmware database fwsym holds spans platform
releases 1.2.0 to 11.2.0, not webOS 3 to 10; libz.so.1 is in every image.
docs/trailer-ux-plan.md: the deferred just_finished proposal names the
preview machine's current transitions, Machine::eos and Machine::stopped,
as docs/TODOS.md already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
… in the audit

#235 gave libavformat-plx a DT_NEEDED on libz.so.1, and nothing graded it:
the libraries are dlopen'd, webosbrew-ipk-verify grades only the app and
service executables, and fwcompat on a bundled library reported every
firmware FAIL for the sibling libav*-plx names no firmware carries.

tools/fwcompat.py --shipped DIR takes DT_NEEDED names that are files in DIR
off the firmware's list and counts what they export as resolved. Watched:
bare, libavformat-plx FAILs everywhere on its siblings; with --shipped pkg
all three pass from 4.4.2 to 11.2.0; against a copy of the 4.4.2 database
with libz removed it FAILs on libz.so.1 (4 symbols) and exits 1.

CI's firmware load matrix and the build's fwcompat gate now run it over
each bundled library; the build appends the matrix to pkg/ipk-verify.md,
which gen-release-audit.py embeds, and gen-release-audit.py lists each
bundled library's DT_NEEDED. Review finding on #241: the zlib verdict is
now read from the published package instead of typed into the audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Sep 25, 2026
…brary firmware gate (#241)

* docs: correct two claims #235 and #239 left stale

ci/build-ffmpeg.sh: the firmware database fwsym holds spans platform
releases 1.2.0 to 11.2.0, not webOS 3 to 10; libz.so.1 is in every image.
docs/trailer-ux-plan.md: the deferred just_finished proposal names the
preview machine's current transitions, Machine::eos and Machine::stopped,
as docs/TODOS.md already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 release note and audit: cover #234-#240

The note gains the image-subtitle fix, the trailer stop/reporting/redirect
behaviour, the art-crop, library-seat and profiles read-out fixes, and a
line for nightly users about BACK from the player. The audit records the
seven changes as host-verified and pending the device pass, the bundled
FFmpeg's new libz.so.1 dependency with its firmware evidence, and the
https HLS cross-origin redirect gap as a known follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: the audit lint refuses an unfilled placeholder in the authored half

Nothing substitutes into a release audit's authored half; gen-release-audit
only replaces the generated block, so a __PLACEHOLDER__ left there
publishes literally. Watched red on the v0.7.0 audit's __GATES__ row before
it was filled; every existing audit and the template pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: record the gates run on the release-prep tree

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: fold in the second device pass over #234-#240

#234, #235, #236, #237 and #239 passed on the television on a debug build
of 3a30a01, each with the log lines behind it; #238 stays pending (it
needs real playback), and #237's new focus-on-Sign-out finding is pending
its own fix. Records the second pass's harness results and marks the
0.6.6 -> 0.7.0 in-place upgrade as blocked, with what unblocks it and what
was observed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 release note and audit: #242 fixes the device pass's Sign-out focus finding

The audit lists #242 among the changes landed after the device pass,
host-verified and pending the device, and marks #237's focus-on-Sign-out
finding fixed by it. The note's smaller fixes gain the menu-focus line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: the gate row names the tree rebased onto #242

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* 0.7.0 note and audit: scope the trailer and library promises, record the pass's account writes

Review findings on #241:
- A trailer started with Play Trailer is an ordinary playback
  (request_play, preview: false) and reports a timeline; only the
  background preview, full-screen mode included, never reports.
- The library DOWN fix holds only when the reader has not moved before
  the shelves load.
- The device-pass summary counts #236 as passed only for shelves-first.
- The pass wrote to the Guest profile: the explicit PGS pick's
  PUT /library/parts selection, and the harness's unscrobble, progress
  seeds and playback timelines.
- The gate row states that every commit after b99e79f is note/audit
  only and which checks were re-run on the head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fwcompat: grade the bundled FFmpeg libraries, and put their DT_NEEDED in the audit

#235 gave libavformat-plx a DT_NEEDED on libz.so.1, and nothing graded it:
the libraries are dlopen'd, webosbrew-ipk-verify grades only the app and
service executables, and fwcompat on a bundled library reported every
firmware FAIL for the sibling libav*-plx names no firmware carries.

tools/fwcompat.py --shipped DIR takes DT_NEEDED names that are files in DIR
off the firmware's list and counts what they export as resolved. Watched:
bare, libavformat-plx FAILs everywhere on its siblings; with --shipped pkg
all three pass from 4.4.2 to 11.2.0; against a copy of the 4.4.2 database
with libz removed it FAILs on libz.so.1 (4 symbols) and exits 1.

CI's firmware load matrix and the build's fwcompat gate now run it over
each bundled library; the build appends the matrix to pkg/ipk-verify.md,
which gen-release-audit.py embeds, and gen-release-audit.py lists each
bundled library's DT_NEEDED. Review finding on #241: the zlib verdict is
now read from the published package instead of typed into the audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* v0.7.0 audit: the zlib entry defers to the generated half; the gate row names the tooling commits

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fwcompat review: row() takes its cells, and --shipped says what it trusts

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* build-package: the bundled-library matrix goes into ipk-verify.md unfenced

gen-release-audit.py already wraps that whole file in one code fence; a nested
fence closed it. Only the step summary fences the aligned columns now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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