Skip to content

Conversation

@ujjwalr27
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.

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 of Changes Made

1. In src/rust/src/lib.rs:

  • Added a new lib_cc_decode struct with a dtvcc_rust field to store the Rust Dtvcc instance.
  • Created ccxr_dtvcc_init() function to initialize the Dtvcc struct only once.
  • Created ccxr_dtvcc_free() function to free the Dtvcc struct.
  • Modified ccxr_process_cc_data() to use the stored Dtvcc instance instead of creating a new one each time.
  • Added a fallback to the old method if initialization fails.

2. In src/lib_ccx/ccx_decoders_structs.h:

  • Added the dtvcc_rust field to the existing lib_cc_decode struct definition.

3. In src/lib_ccx/ccx_decoders_common.h:

  • Added extern declarations for ccxr_dtvcc_init and ccxr_dtvcc_free functions.

4. In src/lib_ccx/ccx_decoders_common.c:

  • Added function declarations for the Rust functions.
  • Added a call to ccxr_dtvcc_init() after dtvcc_init is called.
  • Added a call to ccxr_dtvcc_free() before dtvcc_free is called.
  • Initialized dtvcc_rust to NULL in the init_cc_decode function.
  • Added NULL initialization for dtvcc_rust in the copy_decoder_context function.

5. In src/lib_ccx/mp4.c:

  • Fixed a conflict between multiple MEDIA_TYPE defines.
  • Confirmed that the extern declarations for the Rust functions were already in place.
  • Added code in the process_clcp function to use the Rust implementation of Dtvcc:
    • Checks if dtvcc_rust is NULL and initializes it if needed.
    • Creates a proper cc_block for the Rust implementation.
    • Calls ccxr_process_cc_data() with the block.
    • Falls back to the C implementation if Rust isn't available.

This implementation ensures that the Dtvcc struct is initialized only once at the start of the program and then reused for all subsequent function calls. This fixes the issue where data was being reset each time ccxr_process_cc_data() was called. The changes also integrate this approach into the MP4 code path.

@ujjwalr27 ujjwalr27 closed this by deleting the head repository Apr 27, 2025
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.

1 participant