[PR #1927] Port C(ccx_encoder_srt.c) to Rust(ccxr_encoder_srt.rs) #2724

Open
opened 2026-01-29 17:23:37 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1927
Author: @VivianVRodrigues
Created: 12/29/2025
Status: 🔄 Open

Base: masterHead: rust_encoder_upd2


📝 Commits (10+)

  • 97c981d Some updates of encoder_srt_rust
  • 5b1e7a5 some updates
  • b3471d7 some changes
  • df81343 Refactor SRT encoder to use ccxr_encoder_ctx with Vec<ccxr_s_write>
  • e7e8afa Fix Linux build: Change char types from i8 to u8 for cross-platform compatibility
  • 877a025 Fix infinite recursion: Remove ccxr_write_cc_bitmap_as_srt wrapper
  • d6c6717 Remove all comments from encoder_ctx.rs
  • e15c975 Remove all comments from ccxr_encoder_srt.rs
  • 8b88a61 Fix: Remove semicolon from fh assignment to fix type mismatch
  • b2e3d5b Added Forward declaration for struct type in utility.h

📊 Changes

13 files changed (+878 additions, -101 deletions)

View changed files

📝 src/lib_ccx/ccx_encoders_srt.c (+9 -0)
📝 src/lib_ccx/utility.h (+9 -0)
📝 src/rust/Cargo.lock (+1 -0)
📝 src/rust/Cargo.toml (+1 -0)
📝 src/rust/build.rs (+1 -0)
src/rust/src/encoder/ccxr_encoder_srt.rs (+285 -0)
📝 src/rust/src/encoder/common.rs (+96 -98)
📝 src/rust/src/encoder/g608.rs (+3 -2)
📝 src/rust/src/encoder/mod.rs (+1 -0)
src/rust/src/libccxr_exports/encoder_ctx.rs (+467 -0)
📝 src/rust/src/libccxr_exports/mod.rs (+1 -0)
📝 src/rust/src/utils.rs (+2 -1)
📝 src/rust/wrapper.h (+2 -0)

📄 Description

Overview
This branch migrates the SRT encoder to Rust and refactors the encoder context. 13 files changed: 872 insertions, 101 deletions.
Main Changes

  1. New Rust SRT encoder implementation(ccx_encoder_srt rewrite)
    Added src/rust/src/encoder/ccxr_encoder_srt.rs (285 lines)
    Functions: ccxr_write_stringz_srt, ccxr_write_cc_subtitle_as_srt, ccxr_write_cc_buffer_as_srt

  2. New encoder context module
    Added src/rust/src/libccxr_exports/encoder_ctx.rs (467 lines)
    Safe Rust wrapper for C encoder_ctx
    Conversion functions: copy_encoder_ctx_c_to_rust, copy_encoder_ctx_rust_to_c
    Rust struct ccxr_encoder_ctx with Vec<ccxr_s_write> for file handles

  3. C code integration
    Modified src/lib_ccx/ccx_encoders_srt.c
    Added conditional Rust calls (wrapped in #ifndef DISABLE_RUST)
    Functions delegate to Rust when Rust is enabled:
    write_stringz_as_srt → ccxr_write_stringz_srt
    write_cc_subtitle_as_srt → ccxr_write_cc_subtitle_as_srt
    write_cc_buffer_as_srt → ccxr_write_cc_buffer_as_srt

  4. Refactored common encoder utilities to take Rust struct instead of C
    Modified src/rust/src/encoder/common.rs
    Refactored encode_line to take ccxr_encoder_ctx(Rust) instead of encoder_ctx(C)
    Refactored write_subtitle_file_footer_rust to use ccxr_encoder_ctx(Rust) instead of encoder_ctx(C)

  5. Build system updates(build related to port )
    Updated src/rust/Cargo.toml and Cargo.lock (new dependencies)
    Updated src/rust/build.rs (build configuration)
    Updated src/rust/wrapper.h (C bindings)
    Updated src/lib_ccx/utility.h (utility declarations)

Local testing on Linux
Test data : https://drive.google.com/drive/folders/1qPm8ImCPg_3nK2kH9aWWWWliqJmwwotR?usp=sharing


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1927 **Author:** [@VivianVRodrigues](https://github.com/VivianVRodrigues) **Created:** 12/29/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `rust_encoder_upd2` --- ### 📝 Commits (10+) - [`97c981d`](https://github.com/CCExtractor/ccextractor/commit/97c981d4ef0e29b6fb42b0561b2068ec2e541b52) Some updates of encoder_srt_rust - [`5b1e7a5`](https://github.com/CCExtractor/ccextractor/commit/5b1e7a5cb99e05a708ff88be08c915db43b415b2) some updates - [`b3471d7`](https://github.com/CCExtractor/ccextractor/commit/b3471d7882f1cdf9f0da2f769c0add782517dd80) some changes - [`df81343`](https://github.com/CCExtractor/ccextractor/commit/df81343bda90e629aebb18eb660a957a23831a82) Refactor SRT encoder to use ccxr_encoder_ctx with Vec<ccxr_s_write> - [`e7e8afa`](https://github.com/CCExtractor/ccextractor/commit/e7e8afa18db9d4fdb1b6a926c420fdd7a3a3232c) Fix Linux build: Change char types from i8 to u8 for cross-platform compatibility - [`877a025`](https://github.com/CCExtractor/ccextractor/commit/877a02598cdf6ccb32ed0b9e3235694bcd3514eb) Fix infinite recursion: Remove ccxr_write_cc_bitmap_as_srt wrapper - [`d6c6717`](https://github.com/CCExtractor/ccextractor/commit/d6c6717882b6b7683eb062eccc74d005adc9a412) Remove all comments from encoder_ctx.rs - [`e15c975`](https://github.com/CCExtractor/ccextractor/commit/e15c975aab878d0574058367d413fe64623e678b) Remove all comments from ccxr_encoder_srt.rs - [`8b88a61`](https://github.com/CCExtractor/ccextractor/commit/8b88a619d897475cd7162ffb760eb2c5d1458d40) Fix: Remove semicolon from fh assignment to fix type mismatch - [`b2e3d5b`](https://github.com/CCExtractor/ccextractor/commit/b2e3d5bb8fd60e1212d3c40cdd790f589727f4a3) Added Forward declaration for struct type in utility.h ### 📊 Changes **13 files changed** (+878 additions, -101 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/ccx_encoders_srt.c` (+9 -0) 📝 `src/lib_ccx/utility.h` (+9 -0) 📝 `src/rust/Cargo.lock` (+1 -0) 📝 `src/rust/Cargo.toml` (+1 -0) 📝 `src/rust/build.rs` (+1 -0) ➕ `src/rust/src/encoder/ccxr_encoder_srt.rs` (+285 -0) 📝 `src/rust/src/encoder/common.rs` (+96 -98) 📝 `src/rust/src/encoder/g608.rs` (+3 -2) 📝 `src/rust/src/encoder/mod.rs` (+1 -0) ➕ `src/rust/src/libccxr_exports/encoder_ctx.rs` (+467 -0) 📝 `src/rust/src/libccxr_exports/mod.rs` (+1 -0) 📝 `src/rust/src/utils.rs` (+2 -1) 📝 `src/rust/wrapper.h` (+2 -0) </details> ### 📄 Description Overview This branch migrates the SRT encoder to Rust and refactors the encoder context. 13 files changed: 872 insertions, 101 deletions. Main Changes 1. New Rust SRT encoder implementation(ccx_encoder_srt rewrite) Added src/rust/src/encoder/ccxr_encoder_srt.rs (285 lines) Functions: ccxr_write_stringz_srt, ccxr_write_cc_subtitle_as_srt, ccxr_write_cc_buffer_as_srt 2. New encoder context module Added src/rust/src/libccxr_exports/encoder_ctx.rs (467 lines) Safe Rust wrapper for C encoder_ctx Conversion functions: copy_encoder_ctx_c_to_rust, copy_encoder_ctx_rust_to_c Rust struct ccxr_encoder_ctx with Vec<ccxr_s_write> for file handles 3. C code integration Modified src/lib_ccx/ccx_encoders_srt.c Added conditional Rust calls (wrapped in #ifndef DISABLE_RUST) Functions delegate to Rust when Rust is enabled: write_stringz_as_srt → ccxr_write_stringz_srt write_cc_subtitle_as_srt → ccxr_write_cc_subtitle_as_srt write_cc_buffer_as_srt → ccxr_write_cc_buffer_as_srt 4. Refactored common encoder utilities to take Rust struct instead of C Modified src/rust/src/encoder/common.rs Refactored encode_line to take ccxr_encoder_ctx(Rust) instead of encoder_ctx(C) Refactored write_subtitle_file_footer_rust to use ccxr_encoder_ctx(Rust) instead of encoder_ctx(C) 5. Build system updates(build related to port ) Updated src/rust/Cargo.toml and Cargo.lock (new dependencies) Updated src/rust/build.rs (build configuration) Updated src/rust/wrapper.h (C bindings) Updated src/lib_ccx/utility.h (utility declarations) Local testing on Linux Test data : https://drive.google.com/drive/folders/1qPm8ImCPg_3nK2kH9aWWWWliqJmwwotR?usp=sharing --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:23:37 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2724