From 0c0bf1aafd5c7e24ab62049210bc63b4bf2637ad Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Thu, 6 Jul 2017 13:37:20 -0700 Subject: [PATCH] -Added -nospupngocr (don't OCR bitmaps when generating spupng, faster) --- src/lib_ccx/ccx_common_option.c | 1 + src/lib_ccx/ccx_common_option.h | 1 + src/lib_ccx/ccx_encoders_common.c | 1 + src/lib_ccx/ccx_encoders_common.h | 3 +++ src/lib_ccx/params.c | 9 ++++++++- src/lib_ccx/spupng_encoder.c | 3 ++- 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib_ccx/ccx_common_option.c b/src/lib_ccx/ccx_common_option.c index 572796df..8cee006f 100644 --- a/src/lib_ccx/ccx_common_option.c +++ b/src/lib_ccx/ccx_common_option.c @@ -33,6 +33,7 @@ void init_options (struct ccx_s_options *options) options->no_progress_bar=0; // If 1, suppress the output of the progress to stdout options->enc_cfg.sentence_cap =0 ; // FIX CASE? = Fix case? options->enc_cfg.splitbysentence = 0; // Split text into complete sentences and prorate time? + options->enc_cfg.nospupngocr = 0; options->sentence_cap_file=NULL; // Extra words file? options->live_stream=0; // 0 -> A regular file options->messages_target=1; // 1=stdout diff --git a/src/lib_ccx/ccx_common_option.h b/src/lib_ccx/ccx_common_option.h index 6c697c67..2b9adb51 100644 --- a/src/lib_ccx/ccx_common_option.h +++ b/src/lib_ccx/ccx_common_option.h @@ -70,6 +70,7 @@ struct encoder_cfg LLONG subs_delay; // ms to delay (or advance) subs int program_number; unsigned char in_format; + int nospupngocr; // 1 if we don't want to OCR bitmaps to add the text as comments in the XML file in spupng //CEA-708 int services_enabled[CCX_DTVCC_MAX_SERVICES]; diff --git a/src/lib_ccx/ccx_encoders_common.c b/src/lib_ccx/ccx_encoders_common.c index 8e92218c..d6929fde 100644 --- a/src/lib_ccx/ccx_encoders_common.c +++ b/src/lib_ccx/ccx_encoders_common.c @@ -1039,6 +1039,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt) ctx->segment_pending = 0; ctx->segment_last_key_frame = 0; + ctx->nospupngocr = opt->nospupngocr; return ctx; } diff --git a/src/lib_ccx/ccx_encoders_common.h b/src/lib_ccx/ccx_encoders_common.h index b6f81282..384a7b67 100644 --- a/src/lib_ccx/ccx_encoders_common.h +++ b/src/lib_ccx/ccx_encoders_common.h @@ -128,6 +128,9 @@ struct encoder_ctx // Segmenting int segment_pending; int segment_last_key_frame; + + // OCR in SPUPNG + int nospupngocr; }; #define INITIAL_ENC_BUFFER_CAPACITY 2048 diff --git a/src/lib_ccx/params.c b/src/lib_ccx/params.c index c2915a15..c202b7e9 100644 --- a/src/lib_ccx/params.c +++ b/src/lib_ccx/params.c @@ -612,7 +612,8 @@ void print_usage (void) mprint (" ISO-639-2 form (like \"fre\" for french) or a language\n"); mprint (" code followed by a dash and a country code for specialities\n"); mprint (" in languages (like \"fre-ca\" for Canadian French).\n"); - + mprint (" -nospupngocr When processing DVB don't use the OCR to write the text as"); + mprint (" comments in the XML file.\n"); mprint ("\n"); mprint ("Options that affect how ccextractor reads and writes (buffering):\n"); @@ -1464,6 +1465,12 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[]) opt->ocrlang[char_index] = cctolower(opt->ocrlang[char_index]); continue; } + if (strcmp(argv[i], "-nospupngocr") == 0) + { + opt->enc_cfg.nospupngocr = 1; + continue; + } + if (strcmp(argv[i], "-oem") == 0) { diff --git a/src/lib_ccx/spupng_encoder.c b/src/lib_ccx/spupng_encoder.c index 7b537eca..788b0b58 100644 --- a/src/lib_ccx/spupng_encoder.c +++ b/src/lib_ccx/spupng_encoder.c @@ -565,7 +565,8 @@ int write_cc_bitmap_as_spupng(struct cc_subtitle *sub, struct encoder_ctx *conte /* TODO do rectangle wise, one color table should not be used for all rectangles */ mapclut_paletee(palette, alpha, (uint32_t *)rect[0].data[1],rect[0].nb_colors); -#ifdef ENABLE_OCR +#ifdef ENABLE_OCR + if (!context->nospupngocr) { char *str; str = paraof_ocrtext(sub, context->encoded_crlf, context->encoded_crlf_length);