Skip to content

Commit

Permalink
feat: Use of rust function due to initialization of dtvcc_rust in m…
Browse files Browse the repository at this point in the history
…p4.c
  • Loading branch information
IshanGrover2004 committed Aug 24, 2024
1 parent 3901259 commit ee83a50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib_ccx/ccx_dtvcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void dtvcc_free(dtvcc_ctx **);
#ifndef DISABLE_RUST
extern void *ccxr_dtvcc_init(struct ccx_decoder_dtvcc_settings *settings_dtvcc);
extern void ccxr_dtvcc_free(void *dtvcc_rust);
extern void ccxr_dtvcc_process_data(void *dtvcc_rust, const unsigned char *data);
#endif

#endif // CCEXTRACTOR_CCX_DTVCC_H
6 changes: 6 additions & 0 deletions src/lib_ccx/mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,14 @@ static int process_clcp(struct lib_ccx_ctx *ctx, struct encoder_ctx *enc_ctx,
continue;
}
// WARN: otherwise cea-708 will not work

#ifndef DISABLE_RUST
ccxr_dtvcc_set_encoder(dec_ctx->dtvcc_rust, enc_ctx);
ccxr_dtvcc_process_data(dec_ctx->dtvcc_rust, (unsigned char *)temp);
#else
dec_ctx->dtvcc->encoder = (void *)enc_ctx;
dtvcc_process_data(dec_ctx->dtvcc, (unsigned char *)temp);
#endif
cb_708++;
}
if (ctx->write_format == CCX_OF_MCC)
Expand Down
4 changes: 4 additions & 0 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ extern "C" fn ccxr_dtvcc_set_encoder(dtvcc_rust: *mut Dtvcc, encoder: *mut encod
unsafe { (*dtvcc_rust).encoder = encoder };
}

extern "C" fn ccxr_dtvcc_process_data(dtvcc_rust: *mut Dtvcc, data: &[u8]) {
unsafe { &mut (*dtvcc_rust) }.process_cc_data(data[0], data[1], data[2], data[3]);
}

/// Process cc_data
///
/// # Safety
Expand Down

0 comments on commit ee83a50

Please sign in to comment.