Repository navigation
Text subtitles: decode legacy-encoded tracks (GBK/Big5/Shift_JIS/EUC-KR/…) per track with chardetng (#628) - #708
Merged
Merged
Conversation
…rough a per-track charset step (#628) Embedded subrip/SRT/webvtt/mov_text packets and the sidecar bare fallback were decoded with String::from_utf8_lossy, so a GBK Chinese track rendered as a row of U+FFFD. player::sub_charset::subtitle_text takes BOM, then valid UTF-8 (zero-copy), then the legacy encoding the stream's language tag implies (encoding_rs, pure Rust), decided once per track by its first non-UTF-8 packet. Host-FFmpeg test on a 588-byte GBK subrip MKV fixture. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… its language (#628) Replaces the language table with chardetng (pure Rust, on encoding_rs): any legacy encoding is detected from the track's first non-UTF-8 packets, locked after 160 non-ASCII bytes; the sidecar fallback detects over the whole file. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… (Big5 cue was read as GBK) (#628) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| assert!(avformat_open_input(&mut fmt, path.as_ptr(), std::ptr::null_mut(), std::ptr::null_mut()) >= 0); | ||
| let mut pkt = av_packet_alloc(); | ||
| assert!(!pkt.is_null()); | ||
| let mut subs = SubTracks::open(fmt, (*fmt).streams); |
…it opened CodeQL rust/access-invalid-pointer flagged the (*fmt) dereference in open() and the new test's. A null format context now yields no tracks instead of a fault. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
enabled auto-merge (squash)
October 15, 2026 00:33
This was referenced Oct 15, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #628
Embedded and sidecar text subtitles in a legacy encoding (GBK, Big5, Shift_JIS, EUC-KR, windows-125x, …) rendered as mojibake: the cue bytes went through
from_utf8_lossy. Fonts were not the cause — the 0.8.0 ipk already shipsappfont-cjk.ttf.What changes
media/src/player/sub_charset.rs: a per-trackTrackCharsetdecided once and then reused for every cue. Order: BOM → valid UTF-8 (zero-copyCow) →chardetng(locks after 160 non-ASCII bytes) → lossy.chardetnggets a TLD hint from the stream's language tag (zh-Hans/CN/SG →cn, zh-Hant/TW →tw, zh-HK/MO →hk, ja →jp, ko →kr, ru, …); an unqualifiedchi/zho/zhgives no hint, because acnhint made a Big5 track decode as GBK on the TV.ff_subs.rsdecodes per track;SubCue::TextcarriesCow<[u8]>.ff.rsgainsstream_language()and shares one tag reader withstream_name()(simplify pass).sidecar.rs: the bare-file fallback uses the same detection over the whole file.chardetngon top of the already-pinnedencoding_rs0.8.35; THIRD-PARTY-NOTICES +licenses/WHATWG-BSD-3-Clause.txt.tests/fixtures/gbk-subrip.mkv(588 B) with testff::subtitle_charset_tests, run by the Makefilecheck-ffmpegtarget.Verification
make checkexit 0 (everytest result: ok, 0 failed);cargo check --lib --no-default-featuresclean.make check-ffmpeg(the fixture test) not run locally — CI.make build-bench(same sitting, M4 10 cores, 3 runs; host load was above core count throughout, so treat deltas inside the spread as noise; the base checkout had notarget-fast, so its incremental rows are skipped)Base:
fix-628-subtitle-charset (93d3e97):
Units 180 → 182 (chardetng and its dependency); no build-time regression is visible above the noise.
🤖 Generated with Claude Code