struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt) { int ret = 0; struct lib_ccx_ctx *ctx; struct ccx_decoder_608_report *report_608; struct ccx_decoders_common_settings_t *dec_setting; ctx = malloc(sizeof(struct lib_ccx_ctx)); if(!ctx) return NULL; memset(ctx,0,sizeof(struct lib_ccx_ctx)); report_608 = malloc(sizeof(struct ccx_decoder_608_report)); if (!report_608) return NULL; memset(report_608,0,sizeof(struct ccx_decoder_608_report)); ctx->capbufsize = 20000; ctx->capbuf = NULL; ctx->capbuflen = 0; // Bytes read in capbuf // Initialize some constants init_ts(ctx); init_avc(); ctx->stream_mode = CCX_SM_ELEMENTARY_OR_NOT_FOUND; ctx->auto_stream = opt->auto_stream; ctx->m2ts = opt->m2ts; ctx->screens_to_process = -1; ctx->current_file = -1; ctx->infd = -1;//Set to -1 to indicate no file is open. // Set logging functions for libraries ccx_common_logging.debug_ftn = &dbg_print; ccx_common_logging.debug_mask = opt->debug_mask; ccx_common_logging.fatal_ftn = &fatal; ccx_common_logging.log_ftn = &mprint; ccx_common_logging.gui_ftn = &activity_library_process; // Need to set the 608 data for the report to the correct variable. ctx->freport.data_from_608 = report_608; // Same applies for 708 data ctx->freport.data_from_708 = &ccx_decoder_708_report; // Init shared decoder settings dec_setting = init_decoder_setting(opt); ctx->dec_ctx = init_cc_decode(dec_setting); dinit_decoder_setting(&dec_setting); // Init encoder helper variables ccx_encoders_helpers_setup(opt->encoding, opt->nofontcolor, opt->notypesetting, opt->trim_subs); //Initialize input files ctx->inputfile = opt->inputfile; ctx->num_input_files = opt->num_input_files; ret = init_ctx_input(opt, ctx); if (ret < 0) { goto end; } ret = init_ctx_extension(opt, ctx); if (ret < 0) { goto end; } // Init 708 decoder(s) ccx_decoders_708_init_library(ctx->basefilename, ctx->extension, opt->print_file_reports); // Set output structures for the 608 decoder //ctx->dec_ctx->context_cc608_field_1->out = ctx->dec_ctx->wbout1; //ctx->dec_ctx->context_cc608_field_2->out = ctx->dec_ctx->wbout2; // Init XDS buffers ccx_decoders_xds_init_library(&opt->transcript_settings, ctx->subs_delay, opt->millis_separator); //xds_cea608_test(); ctx->subs_delay = opt->subs_delay; ctx->wbout1.filename = opt->wbout2.filename; ctx->wbout2.filename = opt->wbout2.filename; ctx->buffer = (unsigned char *) malloc (BUFSIZE); ctx->pesheaderbuf = (unsigned char *) malloc (188); // Never larger anyway // Init timing ccx_common_timing_init(&ctx->past,opt->nosync); ctx->cc_to_stdout = opt->cc_to_stdout; ctx->hauppauge_mode = opt->hauppauge_mode; ctx->live_stream = opt->live_stream; ctx->binary_concat = opt->binary_concat; build_parity_table(); end: if (ret < 0) { free(ctx); return NULL; } return ctx; }
struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *setting) { struct lib_cc_decode *ctx = NULL; ctx = malloc(sizeof(struct lib_cc_decode)); if(!ctx) return NULL; ctx->avc_ctx = init_avc(); ctx->codec = setting->codec; ctx->timing = init_timing_ctx(&ccx_common_timing_settings); setting->settings_dtvcc->timing = ctx->timing; setting->settings_608->no_rollup = setting->no_rollup; setting->settings_dtvcc->no_rollup = setting->no_rollup; ctx->no_rollup = setting->no_rollup; ctx->noscte20 = setting->noscte20; ctx->dtvcc = ccx_dtvcc_init(setting->settings_dtvcc); ctx->dtvcc->is_active = setting->settings_dtvcc->enabled; if(setting->codec == CCX_CODEC_ATSC_CC) { // Prepare 608 context ctx->context_cc608_field_1 = ccx_decoder_608_init_library( setting->settings_608, setting->cc_channel, 1, &ctx->processed_enough, setting->cc_to_stdout, setting->output_format, ctx->timing ); ctx->context_cc608_field_2 = ccx_decoder_608_init_library( setting->settings_608, setting->cc_channel, 2, &ctx->processed_enough, setting->cc_to_stdout, setting->output_format, ctx->timing ); } else { ctx->context_cc608_field_1 = NULL; ctx->context_cc608_field_2 = NULL; } ctx->current_field = 1; ctx->private_data = setting->private_data; ctx->fix_padding = setting->fix_padding; ctx->write_format = setting->output_format; ctx->subs_delay = setting->subs_delay; ctx->extract = setting->extract; ctx->fullbin = setting->fullbin; ctx->hauppauge_mode = setting->hauppauge_mode; ctx->program_number = setting->program_number; ctx->processed_enough = 0; ctx->max_gop_length = 0; ctx->has_ccdata_buffered = 0; ctx->in_bufferdatatype = CCX_UNKNOWN; ctx->frames_since_last_gop = 0; ctx->total_pulldownfields = 0; ctx->total_pulldownframes = 0; ctx->stat_numuserheaders = 0; ctx->stat_dvdccheaders = 0; ctx->stat_scte20ccheaders = 0; ctx->stat_replay5000headers = 0; ctx->stat_replay4000headers = 0; ctx->stat_dishheaders = 0; ctx->stat_hdtv = 0; ctx->stat_divicom = 0; ctx->false_pict_header = 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)); if (setting->send_to_srv) ctx->writedata = net_send_cc; else if (setting->output_format==CCX_OF_RAW || setting->output_format==CCX_OF_DVDRAW || setting->output_format==CCX_OF_RCWT ) ctx->writedata = writeraw; else if (setting->output_format==CCX_OF_SMPTETT || setting->output_format==CCX_OF_SAMI || setting->output_format==CCX_OF_SRT || setting->output_format==CCX_OF_SSA || setting->output_format == CCX_OF_WEBVTT || setting->output_format==CCX_OF_TRANSCRIPT || setting->output_format==CCX_OF_SPUPNG || setting->output_format==CCX_OF_SIMPLE_XML || setting->output_format==CCX_OF_G608 || setting->output_format==CCX_OF_NULL || setting->output_format==CCX_OF_CURL) ctx->writedata = process608; else fatal(CCX_COMMON_EXIT_BUG_BUG, "Invalid Write Format Selected"); memset (&ctx->dec_sub, 0,sizeof(ctx->dec_sub)); // Initialize HDTV caption buffer init_hdcc(ctx); ctx->current_hor_size = 0; ctx->current_vert_size = 0; ctx->current_aspect_ratio = 0; ctx->current_frame_rate = 4; // Assume standard fps, 29.97 //Variables used while parsing elementry stream ctx->no_bitstream_error = 0; ctx->saw_seqgoppic = 0; ctx->in_pic_data = 0; ctx->current_progressive_sequence = 2; ctx->current_pulldownfields = 32768; ctx->temporal_reference = 0; ctx->maxtref = 0; ctx->picture_coding_type = CCX_FRAME_TYPE_RESET_OR_UNKNOWN; ctx->picture_structure = 0; ctx->top_field_first = 0; ctx->repeat_first_field = 0; ctx->progressive_frame = 0; ctx->pulldownfields = 0; //es parser related variable ends here memset(ctx->cc_stats, 0, 4 * sizeof(int)); ctx->anchor_seq_number = -1; // Init XDS buffers if(setting->output_format!=CCX_OF_TRANSCRIPT) { setting->xds_write_to_file = 0; } ctx->xds_ctx = ccx_decoders_xds_init_library(ctx->timing, setting->xds_write_to_file); ctx->vbi_decoder = NULL; return ctx; }
struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt) { int ret = 0; struct lib_ccx_ctx *ctx; struct ccx_decoder_608_report *report_608; ctx = malloc(sizeof(struct lib_ccx_ctx)); if(!ctx) return NULL; memset(ctx,0,sizeof(struct lib_ccx_ctx)); report_608 = malloc(sizeof(struct ccx_decoder_608_report)); if (!report_608) return NULL; memset(report_608,0,sizeof(struct ccx_decoder_608_report)); // Initialize some constants ctx->screens_to_process = -1; ctx->current_file = -1; // Set logging functions for libraries ccx_common_logging.debug_ftn = &dbg_print; ccx_common_logging.debug_mask = opt->debug_mask; ccx_common_logging.fatal_ftn = &fatal; ccx_common_logging.log_ftn = &mprint; ccx_common_logging.gui_ftn = &activity_library_process; // Init shared decoder settings ctx->dec_global_setting = init_decoder_setting(opt); if(!ctx->dec_global_setting) return NULL; // Need to set the 608 data for the report to the correct variable. ctx->freport.data_from_608 = report_608; ctx->dec_global_setting->settings_608->report = report_608; // Same applies for 708 data ctx->freport.data_from_708 = &ccx_decoder_708_report; //Initialize input files ctx->inputfile = opt->inputfile; ctx->num_input_files = opt->num_input_files; ret = init_ctx_outbase(opt, ctx); if (ret < 0) { goto end; } // Init 708 decoder(s) ccx_decoders_708_init_library(opt->print_file_reports); // Init XDS buffers ccx_decoders_xds_init_library(&opt->transcript_settings, ctx->subs_delay, opt->millis_separator); //xds_cea608_test(); ctx->subs_delay = opt->subs_delay; ctx->pesheaderbuf = (unsigned char *) malloc (188); // Never larger anyway ctx->cc_to_stdout = opt->cc_to_stdout; ctx->hauppauge_mode = opt->hauppauge_mode; ctx->live_stream = opt->live_stream; ctx->binary_concat = opt->binary_concat; build_parity_table(); ctx->demux_ctx = init_demuxer(ctx, &opt->demux_cfg); INIT_LIST_HEAD(&ctx->dec_ctx_head); INIT_LIST_HEAD(&ctx->enc_ctx_head); // Init timing ccx_common_timing_init(&ctx->demux_ctx->past,opt->nosync); ctx->multiprogram = opt->multiprogram; ctx->write_format = opt->write_format; end: if (ret != EXIT_OK) { free(ctx); return NULL; } return ctx; }