Repository navigation
Description
Unit
libobs/obs-output.c.h: the caption plan of add_caption(), which puts a queued caption into an encoded video packet. The plan covers:
- which carrier the codec gets (AVC SEI, HEVC suffix SEI, AV1 metadata OBU, or none);
- the packet priority gate;
- the length of the HEVC Annex B start code;
- which CEA-608 triplets from the queue go into the CEA-708 frame (
cc_type, padding, zero and parity); - the first byte of the HEVC suffix SEI NAL unit header.
The plan moves to libobs/obs-output-caption.c.h and is ported to rust/obs-output (module output_caption, next to output_pause and output_reconnect).
Phase and position
Phase 2 libobs core, outputs (core-output group). It comes after the output pause plan (#3020) and the encoder pause checks (#3033), which have merged. Tracking: #4.
Dependencies and existing tests
- Depends on nothing open.
- Existing tests that see the function through the real libobs:
test_output_caption_codec(bug: libobs: add_caption() leaks a packet copy for each caption on a codec other than h264, hevc or av1 #1777: a codec with no carrier still drains the queue and frees everything; h264 as the control),test_output_caption_queueandtest_caption_unmappable. - No characterization of the plan on its own yet.
test_output_caption_steps(cmocka, the moved file on its own) lands first. It pins:- the carrier for
h264,hevc,av1and other codecs; priority0, 1 and 2;- the start code length for a 3-byte and a 4-byte start code, and for none;
- the triplet filter: each
cc_type,0x8080,0x0000, bad parity in either byte, valid pairs; - the HEVC header byte with the low bit set and clear.
- the carrier for
Notes
-
What moves are the decisions on plain values.
obs-output.c.hkeeps:- the caption track lookup and its log;
- the deque pops and
bzalloc/bfree; - every libcaption call (
sei_*,cea708_*,caption_frame_*,metadata_obu,extract_buffer_from_sei); - the packet
DARRAY,obs_encoder_packet_release(), and the order of every call.
eia608_parity_varify()is a libcaption inline; the port computes the same parity and Tier 3 compares the two. -
The caption text from
obs_output_output_caption_text2()(which obs-websocket'sSendStreamCaptionreaches) goes throughcaption_frame_from_text(), which stays in C. The ported filter sees only the CEA-608 triplets that sources queue withobs_output_caption(). -
Kept, characterized, not endorsed:
- an AVC caption SEI goes after the whole packet, not before the first VCL NAL unit (the C's
TODO); - a codec with no carrier still drains one caption from the queue and returns false.
- an AVC caption SEI goes after the whole packet, not before the first VCL NAL unit (the C's
-
Possible intentional difference, for a decision before the port: the HEVC start code check and the 2-byte header read do not look at the packet size. A packet of under 6 bytes is read past its end. The port would take the size and treat a short packet as "no start code" (no caption, as for a missing start code). The input is the encoder's own output (trusted local), so this is a normal public bug per SECURITY.md.
-
One slice. The packet layout (the reference count, the old data, then the start code, header and SEI) is darray pushes around libcaption output, so it stays in C. A later slice can take it if a plan for it proves worthwhile.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 30, 2026
Claiming: #3074.
Plan (one PR, in this order):
add_caption()tolibobs/obs-output-caption.c.has hidden functions on plain values, declared inlibobs/obs-output-caption.hwithoutEXPORT.add_caption()keeps every libcaption call, deque pop, allocation and packet step in its order.test_output_caption_steps(cmocka, the moved file on its own), with the cases listed in the issue.rust/obs-outputmoduleoutput_captionwith stubs, Tier 1 tests, and Tier 3 parity against the oracle build of the moved file (carrier, gate, start code, triplet filter including the parity bit, HEVC header byte).The short HEVC packet read (issue, last note) stays as the C does unless it is decided as an intentional difference; I will ask for that with
Decision needed:before GREEN if it is still open.Draft PR within 48 h.
obs-output: Port the output caption plan (obs-rust#3074) (obs-rust#3077)