diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index 53c357e40..9baac9653 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -1,9 +1,22 @@ 0.89 (TBD) +----------------- - New: Added support to output captions to MCC file (#733). +- New: Added a few comments. +- New: Added more fatals on no arguments errors. +- New: Updated ccextractor.cnf.sample. - Fix: ccx_demuxer_mxf.c: Parse framerate from MXF captions to fix caption timings. - Fix: hardsubx_decoder.c: Fix memory leaks using Leptonica API. - Fix: linux/Makefile.am: added some sources to enable rpms to be created. - Fix: Crash when using -sc (sentence case) option (#1115) +- Fix: Correct if-clauses (missing or misplaced brackets). +- Fix: Comment out some unused code. +- Fix: Resolve bunch of compilation's warnings. +- Fix: Segmentation fault on VOB #1128 +- Fix: Hang while processing video #1121 +- Fix: Removed redundant check_configuration_file function +- Fix: lib_ccx.c: Initialize fatal error logging function before first usage in init_libraries +- Fix: Added italics, underline, and color rendering support for -out=spupng with EIA608/teletext +- Fix: Change inet_ntop to inet_ntoa for Windows XP compatibility 0.88 (2019-05-21) ----------------- diff --git a/docs/COMPILATION.MD b/docs/COMPILATION.MD index a5c87f455..0350f83db 100644 --- a/docs/COMPILATION.MD +++ b/docs/COMPILATION.MD @@ -32,7 +32,7 @@ yum install -y glew-devel glfw-devel cmake gcc libcurl-devel tesseract-devel lep 2. Compiling -**Using the build script** +### Using the build script ```bash @@ -45,7 +45,7 @@ cd ccextractor/linux ./ccextractor ``` -**Standard linux compilation through Autoconf scripts** +### Standard linux compilation through Autoconf scripts ```bash sudo apt-get install autoconf #Dependency to generate configuration script @@ -61,7 +61,7 @@ make sudo make install ``` -**Using CMake** +### Using CMake ```bash #Create and navigate to directory where you want to store built files @@ -82,8 +82,9 @@ make sudo make install ``` +`cmake` also accepts the argument `-DWITH_OCR=ON` to enable OCR. -**Compiling with GUI:** +### Compiling with GUI: To build CCExtractor with a gui you will additionally need to install [GLEW](http://glew.sourceforge.net/build.html) and [GLFW](http://www.glfw.org/docs/latest/compile.html) @@ -118,9 +119,9 @@ pkg-config --exists --print-errors tesseract pkg-config --exists --print-errors lept ``` -2. Compiling +### Compiling -**Using build.command script:** +#### Using build.command script: ```bash cd ccextractor/mac @@ -140,7 +141,7 @@ cd ccextractor/mac ./ccextractor ``` -**Using CMake** +#### Using CMake ```bash #Create and navigate to directory where you want to store built files @@ -158,7 +159,7 @@ make ./ccextractor ``` -**Standard compilation through Autoconf scripts :** +#### Standard compilation through Autoconf scripts: ```bash cd ccextractor/mac @@ -170,7 +171,7 @@ make ./ccextractor ``` -**Compiling with GUI:** +#### Compiling with GUI: To use CCExtractor with a gui you will additionally need to install GLEW and GLFW. You can do that by installing it via homebrew using: @@ -219,7 +220,7 @@ Configurations options are: `(Debug|Release)-Full` Configurations options include dependent libraries which are used for OCR. -**Using CMake** +### Using CMake You may also generate `.sln` files for Visual Studio and build using build tools, or open `.sln` files using Visual Studio. diff --git a/docs/ccextractor.cnf.sample b/docs/ccextractor.cnf.sample index f08b6c3a0..0f38026fd 100644 --- a/docs/ccextractor.cnf.sample +++ b/docs/ccextractor.cnf.sample @@ -1,5 +1,5 @@ ####################################################### -# Version 0.01 +# Version 0.02 # # To enable required option please uncomment option # @@ -12,12 +12,15 @@ # 0 = file # 1 = stdin # 2 = network +# 3 = tcp INPUT_SOURCE=0 # The Buffer Input tag # This tag takes number in its input. +# Is it ccx_bufferdata_type ? + #BUFFER_INPUT=0 # The Direct Rollup tag @@ -45,22 +48,28 @@ INPUT_SOURCE=0 #NOTYPE_SETTING= # The Codec Tag takes the preference of codec -# tag CCX_CODEC_ANY is by default +# tag CCX_CODEC_ANY by default # This tag takes number in its input and their meanings # are following -# 0 = CCX_CODEC_ANY +# 0 = CCX_CODEC_ANY (default) # 1 = CCX_CODEC_TELETEXT # 2 = CCX_CODEC_DVB +# 3 = CCX_CODEC_ISDB_CC +# 4 = CCX_CODEC_ATSC_CC +# 5 = CCX_CODEC_NONE #CODEC= -# The NO Codec Tag do not use codec specified -# tag CCX_CODEC_NONE is by default +# The NO Codec Tag uses codec specified +# tag CCX_CODEC_NONE by default # This tag takes number in its input and their meanings # are following +# 0 = CCX_CODEC_ANY # 1 = CCX_CODEC_TELETEXT # 2 = CCX_CODEC_DVB -# 3 = CCX_CODEC_NONE +# 3 = CCX_CODEC_ISDB_CC +# 4 = CCX_CODEC_ATSC_CC +# 5 = CCX_CODEC_NONE (default) #NOCODEC= @@ -68,15 +77,21 @@ INPUT_SOURCE=0 # by default output format is srt # This tag takes number in its input and their meanings # are following -# 0 = CCX_OF_RAW -# 1 = CCX_OF_SRT (default) -# 2 = CCX_OF_SAMI -# 3 = CCX_OF_TRANSCRIPT -# 4 = CCX_OF_RCWT -# 5 = CCX_OF_NULL -# 6 = CCX_OF_SMPTETT -# 7 = CCX_OF_SPUPNG -# 8 = CCX_OF_DVDRAW +# 0 = CCX_OF_RAW +# 1 = CCX_OF_SRT (default) +# 2 = CCX_OF_SAMI +# 3 = CCX_OF_TRANSCRIPT +# 4 = CCX_OF_RCWT +# 5 = CCX_OF_NULL +# 6 = CCX_OF_SMPTETT +# 7 = CCX_OF_SPUPNG +# 8 = CCX_OF_DVDRAW +# 9 = CCX_OF_WEBVTT +# 10 = CCX_OF_SIMPLE_XML +# 11 = CCX_OF_G608 +# 12 = CCX_OF_CURL +# 13 = CCX_OF_SSA +# 14 = CCX_OF_MCC #OUTPUT_FORMAT= diff --git a/linux/autogen.sh b/linux/autogen.sh index f7fc0e5f6..e406d7234 100755 --- a/linux/autogen.sh +++ b/linux/autogen.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ./pre-build.sh autoreconf -i diff --git a/linux/build b/linux/build index c5c8b2efc..b26ece15f 100755 --- a/linux/build +++ b/linux/build @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash BLD_FLAGS="-std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP" bit_os=$(getconf LONG_BIT) if [ "$bit_os"=="64" ] diff --git a/linux/build-static.sh b/linux/build-static.sh index 93f697ad7..3fc95b5b6 100755 --- a/linux/build-static.sh +++ b/linux/build-static.sh @@ -1,4 +1,4 @@ -#!/bin/sh -ex +#!/usr/bin/env sh -ex #################################################################### # setup by tracey apr 2012 diff --git a/linux/build_hardsubx b/linux/build_hardsubx index e9cc9ad04..b4897b042 100755 --- a/linux/build_hardsubx +++ b/linux/build_hardsubx @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash BLD_FLAGS="-g -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DENABLE_HARDSUBX -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP" bit_os=$(getconf LONG_BIT) if [ "$bit_os"=="64" ] diff --git a/linux/builddebug b/linux/builddebug index 758c2d79e..3b2dac912 100755 --- a/linux/builddebug +++ b/linux/builddebug @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash BLD_FLAGS="-g -std=gnu99 -Wno-write-strings -DGPAC_CONFIG_LINUX -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP" bit_os=$(getconf LONG_BIT) if [ "$bit_os"=="64" ] diff --git a/linux/cleanup b/linux/cleanup index ac74401af..01a688c7e 100755 --- a/linux/cleanup +++ b/linux/cleanup @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash make distclean > /dev/null 2>&1 || true rm -rf Makefile configure *.in config.status config.log aclocal.m4 build-conf autom4te.cache diff --git a/linux/module_generator b/linux/module_generator index f8c82cb9e..039efe55b 100755 --- a/linux/module_generator +++ b/linux/module_generator @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash SRC_LIBPNG="$(find ../src/libpng/ -name '*.c')" SRC_ZLIB="$(find ../src/zlib/ -name '*.c')" SRC_ZVBI="$(find ../src/zvbi/ -name '*.c')" diff --git a/linux/pre-build.sh b/linux/pre-build.sh index dbacbbf15..19a3dd365 100755 --- a/linux/pre-build.sh +++ b/linux/pre-build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo "Obtaining Git commit" commit=(`git rev-parse HEAD 2>/dev/null`) if [ -z "$commit" ]; then diff --git a/src/ccextractor.c b/src/ccextractor.c index 457249b28..f7f459df3 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -41,10 +41,10 @@ void print_end_msg(void) int api_start(struct ccx_s_options api_options) { - struct lib_ccx_ctx *ctx; - struct lib_cc_decode *dec_ctx = NULL; - int ret = 0, tmp; - enum ccx_stream_mode_enum stream_mode; + struct lib_ccx_ctx *ctx = NULL; // Context for libs + struct lib_cc_decode *dec_ctx = NULL; // Context for decoder + int ret = 0, tmp = 0; + enum ccx_stream_mode_enum stream_mode = CCX_SM_ELEMENTARY_OR_NOT_FOUND; #if defined(ENABLE_OCR) && defined(_WIN32) setMsgSeverity(LEPT_MSG_SEVERITY); @@ -69,16 +69,20 @@ int api_start(struct ccx_s_options api_options) i++; } #endif - if (!ctx && errno == ENOMEM) - fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory, could not initialize libraries\n"); - else if (!ctx && errno == EINVAL) - fatal (CCX_COMMON_EXIT_BUG_BUG, "Invalid option to CCextractor Library\n"); - else if (!ctx && errno == EPERM) - fatal (CCX_COMMON_EXIT_FILE_CREATION_FAILED, "Unable to create output file: Operation not permitted.\n"); - else if (!ctx && errno == EACCES) - fatal (CCX_COMMON_EXIT_FILE_CREATION_FAILED, "Unable to create output file: Permission denied\n"); - else if (!ctx) - fatal (EXIT_NOT_CLASSIFIED, "Unable to create Library Context %d\n",errno); + + if (!ctx) + { + if (errno == ENOMEM) + fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory, could not initialize libraries\n"); + else if (errno == EINVAL) + fatal(CCX_COMMON_EXIT_BUG_BUG, "Invalid option to CCextractor Library\n"); + else if (errno == EPERM) + fatal(CCX_COMMON_EXIT_FILE_CREATION_FAILED, "Unable to create output file: Operation not permitted.\n"); + else if (errno == EACCES) + fatal(CCX_COMMON_EXIT_FILE_CREATION_FAILED, "Unable to create output file: Permission denied\n"); + else + fatal(EXIT_NOT_CLASSIFIED, "Unable to create Library Context %d\n", errno); + } #ifdef WITH_LIBCURL curl_global_init(CURL_GLOBAL_ALL); @@ -88,7 +92,7 @@ int api_start(struct ccx_s_options api_options) if (!curl) { curl_global_cleanup(); // Must be done even on init fail - fatal (EXIT_NOT_CLASSIFIED, "Unable to init curl."); + fatal(EXIT_NOT_CLASSIFIED, "Unable to init curl."); } #endif @@ -107,7 +111,7 @@ int api_start(struct ccx_s_options api_options) if (api_options.write_format != CCX_OF_TRANSCRIPT) { api_options.transcript_settings.xds = 0; - mprint ("Warning: -xds ignored, XDS can only be exported to transcripts at this time.\n"); + mprint("Warning: -xds ignored, XDS can only be exported to transcripts at this time.\n"); } } @@ -117,7 +121,7 @@ int api_start(struct ccx_s_options api_options) if (api_options.binary_concat) { - ctx->total_inputsize=get_total_file_size(ctx); + ctx->total_inputsize = get_total_file_size(ctx); if (ctx->total_inputsize < 0) { switch (ctx->total_inputsize) @@ -177,7 +181,7 @@ int api_start(struct ccx_s_options api_options) case CCX_SM_RCWT: case CCX_SM_MP4: #ifdef WTV_DEBUG - case CCX_SM_HEX_DUMP: + case CCX_SM_HEX_DUMP: #endif ccx_common_timing_settings.disable_sync_check = 1; break; @@ -200,38 +204,38 @@ int api_start(struct ccx_s_options api_options) case CCX_SM_GXF: case CCX_SM_MXF: #ifdef ENABLE_FFMPEG - case CCX_SM_FFMPEG: + case CCX_SM_FFMPEG: #endif if (!api_options.use_gop_as_pts) // If !0 then the user selected something api_options.use_gop_as_pts = 0; if (api_options.ignore_pts_jumps) ccx_common_timing_settings.disable_sync_check = 1; - mprint ("\rAnalyzing data in general mode\n"); + mprint("\rAnalyzing data in general mode\n"); tmp = general_loop(ctx); if (!ret) ret = tmp; break; case CCX_SM_MCPOODLESRAW: - mprint ("\rAnalyzing data in McPoodle raw mode\n"); + mprint("\rAnalyzing data in McPoodle raw mode\n"); tmp = raw_loop(ctx); if (!ret) ret = tmp; break; case CCX_SM_RCWT: - mprint ("\rAnalyzing data in CCExtractor's binary format\n"); + mprint("\rAnalyzing data in CCExtractor's binary format\n"); tmp = rcwt_loop(ctx); if (!ret) ret = tmp; break; case CCX_SM_MYTH: - mprint ("\rAnalyzing data in MythTV mode\n"); + mprint("\rAnalyzing data in MythTV mode\n"); show_myth_banner = 1; tmp = myth_loop(ctx); if (!ret) ret = tmp; break; case CCX_SM_MP4: - mprint ("\rAnalyzing data with GPAC (MP4 library)\n"); + mprint("\rAnalyzing data with GPAC (MP4 library)\n"); close_input_file(ctx); // No need to have it open. GPAC will do it for us if (ctx->current_file == -1) // We don't have a file to open, must be stdin, and GPAC is incompatible with stdin { - fatal (EXIT_INCOMPATIBLE_PARAMETERS, "MP4 requires an actual file, it's not possible to read from a stream, including stdin.\n"); + fatal(EXIT_INCOMPATIBLE_PARAMETERS, "MP4 requires an actual file, it's not possible to read from a stream, including stdin.\n"); } if(api_options.extract_chapters) { @@ -246,7 +250,7 @@ int api_start(struct ccx_s_options api_options) if (!ret) ret = tmp; break; case CCX_SM_MKV: - mprint ("\rAnalyzing data in Matroska mode\n"); + mprint("\rAnalyzing data in Matroska mode\n"); tmp = matroska_loop(ctx); if (!ret) ret = tmp; break; @@ -278,17 +282,17 @@ int api_start(struct ccx_s_options api_options) if (dec_ctx->codec == CCX_CODEC_ATSC_CC) { - mprint ("\nTotal frames time: %s (%u frames at %.2ffps)\n", + mprint("\nTotal frames time: %s (%u frames at %.2ffps)\n", print_mstime_static( (LLONG)(total_frames_count*1000/current_fps) ), total_frames_count, current_fps); } if (dec_ctx->stat_hdtv) { - mprint ("\rCC type 0: %d (%s)\n", dec_ctx->cc_stats[0], cc_types[0]); - mprint ("CC type 1: %d (%s)\n", dec_ctx->cc_stats[1], cc_types[1]); - mprint ("CC type 2: %d (%s)\n", dec_ctx->cc_stats[2], cc_types[2]); - mprint ("CC type 3: %d (%s)\n", dec_ctx->cc_stats[3], cc_types[3]); + mprint("\rCC type 0: %d (%s)\n", dec_ctx->cc_stats[0], cc_types[0]); + mprint("CC type 1: %d (%s)\n", dec_ctx->cc_stats[1], cc_types[1]); + mprint("CC type 2: %d (%s)\n", dec_ctx->cc_stats[2], cc_types[2]); + mprint("CC type 3: %d (%s)\n", dec_ctx->cc_stats[3], cc_types[3]); } // Add one frame as fts_max marks the beginning of the last frame, // but we need the end. @@ -297,9 +301,9 @@ int api_start(struct ccx_s_options api_options) // timing (cb_fields having a huge number and fts_now and fts_global being 0 all // the time), so we need to take that into account in fts_global before resetting // counters. - if (cb_field1!=0) + if (cb_field1 != 0) dec_ctx->timing->fts_global += cb_field1*1001/3; - else if (cb_field2!=0) + else if (cb_field2 != 0) dec_ctx->timing->fts_global += cb_field2*1001/3; else dec_ctx->timing->fts_global += cb_708*1001/3; @@ -318,21 +322,21 @@ int api_start(struct ccx_s_options api_options) #endif //ENABLE_SHARING if (dec_ctx->total_pulldownframes) - mprint ("incl. pulldown frames: %s (%u frames at %.2ffps)\n", + mprint("incl. pulldown frames: %s (%u frames at %.2ffps)\n", print_mstime_static( (LLONG)(dec_ctx->total_pulldownframes*1000/current_fps) ), dec_ctx->total_pulldownframes, current_fps); if (dec_ctx->timing->pts_set >= 1 && dec_ctx->timing->min_pts != 0x01FFFFFFFFLL) { LLONG postsyncms = (LLONG) (dec_ctx->frames_since_last_gop*1000/current_fps); - mprint ("\nMin PTS: %s\n", - print_mstime_static( dec_ctx->timing->min_pts/(MPEG_CLOCK_FREQ/1000) - dec_ctx->timing->fts_offset)); + mprint("\nMin PTS: %s\n", + print_mstime_static(dec_ctx->timing->min_pts/(MPEG_CLOCK_FREQ/1000) - dec_ctx->timing->fts_offset)); if (pts_big_change) - mprint ("(Reference clock was reset at some point, Min PTS is approximated)\n"); - mprint ("Max PTS: %s\n", - print_mstime_static( dec_ctx->timing->sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms)); + mprint("(Reference clock was reset at some point, Min PTS is approximated)\n"); + mprint("Max PTS: %s\n", + print_mstime_static(dec_ctx->timing->sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms)); - mprint ("Length: %s\n", - print_mstime_static( dec_ctx->timing->sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms + mprint("Length: %s\n", + print_mstime_static(dec_ctx->timing->sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms - dec_ctx->timing->min_pts/(MPEG_CLOCK_FREQ/1000) + dec_ctx->timing->fts_offset )); } @@ -340,21 +344,21 @@ int api_start(struct ccx_s_options api_options) // dvr-ms files have invalid GOPs if (gop_time.inited && first_gop_time.inited && stream_mode != CCX_SM_ASF) { - mprint ("\nInitial GOP time: %s\n", + mprint("\nInitial GOP time: %s\n", print_mstime_static(first_gop_time.ms)); - mprint ("Final GOP time: %s%+3dF\n", + mprint("Final GOP time: %s%+3dF\n", print_mstime_static(gop_time.ms), dec_ctx->frames_since_last_gop); - mprint ("Diff. GOP length: %s%+3dF", + mprint("Diff. GOP length: %s%+3dF", print_mstime_static(gop_time.ms - first_gop_time.ms), dec_ctx->frames_since_last_gop); - mprint (" (%s)\n\n", + mprint(" (%s)\n\n", print_mstime_static(gop_time.ms - first_gop_time.ms +(LLONG) ((dec_ctx->frames_since_last_gop)*1000/29.97)) ); } if (dec_ctx->false_pict_header) - mprint ("Number of likely false picture headers (discarded): %d\n",dec_ctx->false_pict_header); + mprint ("Number of likely false picture headers (discarded): %d\n", dec_ctx->false_pict_header); if (dec_ctx->num_key_frames) mprint("Number of key frames: %d\n", dec_ctx->num_key_frames); @@ -387,15 +391,15 @@ int api_start(struct ccx_s_options api_options) break; } // file loop close_input_file(ctx); - free((void *) ctx->extension); + free((void *)ctx->extension); - prepare_for_new_file (ctx); // To reset counters used by handle_end_of_data() + prepare_for_new_file(ctx); // To reset counters used by handle_end_of_data() - time (&final); + time(&final); long proc_time=(long) (final-start); - mprint ("\rDone, processing time = %ld seconds\n", proc_time); + mprint("\rDone, processing time = %ld seconds\n", proc_time); #if 0 if (proc_time>0) { @@ -409,8 +413,8 @@ int api_start(struct ccx_s_options api_options) if (is_decoder_processed_enough(ctx) == CCX_TRUE) { - mprint ("\rNote: Processing was canceled before all data was processed because\n"); - mprint ("\rone or more user-defined limits were reached.\n"); + mprint("\rNote: Processing was canceled before all data was processed because\n"); + mprint("\rone or more user-defined limits were reached.\n"); } #ifdef CURL @@ -440,11 +444,6 @@ struct ccx_s_options* api_init_options() return &ccx_options; } -void check_configuration_file(struct ccx_s_options api_options) -{ - parse_configuration(&api_options); -} - #ifdef PYTHON_API int compile_params(struct ccx_s_options *api_options,int argc) { @@ -503,24 +502,28 @@ int api_param_count(struct ccx_s_options* api_options) int main(int argc, char* argv[]) { - setlocale(LC_ALL, ""); + setlocale(LC_ALL, ""); // Supports non-English CCs + struct ccx_s_options* api_options = api_init_options(); - check_configuration_file(*api_options); + parse_configuration(api_options); + // If "ccextractor.cnf" is present, takes options from it. + // See docs/ccextractor.cnf.sample for more info. + #ifdef PYTHON_API for(int i = 1; i < argc; i++) - api_add_param(api_options,argv[i]); + api_add_param(api_options, argv[i]); #endif #ifdef PYTHON_API int compile_ret = compile_params(api_options,argc); #else - int compile_ret = parse_parameters (api_options, argc, argv); + int compile_ret = parse_parameters(api_options, argc, argv); #endif if (compile_ret == EXIT_NO_INPUT_FILES) { - print_usage (); - fatal (EXIT_NO_INPUT_FILES, "(This help screen was shown because there were no input files)\n"); + print_usage(); + fatal(EXIT_NO_INPUT_FILES, "(This help screen was shown because there were no input files)\n"); } else if (compile_ret == EXIT_WITH_HELP) { diff --git a/src/ccextractor.h b/src/ccextractor.h index da88dcd8f..4e9ae68f6 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -46,7 +46,7 @@ struct lib_ccx_ctx *signal_ctx; //volatile int terminate_asap = 0; struct ccx_s_options* api_init_options(); -void check_configuration_file(struct ccx_s_options api_options); + int api_start(struct ccx_s_options api_options); diff --git a/src/lib_ccx/cc_bitstream.c b/src/lib_ccx/cc_bitstream.c index cc8997c84..736d25058 100644 --- a/src/lib_ccx/cc_bitstream.c +++ b/src/lib_ccx/cc_bitstream.c @@ -314,7 +314,7 @@ uint64_t read_exp_golomb_unsigned(struct bitstream *bstr) uint64_t res = 0; int zeros=0; - while(!read_bits(bstr,1)) + while(!read_bits(bstr,1) && bstr->bitsleft >= 0) zeros++; res = (0x01 << zeros) - 1 + read_bits(bstr,zeros); diff --git a/src/lib_ccx/ccx_common_constants.h b/src/lib_ccx/ccx_common_constants.h index 0fb9949a5..65908c906 100644 --- a/src/lib_ccx/ccx_common_constants.h +++ b/src/lib_ccx/ccx_common_constants.h @@ -58,9 +58,9 @@ enum ccx_debug_message_types CCX_DMT_LEVENSHTEIN = 0x1000, // Levenshtein distance calculations CCX_DMT_DVB = 0x2000, // DVB #ifdef ENABLE_SHARING - CCX_DMT_SHARE = 0x2000, // Extracted captions sharing service + CCX_DMT_SHARE = 0x2000, // Extracted captions sharing service #endif //ENABLE_SHARING - CCX_DMT_DUMPDEF=0x4000, // Dump defective TS packets + CCX_DMT_DUMPDEF = 0x4000 // Dump defective TS packets }; // AVC NAL types @@ -104,95 +104,105 @@ enum ccx_avc_nal_types enum ccx_stream_type { CCX_STREAM_TYPE_UNKNOWNSTREAM = 0, - CCX_STREAM_TYPE_VIDEO_MPEG1 = 0x01, - CCX_STREAM_TYPE_VIDEO_MPEG2 = 0x02, - CCX_STREAM_TYPE_AUDIO_MPEG1 = 0x03, - CCX_STREAM_TYPE_AUDIO_MPEG2 = 0x04, - CCX_STREAM_TYPE_PRIVATE_TABLE_MPEG2 = 0x05, - CCX_STREAM_TYPE_PRIVATE_MPEG2 = 0x06, - CCX_STREAM_TYPE_MHEG_PACKETS = 0x07, - CCX_STREAM_TYPE_MPEG2_ANNEX_A_DSM_CC = 0x08, - CCX_STREAM_TYPE_ITU_T_H222_1 = 0x09, + + /* + The later constants are defined by MPEG-TS standard + Explore at: https://exiftool.org/TagNames/M2TS.html + */ + CCX_STREAM_TYPE_VIDEO_MPEG1 = 0x01, + CCX_STREAM_TYPE_VIDEO_MPEG2 = 0x02, + CCX_STREAM_TYPE_AUDIO_MPEG1 = 0x03, + CCX_STREAM_TYPE_AUDIO_MPEG2 = 0x04, + CCX_STREAM_TYPE_PRIVATE_TABLE_MPEG2 = 0x05, + CCX_STREAM_TYPE_PRIVATE_MPEG2 = 0x06, + CCX_STREAM_TYPE_MHEG_PACKETS = 0x07, + CCX_STREAM_TYPE_MPEG2_ANNEX_A_DSM_CC = 0x08, + CCX_STREAM_TYPE_ITU_T_H222_1 = 0x09, CCX_STREAM_TYPE_ISO_IEC_13818_6_TYPE_A = 0x0A, CCX_STREAM_TYPE_ISO_IEC_13818_6_TYPE_B = 0x0B, CCX_STREAM_TYPE_ISO_IEC_13818_6_TYPE_C = 0x0C, CCX_STREAM_TYPE_ISO_IEC_13818_6_TYPE_D = 0x0D, - CCX_STREAM_TYPE_AUDIO_AAC = 0x0f, - CCX_STREAM_TYPE_VIDEO_MPEG4 = 0x10, - CCX_STREAM_TYPE_VIDEO_H264 = 0x1b, - CCX_STREAM_TYPE_PRIVATE_USER_MPEG2=0x80, - CCX_STREAM_TYPE_AUDIO_AC3 = 0x81, - CCX_STREAM_TYPE_AUDIO_HDMV_DTS = 0x82, - CCX_STREAM_TYPE_AUDIO_DTS = 0x8a, + CCX_STREAM_TYPE_AUDIO_AAC = 0x0f, + CCX_STREAM_TYPE_VIDEO_MPEG4 = 0x10, + CCX_STREAM_TYPE_VIDEO_H264 = 0x1b, + CCX_STREAM_TYPE_PRIVATE_USER_MPEG2 = 0x80, + CCX_STREAM_TYPE_AUDIO_AC3 = 0x81, + CCX_STREAM_TYPE_AUDIO_HDMV_DTS = 0x82, + CCX_STREAM_TYPE_AUDIO_DTS = 0x8a }; enum ccx_mpeg_descriptor { - CCX_MPEG_DSC_REGISTRATION = 0x05, - CCX_MPEG_DSC_DATA_STREAM_ALIGNMENT = 0x06, - CCX_MPEG_DSC_ISO639_LANGUAGE = 0x0A, - CCX_MPEG_DSC_VBI_DATA_DESCRIPTOR = 0x45, + /* + The later constants are defined by ETSI EN 300 468 standard + Explore at: https://www.etsi.org/deliver/etsi_en/300400_300499/300468/01.11.01_60/en_300468v011101p.pdf + */ + CCX_MPEG_DSC_REGISTRATION = 0x05, + CCX_MPEG_DSC_DATA_STREAM_ALIGNMENT = 0x06, + CCX_MPEG_DSC_ISO639_LANGUAGE = 0x0A, + CCX_MPEG_DSC_VBI_DATA_DESCRIPTOR = 0x45, CCX_MPEG_DSC_VBI_TELETEXT_DESCRIPTOR = 0x46, - CCX_MPEG_DSC_TELETEXT_DESCRIPTOR = 0x56, - CCX_MPEG_DSC_DVB_SUBTITLE = 0x59, - CCX_MPEG_DSC_CAPTION_SERVICE = 0x86, - CCX_MPEG_DESC_DATA_COMP = 0xfd, + CCX_MPEG_DSC_TELETEXT_DESCRIPTOR = 0x56, + CCX_MPEG_DSC_DVB_SUBTITLE = 0x59, + /* User defined */ + CCX_MPEG_DSC_CAPTION_SERVICE = 0x86, + CCX_MPEG_DESC_DATA_COMP = 0xfd // Consider to change DESC to DSC }; enum { - CCX_MESSAGES_QUIET = 0, - CCX_MESSAGES_STDOUT =1, - CCX_MESSAGES_STDERR =2 + CCX_MESSAGES_QUIET = 0, + CCX_MESSAGES_STDOUT = 1, + CCX_MESSAGES_STDERR = 2 }; enum ccx_datasource { - CCX_DS_FILE=0, - CCX_DS_STDIN=1, - CCX_DS_NETWORK=2, - CCX_DS_TCP=3 + CCX_DS_FILE = 0, + CCX_DS_STDIN = 1, + CCX_DS_NETWORK = 2, + CCX_DS_TCP = 3 }; enum ccx_output_format { - CCX_OF_RAW = 0, - CCX_OF_SRT = 1, - CCX_OF_SAMI = 2, + CCX_OF_RAW = 0, + CCX_OF_SRT = 1, + CCX_OF_SAMI = 2, CCX_OF_TRANSCRIPT = 3, - CCX_OF_RCWT = 4, - CCX_OF_NULL = 5, - CCX_OF_SMPTETT = 6, - CCX_OF_SPUPNG = 7, - CCX_OF_DVDRAW = 8, // See -d at http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_TOOLS.HTML#CCExtract - CCX_OF_WEBVTT = 9, + CCX_OF_RCWT = 4, + CCX_OF_NULL = 5, + CCX_OF_SMPTETT = 6, + CCX_OF_SPUPNG = 7, + CCX_OF_DVDRAW = 8, // See -d at http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_TOOLS.HTML#CCExtract + CCX_OF_WEBVTT = 9, CCX_OF_SIMPLE_XML = 10, - CCX_OF_G608 = 11, - CCX_OF_CURL = 12, - CCX_OF_SSA = 13, - CCX_OF_MCC = 14, + CCX_OF_G608 = 11, + CCX_OF_CURL = 12, + CCX_OF_SSA = 13, + CCX_OF_MCC = 14 }; enum ccx_output_date_format { - ODF_NONE = 0, - ODF_HHMMSS = 1, - ODF_SECONDS = 2, - ODF_DATE =3, - ODF_HHMMSSMS = 4, // HH:MM:SS,MILIS (.srt style) + ODF_NONE = 0, + ODF_HHMMSS = 1, + ODF_SECONDS = 2, + ODF_DATE = 3, + ODF_HHMMSSMS = 4 // HH:MM:SS,MILIS (.srt style) }; enum ccx_stream_mode_enum { - CCX_SM_ELEMENTARY_OR_NOT_FOUND=0, - CCX_SM_TRANSPORT=1, - CCX_SM_PROGRAM=2, - CCX_SM_ASF=3, + CCX_SM_ELEMENTARY_OR_NOT_FOUND = 0, + CCX_SM_TRANSPORT = 1, + CCX_SM_PROGRAM = 2, + CCX_SM_ASF = 3, CCX_SM_MCPOODLESRAW = 4, CCX_SM_RCWT = 5, // Raw Captions With Time, not used yet. CCX_SM_MYTH = 6, // Use the myth loop - CCX_SM_MP4 = 7, // MP4, ISO- + CCX_SM_MP4 = 7, // MP4, ISO- #ifdef WTV_DEBUG CCX_SM_HEX_DUMP = 8, // Hexadecimal dump generated by wtvccdump #endif @@ -211,8 +221,8 @@ enum ccx_encoding_type { CCX_ENC_UNICODE = 0, CCX_ENC_LATIN_1 = 1, - CCX_ENC_UTF_8 = 2, - CCX_ENC_ASCII = 3 + CCX_ENC_UTF_8 = 2, + CCX_ENC_ASCII = 3 }; enum ccx_bufferdata_type @@ -228,7 +238,7 @@ enum ccx_bufferdata_type CCX_ISDB_SUBTITLE = 8, /* BUffer where cc data contain 3 byte cc_valid ccdata 1 ccdata 2 */ CCX_RAW_TYPE = 9, - CCX_DVD_SUBTITLE =10, + CCX_DVD_SUBTITLE = 10 }; enum ccx_frame_type @@ -241,26 +251,31 @@ enum ccx_frame_type }; typedef enum { + NO = 0, YES = 1, - NO = 0, UNDEFINED = 0xff } bool_t; enum ccx_code_type { - CCX_CODEC_ANY, - CCX_CODEC_TELETEXT, - CCX_CODEC_DVB, - CCX_CODEC_ISDB_CC, - CCX_CODEC_ATSC_CC, - CCX_CODEC_NONE, + CCX_CODEC_ANY = 0, + CCX_CODEC_TELETEXT = 1, + CCX_CODEC_DVB = 2, + CCX_CODEC_ISDB_CC = 3, + CCX_CODEC_ATSC_CC = 4, + CCX_CODEC_NONE = 5 }; +/* Caption Distribution Packet */ enum cdp_section_type { - CDP_SECTION_DATA = 0x72, + /* + The later constants are defined by SMPTE ST 334 + Purchase for 80$ at: https://ieeexplore.ieee.org/document/8255806 + */ + CDP_SECTION_DATA = 0x72, CDP_SECTION_SVC_INFO = 0x73, - CDP_SECTION_FOOTER = 0x74 + CDP_SECTION_FOOTER = 0x74 }; /* @@ -295,9 +310,9 @@ enum cdp_section_type * to parse. */ #define IS_FEASIBLE(u_sel,u_nsel,f_sel) ( ( (u_sel) == CCX_CODEC_ANY && (u_nsel) != (f_sel) ) || (u_sel) == (f_sel) ) -#define CCX_TXT_FORBIDDEN 0 // Ignore teletext packets +#define CCX_TXT_FORBIDDEN 0 // Ignore teletext packets #define CCX_TXT_AUTO_NOT_YET_FOUND 1 -#define CCX_TXT_IN_USE 2 // Positive auto-detected, or forced, etc +#define CCX_TXT_IN_USE 2 // Positive auto-detected, or forced, etc #define NB_LANGUAGE 100 extern const char *language[NB_LANGUAGE]; @@ -308,5 +323,5 @@ extern const char *language[NB_LANGUAGE]; #define DEF_VAL_STARTCREDITSFORATLEAST "2" #define DEF_VAL_STARTCREDITSFORATMOST "5" #define DEF_VAL_ENDCREDITSFORATLEAST "2" -#define DEF_VAL_ENDCREDITSFORATMOST "5" +#define DEF_VAL_ENDCREDITSFORATMOST "5" #endif diff --git a/src/lib_ccx/ccx_common_option.c b/src/lib_ccx/ccx_common_option.c index 3186459f6..a4357ead7 100644 --- a/src/lib_ccx/ccx_common_option.c +++ b/src/lib_ccx/ccx_common_option.c @@ -140,7 +140,10 @@ void init_options (struct ccx_s_options *options) options->settings_dtvcc.print_file_reports = 1; options->settings_dtvcc.no_rollup = 0; options->settings_dtvcc.report = NULL; - memset(options->settings_dtvcc.services_enabled, 0, CCX_DTVCC_MAX_SERVICES); + memset ( + options->settings_dtvcc.services_enabled, 0, + CCX_DTVCC_MAX_SERVICES * sizeof(options->settings_dtvcc.services_enabled[0]) + ); #ifdef ENABLE_SHARING options->sharing_enabled = 0; diff --git a/src/lib_ccx/ccx_common_option.h b/src/lib_ccx/ccx_common_option.h index ee251b0ec..321ecb16b 100644 --- a/src/lib_ccx/ccx_common_option.h +++ b/src/lib_ccx/ccx_common_option.h @@ -77,6 +77,7 @@ struct encoder_cfg // text -> png (text render) char *render_font; // The font used to render text if needed (e.g. teletext->spupng) + char *render_font_italics; //CEA-708 int services_enabled[CCX_DTVCC_MAX_SERVICES]; @@ -87,7 +88,7 @@ struct encoder_cfg struct ccx_s_options // Options from user parameters { int extract; // Extract 1st, 2nd or both fields - int no_rollup; + int no_rollup; // Disable roll-up emulation (no duplicate output in generated file) int noscte20; int webvtt_create_css; int cc_channel; // Channel we want to dump in srt mode diff --git a/src/lib_ccx/ccx_decoders_708.c b/src/lib_ccx/ccx_decoders_708.c index 7ff43f6e2..35e321d8c 100644 --- a/src/lib_ccx/ccx_decoders_708.c +++ b/src/lib_ccx/ccx_decoders_708.c @@ -1070,8 +1070,8 @@ void dtvcc_handle_DFx_DefineWindow(ccx_dtvcc_service_decoder *decoder, int windo //Apply windows attribute presets if (win_style > 0 && win_style < 8) - - window->win_style = win_style; { + { + window->win_style = win_style; window->attribs.border_color = ccx_dtvcc_predefined_window_styles[win_style].border_color; window->attribs.border_type = ccx_dtvcc_predefined_window_styles[win_style].border_type; window->attribs.display_effect = ccx_dtvcc_predefined_window_styles[win_style].display_effect; @@ -1198,8 +1198,9 @@ void dtvcc_handle_DLW_DeleteWindows(ccx_dtvcc_ctx *dtvcc, { ccx_common_logging.debug_ftn(CCX_DMT_708, "[CEA-708] dtvcc_handle_DLW_DeleteWindows: windows: "); - int screen_content_changed = 0, - window_had_content,current_win_deleted=0; + int screen_content_changed = 0, window_had_content = 0; + // int current_win_deleted = 0; /* currently unused */ + if (windows_bitmap == 0) ccx_common_logging.debug_ftn(CCX_DMT_708, "none\n"); else diff --git a/src/lib_ccx/ccx_decoders_common.c b/src/lib_ccx/ccx_decoders_common.c index 9cab6f128..329289027 100644 --- a/src/lib_ccx/ccx_decoders_common.c +++ b/src/lib_ccx/ccx_decoders_common.c @@ -307,6 +307,7 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set ctx->stat_hdtv = 0; ctx->stat_divicom = 0; ctx->false_pict_header = 0; + ctx->is_alloc=0; memcpy(&ctx->extraction_start, &setting->extraction_start,sizeof(struct ccx_boundary_time)); memcpy(&ctx->extraction_end, &setting->extraction_end,sizeof(struct ccx_boundary_time)); diff --git a/src/lib_ccx/ccx_decoders_isdb.c b/src/lib_ccx/ccx_decoders_isdb.c index 441c98f7e..1eba43e04 100644 --- a/src/lib_ccx/ccx_decoders_isdb.c +++ b/src/lib_ccx/ccx_decoders_isdb.c @@ -182,7 +182,7 @@ struct ISDBPos{ struct ISDBText { - char *buf; + unsigned char *buf; size_t len; size_t used; struct ISDBPos pos; @@ -356,8 +356,8 @@ static struct ISDBText *allocate_text_node(ISDBSubLayout *ls) static int reserve_buf(struct ISDBText *text, size_t len) { - size_t blen; - unsigned char *ptr; + size_t blen = 0; + unsigned char *ptr = NULL; if (text->len >= text->used + len) return CCX_OK; @@ -485,14 +485,15 @@ static int get_text(ISDBSubContext *ctx, unsigned char *buffer, int len) struct ISDBText *text = NULL; struct ISDBText *sb_text = NULL; struct ISDBText *sb_temp = NULL; - struct ISDBText *wtrepeat_text = NULL; + //TO keep track we don't over flow in buffer from user int index = 0; if (ctx->cfg_no_rollup || (ctx->cfg_no_rollup == ctx->current_state.rollup_mode)) // Abhinav95: Forcing -noru to perform deduplication even if stream doesn't honor it { - wtrepeat_text = NULL; + /* Currently unused */ + //struct ISDBText *wtrepeat_text = NULL; if (list_empty(&ctx->buffered_text)) { list_for_each_entry(text, &ctx->text_list_head, list, struct ISDBText) @@ -800,9 +801,10 @@ static int parse_csi(ISDBSubContext *ctx, const uint8_t *buf, int len) case CSI_CMD_ACPS: isdb_command_log("Command:CSI: ACPS\n"); ret = get_csi_params(arg, &p1, &p2); - if (ret > 0) + if (ret > 0) { ls->acps[0] = p1; ls->acps[1] = p1; + } break; default: isdb_log("Command:CSI: Unknown command 0x%x\n", *buf); @@ -1311,7 +1313,7 @@ static int parse_caption_statement_data(ISDBSubContext *ctx, int lang_id, const if (ret > 0) { - add_cc_sub_text(sub, buffer, ctx->prev_timestamp, ctx->timestamp, "NA", "ISDB", CCX_ENC_UTF_8); + add_cc_sub_text(sub, (char *) buffer, ctx->prev_timestamp, ctx->timestamp, "NA", "ISDB", CCX_ENC_UTF_8); if (sub->start_time == sub->end_time) sub->end_time += 2; ctx->prev_timestamp = ctx->timestamp; @@ -1329,9 +1331,11 @@ int isdb_parse_data_group(void *codec_ctx,const uint8_t *buf, struct cc_subtitle ISDBSubContext *ctx = codec_ctx; const uint8_t *buf_pivot = buf; int id = (*buf >> 2); +#ifdef DEBUG // Fix [-Wunused-variable] when no debug int version = (*buf & 2); int link_number = 0; int last_link_number = 0; +#endif int group_size = 0; int ret = 0; @@ -1345,12 +1349,19 @@ int isdb_parse_data_group(void *codec_ctx,const uint8_t *buf, struct cc_subtitle isdb_log("ISDB group B\n"); } + buf++; + +#ifdef DEBUG isdb_log("ISDB (Data group) version %d\n",version); - buf++; link_number = *buf++; last_link_number = *buf++; + isdb_log("ISDB (Data group) link_number %d last_link_number %d\n", link_number, last_link_number); +#else + buf++; + buf++; +#endif group_size = RB16(buf); buf += 2; diff --git a/src/lib_ccx/ccx_decoders_xds.c b/src/lib_ccx/ccx_decoders_xds.c index 5d9c93f88..29618e5dd 100644 --- a/src/lib_ccx/ccx_decoders_xds.c +++ b/src/lib_ccx/ccx_decoders_xds.c @@ -667,12 +667,13 @@ int xds_do_current_and_future (struct cc_subtitle *sub, struct ccx_decoders_xds_ case XDS_TYPE_ASPECT_RATIO_INFO: { unsigned ar_start, ar_end; - int changed = 0; + // int changed = 0; /* Currently unused */ was_proc = 1; if (ctx->cur_xds_payload_length < 5) // We need 2 data bytes break; - if (!ctx->cur_xds_payload[2] & 20 || !ctx->cur_xds_payload[3] & 20) // Bit 6 must be 1 - break; + if (!(ctx->cur_xds_payload[2] & 0x20) || !(ctx->cur_xds_payload[3] & 0x20)) // Bit 6 must be 1 + break; // if bit 6 is not 1 - skip invalid data. + /* CEA-608-B: The starting line is computed by adding 22 to the decimal number represented by bits S0 to S5. The ending line is computing by subtracting the decimal number represented by bits E0 to E5 from 262 */ @@ -685,7 +686,7 @@ int xds_do_current_and_future (struct cc_subtitle *sub, struct ccx_decoders_xds_ { ctx->current_ar_start = ar_start; ctx->current_ar_end = ar_end; - changed = 1; + // changed = 1; /* Currently unused */ ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, start line=%u, end line=%u\n", ar_start, ar_end); ccx_common_logging.log_ftn("\rXDS Notice: Aspect ratio info, active picture height=%u, ratio=%f\n", active_picture_height, aspect_ratio); } diff --git a/src/lib_ccx/ccx_demuxer_mxf.c b/src/lib_ccx/ccx_demuxer_mxf.c index 6556c7c42..64bf445a6 100644 --- a/src/lib_ccx/ccx_demuxer_mxf.c +++ b/src/lib_ccx/ccx_demuxer_mxf.c @@ -381,10 +381,10 @@ static int mxf_read_vanc_data(struct ccx_demuxer *demux, uint64_t size, struct d int len = 0; int ret; int cdp_size; - char vanc_header[16]; + unsigned char vanc_header[16]; uint8_t DID; uint8_t SDID; - uint8_t count; + // uint8_t count; /* Currently unused */ if (size < 19) goto error; diff --git a/src/lib_ccx/ccx_encoders_common.c b/src/lib_ccx/ccx_encoders_common.c index c565232db..eab2311d3 100644 --- a/src/lib_ccx/ccx_encoders_common.c +++ b/src/lib_ccx/ccx_encoders_common.c @@ -1212,7 +1212,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub) case CCX_OF_SSA: if (!context->startcredits_displayed && context->start_credits_text != NULL) try_to_add_start_credits(context, sub->start_time); - wrote_something = write_cc_bitmap_as_ssa(sub, context); + wrote_something = write_cc_bitmap_as_ssa(sub, context); break; case CCX_OF_WEBVTT: if (!context->startcredits_displayed && context->start_credits_text != NULL) diff --git a/src/lib_ccx/ccx_encoders_helpers.c b/src/lib_ccx/ccx_encoders_helpers.c index afe7c31db..beb77b75f 100644 --- a/src/lib_ccx/ccx_encoders_helpers.c +++ b/src/lib_ccx/ccx_encoders_helpers.c @@ -179,6 +179,8 @@ unsigned encode_line(struct encoder_ctx *ctx, unsigned char *buffer, unsigned ch bytes += 2; buffer += 2; break; + case CCX_ENC_ASCII: // Consider to remove ASCII encoding or write some code here + break; } text++; } @@ -315,6 +317,8 @@ unsigned get_decoder_line_encoded(struct encoder_ctx *ctx, unsigned char *buffer get_char_in_unicode(buffer, line[i]); bytes = 2; break; + case CCX_ENC_ASCII: // Consider to remove ASCII encoding or write get_char_in_ascii(...) + break; } buffer += bytes; } diff --git a/src/lib_ccx/ccx_encoders_mcc.c b/src/lib_ccx/ccx_encoders_mcc.c index 3a102f19a..372d7a6ff 100644 --- a/src/lib_ccx/ccx_encoders_mcc.c +++ b/src/lib_ccx/ccx_encoders_mcc.c @@ -94,6 +94,8 @@ boolean mcc_encode_cc_data( struct encoder_ctx *enc_ctx, struct lib_cc_decode *d free(compressed_data_buffer); + return true; // Needed to avoid warning + // With void function type - throws an error } // mcc_encode_cc_data() static void generate_mcc_header( int fh, int fr_code, int dropframe_flag ) { @@ -576,7 +578,6 @@ static void random_chars(char buffer[], int len) { } static void uuid4(char* buffer) { - char* c = buffer; int i = 0; random_chars(buffer + i, 8); i+=8; diff --git a/src/lib_ccx/ccx_encoders_smptett.c b/src/lib_ccx/ccx_encoders_smptett.c index 05dd2aa4b..f0ec1da6d 100644 --- a/src/lib_ccx/ccx_encoders_smptett.c +++ b/src/lib_ccx/ccx_encoders_smptett.c @@ -216,7 +216,7 @@ int write_cc_buffer_as_smptett(struct eia608_screen *data, struct encoder_ctx *c if (context->sentence_cap) { if (clever_capitalize(context, row, data)) - correct_case_with_dictionary(row, data); + correct_case_with_dictionary(row, data); } float row1=0; @@ -248,7 +248,7 @@ int write_cc_buffer_as_smptett(struct eia608_screen *data, struct encoder_ctx *c { wrote_something=1; - sprintf ((char *) str,"

\n ",h1,m1,s1,ms1, h2,m2,s2,ms2,col1,row1); + sprintf (str,"

\n ",h1,m1,s1,ms1, h2,m2,s2,ms2,col1,row1); if (context->encoding!=CCX_ENC_UNICODE) { dbg_print(CCX_DMT_DECODER_608, "\r%s\n", str); @@ -263,11 +263,11 @@ int write_cc_buffer_as_smptett(struct eia608_screen *data, struct encoder_ctx *c dbg_print(CCX_DMT_DECODER_608, "\r"); dbg_print(CCX_DMT_DECODER_608, "%s\n",context->subline); } - int length = get_decoder_line_encoded (context, context->subline, row, data); + get_decoder_line_encoded (context, context->subline, row, data); - unsigned char *final = malloc ( strlen((context->subline)) + 1000); //Being overly generous? :P - unsigned char *temp = malloc ( strlen((context->subline)) + 1000); + char *final = malloc ( strlen((const char*)(context->subline)) + 1000); //Being overly generous? :P + char *temp = malloc ( strlen((const char*)(context->subline)) + 1000); *final=0; *temp=0; /* @@ -290,64 +290,59 @@ int write_cc_buffer_as_smptett(struct eia608_screen *data, struct encoder_ctx *c //Now, searching for first occurrence of OR OR - unsigned char * start = strstr((context->subline), ""); + char * start = strstr((const char*)(context->subline), ""); if(start==NULL) { - start = strstr((context->subline), ""); + start = strstr((const char*)(context->subline), ""); if(start==NULL) { - start = strstr((context->subline), ""); + start = strstr((const char*)(context->subline), ""); style = 3; //underline } - else - style = 2; //bold + style = 2; //bold } - else style = 1; //italics if(start!=NULL) //subtitle has style associated with it, will need formatting. { - unsigned char *end_tag; + char *end_tag; if(style == 1) { - end_tag =""; + end_tag = ""; } - else if(style == 2) { end_tag = ""; } - else { - end_tag = ""; + end_tag = ""; } - unsigned char *end = strstr((context->subline), end_tag); //occurrence of closing tag ( OR OR ) + char *end = strstr((const char*)(context->subline), end_tag); //occurrence of closing tag ( OR OR ) if(end==NULL) { //Incorrect styling, writing as it is - strcpy(final,(context->subline)); + strcpy(final, (const char*)(context->subline)); } - else { - int start_index = start-(context->subline); - int end_index = end-(context->subline); + int start_index = start-(char *)(context->subline); + int end_index = end-(char *)(context->subline); - strncat(final,(context->subline),start_index); // copying content before opening tag e.g. + strncat(final, (const char*)(context->subline),start_index); // copying content before opening tag e.g. strcat(final,""); //adding : replacement of //The content in italics is between and , i.e. between (start_index + 3) and end_index. - strncat(temp, (context->subline) + start_index + 3, end_index - start_index - 3); //the content in italics + strncat(temp, (const char *)(context->subline) + start_index + 3, end_index - start_index - 3); //the content in italics - strcat(final,temp); //attaching to final sentence. + strcat(final, temp); //attaching to final sentence. if (style == 1) strcpy(temp,"