Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ target_include_directories (ccextractor PUBLIC ${EXTRA_INCLUDES})
if (NOT WIN32 AND NOT APPLE)
target_link_options (ccextractor PRIVATE
-Wl,--undefined=decode_vbi
-Wl,--undefined=do_cb
-Wl,--undefined=store_hdcc)
-Wl,--undefined=do_cb)
if (WITH_FFMPEG)
target_link_options (ccextractor PRIVATE
-Wl,--undefined=ccx_mp4_process_avc_sample
Expand Down
33 changes: 33 additions & 0 deletions src/lib_ccx/sequencing.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,38 @@
// #define SORTBUF (2*MAXBFRAMES+1) - from lib_ccx.h
// B-Frames can be (temporally) before or after the anchor

// The reordering logic lives in src/rust/src/sequencing.rs. These four
// functions keep their original names and C ABI so no caller has to change;
// they only forward to the Rust implementation.
#ifndef DISABLE_RUST
extern void ccxr_init_hdcc(struct lib_cc_decode *ctx);
extern void ccxr_store_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned char *cc_data, int cc_count, int sequence_number, LLONG current_fts_now, struct cc_subtitle *sub);
extern void ccxr_anchor_hdcc(struct lib_cc_decode *ctx, int seq);
extern void ccxr_process_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub);

void init_hdcc(struct lib_cc_decode *ctx)
{
ccxr_init_hdcc(ctx);
}

// Buffer caption blocks for later sorting/flushing.
void store_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, unsigned char *cc_data, int cc_count, int sequence_number, LLONG current_fts_now, struct cc_subtitle *sub)
{
ccxr_store_hdcc(enc_ctx, dec_ctx, cc_data, cc_count, sequence_number, current_fts_now, sub);
}

// Set a new anchor frame that new B-frames refer to.
void anchor_hdcc(struct lib_cc_decode *ctx, int seq)
{
ccxr_anchor_hdcc(ctx, seq);
}

// Sort/flash caption block buffer
void process_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub)
{
ccxr_process_hdcc(enc_ctx, dec_ctx, sub);
}
#else
void init_hdcc(struct lib_cc_decode *ctx)
{
for (int j = 0; j < SORTBUF; j++)
Expand Down Expand Up @@ -150,3 +182,4 @@ void process_hdcc(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, st
// Now that we are done, clean up.
init_hdcc(dec_ctx);
}
#endif
4 changes: 1 addition & 3 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ fn main() {
#[cfg(feature = "enable_ffmpeg")]
"init_ffmpeg",
"net_send_header", // shall be removed after NET
"process_hdcc",
"anchor_hdcc",
"store_hdcc",
"do_cb",
"decode_vbi",
"write_spumux_footer",
Expand Down Expand Up @@ -72,6 +69,7 @@ fn main() {
"ccx_boundary_time",
"gop_time_code",
"ccx_common_timing_settings_t",
"ccx_common_timing_ctx",
"ccx_s_options",
"ccx_s_teletext_config",
"ccx_output_date_format",
Expand Down
3 changes: 2 additions & 1 deletion src/rust/src/avc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use crate::bindings::{cc_subtitle, encoder_ctx, lib_cc_decode};
use crate::ctorust::FromCType;
use crate::ffi_alloc::realloc;
use crate::libccxr_exports::time::ccxr_set_fts;
use crate::{anchor_hdcc, current_fps, process_hdcc, store_hdcc, MPEG_CLOCK_FREQ};
use crate::sequencing::{anchor_hdcc, process_hdcc, store_hdcc};
use crate::{current_fps, MPEG_CLOCK_FREQ};
use lib_ccxr::common::AvcNalType;
use lib_ccxr::util::log::DebugMessageFlag;
use lib_ccxr::{debug, info};
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/avc/nal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::bindings::{cc_subtitle, encoder_ctx, lib_cc_decode};
use crate::libccxr_exports::time::{
ccxr_print_debug_timing, ccxr_print_mstime_static, ccxr_set_fts,
};
use crate::{anchor_hdcc, process_hdcc, store_hdcc};
use crate::sequencing::{anchor_hdcc, process_hdcc, store_hdcc};
use crate::{ccx_options, current_fps, total_frames_count, MPEG_CLOCK_FREQ};
use lib_ccxr::common::{AvcNalType, BitStreamRust, BitstreamError, FRAMERATES_VALUES, SLICE_TYPES};
use lib_ccxr::util::log::DebugMessageFlag;
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/es/gop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::libccxr_exports::time::{
ccxr_calculate_ms_gop_time, ccxr_get_fts_max, ccxr_gop_accepted, ccxr_print_debug_timing,
ccxr_set_current_pts, ccxr_set_fts,
};
use crate::process_hdcc;
use crate::sequencing::process_hdcc;
use crate::{
ccx_options, current_fps, first_gop_time, frames_since_ref_time, fts_at_gop_start, gop_time,
total_frames_count, MPEG_CLOCK_FREQ,
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/es/pic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::bindings::{cc_subtitle, encoder_ctx, lib_cc_decode};
use crate::libccxr_exports::time::{ccxr_get_fts, ccxr_print_debug_timing, ccxr_set_fts};
use crate::{anchor_hdcc, process_hdcc};
use crate::sequencing::{anchor_hdcc, process_hdcc};
use crate::{
ccx_options, current_fps, frames_since_ref_time, fts_at_gop_start, total_frames_count,
};
Expand Down
3 changes: 2 additions & 1 deletion src/rust/src/es/userdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
use crate::bindings::{cc_subtitle, encoder_ctx, lib_cc_decode};
use crate::current_fps;
use crate::es::core::dump;
use crate::{decode_vbi, do_cb, store_hdcc};
use crate::sequencing::store_hdcc;
use crate::{decode_vbi, do_cb};
use lib_ccxr::common::{BitStreamRust, BitstreamError};
use lib_ccxr::util::log::{DebugMessageFlag, ExitCause};
use lib_ccxr::{debug, fatal, info};
Expand Down
29 changes: 7 additions & 22 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub mod libccxr_exports;
#[cfg(feature = "enable_mp4_ffmpeg")]
pub mod mp4_ffmpeg_exports;
pub mod parser;
pub mod sequencing;
pub mod track_lister;
pub mod utils;

Expand Down Expand Up @@ -91,17 +92,6 @@ cfg_if! {

unsafe extern "C" fn version(_location: *const c_char) {}
unsafe extern "C" fn set_binary_mode() {}
fn process_hdcc(_enc_ctx: *mut encoder_ctx, _ctx: *mut lib_cc_decode, _sub: *mut cc_subtitle){}
fn store_hdcc(
_enc_ctx: *mut encoder_ctx,
_ctx: *mut lib_cc_decode,
_cc_data: *mut c_uchar,
_cc_count: c_int,
_sequence_number: c_int,
_current_fts_now: LLONG,
_sub: *mut cc_subtitle,
){}
fn anchor_hdcc(_ctx: *mut lib_cc_decode, _seq: c_int){}
fn do_cb(
_ctx: *mut lib_cc_decode,
_cc_block: *mut c_uchar,
Expand Down Expand Up @@ -163,17 +153,6 @@ extern "C" {

fn version(location: *const c_char);
fn set_binary_mode();
fn process_hdcc(enc_ctx: *mut encoder_ctx, ctx: *mut lib_cc_decode, sub: *mut cc_subtitle);
fn store_hdcc(
enc_ctx: *mut encoder_ctx,
ctx: *mut lib_cc_decode,
cc_data: *mut c_uchar,
cc_count: c_int,
sequence_number: c_int,
current_fts_now: LLONG,
sub: *mut cc_subtitle,
);
fn anchor_hdcc(ctx: *mut lib_cc_decode, seq: c_int);
fn do_cb(ctx: *mut lib_cc_decode, cc_block: *mut c_uchar, sub: *mut cc_subtitle) -> c_int;
fn decode_vbi(
dec_ctx: *mut lib_cc_decode,
Expand Down Expand Up @@ -933,6 +912,12 @@ mod test {

#[test]
fn test_do_cb() {
// `cb_708` is a process-wide static that other tests seed with 10 (see
// `set_test_cb_values`/`set_tmp_cb_values`). Set it explicitly so this
// test does not depend on test execution order.
unsafe {
cb_708 = 10;
}
let mut dtvcc_ctx = crate::decoder::test::initialize_dtvcc_ctx();
let mut dtvcc = Dtvcc::new(&mut dtvcc_ctx);
let mut decoder_ctx = lib_cc_decode::default();
Expand Down
Loading
Loading