struct lib_cc_decode *update_decoder_list(struct lib_ccx_ctx *ctx) { struct lib_cc_decode *dec_ctx; list_for_each_entry(dec_ctx, &ctx->dec_ctx_head, list, struct lib_cc_decode) { return dec_ctx; } if (list_empty(&ctx->dec_ctx_head)) { ctx->dec_global_setting->codec = CCX_CODEC_ATSC_CC; ctx->dec_global_setting->program_number = 0; dec_ctx = init_cc_decode(ctx->dec_global_setting); if (!dec_ctx) fatal(EXIT_NOT_ENOUGH_MEMORY, "In update_decoder_list: Not enough memory to init_cc_decode.\n"); list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) ); //DVB related dec_ctx->prev = NULL; dec_ctx->dec_sub.prev = NULL; if (dec_ctx->codec == CCX_CODEC_DVB) { dec_ctx->prev = malloc(sizeof(struct lib_cc_decode)); dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle)); memset (dec_ctx->dec_sub.prev, 0,sizeof(struct cc_subtitle)); } } return dec_ctx; }
struct lib_cc_decode *update_decoder_list_cinfo(struct lib_ccx_ctx *ctx, struct cap_info* cinfo) { struct lib_cc_decode *dec_ctx = NULL; list_for_each_entry(dec_ctx, &ctx->dec_ctx_head, list, struct lib_cc_decode) { if (!cinfo || ctx->multiprogram == CCX_FALSE) return dec_ctx; if (dec_ctx->program_number == cinfo->program_number) return dec_ctx; } if(cinfo) { ctx->dec_global_setting->program_number = cinfo->program_number; ctx->dec_global_setting->codec = cinfo->codec; ctx->dec_global_setting->private_data = cinfo->codec_private_data; } else { ctx->dec_global_setting->program_number = 0; ctx->dec_global_setting->codec = CCX_CODEC_ATSC_CC; } if(ctx->multiprogram == CCX_FALSE) { if (list_empty(&ctx->dec_ctx_head)) { dec_ctx = init_cc_decode(ctx->dec_global_setting); if (!dec_ctx) fatal(EXIT_NOT_ENOUGH_MEMORY, "In update_decoder_list_cinfo: Not enough memory allocating dec_ctx (multiprogram == false)\n"); list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) ); } } else { dec_ctx = init_cc_decode(ctx->dec_global_setting); if (!dec_ctx) fatal(EXIT_NOT_ENOUGH_MEMORY, "In update_decoder_list_cinfo: Not enough memory allocating dec_ctx ((multiprogram == true)\n"); list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) ); } //DVB related dec_ctx->prev = NULL; dec_ctx->dec_sub.prev = NULL; return dec_ctx; }
struct lib_cc_decode *update_decoder_list(struct lib_ccx_ctx *ctx) { struct lib_cc_decode *dec_ctx; list_for_each_entry(dec_ctx, &ctx->dec_ctx_head, list, struct lib_cc_decode) { return dec_ctx; } if (list_empty(&ctx->dec_ctx_head)) { ctx->dec_global_setting->codec = CCX_CODEC_ATSC_CC; ctx->dec_global_setting->program_number = 0; dec_ctx = init_cc_decode(ctx->dec_global_setting); if (!dec_ctx) fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) ); } return dec_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; 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; }