Skip to content

Conversation

@ishwarthecodddr
Copy link

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.

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.

Description
This PR ports the hex_to_int utility function from C (src/lib_ccx/utility.c) to Rust (src/rust/lib_ccxr/src/util/hex.rs) as part of the ongoing Rust migration effort.
Changes
Created src/rust/lib_ccxr/src/util/hex.rs with the Rust implementation. Exposed the function via C-FFI in
src/rust/src/libccxr_exports/util.rs
Updated src/lib_ccx/utility.c to use the Rust implementation when DISABLE_RUST is not defined.

Changes :- Created src/rust/lib_ccxr/src/util/hex.rs with the Rust implementation.Exposed the function via C-FFI in src/rust/src/libccxr_exports/util.rs.
Updated :- src/lib_ccx/utility.c to use the Rust implementation when DISABLE_RUST is not defined.

Verification :- Ran cargo test -p lib_ccxr and verified that all tests passed, including the new
test_hex_to_int.

Copy link
Contributor

@cfsmp3 cfsmp3 left a comment

Choose a reason for hiding this comment

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

Excellent work on this C-to-Rust port! I've done a deep review and the implementation is correct.

Results

  • ALL CI tests pass on Linux (237/237)
  • ✅ Would FIX 1 test that has never passed before (hardsubx sample 184)
  • ✅ Faithful port - Rust behavior exactly matches C behavior
  • ✅ Good test coverage with unit tests
  • ✅ Proper FFI export with extern "C" and #[no_mangle]
  • ✅ Correct conditional compilation pattern (#ifndef DISABLE_RUST)
  • ✅ Changelog updated

Before Merge

Please rebase on master - the PR has merge conflicts.

Windows Build Failure

The Windows build failure is due to vcpkg infrastructure issues, not your code. This is a known issue affecting multiple PRs.

Once rebased, this is ready to merge!


Note: Both the C and Rust versions only handle lowercase hex ('a'-'f'). While uppercase ('A'-'F') support could be a nice enhancement, that would be a separate PR - your port correctly matches the existing C behavior.

@ishwarthecodddr
Copy link
Author

Thanks @cfsmp3 for review and i have done the necessary changes , i think now it is ready to merge

@cfsmp3
Copy link
Contributor

cfsmp3 commented Dec 17, 2025 via email

@ishwarthecodddr
Copy link
Author

@cfsmp3 it's done now.

@cfsmp3
Copy link
Contributor

cfsmp3 commented Jan 1, 2026

@ishwarthecodddr this needs rebase. Please remove CHANGES.txt there - no changes needed (this small thing shouldn't appear in the summary, it's not important to final users).

Other than that, LGTM.

cfsmp3 and others added 9 commits January 1, 2026 15:47
Replace all sprintf calls with snprintf to prevent potential buffer
overflows in CEA-708 output functions. Key changes:

- dtvcc_change_pen_colors: add bounds checking for font color tags
- dtvcc_change_pen_attribs: add bounds checking for italic/underline tags
- dtvcc_write_srt: track buffer length with snprintf
- dtvcc_write_transcript: add bounds checking for CC/mode labels
- dtvcc_write_sami_header: use snprintf macro for all SAMI tags
- dtvcc_write_sami_footer: use snprintf with length check
- dtvcc_write_sami: add bounds checking for sync tags
- dtvcc_write_scc_header: use snprintf for SCC header
- add_needed_scc_labels: add buffer size parameter for safe writes
- dtvcc_write_scc: use snprintf macro for all SCC formatting
- dtvcc_writer_init: use snprintf for filename suffix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fix macro formatting to have 'do' and '{' on separate lines and
align backslashes consistently, as required by clang-format.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace all sprintf calls with snprintf to prevent potential buffer
overflows in CEA-708 output functions. Key changes:

- dtvcc_change_pen_colors: add bounds checking for font color tags
- dtvcc_change_pen_attribs: add bounds checking for italic/underline tags
- dtvcc_write_srt: track buffer length with snprintf
- dtvcc_write_transcript: add bounds checking for CC/mode labels
- dtvcc_write_sami_header: use snprintf macro for all SAMI tags
- dtvcc_write_sami_footer: use snprintf with length check
- dtvcc_write_sami: add bounds checking for sync tags
- dtvcc_write_scc_header: use snprintf for SCC header
- add_needed_scc_labels: add buffer size parameter for safe writes
- dtvcc_write_scc: use snprintf macro for all SCC formatting
- dtvcc_writer_init: use snprintf for filename suffix

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fix macro formatting to have 'do' and '{' on separate lines and
align backslashes consistently, as required by clang-format.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace `.unwrap()` and `.expect()` calls with safe alternatives to prevent
Rust panics when processing multiple files with different characteristics
(e.g., DVD-type followed by HDTV-type).

Changes:
- Use `unwrap_or(0)` for all type conversions that could fail
- Handle RwLock poisoning gracefully in apply_timing_info/write_back_from_timing_info
- Add fps validation and millis capping in GopTimeCode::new()
- Add fallback calculation in ccxr_calculate_ms_gop_time when GopTimeCode
  creation fails

Fixes CCExtractor#1377

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@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 6dcdb4b...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 6/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 86/86
Teletext 21/21
WTV 13/13
XDS 34/34

Your PR breaks these cases:

  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2...

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., 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 --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., 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.

@ccextractor-bot
Copy link
Collaborator

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

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 --in=mp4 --out=srt --latin1 b2771c84c2..., Last passed: Never
  • ccextractor --out=spupng 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 --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never

All tests passed completely.

Check the result page for more info.

@cfsmp3
Copy link
Contributor

cfsmp3 commented Jan 3, 2026

Hi @ishwarthecodddr, this PR needs:

  1. Rebase on current master
  2. Remove CHANGES.txt entry (too minor for changelog)

Let us know if you're still interested in completing this.

@cfsmp3
Copy link
Contributor

cfsmp3 commented Jan 3, 2026

Hi @ishwarthecodddr, this PR has some issues that need fixing:

CI Failures:

  • ❌ Linux tests failing
  • ❌ Format checks failing (both C and Rust)

Unrelated Changes:

  • The Cargo.lock has 140+ lines of unrelated dependency changes (bindgen 0.69.5, bon, darling, rsmpeg 0.18.0)
  • Whitespace changes in ccx_encoders_common.c

Please:

  1. Run clang-format on changed C files
  2. Run cargo fmt in the Rust directories
  3. Remove unrelated Cargo.lock changes (reset to master's version)
  4. Squash/clean up the commit history

The actual hex_to_int port looks fine, just needs these cleanup items.

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