Skip to content

[IMPROVEMENT] Rescue of PR #1927: SRT encoder port to Rust#2188

Closed
Atul-Chahar wants to merge 10 commits intoCCExtractor:masterfrom
Atul-Chahar:rescue/srt-encoder-rust-port
Closed

[IMPROVEMENT] Rescue of PR #1927: SRT encoder port to Rust#2188
Atul-Chahar wants to merge 10 commits intoCCExtractor:masterfrom
Atul-Chahar:rescue/srt-encoder-rust-port

Conversation

@Atul-Chahar
Copy link
Contributor

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

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog. (Actually, the original PR did not update the changelog, but we will add one if requested)

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

Summary

This is a rescue of the stale/closed PR #1927 by @VivianVRodrigues. The original PR successfully ported the SRT encoder to Rust but was abandoned due to a Linux build failure caused by C-header #include ordering and missing struct forward declarations in utility.h.

I have:

  1. Resurrected the branch and rebased it onto the latest master.
  2. Resolved all merge conflicts in Cargo.toml and C files.
  3. Fixed the utility.h include issue by adding the proper struct encoder_ctx;, struct cc_subtitle;, and struct eia608_screen; forward declarations as requested by the reviewers.
  4. Fixed a Rust E0603 (private trait import) compiler error in src/rust/src/libccxr_exports/encoder_ctx.rs.
  5. Verified that both the Linux build and the Rust cargo test suite pass flawlessly.

All credit for the hard porting work goes to Vivian. I merely fixed the compilation bugs, resolved conflicts, and completed the last mile so this feature can merge.

Co-authored-by: Vivian Rodrigues vivianrodrigues@Vivians-Laptop.local

AI disclosure: 🟡 AI-assisted — I reviewed, tested, and resolved the merge conflicts and C-header build failures.

Fixes #1927 requirements.

VivianVRodrigues and others added 9 commits March 8, 2026 04:40
- Renamed CcxSWriteRust to ccxr_s_write for consistency
- Renamed EncoderCtxRust to ccxr_encoder_ctx
- Changed out field from raw pointer to Vec<ccxr_s_write>
- Unified encode_line functions into single optimal version
- Added ccxr_write_cc_bitmap_as_srt (OCR stub)
- Added ccxr_write_cc_subtitle_as_srt with proper cleanup
- Added ccxr_write_cc_buffer_as_srt using Rust context
- Updated C code to call Rust implementations
- Improved type safety and eliminated unsafe pointer dereferencing
…ompatibility

- wrote_ccd_channel_header: i8 -> u8
- millis_separator: i8 -> u8
- Added type casts in from_ctype conversion

This fixes compilation errors on Linux where char is unsigned by default.
The Rust function was calling C which called Rust again, causing infinite recursion.
Removed the wrapper since OCR functionality stays in C for now.
@Atul-Chahar
Copy link
Contributor Author

Tested locally on Linux ✅: The C build compiles flawlessly and cargo test passes all 395 tests. This resolves the previous CI build failure blocking #1927.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 90128d8...:
Report Name Tests Passed
Broken 10/13
CEA-708 2/14
DVB 2/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 0/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 75/86
Teletext 15/21
WTV 13/13
XDS 34/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:

  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed:

    Test 8730

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --out=spupng c83f765c66..., Last passed: Never
  • ccextractor --parsePAT --out=srt c83f765c66..., Last passed: Never
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --endcreditsforatleast 3 --endcreditstext "CCextractor Ends crdit Testing" addf5e2fc9..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@Atul-Chahar Atul-Chahar closed this Mar 8, 2026
@Atul-Chahar Atul-Chahar deleted the rescue/srt-encoder-rust-port branch March 8, 2026 00:15
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.

3 participants