Skip to content

Commit 90f9f0a

Browse files
[FEAT] add teletext and encoders_helpers module (#1635)
* create lib_ccxr and libccxr_exports * add bits and levenshtein module * add log module * add encoding module * add common constants module * add time units module * add options module * add teletext module * chore: remove outdated * chore: update lock files * chore: fix naming * fix: reference to TeletextConfig * fix: issue with ts_forced_program default value * fix: use correct definition * chore: lint warnings * fix: example code * fix(rust): adjust defaults, more accurate logging, use safe functions, add encoders_helper module * fix: tests and formatting * fix: allow hex values for streamtype * chore: format files * fix: naming of fields and docs * fix: defaults for options * fix: memory leak in vector to string * fix(c): init logger before running parser --------- Co-authored-by: Elbert Ronnie <elbert.ronniep@gmail.com>
1 parent 98a85e1 commit 90f9f0a

28 files changed

+2906
-656
lines changed

src/ccextractor.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ int api_start(struct ccx_s_options api_options)
187187
if (!api_options.use_gop_as_pts) // If !0 then the user selected something
188188
api_options.use_gop_as_pts = 1; // Force GOP timing for ES
189189
ccx_common_timing_settings.is_elementary_stream = 1;
190+
break;
190191
case CCX_SM_TRANSPORT:
191192
case CCX_SM_PROGRAM:
192193
case CCX_SM_ASF:
@@ -425,6 +426,7 @@ int api_start(struct ccx_s_options api_options)
425426
mprint("code in the MythTV's branch. Please report results to the address above. If\n");
426427
mprint("something is broken it will be fixed. Thanks\n");
427428
}
429+
428430
return ret ? EXIT_OK : EXIT_NO_CAPTIONS;
429431
}
430432

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

449451
#ifndef DISABLE_RUST
450-
int compile_ret = ccxr_parse_parameters(api_options, argc, argv);
452+
ccxr_init_basic_logger();
453+
#endif
454+
455+
#ifndef DISABLE_RUST
456+
int compile_ret = ccxr_parse_parameters(argc, argv);
451457
#else
452458
int compile_ret = parse_parameters(api_options, argc, argv);
453459
#endif

src/lib_ccx/ccx_common_option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void init_options(struct ccx_s_options *options)
2727

2828
options->extract = 1; // Extract 1st field only (primary language)
2929
options->cc_channel = 1; // Channel we want to dump in srt mode
30-
options->binary_concat = 1; // Disabled by -ve or --videoedited
30+
options->binary_concat = 1; // Disabled by --videoedited
3131
options->use_gop_as_pts = 0; // Use GOP instead of PTS timing (0=do as needed, 1=always, -1=never)
3232
options->fix_padding = 0; // Replace 0000 with 8080 in HDTV (needed for some cards)
3333
options->gui_mode_reports = 0; // If 1, output in stderr progress updates so the GUI can grab them

src/lib_ccx/lib_ccx.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ struct lib_ccx_ctx *init_libraries(struct ccx_s_options *opt)
102102
ccx_common_logging.log_ftn = &mprint;
103103
ccx_common_logging.gui_ftn = &activity_library_process;
104104

105-
#ifndef DISABLE_RUST
106-
ccxr_init_basic_logger(opt);
107-
#endif
108-
109105
struct lib_ccx_ctx *ctx = malloc(sizeof(struct lib_ccx_ctx));
110106
if (!ctx)
111107
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "init_libraries: Not enough memory allocating lib_ccx_ctx context.");

src/lib_ccx/lib_ccx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ struct lib_ccx_ctx *init_libraries(struct ccx_s_options *opt);
154154
void dinit_libraries( struct lib_ccx_ctx **ctx);
155155

156156
#ifndef DISABLE_RUST
157-
extern void ccxr_init_basic_logger(struct ccx_s_options *opts);
157+
extern void ccxr_init_basic_logger();
158158
#endif
159159

160160
//ccextractor.c
161161
void print_end_msg(void);
162162

163163
//params.c
164164
#ifndef DISABLE_RUST
165-
extern int ccxr_parse_parameters(struct ccx_s_options *opt, int argc, char *argv[]);
165+
extern int ccxr_parse_parameters(int argc, char *argv[]);
166166
#endif
167167
int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[]);
168168
void print_usage (void);

src/lib_ccx/params.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,11 @@ void print_usage(void)
395395
mprint(" --tcp-description description: Sends to the server short description about\n");
396396
mprint(" captions e.g. channel name or file name\n");
397397
mprint("Options that affect what will be processed:\n");
398-
mprint(" --output-field 1 / 2 / both: Output Field 1 data, Field 2 data, or both\n");
399-
mprint(" (DEFAULT is 1)\n");
398+
mprint(" --output-field 1 / 2 / both:\n");
399+
mprint(" Values: 1 = Output Field 1\n");
400+
mprint(" 2 = Output Field 2\n");
401+
mprint(" both = Both Output Field 1 and 2\n");
402+
mprint(" Defaults to 1\n");
400403
mprint("Use --append to prevent overwriting of existing files. The output will be\n");
401404
mprint(" appended instead.\n");
402405
mprint(" --cc2: When in srt/sami mode, process captions in channel 2\n");
@@ -601,7 +604,7 @@ void print_usage(void)
601604
mprint(" white). This causes all output in .srt/.smi/.vtt\n");
602605
mprint(" files to have a font tag, which makes the files\n");
603606
mprint(" larger. Add the color you want in RGB, such as\n");
604-
mprint(" --dc #FF0000 for red.\n");
607+
mprint(" --defaultcolor #FF0000 for red.\n");
605608
mprint(" --sentencecap: Sentence capitalization. Use if you hate\n");
606609
mprint(" ALL CAPS in subtitles.\n");
607610
mprint(" --capfile file: Add the contents of 'file' to the list of words\n");
@@ -992,7 +995,7 @@ void print_usage(void)
992995
mprint(" input.d/sub0001.png\n");
993996
mprint(" ...\n");
994997
mprint(" The command:\n");
995-
mprint(" ccextractor --out=spupng -o /tmp/output --12 input.mpg\n");
998+
mprint(" ccextractor --out=spupng -o /tmp/output --output-field both input.mpg\n");
996999
mprint(" will create the files:\n");
9971000
mprint(" /tmp/output_1.xml\n");
9981001
mprint(" /tmp/output_1.d/sub0000.png\n");
@@ -2111,7 +2114,7 @@ int parse_parameters(struct ccx_s_options *opt, int argc, char *argv[])
21112114
opt->extract = strcmp(argv[i], "both") == 0 ? 12 : atoi_hex(argv[i]);
21122115
if (opt->extract != 1 && opt->extract != 2 && opt->extract != 12)
21132116
{
2114-
fatal(EXIT_MALFORMED_PARAMETER, "--output-field only accepts 1 or 2 or both.\n");
2117+
fatal(EXIT_MALFORMED_PARAMETER, "--output-field only accepts 1 , 2 , 12 / both.\n");
21152118
}
21162119
opt->is_608_enabled = 1;
21172120
continue;

src/lib_ccx/utility.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ int temp_debug = 0; // This is a convenience variable used to enable/disable deb
1010
volatile sig_atomic_t change_filename_requested = 0;
1111

1212
#ifndef DISABLE_RUST
13+
extern int ccxr_verify_crc32(uint8_t *buf, int len);
14+
extern int ccxr_levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, unsigned s2len);
15+
extern int ccxr_levenshtein_dist_char(const char *s1, const char *s2, unsigned s1len, unsigned s2len);
1316
extern void ccxr_timestamp_to_srttime(uint64_t timestamp, char *buffer);
1417
extern void ccxr_timestamp_to_vtttime(uint64_t timestamp, char *buffer);
1518
extern void ccxr_millis_to_date(uint64_t timestamp, char *buffer, enum ccx_output_date_format date_format, char millis_separator);
@@ -86,7 +89,8 @@ int verify_crc32(uint8_t *buf, int len)
8689
{
8790
#ifndef DISABLE_RUST
8891
return ccxr_verify_crc32(buf, len);
89-
#endif /* ifndef DISABLE_RUST */
92+
#endif
93+
9094
int i = 0;
9195
int32_t crc = -1;
9296
for (i = 0; i < len; i++)
@@ -99,8 +103,8 @@ int stringztoms(const char *s, struct ccx_boundary_time *bt)
99103
#ifndef DISABLE_RUST
100104
return ccxr_stringztoms(s, bt);
101105
#endif
102-
unsigned ss = 0,
103-
mm = 0, hh = 0;
106+
107+
unsigned ss = 0, mm = 0, hh = 0;
104108
int value = -1;
105109
int colons = 0;
106110
const char *c = s;
@@ -176,6 +180,7 @@ int levenshtein_dist(const uint64_t *s1, const uint64_t *s2, unsigned s1len, uns
176180
#ifndef DISABLE_RUST
177181
return ccxr_levenshtein_dist(s1, s2, s1len, s2len);
178182
#endif
183+
179184
unsigned int x, y, v, lastdiag, olddiag;
180185
unsigned int *column = (unsigned *)malloc((s1len + 1) * sizeof(unsigned int));
181186
for (y = 1; y <= s1len; y++)

0 commit comments

Comments
 (0)