Beispiel #1
0
void dinit_libraries( struct lib_ccx_ctx **ctx)
{
	struct lib_ccx_ctx *lctx = *ctx;
	struct encoder_ctx *enc_ctx;
	struct lib_cc_decode *dec_ctx;
	struct lib_cc_decode *dec_ctx1;
	int i;
	list_for_each_entry_safe(dec_ctx, dec_ctx1, &lctx->dec_ctx_head, list, struct lib_cc_decode)
	{
		LLONG cfts;
		if (dec_ctx->codec == CCX_CODEC_DVB)
			dvbsub_close_decoder(&dec_ctx->private_data);
		//Test memory for teletext
		else if (dec_ctx->codec == CCX_CODEC_TELETEXT)
			telxcc_close(&dec_ctx->private_data, &dec_ctx->dec_sub);
		else if (dec_ctx->codec == CCX_CODEC_ISDB_CC)
			delete_isdb_decoder(&dec_ctx->private_data);

		flush_cc_decode(dec_ctx, &dec_ctx->dec_sub);
		cfts = get_fts(dec_ctx->timing, dec_ctx->current_field);
		enc_ctx = get_encoder_by_pn(lctx, dec_ctx->program_number);
		if (enc_ctx && dec_ctx->dec_sub.got_output == CCX_TRUE)
		{
			encode_sub(enc_ctx, &dec_ctx->dec_sub);
			dec_ctx->dec_sub.got_output = CCX_FALSE;
		}
		list_del(&dec_ctx->list);
		dinit_cc_decode(&dec_ctx);
		if (enc_ctx)
		{
			list_del(&enc_ctx->list);
			dinit_encoder(&enc_ctx, cfts);
		}
	}

	// free EPG memory
	EPG_free(lctx);
	freep(&lctx->freport.data_from_608);
	freep(&lctx->freport.data_from_708);
	ccx_demuxer_delete(&lctx->demux_ctx);
	dinit_decoder_setting(&lctx->dec_global_setting);
	freep(&ccx_options.enc_cfg.output_filename);
	freep(&lctx->basefilename);
	freep(&lctx->pesheaderbuf);
	for(i = 0;i < lctx->num_input_files;i++)
		freep(&lctx->inputfile[i]);
	freep(&lctx->inputfile);
	freep(ctx);
}
Beispiel #2
0
void dinit_libraries( struct lib_ccx_ctx **ctx)
{
	struct lib_ccx_ctx *lctx = *ctx;
	struct encoder_ctx *enc_ctx;
	struct lib_cc_decode *dec_ctx;
	struct lib_cc_decode *dec_ctx1;
	int i;
	list_for_each_entry_safe(dec_ctx, dec_ctx1, &lctx->dec_ctx_head, list, struct lib_cc_decode)
	{
		flush_cc_decode(dec_ctx, &dec_ctx->dec_sub);
		enc_ctx = get_encoder_by_pn(lctx, dec_ctx->program_number);
		if (enc_ctx && dec_ctx->dec_sub.got_output == CCX_TRUE)
		{
			encode_sub(enc_ctx, &dec_ctx->dec_sub);
			dec_ctx->dec_sub.got_output = CCX_FALSE;
		}
		list_del(&dec_ctx->list);
		dinit_cc_decode(&dec_ctx);
		if (enc_ctx)
		{
			list_del(&enc_ctx->list);
			dinit_encoder(&enc_ctx);
		}
	}


	// free EPG memory
	EPG_free(lctx);
	freep(&lctx->freport.data_from_608);
	ccx_demuxer_delete(&lctx->demux_ctx);
	dinit_decoder_setting(&lctx->dec_global_setting);
	freep(&ccx_options.enc_cfg.output_filename);
	freep(&lctx->basefilename);
	freep(&lctx->pesheaderbuf);
	for(i = 0;i < lctx->num_input_files;i++)
		freep(&lctx->inputfile[i]);
	freep(&lctx->inputfile);
	freep(ctx);
}
Beispiel #3
0
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;
}