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
9 changes: 9 additions & 0 deletions src/lib_ccx/ccx_encoders_srt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
if there is any */
int write_stringz_as_srt(char *string, struct encoder_ctx *context, LLONG ms_start, LLONG ms_end)
{
#ifndef DISABLE_RUST
return ccxr_write_stringz_srt(context, string, ms_start, ms_end);
#endif
int used;
unsigned h1, m1, s1, ms1;
unsigned h2, m2, s2, ms2;
Expand Down Expand Up @@ -142,6 +145,9 @@ int write_cc_bitmap_as_srt(struct cc_subtitle *sub, struct encoder_ctx *context)

int write_cc_subtitle_as_srt(struct cc_subtitle *sub, struct encoder_ctx *context)
{
#ifndef DISABLE_RUST
return ccxr_write_cc_subtitle_as_srt(sub, context);
#endif
int ret = 0;
struct cc_subtitle *osub = sub;
struct cc_subtitle *lsub = sub;
Expand Down Expand Up @@ -170,6 +176,9 @@ int write_cc_subtitle_as_srt(struct cc_subtitle *sub, struct encoder_ctx *contex

int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *context)
{
#ifndef DISABLE_RUST
return ccxr_write_cc_buffer_as_srt(data, context);
#endif
int used;
unsigned h1, m1, s1, ms1;
unsigned h2, m2, s2, ms2;
Expand Down
31 changes: 20 additions & 11 deletions src/lib_ccx/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CC_UTILITY_H
#include <signal.h>
#ifndef _WIN32
#include <arpa/inet.h>
#include <arpa/inet.h>
#endif

#ifndef MIN
Expand All @@ -11,12 +11,12 @@

#define RL32(x) (*(unsigned int *)(x))
#define RB32(x) (ntohl(*(unsigned int *)(x)))
#define RL16(x) (*(unsigned short int*)(x))
#define RB16(x) (ntohs(*(unsigned short int*)(x)))
#define RL16(x) (*(unsigned short int *)(x))
#define RB16(x) (ntohs(*(unsigned short int *)(x)))

#define RB24(x) ( ((unsigned char*)(x))[0] << 16 | ((unsigned char*)(x))[1] << 8 | ((unsigned char*)(x))[2] )
#define RB24(x) (((unsigned char *)(x))[0] << 16 | ((unsigned char *)(x))[1] << 8 | ((unsigned char *)(x))[2])

#define CCX_NOPTS ((int64_t)UINT64_C(0x8000000000000000))
#define CCX_NOPTS ((int64_t)UINT64_C(0x8000000000000000))

struct ccx_rational
{
Expand All @@ -26,6 +26,12 @@ struct ccx_rational
extern int temp_debug;
volatile extern sig_atomic_t change_filename_requested;

//Forward declaration for the structs used in the Rust code
struct encoder_ctx;
struct cc_subtitle;
struct eia608_screen;


#ifndef DISABLE_RUST
extern int ccxr_verify_crc32(uint8_t *buf, int len);
extern int ccxr_levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len);
Expand All @@ -34,12 +40,15 @@ extern void ccxr_timestamp_to_srttime(uint64_t timestamp, char *buffer);
extern void ccxr_timestamp_to_vtttime(uint64_t timestamp, char *buffer);
extern void ccxr_millis_to_date(uint64_t timestamp, char *buffer, enum ccx_output_date_format date_format, char millis_separator);
extern int ccxr_stringztoms(const char *s, struct ccx_boundary_time *bt);
extern int ccxr_write_stringz_srt(struct encoder_ctx *context, const char *string, LLONG ms_start, LLONG ms_end);
extern int ccxr_write_cc_subtitle_as_srt(struct cc_subtitle *sub, struct encoder_ctx *context);
extern int ccxr_write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *context);
#endif

int levenshtein_dist_char (const char *s1, const char *s2, unsigned s1len, unsigned s2len);
void init_boundary_time (struct ccx_boundary_time *bt);
void print_error (int mode, const char *fmt, ...);
int stringztoms (const char *s, struct ccx_boundary_time *bt);
int levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsigned s2len);
void init_boundary_time(struct ccx_boundary_time *bt);
void print_error(int mode, const char *fmt, ...);
int stringztoms(const char *s, struct ccx_boundary_time *bt);
char *get_basename(char *filename);
const char *get_file_extension(const enum ccx_output_format write_format);
char *create_outfilename(const char *basename, const char *suffix, const char *extension);
Expand All @@ -48,7 +57,7 @@ size_t utf16_to_utf8(unsigned short utf16_char, unsigned char *out);
LLONG change_timebase(LLONG val, struct ccx_rational cur_tb, struct ccx_rational dest_tb);
char *str_reallocncat(char *dst, char *src);

void dump (LLONG mask, unsigned char *start, int l, unsigned long abs_start, unsigned clear_high_bit);
void dump(LLONG mask, unsigned char *start, int l, unsigned long abs_start, unsigned clear_high_bit);
LLONG change_timebase(LLONG val, struct ccx_rational cur_tb, struct ccx_rational dest_tb);
void timestamp_to_vtttime(uint64_t timestamp, char *buffer);
int vasprintf(char **strp, const char *fmt, va_list ap);
Expand All @@ -60,4 +69,4 @@ char *strtok_r(char *str, const char *delim, char **saveptr);

void write_wrapped(int fd, const char *buf, size_t count);

#endif //CC_UTILITY_H
#endif // CC_UTILITY_H
1 change: 1 addition & 0 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 24 additions & 7 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,48 @@ crate-type = ["staticlib"]
[dependencies]
log = "0.4.26"
env_logger = "0.8.4"
palette = "0.6.1"
rsmpeg = { version = "0.14.2", optional = true, features = [
"link_system_ffmpeg",
] }
palette = "0.7"
tesseract-sys = { version = "0.5.15", optional = true, default-features = false }
leptonica-sys = { version = "= 0.4.6", optional = true, default-features = false }
clap = { version = "4.5.31", features = ["derive"] }
strum = "0.25"
strum_macros = "0.25.3"
time = "0.3.39"
cfg-if = "1.0.0"
num-integer = "0.1.46"
lib_ccxr = { path = "lib_ccxr" }
url = "2.5.4"
encoding_rs = "0.8.5"
serial_test = "3.2.0"
encoding_rs = "0.8.35"
libc = "0.2"

# Use CCExtractor's forked rsmpeg with FFmpeg 7
# All platforms use ffmpeg7 feature with prebuilt bindings for API consistency
[target.'cfg(target_os = "linux")'.dependencies]
rsmpeg = { git = "https://github.com/CCExtractor/rsmpeg.git", default-features = false, features = ["ffmpeg7", "link_system_ffmpeg", "use_prebuilt_binding"], optional = true }

[target.'cfg(target_os = "windows")'.dependencies]
rsmpeg = { git = "https://github.com/CCExtractor/rsmpeg.git", default-features = false, features = ["ffmpeg7", "link_vcpkg_ffmpeg"], optional = true }

# macOS and other platforms use FFmpeg 7
[target.'cfg(not(any(target_os = "linux", target_os = "windows")))'.dependencies]
rsmpeg = { git = "https://github.com/CCExtractor/rsmpeg.git", default-features = false, features = ["ffmpeg7", "link_system_ffmpeg"], optional = true }

[build-dependencies]
bindgen = "0.64.0"
bindgen = "0.72.1"
pkg-config = "0.3.32"

[dev-dependencies]
tempfile = "3.20.0"


[features]
wtv_debug = []
enable_ffmpeg = []
with_libcurl = []

# hardsubx_ocr enables OCR and the platform-appropriate rsmpeg
hardsubx_ocr = ["rsmpeg", "tesseract-sys", "leptonica-sys"]
sanity_check = []

[profile.release-with-debug]
inherits = "release"
Expand Down
1 change: 1 addition & 0 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn main() {
"eia608_screen",
"uint8_t",
"word_list",
"ccx_s_write",
]);

#[cfg(feature = "hardsubx_ocr")]
Expand Down
Loading