static void ddl_encoder_frame_run_callback(struct ddl_context
					   *ddl_context)
{
	struct ddl_client_context *ddl = ddl_context->current_ddl;
	struct ddl_encoder_data *encoder = &(ddl->codec_data.encoder);
	u32 eos_present = false;

	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)
		) {
		VIDC_LOG_STRING("STATE-CRITICAL-ENCFRMRUN");
		ddl_client_fatal_cb(ddl_context);
		return;
	}

	VIDC_LOG_STRING("ENC_FRM_RUN_DONE");

	ddl_move_command_state(ddl_context, DDL_CMD_INVALID);
	vidc_720p_enc_frame_info(&encoder->enc_frame_info);

	ddl->output_frame.vcd_frm.ip_frm_tag =
		ddl->input_frame.vcd_frm.ip_frm_tag;
	ddl->output_frame.vcd_frm.data_len =
		encoder->enc_frame_info.enc_size;
	ddl->output_frame.vcd_frm.flags |= VCD_FRAME_FLAG_ENDOFFRAME;
	ddl_get_frame
		(&(ddl->output_frame.vcd_frm),
		 encoder->enc_frame_info.frame);
	ddl_process_encoder_metadata(ddl);

	ddl_encode_dynamic_property(ddl, false);

	ddl->input_frame.frm_trans_end = false;
	ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS,
		&(ddl->input_frame), sizeof(struct ddl_frame_data_tag),
		(u32 *) ddl, ddl_context->client_data);

	if (vidc_msg_timing)
		ddl_calc_core_proc_time(__func__, ENC_OP_TIME);

	/* check the presence of EOS */
   eos_present =
	((VCD_FRAME_FLAG_EOS & ddl->input_frame.vcd_frm.flags));

	ddl->output_frame.frm_trans_end = !eos_present;
	ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS,
		&(ddl->output_frame),	sizeof(struct ddl_frame_data_tag),
		(u32 *) ddl, ddl_context->client_data);

	if (eos_present) {
		VIDC_LOG_STRING("ENC-EOS_DONE");
		ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE,
				VCD_S_SUCCESS, NULL, 0,	(u32 *)ddl,
				ddl_context->client_data);
	}

	ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME);
	DDL_IDLE(ddl_context);
}
Пример #2
0
static void ddl_encoder_frame_run_callback(struct ddl_context_type
					   *p_ddl_context)
{
	struct ddl_client_context_type *p_ddl = p_ddl_context->p_current_ddl;
	struct ddl_encoder_data_type *p_encoder = &(p_ddl->codec_data.encoder);
	u32 b_eos_present = FALSE;

	if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE)
		) {
		VIDC_LOG_STRING("STATE-CRITICAL-ENCFRMRUN");
		ddl_client_fatal_cb(p_ddl_context);
		return;
	}

	VIDC_LOG_STRING("ENC_FRM_RUN_DONE");

	ddl_move_command_state(p_ddl_context, DDL_CMD_INVALID);
	vidc_720p_enc_frame_info(&p_encoder->enc_frame_info);

	p_ddl->output_frame.vcd_frm.n_ip_frm_tag =
		p_ddl->input_frame.vcd_frm.n_ip_frm_tag;
	p_ddl->output_frame.vcd_frm.n_data_len =
		p_encoder->enc_frame_info.n_enc_size;
	p_ddl->output_frame.vcd_frm.n_flags |= VCD_FRAME_FLAG_ENDOFFRAME;
	ddl_get_frame_type
		(&(p_ddl->output_frame.vcd_frm),
		 p_encoder->enc_frame_info.n_frame_type);
	ddl_process_encoder_metadata(p_ddl);

	ddl_encode_dynamic_property(p_ddl, FALSE);

	p_ddl->input_frame.b_frm_trans_end = FALSE;
	p_ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS,
		&(p_ddl->input_frame), sizeof(struct ddl_frame_data_type_tag),
		(u32 *) p_ddl, p_ddl_context->p_client_data);

#ifdef CORE_TIMING_INFO
	ddl_calc_core_time(1);
#endif
	
   b_eos_present =
	((VCD_FRAME_FLAG_EOS & p_ddl->input_frame.vcd_frm.n_flags));

	p_ddl->output_frame.b_frm_trans_end = !b_eos_present;
	p_ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, VCD_S_SUCCESS,
		&(p_ddl->output_frame),	sizeof(struct ddl_frame_data_type_tag),
		(u32 *) p_ddl, p_ddl_context->p_client_data);

	if (b_eos_present) {
		VIDC_LOG_STRING("ENC-EOS_DONE");
		p_ddl_context->ddl_callback(VCD_EVT_RESP_EOS_DONE,
				VCD_S_SUCCESS, NULL, 0,	(u32 *)p_ddl,
				p_ddl_context->p_client_data);
	}

	ddl_move_client_state(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME);
	DDL_IDLE(p_ddl_context);
}
static void ddl_handle_enc_frame_done(struct ddl_client_context *ddl)
{
	struct ddl_context       *ddl_context = ddl->ddl_context;
	struct ddl_encoder_data  *encoder = &(ddl->codec_data.encoder);
	struct vcd_frame_data    *output_frame = &(ddl->output_frame.vcd_frm);
	u32 bottom_frame_tag;
	u8  *input_buffer_address = NULL;

	vidc_sm_get_frame_tags(&ddl->shared_mem[ddl->command_channel],
		&output_frame->ip_frm_tag, &bottom_frame_tag);
	output_frame->data_len = encoder->enc_frame_info.enc_frame_size;
	output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME;
	(void)ddl_get_encoded_frame(output_frame,
		encoder->codec.codec, encoder->enc_frame_info.enc_frame);
	ddl_process_encoder_metadata(ddl);
	ddl_vidc_encode_dynamic_property(ddl, false);
	ddl->input_frame.frm_trans_end = false;
	input_buffer_address = ddl_context->dram_base_a.align_physical_addr +
			encoder->enc_frame_info.enc_luma_address;
	ddl_get_input_frame_from_pool(ddl, input_buffer_address);

	ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE,
		VCD_S_SUCCESS, &(ddl->input_frame),
		sizeof(struct ddl_frame_data_tag),
		(u32 *) ddl, ddl->client_data);

	ddl->output_frame.frm_trans_end =
		DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)
			? false : true;

	ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE,
		VCD_S_SUCCESS, &(ddl->output_frame),
		sizeof(struct ddl_frame_data_tag),
		(u32 *) ddl, ddl->client_data);

}
static void ddl_encoder_frame_run_callback(
	struct ddl_client_context *ddl)
{
	struct ddl_context *ddl_context = ddl->ddl_context;
	struct ddl_encoder_data *encoder =
		&(ddl->codec_data.encoder);
	struct vcd_frame_data *output_frame =
		&(ddl->output_frame.vcd_frm);
	u32 bottom_frame_tag;

	DDL_MSG_MED("ddl_encoder_frame_run_callback");
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME_DONE) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_EOS_DONE)) {
		DDL_MSG_ERROR("STATE-CRITICAL-ENCFRMRUN");
		ddl_client_fatal_cb(ddl);
	} else {
		if (vidc_msg_timing)
			ddl_calc_core_proc_time(__func__, ENC_OP_TIME);
		DDL_MSG_LOW("ENC_FRM_RUN_DONE");
		ddl->cmd_state = DDL_CMD_INVALID;
		vidc_1080p_get_encode_frame_info(&encoder->enc_frame_info);
		vidc_sm_get_frame_tags(&ddl->shared_mem
			[ddl->command_channel],
			&output_frame->ip_frm_tag, &bottom_frame_tag);

		if (encoder->meta_data_enable_flag)
			vidc_sm_get_metadata_status(&ddl->shared_mem
				[ddl->command_channel],
				&encoder->enc_frame_info.meta_data_exists);

		if (encoder->enc_frame_info.enc_frame_size ||
			(encoder->enc_frame_info.enc_frame ==
			VIDC_1080P_ENCODE_FRAMETYPE_SKIPPED) ||
			DDLCLIENT_STATE_IS(ddl,
			DDL_CLIENT_WAIT_FOR_EOS_DONE)) {
			u8 *input_buffer_address = NULL;
			output_frame->data_len =
				encoder->enc_frame_info.enc_frame_size;
			output_frame->flags |= VCD_FRAME_FLAG_ENDOFFRAME;
			ddl_get_encoded_frame(output_frame,
				encoder->codec.codec,
				encoder->enc_frame_info.enc_frame);
			ddl_process_encoder_metadata(ddl);
			ddl_vidc_encode_dynamic_property(ddl, false);
			ddl->input_frame.frm_trans_end = false;
			input_buffer_address = ddl_context->dram_base_a.\
				align_physical_addr +
				encoder->enc_frame_info.enc_luma_address;
			ddl_get_input_frame_from_pool(ddl,
				input_buffer_address);
			ddl_context->ddl_callback(VCD_EVT_RESP_INPUT_DONE,
				VCD_S_SUCCESS, &(ddl->input_frame),
				sizeof(struct ddl_frame_data_tag),
				(u32 *)ddl, ddl->client_data);
			ddl->output_frame.frm_trans_end =
				DDLCLIENT_STATE_IS(ddl,
				DDL_CLIENT_WAIT_FOR_EOS_DONE) ? false : true;
			ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE,
				VCD_S_SUCCESS, &(ddl->output_frame),
				sizeof(struct ddl_frame_data_tag),
				(u32 *)ddl, ddl->client_data);

			if (DDLCLIENT_STATE_IS(ddl,
				DDL_CLIENT_WAIT_FOR_EOS_DONE) &&
				encoder->i_period.b_frames) {
				if ((ddl->extra_output_buf_count < 0) ||
					(ddl->extra_output_buf_count >
					encoder->i_period.b_frames)) {
					DDL_MSG_ERROR("Invalid B frame output"
								"buffer index");
				} else {
					struct vidc_1080p_enc_frame_start_param
						enc_param;
					ddl->output_frame = ddl->\
					extra_output_frame[ddl->\
					extra_output_buf_count];
					ddl->\
					extra_output_buf_count--;
					output_frame =
					&ddl->output_frame.\
					vcd_frm;
					memset(&enc_param, 0,
						sizeof(enc_param));
					enc_param.cmd_seq_num =
						++ddl_context->cmd_seq_num;
					enc_param.inst_id = ddl->instance_id;
					enc_param.shared_mem_addr_offset =
					   DDL_ADDR_OFFSET(ddl_context->\
						dram_base_a, ddl->shared_mem
						[ddl->command_channel]);
					enc_param.stream_buffer_addr_offset =
						DDL_OFFSET(ddl_context->\
						dram_base_a.\
						align_physical_addr,
						output_frame->physical);
					enc_param.stream_buffer_size =
					encoder->client_output_buf_req.sz;
					enc_param.encode =
					VIDC_1080P_ENC_TYPE_LAST_FRAME_DATA;
					ddl->cmd_state = DDL_CMD_ENCODE_FRAME;
					ddl_context->vidc_encode_frame_start
						[ddl->command_channel]
						(&enc_param);
				} } else {
				DDL_MSG_LOW("ddl_state_transition: %s ~~>"
					"DDL_CLIENT_WAIT_FOR_FRAME",
					ddl_get_state_string(
					ddl->client_state));
				ddl->client_state =
					DDL_CLIENT_WAIT_FOR_FRAME;
				ddl_release_command_channel(ddl_context,
				ddl->command_channel);
			}
		} else {
			ddl_context->ddl_callback(
				VCD_EVT_RESP_TRANSACTION_PENDING,
				VCD_S_SUCCESS, NULL, 0, (u32 *)ddl,
				ddl->client_data);
			DDL_MSG_LOW("ddl_state_transition: %s ~~>"
				"DDL_CLIENT_WAIT_FOR_FRAME",
			ddl_get_state_string(ddl->client_state));
			ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME;
			ddl_release_command_channel(ddl_context,
			ddl->command_channel);
		}
	}
}