From ff4ae8d6aed0bb65ad61590b0e2d6c885d900c34 Mon Sep 17 00:00:00 2001 From: Anshul Maheshwari Date: Sun, 15 Jun 2014 13:33:28 +0530 Subject: [PATCH] converting soace to tab --- src/ccextractor.c | 756 +++++++++++++++++++++++----------------------- src/ccextractor.h | 54 ++-- 2 files changed, 405 insertions(+), 405 deletions(-) diff --git a/src/ccextractor.c b/src/ccextractor.c index 8e6bdfe8..8efe62ee 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -119,7 +119,7 @@ void init_options (struct ccx_s_options *options) options->fix_padding = 0; // Replace 0000 with 8080 in HDTV (needed for some cards) options->norollup=0; // If 1, write one line at a time options->forced_ru=0; // 0=Disabled, 1, 2 or 3=max lines in roll-up mode - options->trim_subs=0; // " Remove spaces at sides? " + options->trim_subs=0; // " Remove spaces at sides? " options->gui_mode_reports=0; // If 1, output in stderr progress updates so the GUI can grab them options->no_progress_bar=0; // If 1, suppress the output of the progress to stdout options->sentence_cap =0 ; // FIX CASE? = Fix case? @@ -230,17 +230,17 @@ LLONG process_raw_with_field (void); int main(int argc, char *argv[]) { - char *c; + char *c; - // Initialize some constants - init_ts(); + // Initialize some constants + init_ts(); init_avc(); init_options (&ccx_options); - // Prepare write structures - init_write(&wbout1); - init_write(&wbout2); + // Prepare write structures + init_write(&wbout1); + init_write(&wbout2); // Prepare 608 context init_context_cc608(&context_cc608_field_1,1); @@ -252,34 +252,34 @@ int main(int argc, char *argv[]) xds_init(); //xds_cea608_test(); - // Prepare time structures - init_boundary_time (&ccx_options.extraction_start); - init_boundary_time (&ccx_options.extraction_end); - init_boundary_time (&ccx_options.startcreditsnotbefore); - init_boundary_time (&ccx_options.startcreditsnotafter); - init_boundary_time (&ccx_options.startcreditsforatleast); - init_boundary_time (&ccx_options.startcreditsforatmost); - init_boundary_time (&ccx_options.endcreditsforatleast); - init_boundary_time (&ccx_options.endcreditsforatmost); + // Prepare time structures + init_boundary_time (&ccx_options.extraction_start); + init_boundary_time (&ccx_options.extraction_end); + init_boundary_time (&ccx_options.startcreditsnotbefore); + init_boundary_time (&ccx_options.startcreditsnotafter); + init_boundary_time (&ccx_options.startcreditsforatleast); + init_boundary_time (&ccx_options.startcreditsforatmost); + init_boundary_time (&ccx_options.endcreditsforatleast); + init_boundary_time (&ccx_options.endcreditsforatmost); - int show_myth_banner = 0; - + int show_myth_banner = 0; + memset (&cea708services[0],0,63*sizeof (int)); - parse_parameters (argc,argv); + parse_parameters (argc,argv); if (num_input_files==0 && ccx_options.input_source==CCX_DS_FILE) - { - usage (); - fatal (EXIT_NO_INPUT_FILES, "(This help screen was shown because there were no input files)\n"); - } - if (num_input_files>1 && ccx_options.live_stream) - { - fatal(EXIT_TOO_MANY_INPUT_FILES, "Live stream mode accepts only one input file.\n"); - } - if (num_input_files && ccx_options.input_source==CCX_DS_NETWORK) - { - fatal(EXIT_TOO_MANY_INPUT_FILES, "UDP mode is not compatible with input files.\n"); - } + { + usage (); + fatal (EXIT_NO_INPUT_FILES, "(This help screen was shown because there were no input files)\n"); + } + if (num_input_files>1 && ccx_options.live_stream) + { + fatal(EXIT_TOO_MANY_INPUT_FILES, "Live stream mode accepts only one input file.\n"); + } + if (num_input_files && ccx_options.input_source==CCX_DS_NETWORK) + { + fatal(EXIT_TOO_MANY_INPUT_FILES, "UDP mode is not compatible with input files.\n"); + } if (ccx_options.input_source==CCX_DS_NETWORK) { ccx_options.buffer_input=1; // Mandatory, because each datagram must be read complete. @@ -290,50 +290,50 @@ int main(int argc, char *argv[]) fatal (EXIT_NOT_CLASSIFIED, "Teletext page number could not be lower than 100 or higher than 899\n"); } - if (ccx_options.output_filename!=NULL) - { - // Use the given output file name for the field specified by - // the -1, -2 switch. If -12 is used, the filename is used for - // field 1. - if (ccx_options.extract==2) - wbout2.filename=ccx_options.output_filename; - else - wbout1.filename=ccx_options.output_filename; - } + if (ccx_options.output_filename!=NULL) + { + // Use the given output file name for the field specified by + // the -1, -2 switch. If -12 is used, the filename is used for + // field 1. + if (ccx_options.extract==2) + wbout2.filename=ccx_options.output_filename; + else + wbout1.filename=ccx_options.output_filename; + } - switch (ccx_options.write_format) - { - case CCX_OF_RAW: - extension = ".raw"; - break; - case CCX_OF_SRT: - extension = ".srt"; - break; - case CCX_OF_SAMI: - extension = ".smi"; - break; - case CCX_OF_SMPTETT: - extension = ".ttml"; - break; - case CCX_OF_TRANSCRIPT: - extension = ".txt"; - break; - case CCX_OF_RCWT: - extension = ".bin"; - break; - case CCX_OF_SPUPNG: - extension = ".xml"; - break; + switch (ccx_options.write_format) + { + case CCX_OF_RAW: + extension = ".raw"; + break; + case CCX_OF_SRT: + extension = ".srt"; + break; + case CCX_OF_SAMI: + extension = ".smi"; + break; + case CCX_OF_SMPTETT: + extension = ".ttml"; + break; + case CCX_OF_TRANSCRIPT: + extension = ".txt"; + break; + case CCX_OF_RCWT: + extension = ".bin"; + break; + case CCX_OF_SPUPNG: + extension = ".xml"; + break; case CCX_OF_NULL: extension = ""; break; case CCX_OF_DVDRAW: extension = ".dvdraw"; break; - default: - fatal (EXIT_BUG_BUG, "write_format doesn't have any legal value, this is a bug.\n"); - } - params_dump(); + default: + fatal (EXIT_BUG_BUG, "write_format doesn't have any legal value, this is a bug.\n"); + } + params_dump(); // default teletext page if (tlt_config.page > 0) { @@ -341,19 +341,19 @@ int main(int argc, char *argv[]) tlt_config.page = ((tlt_config.page / 100) << 8) | (((tlt_config.page / 10) % 10) << 4) | (tlt_config.page % 10); } - if (auto_stream==CCX_SM_MCPOODLESRAW && ccx_options.write_format==CCX_OF_RAW) - { - fatal (EXIT_INCOMPATIBLE_PARAMETERS, "-in=raw can only be used if the output is a subtitle file.\n"); - } - if (auto_stream==CCX_SM_RCWT && ccx_options.write_format==CCX_OF_RCWT && ccx_options.output_filename==NULL) - { - fatal (EXIT_INCOMPATIBLE_PARAMETERS, - "CCExtractor's binary format can only be used simultaneously for input and\noutput if the output file name is specified given with -o.\n"); - } + if (auto_stream==CCX_SM_MCPOODLESRAW && ccx_options.write_format==CCX_OF_RAW) + { + fatal (EXIT_INCOMPATIBLE_PARAMETERS, "-in=raw can only be used if the output is a subtitle file.\n"); + } + if (auto_stream==CCX_SM_RCWT && ccx_options.write_format==CCX_OF_RCWT && ccx_options.output_filename==NULL) + { + fatal (EXIT_INCOMPATIBLE_PARAMETERS, + "CCExtractor's binary format can only be used simultaneously for input and\noutput if the output file name is specified given with -o.\n"); + } - buffer = (unsigned char *) malloc (BUFSIZE); - subline = (unsigned char *) malloc (SUBLINESIZE); - pesheaderbuf = (unsigned char *) malloc (188); // Never larger anyway + buffer = (unsigned char *) malloc (BUFSIZE); + subline = (unsigned char *) malloc (SUBLINESIZE); + pesheaderbuf = (unsigned char *) malloc (188); // Never larger anyway switch (ccx_options.input_source) { @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) break; } if (basefilename == NULL) - fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); + fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); switch (ccx_options.input_source) { case CCX_DS_FILE: @@ -381,27 +381,27 @@ int main(int argc, char *argv[]) strcpy (basefilename, basefilename_for_network); break; } - for (c=basefilename+strlen (basefilename)-1; c>basefilename && - *c!='.'; c--) {;} // Get last . - if (*c=='.') - *c=0; + for (c=basefilename+strlen (basefilename)-1; c>basefilename && + *c!='.'; c--) {;} // Get last . + if (*c=='.') + *c=0; - if (wbout1.filename==NULL) - { - wbout1.filename = (char *) malloc (strlen (basefilename)+3+strlen (extension)); - wbout1.filename[0]=0; - } - if (wbout2.filename==NULL) - { - wbout2.filename = (char *) malloc (strlen (basefilename)+3+strlen (extension)); - wbout2.filename[0]=0; - } - if (buffer == NULL || pesheaderbuf==NULL || - wbout1.filename == NULL || wbout2.filename == NULL || - subline==NULL || init_file_buffer() || general_608_init()) - { - fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); - } + if (wbout1.filename==NULL) + { + wbout1.filename = (char *) malloc (strlen (basefilename)+3+strlen (extension)); + wbout1.filename[0]=0; + } + if (wbout2.filename==NULL) + { + wbout2.filename = (char *) malloc (strlen (basefilename)+3+strlen (extension)); + wbout2.filename[0]=0; + } + if (buffer == NULL || pesheaderbuf==NULL || + wbout1.filename == NULL || wbout2.filename == NULL || + subline==NULL || init_file_buffer() || general_608_init()) + { + fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); + } if (ccx_options.write_format!=CCX_OF_NULL) { @@ -496,7 +496,7 @@ int main(int argc, char *argv[]) wbout2.fh=open (wbout2.filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE); if (wbout2.fh==-1) { - fatal (EXIT_FILE_CREATION_FAILED, "Failed\n"); + fatal (EXIT_FILE_CREATION_FAILED, "Failed\n"); } } switch (ccx_options.write_format) @@ -534,14 +534,14 @@ int main(int argc, char *argv[]) if (ccx_options.teletext_mode == CCX_TXT_IN_USE) // Here, it would mean it was forced by user telxcc_init(); - fh_out_elementarystream = NULL; - if (ccx_options.out_elementarystream_filename!=NULL) - { - if ((fh_out_elementarystream = fopen (ccx_options.out_elementarystream_filename,"wb"))==NULL) - { - fatal (EXIT_FILE_CREATION_FAILED, "Unable to open clean file: %s\n",ccx_options.out_elementarystream_filename); - } - } + fh_out_elementarystream = NULL; + if (ccx_options.out_elementarystream_filename!=NULL) + { + if ((fh_out_elementarystream = fopen (ccx_options.out_elementarystream_filename,"wb"))==NULL) + { + fatal (EXIT_FILE_CREATION_FAILED, "Unable to open clean file: %s\n",ccx_options.out_elementarystream_filename); + } + } if (ccx_options.line_terminator_lf) encoded_crlf_length = encode_line (encoded_crlf,(unsigned char *) "\n"); else @@ -550,132 +550,132 @@ int main(int argc, char *argv[]) encoded_br_length = encode_line (encoded_br, (unsigned char *) "
"); - build_parity_table(); + build_parity_table(); - // Initialize HDTV caption buffer - init_hdcc(); - init_708(); // Init 708 decoders + // Initialize HDTV caption buffer + init_hdcc(); + init_708(); // Init 708 decoders - time_t start, final; - time(&start); + time_t start, final; + time(&start); - processed_enough=0; - if (ccx_options.binary_concat) - { - total_inputsize=gettotalfilessize(); - if (total_inputsize==-1) - fatal (EXIT_UNABLE_TO_DETERMINE_FILE_SIZE, "Failed to determine total file size.\n"); - } + processed_enough=0; + if (ccx_options.binary_concat) + { + total_inputsize=gettotalfilessize(); + if (total_inputsize==-1) + fatal (EXIT_UNABLE_TO_DETERMINE_FILE_SIZE, "Failed to determine total file size.\n"); + } - while (switch_to_next_file(0) && !processed_enough) - { - prepare_for_new_file(); + while (switch_to_next_file(0) && !processed_enough) + { + prepare_for_new_file(); - if (auto_stream == CCX_SM_AUTODETECT) - { - detect_stream_type(); - switch (stream_mode) - { - case CCX_SM_ELEMENTARY_OR_NOT_FOUND: - mprint ("\rFile seems to be an elementary stream, enabling ES mode\n"); - break; - case CCX_SM_TRANSPORT: - mprint ("\rFile seems to be a transport stream, enabling TS mode\n"); - break; - case CCX_SM_PROGRAM: - mprint ("\rFile seems to be a program stream, enabling PS mode\n"); - break; - case CCX_SM_ASF: - mprint ("\rFile seems to be an ASF, enabling DVR-MS mode\n"); - break; - case CCX_SM_WTV: - mprint ("\rFile seems to be a WTV, enabling WTV mode\n"); - break; - case CCX_SM_MCPOODLESRAW: - mprint ("\rFile seems to be McPoodle raw data\n"); - break; - case CCX_SM_RCWT: - mprint ("\rFile seems to be a raw caption with time data\n"); - break; + if (auto_stream == CCX_SM_AUTODETECT) + { + detect_stream_type(); + switch (stream_mode) + { + case CCX_SM_ELEMENTARY_OR_NOT_FOUND: + mprint ("\rFile seems to be an elementary stream, enabling ES mode\n"); + break; + case CCX_SM_TRANSPORT: + mprint ("\rFile seems to be a transport stream, enabling TS mode\n"); + break; + case CCX_SM_PROGRAM: + mprint ("\rFile seems to be a program stream, enabling PS mode\n"); + break; + case CCX_SM_ASF: + mprint ("\rFile seems to be an ASF, enabling DVR-MS mode\n"); + break; + case CCX_SM_WTV: + mprint ("\rFile seems to be a WTV, enabling WTV mode\n"); + break; + case CCX_SM_MCPOODLESRAW: + mprint ("\rFile seems to be McPoodle raw data\n"); + break; + case CCX_SM_RCWT: + mprint ("\rFile seems to be a raw caption with time data\n"); + break; case CCX_SM_MP4: - mprint ("\rFile seems to be a MP4\n"); - break; + mprint ("\rFile seems to be a MP4\n"); + break; case CCX_SM_HEX_DUMP: - mprint ("\rFile seems to be an hexadecimal dump\n"); - break; - case CCX_SM_MYTH: - case CCX_SM_AUTODETECT: - fatal(EXIT_BUG_BUG, "Cannot be reached!"); - break; - } - } - else - { - stream_mode=auto_stream; - } + mprint ("\rFile seems to be an hexadecimal dump\n"); + break; + case CCX_SM_MYTH: + case CCX_SM_AUTODETECT: + fatal(EXIT_BUG_BUG, "Cannot be reached!"); + break; + } + } + else + { + stream_mode=auto_stream; + } - /* ----------------------------------------------------------------- - MAIN LOOP - ----------------------------------------------------------------- */ + /* ----------------------------------------------------------------- + MAIN LOOP + ----------------------------------------------------------------- */ - // The myth loop autodetect will only be used with ES or PS streams - switch (ccx_options.auto_myth) - { - case 0: - // Use whatever stream mode says - break; - case 1: - // Force stream mode to myth - stream_mode=CCX_SM_MYTH; - break; - case 2: - // autodetect myth files, but only if it does not conflict with - // the current stream mode - switch (stream_mode) - { - case CCX_SM_ELEMENTARY_OR_NOT_FOUND: - case CCX_SM_PROGRAM: - if ( detect_myth() ) - { - stream_mode=CCX_SM_MYTH; - } - break; - default: - // Keep stream_mode - break; - } - break; - } - - switch (stream_mode) - { - case CCX_SM_ELEMENTARY_OR_NOT_FOUND: + // The myth loop autodetect will only be used with ES or PS streams + switch (ccx_options.auto_myth) + { + case 0: + // Use whatever stream mode says + break; + case 1: + // Force stream mode to myth + stream_mode=CCX_SM_MYTH; + break; + case 2: + // autodetect myth files, but only if it does not conflict with + // the current stream mode + switch (stream_mode) + { + case CCX_SM_ELEMENTARY_OR_NOT_FOUND: + case CCX_SM_PROGRAM: + if ( detect_myth() ) + { + stream_mode=CCX_SM_MYTH; + } + break; + default: + // Keep stream_mode + break; + } + break; + } + + switch (stream_mode) + { + case CCX_SM_ELEMENTARY_OR_NOT_FOUND: if (!ccx_options.use_gop_as_pts) // If !0 then the user selected something ccx_options.use_gop_as_pts = 1; // Force GOP timing for ES - case CCX_SM_TRANSPORT: - case CCX_SM_PROGRAM: - case CCX_SM_ASF: - case CCX_SM_WTV: + case CCX_SM_TRANSPORT: + case CCX_SM_PROGRAM: + case CCX_SM_ASF: + case CCX_SM_WTV: if (!ccx_options.use_gop_as_pts) // If !0 then the user selected something ccx_options.use_gop_as_pts = 0; - mprint ("\rAnalyzing data in general mode\n"); - general_loop(); - break; - case CCX_SM_MCPOODLESRAW: - mprint ("\rAnalyzing data in McPoodle raw mode\n"); - raw_loop(); - break; - case CCX_SM_RCWT: - mprint ("\rAnalyzing data in CCExtractor's binary format\n"); - rcwt_loop(); - break; - case CCX_SM_MYTH: - mprint ("\rAnalyzing data in MythTV mode\n"); - show_myth_banner = 1; - myth_loop(); + mprint ("\rAnalyzing data in general mode\n"); + general_loop(); + break; + case CCX_SM_MCPOODLESRAW: + mprint ("\rAnalyzing data in McPoodle raw mode\n"); + raw_loop(); + break; + case CCX_SM_RCWT: + mprint ("\rAnalyzing data in CCExtractor's binary format\n"); + rcwt_loop(); + break; + case CCX_SM_MYTH: + mprint ("\rAnalyzing data in MythTV mode\n"); + show_myth_banner = 1; + myth_loop(); break; case CCX_SM_MP4: - mprint ("\rAnalyzing data with GPAC (MP4 library)\n"); + mprint ("\rAnalyzing data with GPAC (MP4 library)\n"); close_input_file(); // No need to have it open. GPAC will do it for us processmp4 (inputfile[0]); break; @@ -683,107 +683,107 @@ int main(int argc, char *argv[]) close_input_file(); // processhex will open it in text mode processhex (inputfile[0]); break; - case CCX_SM_AUTODETECT: - fatal(EXIT_BUG_BUG, "Cannot be reached!"); - break; - } + case CCX_SM_AUTODETECT: + fatal(EXIT_BUG_BUG, "Cannot be reached!"); + break; + } - mprint("\n"); - dbg_print(CCX_DMT_608, "\nTime stamps after last caption block was written:\n"); - dbg_print(CCX_DMT_608, "Last time stamps: PTS: %s (%+2dF) ", - print_mstime( (LLONG) (sync_pts/(MPEG_CLOCK_FREQ/1000) - +frames_since_ref_time*1000.0/current_fps) ), - frames_since_ref_time); - dbg_print(CCX_DMT_608, "GOP: %s \n", print_mstime(gop_time.ms) ); + mprint("\n"); + dbg_print(CCX_DMT_608, "\nTime stamps after last caption block was written:\n"); + dbg_print(CCX_DMT_608, "Last time stamps: PTS: %s (%+2dF) ", + print_mstime( (LLONG) (sync_pts/(MPEG_CLOCK_FREQ/1000) + +frames_since_ref_time*1000.0/current_fps) ), + frames_since_ref_time); + dbg_print(CCX_DMT_608, "GOP: %s \n", print_mstime(gop_time.ms) ); - // Blocks since last PTS/GOP time stamp. - dbg_print(CCX_DMT_608, "Calc. difference: PTS: %s (%+3lldms incl.) ", - print_mstime( (LLONG) ((sync_pts-min_pts)/(MPEG_CLOCK_FREQ/1000) - + fts_offset + frames_since_ref_time*1000.0/current_fps)), - fts_offset + (LLONG) (frames_since_ref_time*1000.0/current_fps) ); - dbg_print(CCX_DMT_608, "GOP: %s (%+3dms incl.)\n", - print_mstime((LLONG)(gop_time.ms - -first_gop_time.ms - +get_fts_max()-fts_at_gop_start)), - (int)(get_fts_max()-fts_at_gop_start)); - // When padding is active the CC block time should be within - // 1000/29.97 us of the differences. - dbg_print(CCX_DMT_608, "Max. FTS: %s (without caption blocks since then)\n", - print_mstime(get_fts_max())); + // Blocks since last PTS/GOP time stamp. + dbg_print(CCX_DMT_608, "Calc. difference: PTS: %s (%+3lldms incl.) ", + print_mstime( (LLONG) ((sync_pts-min_pts)/(MPEG_CLOCK_FREQ/1000) + + fts_offset + frames_since_ref_time*1000.0/current_fps)), + fts_offset + (LLONG) (frames_since_ref_time*1000.0/current_fps) ); + dbg_print(CCX_DMT_608, "GOP: %s (%+3dms incl.)\n", + print_mstime((LLONG)(gop_time.ms + -first_gop_time.ms + +get_fts_max()-fts_at_gop_start)), + (int)(get_fts_max()-fts_at_gop_start)); + // When padding is active the CC block time should be within + // 1000/29.97 us of the differences. + dbg_print(CCX_DMT_608, "Max. FTS: %s (without caption blocks since then)\n", + print_mstime(get_fts_max())); - if (stat_hdtv) - { - mprint ("\rCC type 0: %d (%s)\n", cc_stats[0], cc_types[0]); - mprint ("CC type 1: %d (%s)\n", cc_stats[1], cc_types[1]); - mprint ("CC type 2: %d (%s)\n", cc_stats[2], cc_types[2]); - mprint ("CC type 3: %d (%s)\n", cc_stats[3], cc_types[3]); - } - mprint ("\nTotal frames time: %s (%u frames at %.2ffps)\n", - print_mstime( (LLONG)(total_frames_count*1000/current_fps) ), - total_frames_count, current_fps); - if (total_pulldownframes) - mprint ("incl. pulldown frames: %s (%u frames at %.2ffps)\n", - print_mstime( (LLONG)(total_pulldownframes*1000/current_fps) ), - total_pulldownframes, current_fps); - if (pts_set >= 1 && min_pts != 0x01FFFFFFFFLL) - { - LLONG postsyncms = (LLONG) (frames_since_last_gop*1000/current_fps); - mprint ("\nMin PTS: %s\n", - print_mstime( min_pts/(MPEG_CLOCK_FREQ/1000) - 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( sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms)); + if (stat_hdtv) + { + mprint ("\rCC type 0: %d (%s)\n", cc_stats[0], cc_types[0]); + mprint ("CC type 1: %d (%s)\n", cc_stats[1], cc_types[1]); + mprint ("CC type 2: %d (%s)\n", cc_stats[2], cc_types[2]); + mprint ("CC type 3: %d (%s)\n", cc_stats[3], cc_types[3]); + } + mprint ("\nTotal frames time: %s (%u frames at %.2ffps)\n", + print_mstime( (LLONG)(total_frames_count*1000/current_fps) ), + total_frames_count, current_fps); + if (total_pulldownframes) + mprint ("incl. pulldown frames: %s (%u frames at %.2ffps)\n", + print_mstime( (LLONG)(total_pulldownframes*1000/current_fps) ), + total_pulldownframes, current_fps); + if (pts_set >= 1 && min_pts != 0x01FFFFFFFFLL) + { + LLONG postsyncms = (LLONG) (frames_since_last_gop*1000/current_fps); + mprint ("\nMin PTS: %s\n", + print_mstime( min_pts/(MPEG_CLOCK_FREQ/1000) - 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( sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms)); - mprint ("Length: %s\n", - print_mstime( sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms - - min_pts/(MPEG_CLOCK_FREQ/1000) + fts_offset )); - } - // 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", - print_mstime(first_gop_time.ms)); - mprint ("Final GOP time: %s%+3dF\n", - print_mstime(gop_time.ms), - frames_since_last_gop); - mprint ("Diff. GOP length: %s%+3dF", - print_mstime(gop_time.ms - first_gop_time.ms), - frames_since_last_gop); - mprint (" (%s)\n", - print_mstime(gop_time.ms - first_gop_time.ms - +(LLONG) ((frames_since_last_gop)*1000/29.97)) ); - } + mprint ("Length: %s\n", + print_mstime( sync_pts/(MPEG_CLOCK_FREQ/1000) + postsyncms + - min_pts/(MPEG_CLOCK_FREQ/1000) + fts_offset )); + } + // 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", + print_mstime(first_gop_time.ms)); + mprint ("Final GOP time: %s%+3dF\n", + print_mstime(gop_time.ms), + frames_since_last_gop); + mprint ("Diff. GOP length: %s%+3dF", + print_mstime(gop_time.ms - first_gop_time.ms), + frames_since_last_gop); + mprint (" (%s)\n", + print_mstime(gop_time.ms - first_gop_time.ms + +(LLONG) ((frames_since_last_gop)*1000/29.97)) ); + } - if (false_pict_header) - mprint ("\nNumber of likely false picture headers (discarded): %d\n",false_pict_header); + if (false_pict_header) + mprint ("\nNumber of likely false picture headers (discarded): %d\n",false_pict_header); - if (stat_numuserheaders) - mprint("\nTotal user data fields: %d\n", stat_numuserheaders); - if (stat_dvdccheaders) - mprint("DVD-type user data fields: %d\n", stat_dvdccheaders); - if (stat_scte20ccheaders) - mprint("SCTE-20 type user data fields: %d\n", stat_scte20ccheaders); - if (stat_replay4000headers) - mprint("ReplayTV 4000 user data fields: %d\n", stat_replay4000headers); - if (stat_replay5000headers) - mprint("ReplayTV 5000 user data fields: %d\n", stat_replay5000headers); - if (stat_hdtv) - mprint("HDTV type user data fields: %d\n", stat_hdtv); - if (stat_dishheaders) - mprint("Dish Network user data fields: %d\n", stat_dishheaders); - if (stat_divicom) - { - mprint("CEA608/Divicom user data fields: %d\n", stat_divicom); + if (stat_numuserheaders) + mprint("\nTotal user data fields: %d\n", stat_numuserheaders); + if (stat_dvdccheaders) + mprint("DVD-type user data fields: %d\n", stat_dvdccheaders); + if (stat_scte20ccheaders) + mprint("SCTE-20 type user data fields: %d\n", stat_scte20ccheaders); + if (stat_replay4000headers) + mprint("ReplayTV 4000 user data fields: %d\n", stat_replay4000headers); + if (stat_replay5000headers) + mprint("ReplayTV 5000 user data fields: %d\n", stat_replay5000headers); + if (stat_hdtv) + mprint("HDTV type user data fields: %d\n", stat_hdtv); + if (stat_dishheaders) + mprint("Dish Network user data fields: %d\n", stat_dishheaders); + if (stat_divicom) + { + mprint("CEA608/Divicom user data fields: %d\n", stat_divicom); - mprint("\n\nNOTE! The CEA 608 / Divicom standard encoding for closed\n"); - mprint("caption is not well understood!\n\n"); - mprint("Please submit samples to the developers.\n\n\n"); - } + mprint("\n\nNOTE! The CEA 608 / Divicom standard encoding for closed\n"); + mprint("caption is not well understood!\n\n"); + mprint("Please submit samples to the developers.\n\n\n"); + } - // Add one frame as fts_max marks the beginning of the last frame, - // but we need the end. - fts_global += fts_max + (LLONG) (1000.0/current_fps); + // Add one frame as fts_max marks the beginning of the last frame, + // but we need the end. + fts_global += fts_max + (LLONG) (1000.0/current_fps); // CFS: At least in Hauppage mode, cb_field can be responsible for ALL the // 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 @@ -792,93 +792,93 @@ int main(int argc, char *argv[]) fts_global += cb_field1*1001/3; else fts_global += cb_field2*1001/3; - // Reset counters - This is needed if some captions are still buffered - // 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; - } // file loop - close_input_file(); - - if (fh_out_elementarystream!=NULL) - fclose (fh_out_elementarystream); + // Reset counters - This is needed if some captions are still buffered + // 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; + } // file loop + close_input_file(); + + if (fh_out_elementarystream!=NULL) + fclose (fh_out_elementarystream); - flushbuffer (&wbout1,false); - flushbuffer (&wbout2,false); + flushbuffer (&wbout1,false); + flushbuffer (&wbout2,false); - prepare_for_new_file (); // To reset counters used by handle_end_of_data() + prepare_for_new_file (); // To reset counters used by handle_end_of_data() - if (wbout1.fh!=-1) - { - if (ccx_options.write_format==CCX_OF_SPUPNG) - { + if (wbout1.fh!=-1) + { + if (ccx_options.write_format==CCX_OF_SPUPNG) + { handle_end_of_data(&context_cc608_field_1); - } - if (ccx_options.write_format==CCX_OF_SMPTETT || ccx_options.write_format==CCX_OF_SAMI || + } + if (ccx_options.write_format==CCX_OF_SMPTETT || ccx_options.write_format==CCX_OF_SAMI || ccx_options.write_format==CCX_OF_SRT || ccx_options.write_format==CCX_OF_TRANSCRIPT) - { + { handle_end_of_data(&context_cc608_field_1); - } - else if(ccx_options.write_format==CCX_OF_RCWT) - { - // Write last header and data - writercwtdata (NULL); - } - if (ccx_options.end_credits_text!=NULL) + } + else if(ccx_options.write_format==CCX_OF_RCWT) + { + // Write last header and data + writercwtdata (NULL); + } + if (ccx_options.end_credits_text!=NULL) try_to_add_end_credits(&context_cc608_field_1); write_subtitle_file_footer(context_cc608_field_1.out); - } - if (wbout2.fh!=-1) - { - if (ccx_options.write_format==CCX_OF_SPUPNG) - { + } + if (wbout2.fh!=-1) + { + if (ccx_options.write_format==CCX_OF_SPUPNG) + { handle_end_of_data(&context_cc608_field_2); - } - if (ccx_options.write_format==CCX_OF_SMPTETT || ccx_options.write_format==CCX_OF_SAMI || + } + if (ccx_options.write_format==CCX_OF_SMPTETT || ccx_options.write_format==CCX_OF_SAMI || ccx_options.write_format==CCX_OF_SRT || ccx_options.write_format==CCX_OF_TRANSCRIPT) - { + { handle_end_of_data(&context_cc608_field_2); - } - if (ccx_options.end_credits_text!=NULL) + } + if (ccx_options.end_credits_text!=NULL) try_to_add_end_credits(&context_cc608_field_2); write_subtitle_file_footer(context_cc608_field_2.out); - } + } telxcc_close(); - flushbuffer (&wbout1,true); - flushbuffer (&wbout2,true); - time (&final); + flushbuffer (&wbout1,true); + flushbuffer (&wbout2,true); + time (&final); - long proc_time=(long) (final-start); - mprint ("\rDone, processing time = %ld seconds\n", proc_time); - if (proc_time>0) - { - LLONG ratio=(get_fts_max()/10)/proc_time; - unsigned s1=(unsigned) (ratio/100); - unsigned s2=(unsigned) (ratio%100); - mprint ("Performance (real length/process time) = %u.%02u\n", - s1, s2); - } - dbg_print(CCX_DMT_708, "The 708 decoder was reset [%d] times.\n",resets_708); + long proc_time=(long) (final-start); + mprint ("\rDone, processing time = %ld seconds\n", proc_time); + if (proc_time>0) + { + LLONG ratio=(get_fts_max()/10)/proc_time; + unsigned s1=(unsigned) (ratio/100); + unsigned s2=(unsigned) (ratio%100); + mprint ("Performance (real length/process time) = %u.%02u\n", + s1, s2); + } + dbg_print(CCX_DMT_708, "The 708 decoder was reset [%d] times.\n",resets_708); if (ccx_options.teletext_mode == CCX_TXT_IN_USE) mprint ( "Teletext decoder: %"PRIu32" packets processed, %"PRIu32" SRT frames written.\n", tlt_packet_counter, tlt_frames_produced); - if (processed_enough) - { - mprint ("\rNote: Processing was cancelled before all data was processed because\n"); - mprint ("\rone or more user-defined limits were reached.\n"); - } + if (processed_enough) + { + mprint ("\rNote: Processing was cancelled before all data was processed because\n"); + mprint ("\rone or more user-defined limits were reached.\n"); + } if (ccblocks_in_avc_lost>0) { mprint ("Total caption blocks received: %d\n", ccblocks_in_avc_total); mprint ("Total caption blocks lost: %d\n", ccblocks_in_avc_lost); } - mprint ("This is beta software. Report issues to carlos at ccextractor org...\n"); - if (show_myth_banner) - { - mprint ("NOTICE: Due to the major rework in 0.49, we needed to change part of the timing\n"); - mprint ("code in the MythTV's branch. Please report results to the address above. If\n"); - mprint ("something is broken it will be fixed. Thanks\n"); - } + mprint ("This is beta software. Report issues to carlos at ccextractor org...\n"); + if (show_myth_banner) + { + mprint ("NOTICE: Due to the major rework in 0.49, we needed to change part of the timing\n"); + mprint ("code in the MythTV's branch. Please report results to the address above. If\n"); + mprint ("something is broken it will be fixed. Thanks\n"); + } return EXIT_OK; } diff --git a/src/ccextractor.h b/src/ccextractor.h index c6c9e319..d960e743 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -28,9 +28,9 @@ extern int ccblocks_in_avc_lost; // CC blocks found by the AVC code lost due to struct ccx_boundary_time { - int hh,mm,ss; - LLONG time_in_ms; - int set; + int hh,mm,ss; + LLONG time_in_ms; + int set; }; struct ccx_s_options // Options from user parameters @@ -110,11 +110,11 @@ struct ccx_s_options // Options from user parameters struct ts_payload { - unsigned char *start; // Payload start - unsigned length; // Payload length - unsigned pesstart; // PES or PSI start - unsigned pid; // Stream PID - int counter; // continuity counter + unsigned char *start; // Payload start + unsigned length; // Payload length + unsigned pesstart; // PES or PSI start + unsigned pid; // Stream PID + int counter; // continuity counter int transport_error; // 0 = packet OK, non-zero damaged }; @@ -138,22 +138,22 @@ struct PMT_entry struct ccx_s_write { - int fh; - char *filename; + int fh; + char *filename; void* spupng_data; }; struct gop_time_code { - int drop_frame_flag; - int time_code_hours; - int time_code_minutes; - int marker_bit; - int time_code_seconds; - int time_code_pictures; - int inited; - LLONG ms; + int drop_frame_flag; + int time_code_hours; + int time_code_minutes; + int marker_bit; + int time_code_seconds; + int time_code_pictures; + int inited; + LLONG ms; }; @@ -176,15 +176,15 @@ struct file_report_t // Stuff for telcc.cpp struct ccx_s_teletext_config { - uint8_t verbose : 1; // should telxcc be verbose? - uint16_t page; // teletext page containing cc we want to filter - uint16_t tid; // 13-bit packet ID for teletext stream - double offset; // time offset in seconds - uint8_t bom : 1; // print UTF-8 BOM characters at the beginning of output - uint8_t nonempty : 1; // produce at least one (dummy) frame - // uint8_t se_mode : 1; // search engine compatible mode => Uses CCExtractor's write_format - // uint64_t utc_refvalue; // UTC referential value => Moved to CCExtractor global, so can be used for 608 too - uint16_t user_page; // Page selected by user, which MIGHT be different to 'page' depending on autodetection stuff + uint8_t verbose : 1; // should telxcc be verbose? + uint16_t page; // teletext page containing cc we want to filter + uint16_t tid; // 13-bit packet ID for teletext stream + double offset; // time offset in seconds + uint8_t bom : 1; // print UTF-8 BOM characters at the beginning of output + uint8_t nonempty : 1; // produce at least one (dummy) frame + // uint8_t se_mode : 1; // search engine compatible mode => Uses CCExtractor's write_format + // uint64_t utc_refvalue; // UTC referential value => Moved to CCExtractor global, so can be used for 608 too + uint16_t user_page; // Page selected by user, which MIGHT be different to 'page' depending on autodetection stuff }; #define buffered_skip(bytes) if (bytes<=bytesinbuffer-filebuffer_pos) { \