edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane/dvdsubs: DVD (VobSub) and DVB bitmap subtitles
What was added
ec-coreregistry:CodecId::DvdSub(dvd_subtitle) andCodecId::DvbSub(dvb_subtitle), bothMediaType::Subtitle. Variants are contiguous afterRawVideo; test list count 41 -> 43.ec-dvdsub(new crate): SPU decode (decode_spu),.idx/ MatroskaCodecPrivatetext (parse_idx:size:,palette:,id:,timestamp:/filepos:),SpuAssembler(units are cut from the PES byte stream by their size field, PTS handed out in order),sub_file_units(standalone.subMPEG-PS, private stream 1 substreams 0x20-0x3f),DvdSubDecoder(+make_decoder).ec-dvbsub(new crate): page / region / CLUT / object (2, 4, 8 bit, map tables, top/bottom field) / display-definition / end-of-set segments;DvbSubDecoder(+make_decoder). Spec default CLUTs when none is sent.- Container wiring: Matroska
S_VOBSUBandS_DVBSUB(demux + codec id in mux); MPEG-PS private stream 1 0x20-0x3f (was a refusal) ->StreamKind::DvdSub; MPEG-TS stream_type 0x06 with descriptor 0x59 ->StreamKind::DvbSub; mp4mp4ssample entry withesdsobject type 0xE0 ->DvdSub(extradata = the idx text from the decoder-specific info). Bitmap subtitle streams (PGS, DVD, DVB) no longer wait for 3 packets / a timing probe. - Fuzz targets (same layout as ec-pgs):
ec-dvdsub/fuzz(unit,sub_file),ec-dvbsub/fuzz(packets). Plus in-crate "rubbish never panics" tests. - Fixtures: tiny files under
crates/ec-dvdsub/tests/dataandcrates/ec-dvbsub/tests/data, regenerated byscripts/gen-bitmap-sub-fixtures.sh(ffmpeg's dvdsub/dvbsub encoders need bitmaps, so the source is a synthetic 720x576 PGS fromscripts/gen-bitmap-sub-fixtures.py, four cues; no third-party media).
Output type (what edith consumes)
Same as ec-pgs: Decoder::receive_frame gives Frame::Video RGBA8 straight-alpha, canvas-sized (720x576 by default; DVD takes size: from the idx text; DVB takes the display-definition segment), transparent where nothing is painted. Richer API next to it:
- DVD:
DvdSubDecoder::take_cue() -> Cue { frame, area (x,y,w,h), start_90k, end_90k: Option, forced }. Times are 90 kHz ticks after the packet PTS (SPU delay unit 1024/90000 s).frame.pts= packet pts + start delay.end_90k = Nonemeans "until the next cue". The decoder is built withDvdSubDecoder::new(extradata)(idx text); without a palette it uses the DVD default 16-colour table (what ffmpeg's encoder writes). For VOB/PS there is no IFO reader here: the caller passes the palette as idx text (palette: rrggbb, ...), e.g. built from the IFO. - DVB:
DvbSubDecoder::take_cue() -> DvbCue { frame, timeout_ms, empty, page_state, regions }. A set with no regions yieldsempty: true(a clear). Display time = packet pts .. pts +timeout_ms, or the next set. - Packet framing: DVB takes the TS PES payload (
20 00 0f ...) or the Matroska block (no20 00); DVD takes one whole SPU per packet (mkv, mp4) -ec-mpegtsreassembles units for VOB/PS.
edith needs: map CodecId::DvdSub / DvbSub to ec_dvdsub::make_decoder / ec_dvbsub::make_decoder where it maps Pgs; to show end times for DVD use take_cue() (or the next frame's pts), and for DVB timeout_ms; list the new codecs as bitmap subtitle in the track picker. Nothing in edith's crates/app was touched.
Verification (ffmpeg 8.1 as oracle; sub2video frames as raw RGBA)
- DVD: mkv (S_VOBSUB), VOB (
-target pal-dvd, private stream 1), mp4 (mp4s),.idx/.subpair: 4 cues each, pixel-exact (0 differing pixels, alpha and RGB), starts within 2 ms, ends within 15 ms of ffmpeg. VOB, mp4 and idx/sub are compared against the mkv oracle frames (same cues) with one constant time shift for the muxing offset. - DVB: mkv (S_DVBSUB) and TS (0x06 + subtitling descriptor): 4 cues each, pixel-exact (max channel delta 0), starts within 2 ms.
- Tests:
crates/ec-dvdsub/tests/ffmpeg_parity.rs,crates/ec-dvbsub/tests/ffmpeg_parity.rs(skip loudly without ffmpeg;EC_REQUIRE_FIXTURES=1makes that a failure).
Known limits
- DVD: the colour/contrast change command (0x07) is skipped, not applied (menu highlights); forced flag is reported, not filtered. ffmpeg's own VOB muxer with a video stream (
-f vobwithout-target) packs units across PES packets and states one PTS per two units; units without a PTS getpts = None(a standard disc and-target pal-dvdgive one PTS per unit and decode fully). - DVB: character-coded objects (coding method 1) and the ancillary/composition page-id split are ignored (all page ids are decoded together); region/object state across epochs follows the page state (acquisition/mode change clears it). The ffmpeg fixtures exercise only the depth ffmpeg's encoder picks; the other depths are covered by hand-built unit tests.
- Only whole-set cues are produced; edith does the compositing.