Merge branch 'pr/n121_anshul1912'

This commit is contained in:
cfsmp3 2014-11-26 13:57:53 +01:00
commit 4db37e7ac3
8 changed files with 62 additions and 20 deletions

View File

@ -0,0 +1,28 @@
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
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/

View File

@ -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})

View File

@ -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);

View File

@ -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)

View File

@ -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 ) )

View File

@ -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;

View File

@ -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

View File

@ -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