u32 ddl_encode_end(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context  *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;

	DDL_MSG_HIGH("ddl_encode_end");
#ifdef DDL_PROFILE
	ddl_reset_time_variables(1);
#endif
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_end:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_end:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_end:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) &&
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_FAVIDC_ERROR)) {
		DDL_MSG_ERROR("ddl_enc_end:Wrong_state");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_end(ddl);
	return VCD_S_SUCCESS;
}
u32 ddl_decode_start(u32 *ddl_handle, struct vcd_sequence_hdr *header,
	void *client_data)
{
	struct ddl_client_context  *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_decoder_data *decoder;
	u32 status = VCD_S_SUCCESS;

	DDL_MSG_HIGH("ddl_decode_start");
#ifdef DDL_PROFILE
	ddl_reset_time_variables(0);
#endif
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_dec_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_dec_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		DDL_MSG_ERROR("ddl_dec_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_dec_start:Not_in_opened_state");
		return VCD_ERR_ILLEGAL_OP;
	}

	if ((header) && ((!header->sequence_header_len) ||
		(!header->sequence_header))) {
		DDL_MSG_ERROR("ddl_dec_start:Bad_param_seq_header");
		return VCD_ERR_ILLEGAL_PARM;
	}
	if (!ddl_decoder_ready_to_start(ddl, header)) {
		DDL_MSG_ERROR("ddl_dec_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	decoder = &ddl->codec_data.decoder;
	status = ddl_allocate_dec_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	if (header) {
		decoder->header_in_start = true;
		decoder->decode_config = *header;
	} else {
		decoder->header_in_start = false;
		decoder->decode_config.sequence_header_len = 0;
	}
	ddl_vidc_channel_set(ddl);
	return status;
}
u32 ddl_encode_start(u32 *ddl_handle, void *client_data)
{
	struct ddl_client_context *ddl =
		(struct ddl_client_context *) ddl_handle;
	struct ddl_context *ddl_context;
	struct ddl_encoder_data *encoder;
	void *ptr;
	u32 status = VCD_S_SUCCESS;

	DDL_MSG_HIGH("ddl_encode_start");
#ifdef DDL_PROFILE
	if (first_time < 2) {
		ddl_reset_time_variables(1);
		first_time++;
	 }
	ddl_get_core_start_time(1);
#endif
	ddl_context = ddl_get_context();
	if (!DDL_IS_INITIALIZED(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		DDL_MSG_ERROR("ddl_enc_start:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || ddl->decoding) {
		DDL_MSG_ERROR("ddl_enc_start:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_OPEN)) {
		DDL_MSG_ERROR("ddl_enc_start:Not_opened");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (!ddl_encoder_ready_to_start(ddl)) {
		DDL_MSG_ERROR("ddl_enc_start:Err_param_settings");
		return VCD_ERR_ILLEGAL_OP;
	}
	encoder = &ddl->codec_data.encoder;
	status = ddl_allocate_enc_hw_buffers(ddl);
	if (status)
		return status;
#ifdef DDL_BUF_LOG
	ddl_list_buffers(ddl);
#endif

	ptr = ddl_pmem_alloc(&encoder->seq_header,
		DDL_ENC_SEQHEADER_SIZE, DDL_LINEAR_BUFFER_ALIGN_BYTES);
	if (!ptr) {
		ddl_free_enc_hw_buffers(ddl);
		DDL_MSG_ERROR("ddl_enc_start:Seq_hdr_alloc_failed");
		return VCD_ERR_ALLOC_FAIL;
	}
	if (!ddl_take_command_channel(ddl_context, ddl, client_data))
		return VCD_ERR_BUSY;
	ddl_vidc_channel_set(ddl);
	return status;
}
Exemple #4
0
u32 ddl_decode_end(u32 *ddl_handle, void *p_client_data)
{
    struct ddl_client_context_type *p_ddl =
        (struct ddl_client_context_type *)ddl_handle;
    struct ddl_context_type *p_ddl_context;

    p_ddl_context = ddl_get_context();

#ifdef CORE_TIMING_INFO
    ddl_reset_time_variables(0);
#endif

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_end:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_end:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || FALSE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_dec_end:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_INITCODEC) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_DPB) &&
            !DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_FATAL_ERROR)
       ) {
        VIDC_LOGERR_STRING("ddl_dec_end:Wrong_state");
        return VCD_ERR_ILLEGAL_OP;
    }
    DDL_BUSY(p_ddl_context);

    p_ddl_context->p_current_ddl = p_ddl;
    p_ddl_context->p_client_data = p_client_data;

    ddl_channel_end(p_ddl);
    return VCD_S_SUCCESS;
}