diff --git a/src/lib_ccx/asf_functions.c b/src/lib_ccx/asf_functions.c index 27ff8dd9..58c4ce3c 100644 --- a/src/lib_ccx/asf_functions.c +++ b/src/lib_ccx/asf_functions.c @@ -100,7 +100,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata) unsigned char *curpos; int64_t getbytes; - int result = 0; + size_t result = 0; struct demuxer_data *data; if(!*ppdata) diff --git a/src/lib_ccx/avc_functions.c b/src/lib_ccx/avc_functions.c index 3af0d338..ecbff0a2 100644 --- a/src/lib_ccx/avc_functions.c +++ b/src/lib_ccx/avc_functions.c @@ -133,7 +133,7 @@ void do_NAL (struct lib_cc_decode *ctx, unsigned char *NALstart, LLONG NAL_lengt // Process inbuf bytes in buffer holding and AVC (H.264) video stream. // The number of processed bytes is returned. -LLONG process_avc ( struct lib_cc_decode *ctx, unsigned char *avcbuf, LLONG avcbuflen ,struct cc_subtitle *sub) +size_t process_avc ( struct lib_cc_decode *ctx, unsigned char *avcbuf, size_t avcbuflen ,struct cc_subtitle *sub) { unsigned char *bpos = avcbuf; unsigned char *NALstart; diff --git a/src/lib_ccx/avc_functions.h b/src/lib_ccx/avc_functions.h index adddfd0f..3c9fed22 100644 --- a/src/lib_ccx/avc_functions.h +++ b/src/lib_ccx/avc_functions.h @@ -49,5 +49,5 @@ struct avc_ctx struct avc_ctx *init_avc(void); void dinit_avc(struct avc_ctx **ctx); void do_NAL (struct lib_cc_decode *ctx, unsigned char *NALstart, LLONG NAL_length, struct cc_subtitle *sub); - +size_t process_avc(struct lib_cc_decode *ctx, unsigned char *avcbuf, size_t avcbuflen, struct cc_subtitle *sub); #endif diff --git a/src/lib_ccx/ccx_decoders_isdb.c b/src/lib_ccx/ccx_decoders_isdb.c index 7a9e6d56..08ace4be 100644 --- a/src/lib_ccx/ccx_decoders_isdb.c +++ b/src/lib_ccx/ccx_decoders_isdb.c @@ -1170,7 +1170,7 @@ int isdb_parse_data_group(void *codec_ctx,const uint8_t *buf, struct cc_subtitle return buf - buf_pivot; } -int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, int buf_size, struct cc_subtitle *sub) +int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf_size, struct cc_subtitle *sub) { const uint8_t *header_end = NULL; int ret = 0; @@ -1200,5 +1200,5 @@ int isdb_set_global_time(struct lib_cc_decode *dec_ctx, uint64_t timestamp) { ISDBSubContext *ctx = dec_ctx->private_data; ctx->timestamp = timestamp; - + return CCX_OK; } diff --git a/src/lib_ccx/ccx_decoders_isdb.h b/src/lib_ccx/ccx_decoders_isdb.h index 45b44b77..02cdb470 100644 --- a/src/lib_ccx/ccx_decoders_isdb.h +++ b/src/lib_ccx/ccx_decoders_isdb.h @@ -5,7 +5,7 @@ #include "ccx_decoders_structs.h" int isdb_set_global_time(struct lib_cc_decode *dec_ctx, uint64_t timestamp); -int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, int buf_size, struct cc_subtitle *sub); +int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf_size, struct cc_subtitle *sub); void delete_isdb_caption(void *isdb_ctx); void *init_isdb_caption(void); diff --git a/src/lib_ccx/ccx_demuxer.h b/src/lib_ccx/ccx_demuxer.h index 44dfffd0..c50482d8 100644 --- a/src/lib_ccx/ccx_demuxer.h +++ b/src/lib_ccx/ccx_demuxer.h @@ -144,7 +144,7 @@ struct demuxer_data enum ccx_code_type codec; enum ccx_bufferdata_type bufferdatatype; unsigned char *buffer; - int len; + size_t len; LLONG pts; struct demuxer_data *next_stream; struct demuxer_data *next_program; diff --git a/src/lib_ccx/ccx_encoders_common.c b/src/lib_ccx/ccx_encoders_common.c index bc47379c..7645183a 100644 --- a/src/lib_ccx/ccx_encoders_common.c +++ b/src/lib_ccx/ccx_encoders_common.c @@ -474,7 +474,7 @@ void write_cc_line_as_transcript2(struct eia608_screen *data, struct encoder_ctx } ret = write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length); - if(ret < context->encoded_crlf_length) + if(ret < context->encoded_crlf_length) { mprint("Warning:Loss of data\n"); } diff --git a/src/lib_ccx/es_functions.c b/src/lib_ccx/es_functions.c index 3bfce59c..bc7e013c 100644 --- a/src/lib_ccx/es_functions.c +++ b/src/lib_ccx/es_functions.c @@ -37,7 +37,7 @@ static int read_pic_data(struct bitstream *esstream); /* Process a mpeg-2 data stream with "lenght" bytes in buffer "data". * The number of processed bytes is returned. * Defined in ISO/IEC 13818-2 6.2 */ -LLONG process_m2v (struct lib_cc_decode *ctx, unsigned char *data, LLONG length, struct cc_subtitle *sub) +size_t process_m2v (struct lib_cc_decode *ctx, unsigned char *data, size_t length, struct cc_subtitle *sub) { if (length<8) // Need to look ahead 8 bytes return length; diff --git a/src/lib_ccx/file_buffer.h b/src/lib_ccx/file_buffer.h index 0ee3b3e8..527c656e 100644 --- a/src/lib_ccx/file_buffer.h +++ b/src/lib_ccx/file_buffer.h @@ -15,16 +15,16 @@ * @return 0 or number of bytes, if returned 0 then op should check error number to know * details of error */ -LLONG buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, unsigned int bytes); +size_t buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, unsigned int bytes); /** * Skip bytes from file buffer and if needed also seek file for number of bytes. * */ -static LLONG inline buffered_skip(struct ccx_demuxer *ctx, unsigned int bytes) +static size_t inline buffered_skip(struct ccx_demuxer *ctx, unsigned int bytes) { - LLONG result; + size_t result; if (bytes <= ctx->bytesinbuffer - ctx->filebuffer_pos) { ctx->filebuffer_pos += bytes; @@ -41,9 +41,9 @@ static LLONG inline buffered_skip(struct ccx_demuxer *ctx, unsigned int bytes) * Read bytes from file buffer and if needed also read file for number of bytes. * */ -static LLONG inline buffered_read(struct ccx_demuxer *ctx, unsigned char *buffer, unsigned int bytes) +static size_t inline buffered_read(struct ccx_demuxer *ctx, unsigned char *buffer, size_t bytes) { - LLONG result; + size_t result; if (bytes <= ctx->bytesinbuffer - ctx->filebuffer_pos) { if (buffer != NULL) @@ -68,9 +68,9 @@ static LLONG inline buffered_read(struct ccx_demuxer *ctx, unsigned char *buffer * Read single byte from file buffer and if needed also read file for number of bytes. * */ -static LLONG inline buffered_read_byte(struct ccx_demuxer *ctx, unsigned char *buffer) +static size_t inline buffered_read_byte(struct ccx_demuxer *ctx, unsigned char *buffer) { - LLONG result; + size_t result; if (ctx->bytesinbuffer - ctx->filebuffer_pos) { if (buffer) diff --git a/src/lib_ccx/file_functions.c b/src/lib_ccx/file_functions.c index 50e78502..7e2f96cd 100644 --- a/src/lib_ccx/file_functions.c +++ b/src/lib_ccx/file_functions.c @@ -284,9 +284,9 @@ void return_to_buffer (struct ccx_demuxer *ctx, unsigned char *buffer, unsigned * * TODO instead of using global ccx_options move them to ccx_demuxer */ -LLONG buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, unsigned int bytes) +size_t buffered_read_opt (struct ccx_demuxer *ctx, unsigned char *buffer, size_t bytes) { - LLONG copied = 0; + size_t copied = 0; time_t seconds = 0; position_sanity_check(ctx->infd); @@ -465,7 +465,7 @@ unsigned char buffered_get_byte (struct ccx_demuxer *ctx) { unsigned char b; unsigned char *b_p = &b; - int result; + size_t result; result = buffered_read_byte(ctx, b_p); if (result == 1) diff --git a/src/lib_ccx/general_loop.c b/src/lib_ccx/general_loop.c index a715e7a1..b6df6127 100644 --- a/src/lib_ccx/general_loop.c +++ b/src/lib_ccx/general_loop.c @@ -26,7 +26,7 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata) { int enough = 0; int payload_read = 0; - int result; + size_t result; static unsigned vpesnum=0; @@ -192,18 +192,24 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata) else if ((nextheader[3]&0xf0)==0xe0) { int hlen; // Dummy variable, unused - int peslen = read_video_pes_header(ctx->demux_ctx, data, nextheader, &hlen, 0); - if (peslen < 0) + int ret; + size_t peslen; + ret = read_video_pes_header(ctx->demux_ctx, data, nextheader, &hlen, 0); + if (ret < 0) { end_of_file=1; break; } + else + { + peslen = ret; + } vpesnum++; dbg_print(CCX_DMT_VERBOSE, "PES video packet #%u\n", vpesnum); - - int want = (int) ((BUFSIZE-data->len)>peslen ? peslen : (BUFSIZE-data->len)); + //peslen is unsigned since loop would have already broken if it was negative + int want = (int) ((BUFSIZE-data->len) > peslen ? peslen : (BUFSIZE-data->len)); if (want != peslen) { mprint("General LOOP: want(%d) != peslen(%d) \n", want, peslen); @@ -480,13 +486,14 @@ void raw_loop (struct lib_ccx_ctx *ctx) /* Process inbuf bytes in buffer holding raw caption data (three byte packets, the first being the field). * The number of processed bytes is returned. */ -LLONG process_raw_with_field (struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub, unsigned char* buffer, int len) +size_t process_raw_with_field(struct lib_cc_decode *dec_ctx, struct cc_subtitle *sub, unsigned char* buffer, size_t len) { unsigned char data[3]; + size_t i; data[0]=0x04; // Field 1 dec_ctx->current_field = 1; - for (unsigned long i=0; i < len; i=i+3) + for (i = 0; i < len; i=i+3) { if ( !dec_ctx->saw_caption_block && *(buffer+i)==0xff && *(buffer+i+1)==0xff) { @@ -508,12 +515,13 @@ LLONG process_raw_with_field (struct lib_cc_decode *dec_ctx, struct cc_subtitle /* Process inbuf bytes in buffer holding raw caption data (two byte packets). * The number of processed bytes is returned. */ -LLONG process_raw ( struct lib_cc_decode *ctx, struct cc_subtitle *sub, unsigned char *buffer, int len) +size_t process_raw(struct lib_cc_decode *ctx, struct cc_subtitle *sub, unsigned char *buffer, size_t len) { unsigned char data[3]; + size_t i; data[0]=0x04; // Field 1 - for (unsigned long i=0; i < len; i=i+2) + for (i = 0; i < len; i = i+2) { if ( !ctx->saw_caption_block && *(buffer+i)==0xff && *(buffer+i+1)==0xff) { @@ -547,7 +555,7 @@ void delete_datalist(struct demuxer_data *list) int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, struct demuxer_data *data_node) { - LLONG got; // Means 'consumed' from buffer actually + size_t got; // Means 'consumed' from buffer actually int ret = 0; static LLONG last_pts = 0x01FFFFFFFFLL; struct cc_subtitle *dec_sub = &dec_ctx->dec_sub; @@ -868,7 +876,7 @@ void rcwt_loop(struct lib_ccx_ctx *ctx) LLONG currfts; uint16_t cbcount = 0; int bread = 0; // Bytes read - int result; + LLONG result; struct encoder_ctx *enc_ctx = update_encoder_list(ctx); diff --git a/src/lib_ccx/lib_ccx.h b/src/lib_ccx/lib_ccx.h index f47e8aa5..f9f67898 100644 --- a/src/lib_ccx/lib_ccx.h +++ b/src/lib_ccx/lib_ccx.h @@ -155,7 +155,7 @@ int init_file_buffer(struct ccx_demuxer *ctx); int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata); int general_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **data); void raw_loop (struct lib_ccx_ctx *ctx); -LLONG process_raw (struct lib_cc_decode *ctx, struct cc_subtitle *sub, unsigned char *buffer, int len); +size_t process_raw(struct lib_cc_decode *ctx, struct cc_subtitle *sub, unsigned char *buffer, size_t len); void general_loop(struct lib_ccx_ctx *ctx); void processhex (char *filename); void rcwt_loop(struct lib_ccx_ctx *ctx); @@ -169,7 +169,7 @@ int asf_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata); int wtv_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data **ppdata); // es_functions.c -LLONG process_m2v (struct lib_cc_decode *ctx, unsigned char *data, LLONG length,struct cc_subtitle *sub); +size_t process_m2v(struct lib_cc_decode *ctx, unsigned char *data, size_t length, struct cc_subtitle *sub); extern unsigned top_field_first; @@ -213,7 +213,7 @@ int read_video_pes_header (struct ccx_demuxer *ctx, struct demuxer_data *data, u void init_ts(struct ccx_demuxer *ctx); int ts_readpacket(struct ccx_demuxer* ctx, struct ts_payload *payload); long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data); -LLONG ts_getmoredata(struct ccx_demuxer *ctx, struct demuxer_data **data); +int ts_getmoredata(struct ccx_demuxer *ctx, struct demuxer_data **data); int write_section(struct ccx_demuxer *ctx, struct ts_payload *payload, unsigned char*buf, int size, struct program_info *pinfo); void ts_buffer_psi_packet(struct ccx_demuxer *ctx); int parse_PMT (struct ccx_demuxer *ctx, unsigned char *buf, int len, struct program_info *pinfo); @@ -226,7 +226,6 @@ void parse_SDT(struct ccx_demuxer *ctx); // myth.c void myth_loop(struct lib_ccx_ctx *ctx); -LLONG process_avc (struct lib_cc_decode *ctx, unsigned char *avcbuf, LLONG avcbuflen ,struct cc_subtitle *sub); // utility.c void fatal(int exit_code, const char *fmt, ...); void mprint (const char *fmt, ...); diff --git a/src/lib_ccx/list.h b/src/lib_ccx/list.h index 2382fa6c..d08dec01 100644 --- a/src/lib_ccx/list.h +++ b/src/lib_ccx/list.h @@ -16,8 +16,9 @@ /** * Get offset of a member */ -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#ifndef ccx_offsetof +#define ccx_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif /** @@ -27,7 +28,7 @@ * @param member the name of the member within the struct. * */ -#define container_of(ptr, type, member) ((type *)( (char *)ptr - offsetof(type,member) )) +#define container_of(ptr, type, member) ((type *)( (char *)ptr - ccx_offsetof(type,member) )) /*@}*/ diff --git a/src/lib_ccx/ts_functions.c b/src/lib_ccx/ts_functions.c index 501f24cb..a620d12b 100644 --- a/src/lib_ccx/ts_functions.c +++ b/src/lib_ccx/ts_functions.c @@ -774,7 +774,7 @@ long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data) // TS specific data grabber -LLONG ts_getmoredata(struct ccx_demuxer *ctx, struct demuxer_data **data) +int ts_getmoredata(struct ccx_demuxer *ctx, struct demuxer_data **data) { int ret = CCX_OK; diff --git a/windows/ccextractor.vcxproj b/windows/ccextractor.vcxproj index a6f84ac7..0f73437f 100644 --- a/windows/ccextractor.vcxproj +++ b/windows/ccextractor.vcxproj @@ -42,6 +42,7 @@ + @@ -53,6 +54,7 @@ + @@ -149,6 +151,7 @@ + @@ -206,7 +209,7 @@ Application - v140 + v120 diff --git a/windows/ccextractor.vcxproj.filters b/windows/ccextractor.vcxproj.filters index 5f011c15..f5909363 100644 --- a/windows/ccextractor.vcxproj.filters +++ b/windows/ccextractor.vcxproj.filters @@ -246,6 +246,12 @@ Header Files\ccx_decoders + + Header Files\ccx_decoders + + + Header Files + @@ -587,12 +593,6 @@ Source Files - - Source Files\ccx_encoders - - - Source Files\ccx_encoders - Source Files\ccx_encoders @@ -611,5 +611,8 @@ Source Files\ccx_encoders + + Source Files\ccx_decoders + \ No newline at end of file