From 9f6309ef142b2e9fe4824084c4c5a15b7c99d13b Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Fri, 14 Nov 2014 18:12:48 +0530 Subject: [PATCH 1/8] More elaborate warning for DVB subtitle's --- src/lib_ccx/ts_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/ts_tables.c b/src/lib_ccx/ts_tables.c index 451f1f51..23de753f 100644 --- a/src/lib_ccx/ts_tables.c +++ b/src/lib_ccx/ts_tables.c @@ -271,7 +271,7 @@ int parse_PMT (struct lib_ccx_ctx *ctx, unsigned char *buf, int len, int pos) #ifndef ENABLE_OCR if(ccx_options.write_format != CCX_OF_SPUPNG ) { - mprint ("Please Compile with ENABLE_OCR flag \n"); + mprint ("DVB subtitles detected, OCR subsystem not present. Use -out=spupng for graphic output\n"); continue; } #endif From b3b683aa83b90eff78043ebaccd30ae6fccd85f5 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Tue, 25 Nov 2014 15:00:39 +0530 Subject: [PATCH 2/8] Instruction on how to build ccextractor with CMake --- docs/using_cmake_build.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/using_cmake_build.txt diff --git a/docs/using_cmake_build.txt b/docs/using_cmake_build.txt new file mode 100644 index 00000000..1e41b1d9 --- /dev/null +++ b/docs/using_cmake_build.txt @@ -0,0 +1,21 @@ +For building ccextractor using cmake folllow below steps.. + +Step 1) Check you have right version of cmake installed. ( version >= 3.0.2 ) + We are using CMP0037 policy of cmake which was introduced in 3.0.0 + since we have tested our system only with cmake version 3.0.2, I would + suggest to use 3.0.2 or higher version. + + +Step 2) create a seprate directory where you want to build the target. + In Unix you can do it using follwing commands. + ~> cd ccextractor + ~> mkdir build + +Step 3) make the build sytem using cmake + ~> cmake ../src/ + +Step 4) Compile the code. + ~> make + ~> make install + +Step 5) Use CCextractor as you would like From cf508653f2ef0b613281b3f52cc9d53688bff255 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 17:53:12 +0530 Subject: [PATCH 3/8] documented how to compile ccextractor with FFmpeg using cmake --- docs/using_cmake_build.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/using_cmake_build.txt b/docs/using_cmake_build.txt index 1e41b1d9..67077d27 100644 --- a/docs/using_cmake_build.txt +++ b/docs/using_cmake_build.txt @@ -19,3 +19,10 @@ Step 4) Compile the code. ~> make install Step 5) Use CCextractor as you would like + + +If you want to build CCExtractor with FFMpeg you need to pass +cmake -DWITH_FFMPEG=ON ../src/ + +Hint for looking all the things you want to set from outside +cmake -LAH ../src/ From 866c4ea1592754279a927fa44458fa71582a1e1b Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 17:55:20 +0530 Subject: [PATCH 4/8] added flag in CCExtractor Cmake to build with FFMpeg --- src/CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 229f22ba..f0093143 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.0.2) project (CCExtractor) +option(WITH_FFMPEG "Build using FFmpeg demuxer and decoder" OFF) #Version number set (CCEXTRACTOR_VERSION_MAJOR 0) set (CCEXTRACTOR_VERSION_MINOR 75) @@ -13,6 +14,7 @@ configure_file ( "${PROJECT_BINARY_DIR}/CCExtractorConfig.h" ) + include_directories ("${PROJECT_SOURCE_DIR}") include_directories ("${PROJECT_SOURCE_DIR}/lib_ccx") include_directories ("${PROJECT_SOURCE_DIR}/gpacmp4/") @@ -22,7 +24,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/libccx_common/") LINK_DIRECTORIES(/opt/local/lib) LINK_DIRECTORIES(/usr/local/lib) -SET (CMAKE_C_FLAGS "-O0 -Wall -g -std=gnu99 -Wno-write-strings -D_FILE_OFFSET_BITS=64") +SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -Wall -g -std=gnu99 -Wno-write-strings -D_FILE_OFFSET_BITS=64") add_subdirectory (lib_ccx) AUX_SOURCE_DIRECTORY(${PROJECT_SOURCE_DIR} SOURCEFILE) @@ -30,6 +32,22 @@ set (EXTRA_LIBS ${EXTRA_LIBS} ccx) set (EXTRA_LIBS ${EXTRA_LIBS} png) set (EXTRA_LIBS ${EXTRA_LIBS} m) +######################################################## +# Build using FFmpeg libraries +# +if (WITH_FFMPEG) + +find_package(PkgConfig) +pkg_check_modules(AVFORMAT REQUIRED libavformat) +pkg_check_modules(AVUTIL REQUIRED libavutil) +pkg_check_modules(AVCODEC REQUIRED libavcodec) +set (EXTRA_LIBS ${EXTRA_LIBS} ${AVFORMAT_STATIC_LIBRARIES} ) +set (EXTRA_LIBS ${EXTRA_LIBS} ${AVUTIL_STATIC_LIBRARIES} ) +set (EXTRA_LIBS ${EXTRA_LIBS} ${AVCODEC_STATIC_LIBRARIES} ) + +SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_FFMPEG") +endif (WITH_FFMPEG) + add_executable(ccextractor ${SOURCEFILE}) target_link_libraries (ccextractor ${EXTRA_LIBS}) From 4d7e629ba5649c963c70fa83bac35e6684616a25 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 17:57:41 +0530 Subject: [PATCH 5/8] in ffmpeg intigration logic, removed unneeded malloc and free --- src/ccextractor.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/ccextractor.c b/src/ccextractor.c index 1cd9bbf6..01970fb6 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -28,7 +28,9 @@ int main(int argc, char *argv[]) char *c; struct encoder_ctx enc_ctx[2]; struct cc_subtitle dec_sub; +#ifdef ENABLE_FFMPEG void *ffmpeg_ctx = NULL; +#endif struct lib_ccx_ctx *ctx; struct lib_cc_decode *dec_ctx = NULL; @@ -416,20 +418,12 @@ int main(int argc, char *argv[]) ffmpeg_ctx = init_ffmpeg(ctx->inputfile[0]); if(ffmpeg_ctx) { - int i =0; - ctx->buffer = malloc(1024); - if(!ctx->buffer) - { - mprint("no memory left\n"); - break; - } do { int ret = 0; - char *bptr = ctx->buffer; + unsigned char *bptr = ctx->buffer; int len = ff_get_ccframe(ffmpeg_ctx, bptr, 1024); int cc_count = 0; - memset(bptr,0,1024); if(len == AVERROR(EAGAIN)) { continue; @@ -446,15 +440,13 @@ int main(int argc, char *argv[]) } else cc_count = len/3; - store_hdcc(ctx, bptr, cc_count, i++,fts_now,&dec_sub); - if(dec_sub.got_output) + ret = process_cc_data(dec_ctx, bptr, cc_count, &dec_sub); + if(ret >= 0 && dec_sub.got_output) { encode_sub(enc_ctx, &dec_sub); dec_sub.got_output = 0; } }while(1); - - free(ctx->buffer); continue; } else @@ -462,7 +454,6 @@ int main(int argc, char *argv[]) mprint ("\rFailed to initialized ffmpeg falling back to legacy\n"); } #endif - if (ctx->auto_stream == CCX_SM_AUTODETECT) { detect_stream_type(ctx); @@ -711,7 +702,7 @@ int main(int argc, char *argv[]) // and need to be written after the last file is processed. cb_field1 = 0; cb_field2 = 0; cb_708 = 0; fts_now = 0; - fts_max = 0; + fts_max = 0; } // file loop close_input_file(ctx); From 559d05c478d6269a5cb4d1f52dd5595b2bc47492 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 17:58:49 +0530 Subject: [PATCH 6/8] added flag in CCExtractor Cmake to build with FFMpeg --- src/lib_ccx/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib_ccx/CMakeLists.txt b/src/lib_ccx/CMakeLists.txt index 475c7c70..3a36f53f 100644 --- a/src/lib_ccx/CMakeLists.txt +++ b/src/lib_ccx/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_policy(SET CMP0037 NEW) SET (CMAKE_C_FLAGS "-O0 -Wall -g -std=gnu99") + +if (WITH_FFMPEG) +SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_FFMPEG") +endif (WITH_FFMPEG) + AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE) AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/gpacmp4/" SOURCEFILE) #AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/libpng/" SOURCEFILE) From cf0ebd27f778e255027e31a795e63afcc2f58261 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 18:00:53 +0530 Subject: [PATCH 7/8] corrected initial value of ret --- src/lib_ccx/ccx_decoders_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib_ccx/ccx_decoders_common.c b/src/lib_ccx/ccx_decoders_common.c index 9c182667..8cd800a2 100644 --- a/src/lib_ccx/ccx_decoders_common.c +++ b/src/lib_ccx/ccx_decoders_common.c @@ -100,7 +100,7 @@ unsigned get_decoder_line_basic(unsigned char *buffer, int line_num, struct eia6 int process_cc_data (struct lib_cc_decode *ctx, unsigned char *cc_data, int cc_count, struct cc_subtitle *sub) { - int ret = 0; + int ret = -1; for (int j = 0; j < cc_count * 3; j = j + 3) { if (validate_cc_data_pair( cc_data + j ) ) From 3953f806b00139cd511b3dc00e9db720316422a0 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Wed, 26 Nov 2014 18:02:25 +0530 Subject: [PATCH 8/8] corrected sign of argument --- src/lib_ccx/ffmpeg_intgr.c | 2 +- src/lib_ccx/ffmpeg_intgr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c index 6fe5b14f..0a74ec9c 100644 --- a/src/lib_ccx/ffmpeg_intgr.c +++ b/src/lib_ccx/ffmpeg_intgr.c @@ -126,7 +126,7 @@ fail: * @param maxlen length of buffer, where data will be copied * @return number of bytes recieved as data */ -int ff_get_ccframe(void *arg,char*data,int maxlen) +int ff_get_ccframe(void *arg, unsigned char*data, int maxlen) { struct ffmpeg_ctx *ctx = arg; int len = 0; diff --git a/src/lib_ccx/ffmpeg_intgr.h b/src/lib_ccx/ffmpeg_intgr.h index efc963d9..3d0bce0b 100644 --- a/src/lib_ccx/ffmpeg_intgr.h +++ b/src/lib_ccx/ffmpeg_intgr.h @@ -19,5 +19,5 @@ void *init_ffmpeg(char *path); * @param maxlen length of buffer, where data will be copied * @return number of bytes recieved as data */ -int ff_get_ccframe(void *arg,char*data,int maxlen); +int ff_get_ccframe(void *arg, unsigned char*data, int maxlen); #endif