mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-04-21 05:29:50 +00:00
[PR #1927] Port C(ccx_encoder_srt.c) to Rust(ccxr_encoder_srt.rs) #2724
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/CCExtractor/ccextractor/pull/1927
Author: @VivianVRodrigues
Created: 12/29/2025
Status: 🔄 Open
Base:
master← Head:rust_encoder_upd2📝 Commits (10+)
97c981dSome updates of encoder_srt_rust5b1e7a5some updatesb3471d7some changesdf81343Refactor SRT encoder to use ccxr_encoder_ctx with Vec<ccxr_s_write>e7e8afaFix Linux build: Change char types from i8 to u8 for cross-platform compatibility877a025Fix infinite recursion: Remove ccxr_write_cc_bitmap_as_srt wrapperd6c6717Remove all comments from encoder_ctx.rse15c975Remove all comments from ccxr_encoder_srt.rs8b88a61Fix: Remove semicolon from fh assignment to fix type mismatchb2e3d5bAdded 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
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
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
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
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)
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.