Skip to content

[FIX] Restore CEA-708 output in the min-rust (DISABLE_RUST) build - #2399

Open
Deepak-negi11 wants to merge 1 commit into
CCExtractor:masterfrom
Deepak-negi11:fix/min-rust-708
Open

Deepak-negi11 wants to merge 1 commit into
CCExtractor:masterfrom
Deepak-negi11:fix/min-rust-708

Conversation

@Deepak-negi11

@Deepak-negi11 Deepak-negi11 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

Samples from https://streams.videolan.org/streams/ts/ (more details in #2398). Build both versions from the same commit: ./build -min-rust (C) and ./build (Rust).

Sample Before (C build vs Rust build) After
CC/wabc-4pm-ota.clip1.ts C build writes no 708 captions (Rust: 42) Same output from both builds
atsc-cea-708-dtvcc-and-cea-608.ts C build writes no 708 captions Same text (start times 1 ms apart)
--out=report on atsc-cea-708-dtvcc-and-cea-608.ts C build's report leaves the CEA-708 "Services:" line empty (Rust: 1) Same report from both builds

Problem

#2207 added a C-only build (min-rust) that should give the same output as the Rust build. For 708 captions it doesn't: #1738 removed the code that sends 708 data to the C decoder. The data goes to the Rust decoder instead, which isn't running in this build, so no 708 captions are written and --out=report doesn't list the 708 services.

Sending the data to the C decoder again showed two more problems in the C 708 code:

  • The C writer wrote every letter as 2 bytes, so the file wasn't readable text.
  • With --out=report there's no output writer, and the C decoder used it anyway, which crashed.

Fix

  1. Add process_cc_data_dtvcc(), the C version of ccxr_process_cc_data(). In the C-only build it sends all 708 blocks to the C decoder before do_cb() runs, with the same rules as Rust: skip RAW output, same time-window check. So the timing matches the Rust build too.
  2. Write 2 bytes per letter only for UTF-16 charsets, the same rule the Rust writer uses.
  3. With --out=report there's no output writer. Once 708 data reaches the C decoder again (fix 1), the C decoder would use that missing writer and crash, so the decoder now skips decoding when there is no writer, the same as the Rust decoder.

Testing

Copilot AI balanced review requested due to automatic review settings October 18, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The min-rust build (CCExtractor#2207) should produce the same output as the Rust
build, but it wrote no CEA-708 captions at all, wrote unreadable 2-byte
characters once fed, and crashed with --out=report.

- CCExtractor#1738 removed both the DISABLE_RUST guard around
  ccxr_process_cc_data() and the dtvcc_process_data() call in do_cb(),
  so with DISABLE_RUST the 708 data went to Rust, which returns early
  because dtvcc_rust is NULL. Add process_cc_data_dtvcc(), the C
  counterpart of ccxr_process_cc_data()/do_cb_dtvcc_rust(): it passes
  every 708 block to the C decoder before do_cb() runs, with the same
  rules (skip RAW output, same time window check), so the timing
  matches the Rust build.
- write_utf16_char() always wrote 2 bytes (CCExtractor#1451). Without a charset
  that raw UTF-16 reached the file. Write 2 bytes only for UTF-16/UCS-2
  charsets, as the Rust writer does (write_char/is_utf16_charset).
- With --out=report there is no encoder, and dtvcc_screen_print()
  dereferenced it. Only decode service blocks when an encoder exists,
  as the Rust decoder does.

The Rust build is unchanged: its output is identical before and after
on all compared samples.
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.

2 participants