@@ -38,7 +38,7 @@ void print_end_msg(void)
38
38
mprint ("https://github.com/CCExtractor/ccextractor/issues\n" );
39
39
}
40
40
41
- int api_start ( struct ccx_s_options api_options )
41
+ int start_ccx ( )
42
42
{
43
43
struct lib_ccx_ctx * ctx = NULL ; // Context for libs
44
44
struct lib_cc_decode * dec_ctx = NULL ; // Context for decoder
@@ -49,7 +49,7 @@ int api_start(struct ccx_s_options api_options)
49
49
setMsgSeverity (LEPT_MSG_SEVERITY );
50
50
#endif
51
51
// Initialize CCExtractor libraries
52
- ctx = init_libraries (& api_options );
52
+ ctx = init_libraries (& ccx_options );
53
53
54
54
if (!ctx )
55
55
{
@@ -66,10 +66,10 @@ int api_start(struct ccx_s_options api_options)
66
66
}
67
67
68
68
#ifdef ENABLE_HARDSUBX
69
- if (api_options .hardsubx )
69
+ if (ccx_options .hardsubx )
70
70
{
71
71
// Perform burned in subtitle extraction
72
- hardsubx (& api_options , ctx );
72
+ hardsubx (& ccx_options , ctx );
73
73
return 0 ;
74
74
}
75
75
#endif
@@ -97,19 +97,19 @@ int api_start(struct ccx_s_options api_options)
97
97
tlt_config .page = ((tlt_config .page / 100 ) << 8 ) | (((tlt_config .page / 10 ) % 10 ) << 4 ) | (tlt_config .page % 10 );
98
98
}
99
99
100
- if (api_options .transcript_settings .xds )
100
+ if (ccx_options .transcript_settings .xds )
101
101
{
102
- if (api_options .write_format != CCX_OF_TRANSCRIPT )
102
+ if (ccx_options .write_format != CCX_OF_TRANSCRIPT )
103
103
{
104
- api_options .transcript_settings .xds = 0 ;
104
+ ccx_options .transcript_settings .xds = 0 ;
105
105
mprint ("Warning: -xds ignored, XDS can only be exported to transcripts at this time.\n" );
106
106
}
107
107
}
108
108
109
109
time_t start , final ;
110
110
time (& start );
111
111
112
- if (api_options .binary_concat )
112
+ if (ccx_options .binary_concat )
113
113
{
114
114
ctx -> total_inputsize = get_total_file_size (ctx );
115
115
if (ctx -> total_inputsize < 0 )
@@ -139,24 +139,24 @@ int api_start(struct ccx_s_options api_options)
139
139
terminate_asap = 0 ;
140
140
141
141
#ifdef ENABLE_SHARING
142
- if (api_options .translate_enabled && ctx -> num_input_files > 1 )
142
+ if (ccx_options .translate_enabled && ctx -> num_input_files > 1 )
143
143
{
144
144
mprint ("[share] WARNING: simultaneous translation of several input files is not supported yet\n" );
145
- api_options .translate_enabled = 0 ;
146
- api_options .sharing_enabled = 0 ;
145
+ ccx_options .translate_enabled = 0 ;
146
+ ccx_options .sharing_enabled = 0 ;
147
147
}
148
- if (api_options .translate_enabled )
148
+ if (ccx_options .translate_enabled )
149
149
{
150
150
mprint ("[share] launching translate service\n" );
151
- ccx_share_launch_translator (api_options .translate_langs , api_options .translate_key );
151
+ ccx_share_launch_translator (ccx_options .translate_langs , ccx_options .translate_key );
152
152
}
153
153
#endif // ENABLE_SHARING
154
154
ret = 0 ;
155
155
while (switch_to_next_file (ctx , 0 ))
156
156
{
157
157
prepare_for_new_file (ctx );
158
158
#ifdef ENABLE_SHARING
159
- if (api_options .sharing_enabled )
159
+ if (ccx_options .sharing_enabled )
160
160
ccx_share_start (ctx -> basefilename );
161
161
#endif // ENABLE_SHARING
162
162
@@ -185,8 +185,8 @@ int api_start(struct ccx_s_options api_options)
185
185
{
186
186
// Note: This case is meant to fall through
187
187
case CCX_SM_ELEMENTARY_OR_NOT_FOUND :
188
- if (!api_options .use_gop_as_pts ) // If !0 then the user selected something
189
- api_options .use_gop_as_pts = 1 ; // Force GOP timing for ES
188
+ if (!ccx_options .use_gop_as_pts ) // If !0 then the user selected something
189
+ ccx_options .use_gop_as_pts = 1 ; // Force GOP timing for ES
190
190
ccx_common_timing_settings .is_elementary_stream = 1 ;
191
191
case CCX_SM_TRANSPORT :
192
192
case CCX_SM_PROGRAM :
@@ -197,9 +197,9 @@ int api_start(struct ccx_s_options api_options)
197
197
#ifdef ENABLE_FFMPEG
198
198
case CCX_SM_FFMPEG :
199
199
#endif
200
- if (!api_options .use_gop_as_pts ) // If !0 then the user selected something
201
- api_options .use_gop_as_pts = 0 ;
202
- if (api_options .ignore_pts_jumps )
200
+ if (!ccx_options .use_gop_as_pts ) // If !0 then the user selected something
201
+ ccx_options .use_gop_as_pts = 0 ;
202
+ if (ccx_options .ignore_pts_jumps )
203
203
ccx_common_timing_settings .disable_sync_check = 1 ;
204
204
mprint ("\rAnalyzing data in general mode\n" );
205
205
tmp = general_loop (ctx );
@@ -232,15 +232,15 @@ int api_start(struct ccx_s_options api_options)
232
232
{
233
233
fatal (EXIT_INCOMPATIBLE_PARAMETERS , "MP4 requires an actual file, it's not possible to read from a stream, including stdin.\n" );
234
234
}
235
- if (api_options .extract_chapters )
235
+ if (ccx_options .extract_chapters )
236
236
{
237
237
tmp = dumpchapters (ctx , & ctx -> mp4_cfg , ctx -> inputfile [ctx -> current_file ]);
238
238
}
239
239
else
240
240
{
241
241
tmp = processmp4 (ctx , & ctx -> mp4_cfg , ctx -> inputfile [ctx -> current_file ]);
242
242
}
243
- if (api_options .print_file_reports )
243
+ if (ccx_options .print_file_reports )
244
244
print_file_report (ctx );
245
245
if (!ret )
246
246
ret = tmp ;
@@ -311,7 +311,7 @@ int api_start(struct ccx_s_options api_options)
311
311
dec_ctx -> timing -> fts_max = 0 ;
312
312
313
313
#ifdef ENABLE_SHARING
314
- if (api_options .sharing_enabled )
314
+ if (ccx_options .sharing_enabled )
315
315
{
316
316
ccx_share_stream_done (ctx -> basefilename );
317
317
ccx_share_stop ();
@@ -430,23 +430,18 @@ int api_start(struct ccx_s_options api_options)
430
430
return ret ? EXIT_OK : EXIT_NO_CAPTIONS ;
431
431
}
432
432
433
- struct ccx_s_options * api_init_options ()
434
- {
435
- init_options (& ccx_options );
436
- return & ccx_options ;
437
- }
438
-
439
433
int main (int argc , char * argv [])
440
434
{
441
435
setlocale (LC_ALL , "" ); // Supports non-English CCs
442
436
// Use POSIX locale for numbers so we get "." as decimal separator and no
443
437
// thousands' groupoing instead of what the locale might say
444
438
setlocale (LC_NUMERIC , "POSIX" );
445
439
446
- struct ccx_s_options * api_options = api_init_options ( );
447
- parse_configuration ( api_options );
440
+ init_options ( & ccx_options );
441
+
448
442
// If "ccextractor.cnf" is present, takes options from it.
449
443
// See docs/ccextractor.cnf.sample for more info.
444
+ parse_configuration (& ccx_options );
450
445
451
446
#ifndef DISABLE_RUST
452
447
ccxr_init_basic_logger ();
@@ -455,7 +450,7 @@ int main(int argc, char *argv[])
455
450
#ifndef DISABLE_RUST
456
451
int compile_ret = ccxr_parse_parameters (argc , argv );
457
452
#else
458
- int compile_ret = parse_parameters (api_options , argc , argv );
453
+ int compile_ret = parse_parameters (& ccx_options , argc , argv );
459
454
#endif
460
455
461
456
if (compile_ret == EXIT_NO_INPUT_FILES )
@@ -472,6 +467,6 @@ int main(int argc, char *argv[])
472
467
exit (compile_ret );
473
468
}
474
469
475
- int start_ret = api_start ( * api_options );
470
+ int start_ret = start_ccx ( );
476
471
return start_ret ;
477
472
}
0 commit comments