Skip to content
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

[FEAT] add teletext and encoders_helpers module #1635

Merged
merged 29 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8014d8b
create lib_ccxr and libccxr_exports
elbertronnie Aug 27, 2023
4f0dc69
add bits and levenshtein module
elbertronnie Aug 27, 2023
8f348fe
add log module
elbertronnie Aug 27, 2023
676ef84
add encoding module
elbertronnie Aug 27, 2023
f4d4d7c
add common constants module
elbertronnie Aug 26, 2023
49cdd1f
add time units module
elbertronnie Aug 27, 2023
6db74b7
Merge branch 'add-log-module'
elbertronnie Aug 27, 2023
4e44c55
Merge branch 'add-constants-module'
elbertronnie Aug 27, 2023
8bf7180
Merge branch 'add-encoding-module'
elbertronnie Aug 27, 2023
e60b460
add options module
elbertronnie Aug 27, 2023
6d354ac
Merge branch 'add-bits-and-levenshtein-module'
elbertronnie Aug 27, 2023
f8eb1a7
add teletext module
elbertronnie Aug 27, 2023
0da3764
Merge remote-tracking branch 'elb/add-teletext-module' into rust-tele…
prateekmedia Aug 19, 2024
b2bada4
chore: remove outdated
prateekmedia Aug 19, 2024
201233e
chore: update lock files
prateekmedia Aug 19, 2024
23d4b4e
chore: fix naming
prateekmedia Aug 19, 2024
e89dd74
fix: reference to TeletextConfig
prateekmedia Aug 19, 2024
ba026e2
fix: issue with ts_forced_program default value
prateekmedia Aug 19, 2024
cb6bb54
fix: use correct definition
prateekmedia Aug 19, 2024
4ab9181
chore: lint warnings
prateekmedia Aug 19, 2024
e6ff963
fix: example code
prateekmedia Aug 19, 2024
ac832a6
fix(rust): adjust defaults, more accurate logging, use safe functions…
prateekmedia Aug 21, 2024
8e03558
fix: tests and formatting
prateekmedia Aug 21, 2024
316a7c9
fix: allow hex values for streamtype
prateekmedia Aug 21, 2024
f2e85b6
chore: format files
prateekmedia Aug 21, 2024
0d4f3cd
fix: naming of fields and docs
prateekmedia Aug 23, 2024
ca0b250
fix: defaults for options
prateekmedia Aug 23, 2024
8eceabb
fix: memory leak in vector to string
prateekmedia Aug 25, 2024
fba63f5
fix(c): init logger before running parser
prateekmedia Aug 25, 2024
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
8 changes: 7 additions & 1 deletion src/ccextractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ int api_start(struct ccx_s_options api_options)
if (!api_options.use_gop_as_pts) // If !0 then the user selected something
api_options.use_gop_as_pts = 1; // Force GOP timing for ES
ccx_common_timing_settings.is_elementary_stream = 1;
break;
case CCX_SM_TRANSPORT:
case CCX_SM_PROGRAM:
case CCX_SM_ASF:
Expand Down Expand Up @@ -425,6 +426,7 @@ int api_start(struct ccx_s_options api_options)
mprint("code in the MythTV's branch. Please report results to the address above. If\n");
mprint("something is broken it will be fixed. Thanks\n");
}

return ret ? EXIT_OK : EXIT_NO_CAPTIONS;
}

Expand All @@ -447,7 +449,11 @@ int main(int argc, char *argv[])
// See docs/ccextractor.cnf.sample for more info.

#ifndef DISABLE_RUST
int compile_ret = ccxr_parse_parameters(api_options, argc, argv);
ccxr_init_basic_logger();
#endif

#ifndef DISABLE_RUST
int compile_ret = ccxr_parse_parameters(argc, argv);
#else
int compile_ret = parse_parameters(api_options, argc, argv);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib_ccx/ccx_common_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void init_options(struct ccx_s_options *options)

options->extract = 1; // Extract 1st field only (primary language)
options->cc_channel = 1; // Channel we want to dump in srt mode
options->binary_concat = 1; // Disabled by -ve or --videoedited
options->binary_concat = 1; // Disabled by --videoedited
options->use_gop_as_pts = 0; // Use GOP instead of PTS timing (0=do as needed, 1=always, -1=never)
options->fix_padding = 0; // Replace 0000 with 8080 in HDTV (needed for some cards)
options->gui_mode_reports = 0; // If 1, output in stderr progress updates so the GUI can grab them
Expand Down
4 changes: 0 additions & 4 deletions src/lib_ccx/lib_ccx.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ struct lib_ccx_ctx *init_libraries(struct ccx_s_options *opt)
ccx_common_logging.log_ftn = &mprint;
ccx_common_logging.gui_ftn = &activity_library_process;

#ifndef DISABLE_RUST
ccxr_init_basic_logger(opt);
#endif

struct lib_ccx_ctx *ctx = malloc(sizeof(struct lib_ccx_ctx));
if (!ctx)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "init_libraries: Not enough memory allocating lib_ccx_ctx context.");
Expand Down
4 changes: 2 additions & 2 deletions src/lib_ccx/lib_ccx.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ struct lib_ccx_ctx *init_libraries(struct ccx_s_options *opt);
void dinit_libraries( struct lib_ccx_ctx **ctx);

#ifndef DISABLE_RUST
extern void ccxr_init_basic_logger(struct ccx_s_options *opts);
extern void ccxr_init_basic_logger();
#endif

//ccextractor.c
void print_end_msg(void);

//params.c
#ifndef DISABLE_RUST
extern int ccxr_parse_parameters(struct ccx_s_options *opt, int argc, char *argv[]);
extern int ccxr_parse_parameters(int argc, char *argv[]);
#endif
int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[]);
void print_usage (void);
Expand Down
13 changes: 8 additions & 5 deletions src/lib_ccx/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,11 @@ void print_usage(void)
mprint(" --tcp-description description: Sends to the server short description about\n");
mprint(" captions e.g. channel name or file name\n");
mprint("Options that affect what will be processed:\n");
mprint(" --output-field 1 / 2 / both: Output Field 1 data, Field 2 data, or both\n");
mprint(" (DEFAULT is 1)\n");
mprint(" --output-field 1 / 2 / both:\n");
mprint(" Values: 1 = Output Field 1\n");
mprint(" 2 = Output Field 2\n");
mprint(" both = Both Output Field 1 and 2\n");
mprint(" Defaults to 1\n");
mprint("Use --append to prevent overwriting of existing files. The output will be\n");
mprint(" appended instead.\n");
mprint(" --cc2: When in srt/sami mode, process captions in channel 2\n");
Expand Down Expand Up @@ -601,7 +604,7 @@ void print_usage(void)
mprint(" white). This causes all output in .srt/.smi/.vtt\n");
mprint(" files to have a font tag, which makes the files\n");
mprint(" larger. Add the color you want in RGB, such as\n");
mprint(" --dc #FF0000 for red.\n");
mprint(" --defaultcolor #FF0000 for red.\n");
mprint(" --sentencecap: Sentence capitalization. Use if you hate\n");
mprint(" ALL CAPS in subtitles.\n");
mprint(" --capfile file: Add the contents of 'file' to the list of words\n");
Expand Down Expand Up @@ -992,7 +995,7 @@ void print_usage(void)
mprint(" input.d/sub0001.png\n");
mprint(" ...\n");
mprint(" The command:\n");
mprint(" ccextractor --out=spupng -o /tmp/output --12 input.mpg\n");
mprint(" ccextractor --out=spupng -o /tmp/output --output-field both input.mpg\n");
mprint(" will create the files:\n");
mprint(" /tmp/output_1.xml\n");
mprint(" /tmp/output_1.d/sub0000.png\n");
Expand Down Expand Up @@ -2111,7 +2114,7 @@ int parse_parameters(struct ccx_s_options *opt, int argc, char *argv[])
opt->extract = strcmp(argv[i], "both") == 0 ? 12 : atoi_hex(argv[i]);
if (opt->extract != 1 && opt->extract != 2 && opt->extract != 12)
{
fatal(EXIT_MALFORMED_PARAMETER, "--output-field only accepts 1 or 2 or both.\n");
fatal(EXIT_MALFORMED_PARAMETER, "--output-field only accepts 1 , 2 , 12 / both.\n");
}
opt->is_608_enabled = 1;
continue;
Expand Down
11 changes: 8 additions & 3 deletions src/lib_ccx/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ int temp_debug = 0; // This is a convenience variable used to enable/disable deb
volatile sig_atomic_t change_filename_requested = 0;

#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);
extern int ccxr_levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsigned s2len);
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);
Expand Down Expand Up @@ -86,7 +89,8 @@ int verify_crc32(uint8_t *buf, int len)
{
#ifndef DISABLE_RUST
return ccxr_verify_crc32(buf, len);
#endif /* ifndef DISABLE_RUST */
#endif

int i = 0;
int32_t crc = -1;
for (i = 0; i < len; i++)
Expand All @@ -99,8 +103,8 @@ int stringztoms(const char *s, struct ccx_boundary_time *bt)
#ifndef DISABLE_RUST
return ccxr_stringztoms(s, bt);
#endif
unsigned ss = 0,
mm = 0, hh = 0;

unsigned ss = 0, mm = 0, hh = 0;
int value = -1;
int colons = 0;
const char *c = s;
Expand Down Expand Up @@ -176,6 +180,7 @@ int levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, uns
#ifndef DISABLE_RUST
return ccxr_levenshtein_dist(s1, s2, s1len, s2len);
#endif

unsigned int x, y, v, lastdiag, olddiag;
unsigned int *column = (unsigned *)malloc((s1len + 1) * sizeof(unsigned int));
for (y = 1; y <= s1len; y++)
Expand Down
Loading
Loading