Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekmedia committed Sep 2, 2024
2 parents bc8c86f + 1a13bbb commit d5d703c
Show file tree
Hide file tree
Showing 34 changed files with 2,967 additions and 676 deletions.
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
7 changes: 0 additions & 7 deletions src/lib_ccx/ccx_encoders_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
// userdefined rgb color
unsigned char usercolor_rgb[8] = "";

struct word_list
{
char **words;
size_t len;
size_t capacity;
};

struct word_list capitalization_list = {
.words = NULL,
.len = 0,
Expand Down
10 changes: 7 additions & 3 deletions src/lib_ccx/ccx_encoders_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "ccx_decoders_structs.h"
#include "ccx_decoders_608.h"
#include "ccx_encoders_common.h"
#include <png.h>

extern struct word_list capitalization_list;
extern struct word_list profane;
Expand All @@ -15,6 +14,13 @@ extern const char *profane_builtin[];

extern unsigned char usercolor_rgb[8];

struct word_list
{
char **words;
size_t len;
size_t capacity;
};

struct ccx_encoders_helpers_settings_t
{
int trim_subs;
Expand Down Expand Up @@ -43,6 +49,4 @@ void shell_sort(void *base, int nb, size_t size, int (*compar)(const void *p1, c

void ccx_encoders_helpers_perform_shellsort_words(void);
void ccx_encoders_helpers_setup(enum ccx_encoding_type encoding, int no_font_color, int no_type_setting, int trim_subs);

int mapclut_paletee(png_color *palette, png_byte *alpha, uint32_t *clut, uint8_t depth);
#endif
2 changes: 1 addition & 1 deletion src/lib_ccx/ccx_encoders_spupng.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ccfont2.xbm" // CC font from libzvbi
#include "ccx_common_common.h"
#include "ccx_encoders_common.h"
#include "ccx_encoders_spupng.h"
#include <png.h>
#include <ft2build.h>
#include <math.h>
Expand Down
4 changes: 4 additions & 0 deletions src/lib_ccx/ccx_encoders_spupng.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <png.h>
#include "ccx_encoders_common.h"

int mapclut_paletee(png_color *palette, png_byte *alpha, uint32_t *clut, uint8_t depth);
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 @@ -1009,7 +1012,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 @@ -2149,7 +2152,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

0 comments on commit d5d703c

Please sign in to comment.