Skip to content

[FEAT] Add bitstream module in lib_ccxr #1649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

mrswastik-robot
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.

This PR migrates the bitstream functionality from C to Rust while maintaining backward compatibility by creating a new Rust implementation in lib_ccxr/src/common/bitstream.rs and connecting it to the existing C code through FFI bindings.

@@ -25,6 +24,9 @@ struct bitstream
// increased by the calling function, or not.
unsigned char *_i_pos;
int _i_bpos;
#ifndef DISABLE_RUST
void *rust_bs; // Pointer to Rust's Bitstream struct
Copy link
Member

Choose a reason for hiding this comment

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

Could we construct / deconstruct the struct when passing to rust instead of storing a different pointer?

There are other files, where you can see the to_ctype()

Copy link
Author

Choose a reason for hiding this comment

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

yaa surely, this should be a better approach rather than having to maintain two structures. I will try to fix it in my next commit

Copy link
Author

Choose a reason for hiding this comment

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

@prateekmedia , I have made changes in the bitstream.rs file , can you please review it now

Copy link
Member

Choose a reason for hiding this comment

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

will check this.

@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 5b327c7...:

Report Name Tests Passed
Broken 12/13
CEA-708 5/14
DVB 7/7
DVD 0/3
DVR-MS 2/2
General 10/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 82/86
Teletext 21/21
WTV 12/13
XDS 17/34

All tests passing on the master branch were passed completely.

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

Congratulations: Merging this PR would fix the following tests:


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 407d0f4...:

Report Name Tests Passed
Broken 11/13
CEA-708 6/14
DVB 2/7
DVD 0/3
DVR-MS 2/2
General 9/27
Hauppage 1/3
MP4 3/3
NoCC 10/10
Options 78/86
Teletext 4/21
WTV 10/13
XDS 14/34

All tests passing on the master branch were passed completely.

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

Congratulations: Merging this PR would fix the following tests:


Check the result page for more info.

@prateekmedia prateekmedia requested a review from Copilot June 21, 2025 09:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new bitstream module implemented in Rust and connects it to the existing C code via FFI.

  • Introduces Rust-side bitstream functions and exposes them through the C wrapper
  • Updates C bitstream implementation to delegate to Rust when DISABLE_RUST is not defined
  • Adjusts tests and build configuration to include the new module

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/rust/wrapper.h Includes the C header for bitstream to expose FFI
src/rust/src/libccxr_exports/mod.rs Registers the bitstream export module
src/rust/lib_ccxr/src/util/bits.rs Refactors parity tests to use assert!
src/rust/lib_ccxr/src/common/mod.rs Adds bitstream to the common mod exports
src/rust/build.rs Links the bitstream library into the build script
src/lib_ccx/cc_bitstream.c Wraps the C implementation to call into Rust
Comments suppressed due to low confidence (3)

src/lib_ccx/cc_bitstream.c:238

  • The function signature returns unsigned char * but the Rust FFI ccxr_next_bytes exports a const uint8_t *. Consider updating this to const unsigned char * to preserve the const qualifier and avoid discarding it.
		bstr->bpos = 8;

src/rust/wrapper.h:14

  • wrapper.h includes the C header for bitstream but does not declare the extern ccxr_* functions provided by the Rust bitstream module, so consumers won’t see the Rust FFI symbols. Consider adding extern declarations for each ccxr_* function in this header.
#include "../lib_ccx/cc_bitstream.h"

src/rust/build.rs:30

  • The bitstream entry may not match the actual C library name produced (likely something like ccx_bitstream or part of the existing ccx library), which could cause linker errors. Verify that the linked library name matches the compiled archive.
        "bitstream",

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.

4 participants