Пример #1
0
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;

	// Prepare 608 context
	ctx->context_cc608_field_1 = ccx_decoder_608_init_library(
		ccx_options.settings_608,
		ccx_options.cc_channel,
		1,
		ccx_options.trim_subs,
		ccx_options.encoding,
		&ctx->processed_enough,
		setting->cc_to_stdout,
		setting->subs_delay,
		setting->output_format
		);
	ctx->context_cc608_field_2 = ccx_decoder_608_init_library(
		ccx_options.settings_608,
		ccx_options.cc_channel,
		2,
		ccx_options.trim_subs,
		ccx_options.encoding,
		&ctx->processed_enough,
		setting->cc_to_stdout,
		setting->subs_delay,
		setting->output_format
		);

	ctx->fix_padding = setting->fix_padding;
	ctx->write_format =  setting->output_format;
	ctx->subs_delay =  setting->subs_delay;
	ctx->wbout1 = setting->wbout1;
	memcpy(&ctx->extraction_start, &setting->extraction_start,sizeof(struct ccx_boundary_time));
	memcpy(&ctx->extraction_end, &setting->extraction_end,sizeof(struct ccx_boundary_time));
	return ctx;
}
Пример #2
0
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;
}