static u32 ddl_header_done_callback(struct ddl_context *ddl_context)
{
	struct ddl_client_context *ddl = ddl_context->current_ddl;
	struct ddl_decoder_data *decoder;
	struct vidc_720p_seq_hdr_info seq_hdr_info;

	u32 process_further = true;
	u32 seq_hdr_only_frame = false;
	u32 need_reconfig = true;
	struct vcd_frame_data *input_vcd_frm;
	struct ddl_frame_data_tag *reconfig_payload = NULL;
	u32 reconfig_payload_size = 0;

	if (!ddl ||
		!ddl->decoding ||
		!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)
		) {
		VIDC_LOG_STRING("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(ddl_context);
		return true;
	}
	if (vidc_msg_timing)
		ddl_calc_core_proc_time(__func__, DEC_OP_TIME);
	ddl_move_command_state(ddl_context, DDL_CMD_INVALID);
	ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_DPB);
	VIDC_LOG_STRING("HEADER_DONE");
	VIDC_DEBUG_REGISTER_LOG;

	vidc_720p_decode_get_seq_hdr_info(&seq_hdr_info);

	decoder = &(ddl->codec_data.decoder);
	decoder->frame_size.width = seq_hdr_info.img_size_x;
	decoder->frame_size.height = seq_hdr_info.img_size_y;
	decoder->min_dpb_num = seq_hdr_info.min_num_dpb;
	decoder->y_cb_cr_size = seq_hdr_info.min_dpb_size;
	decoder->progressive_only = 1 - seq_hdr_info.progressive;
	if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) {
		VIDC_LOGERR_STRING("FATAL: ZeroImageSize");
		ddl_client_fatal_cb(ddl_context);
		return process_further;
	}
	if (seq_hdr_info.data_partitioned == 0x1 &&
		decoder->codec.codec == VCD_CODEC_MPEG4 &&
		seq_hdr_info.img_size_x > DDL_MAX_DP_FRAME_WIDTH &&
		seq_hdr_info.img_size_y > DDL_MAX_DP_FRAME_HEIGHT)	{
		ddl_client_fatal_cb(ddl_context);
		return process_further;
	}
	ddl_getdec_profilelevel(decoder, seq_hdr_info.profile,
		seq_hdr_info.level);
	ddl_calculate_stride(&decoder->frame_size,
			!decoder->progressive_only,
			decoder->codec.codec);
	if (seq_hdr_info.crop_exists)	{
		decoder->frame_size.width -=
		(seq_hdr_info.crop_right_offset
		+ seq_hdr_info.crop_left_offset);
		decoder->frame_size.height -=
		(seq_hdr_info.crop_top_offset +
		seq_hdr_info.crop_bottom_offset);
	}
	ddl_set_default_decoder_buffer_req(decoder, false);

	if (decoder->header_in_start) {
		decoder->client_frame_size = decoder->frame_size;
		decoder->client_output_buf_req =
			decoder->actual_output_buf_req;
		decoder->client_input_buf_req =
			decoder->actual_input_buf_req;
		ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS,
			NULL, 0, (u32 *) ddl,	ddl_context->client_data);
		DDL_IDLE(ddl_context);
	} else {
		DBG("%s(): Client data: WxH(%u x %u) SxSL(%u x %u) Sz(%u)\n",
			__func__, decoder->client_frame_size.width,
			decoder->client_frame_size.height,
			decoder->client_frame_size.stride,
			decoder->client_frame_size.scan_lines,
			decoder->client_output_buf_req.sz);
		DBG("%s(): DDL data: WxH(%u x %u) SxSL(%u x %u) Sz(%u)\n",
			__func__, decoder->frame_size.width,
			decoder->frame_size.height,
			decoder->frame_size.stride,
			decoder->frame_size.scan_lines,
			decoder->actual_output_buf_req.sz);
		DBG("%s(): min_dpb_num = %d actual_count = %d\n", __func__,
			decoder->min_dpb_num,
			decoder->client_output_buf_req.actual_count);

		input_vcd_frm = &(ddl->input_frame.vcd_frm);

		if (decoder->frame_size.width ==
			decoder->client_frame_size.width
			&& decoder->frame_size.height ==
			decoder->client_frame_size.height
			&& decoder->frame_size.stride ==
			decoder->client_frame_size.stride
			&& decoder->frame_size.scan_lines ==
			decoder->client_frame_size.scan_lines
			&& decoder->actual_output_buf_req.sz <=
			decoder->client_output_buf_req.sz
			&& decoder->actual_output_buf_req.actual_count <=
			decoder->client_output_buf_req.actual_count
			&& decoder->progressive_only)
			need_reconfig = false;
		if ((input_vcd_frm->data_len == seq_hdr_info.dec_frm_size ||
			 (input_vcd_frm->flags & VCD_FRAME_FLAG_CODECCONFIG)) &&
			(!need_reconfig ||
			 !(input_vcd_frm->flags & VCD_FRAME_FLAG_EOS))) {
			input_vcd_frm->flags |=
				VCD_FRAME_FLAG_CODECCONFIG;
			seq_hdr_only_frame = true;
			ddl->input_frame.frm_trans_end = !need_reconfig;
			ddl_context->ddl_callback(
				VCD_EVT_RESP_INPUT_DONE,
				VCD_S_SUCCESS, &ddl->input_frame,
				sizeof(struct ddl_frame_data_tag),
				(u32 *) ddl,
				ddl->ddl_context->client_data);
		} else if (decoder->codec.codec != VCD_CODEC_H263) {
			input_vcd_frm->offset += seq_hdr_info.dec_frm_size;
			input_vcd_frm->data_len -= seq_hdr_info.dec_frm_size;
		}
		if (need_reconfig) {
			decoder->client_frame_size = decoder->frame_size;
			decoder->client_output_buf_req =
				decoder->actual_output_buf_req;
			decoder->client_input_buf_req =
				decoder->actual_input_buf_req;
			if (!seq_hdr_only_frame) {
				reconfig_payload = &ddl->input_frame;
				reconfig_payload_size =
					sizeof(struct ddl_frame_data_tag);
			}
			ddl_context->ddl_callback(VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, reconfig_payload,
					reconfig_payload_size,
					(u32 *) ddl,
					ddl_context->client_data);
		}
		if (!need_reconfig && !seq_hdr_only_frame) {
			if (ddl_decode_set_buffers(ddl) == VCD_S_SUCCESS)
				process_further = false;
			else
				ddl_client_fatal_cb(ddl_context);
		} else
			DDL_IDLE(ddl_context);
	}
	return process_further;
}
Ejemplo n.º 2
0
static u32 ddl_header_done_callback(struct ddl_context_type *p_ddl_context)
{
	struct ddl_client_context_type *p_ddl = p_ddl_context->p_current_ddl;
	struct ddl_decoder_data_type *p_decoder;
	struct vidc_720p_seq_hdr_info_type seq_hdr_info;

	u32 b_process_further = TRUE;
	u32 b_seq_hdr_only_frame = FALSE;
	u32 b_need_reconfig = TRUE;
	struct vcd_frame_data_type *p_input_vcd_frm;
	struct ddl_frame_data_type_tag *p_reconfig_payload;
	u32 reconfig_payload_size;

	if (!p_ddl ||
		!p_ddl->b_decoding ||
		!DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)
		) {
		VIDC_LOG_STRING("STATE-CRITICAL-HDDONE");
		ddl_client_fatal_cb(p_ddl_context);
		return TRUE;
	}
	ddl_move_command_state(p_ddl_context, DDL_CMD_INVALID);
	ddl_move_client_state(p_ddl, DDL_CLIENT_WAIT_FOR_DPB);
	VIDC_LOG_STRING("HEADER_DONE");
	VIDC_DEBUG_REGISTER_LOG;

	vidc_720p_decode_get_seq_hdr_info(&seq_hdr_info);

	p_decoder = &(p_ddl->codec_data.decoder);
	p_decoder->frame_size.n_width = seq_hdr_info.n_img_size_x;
	p_decoder->frame_size.n_height = seq_hdr_info.n_img_size_y;
	p_decoder->n_min_dpb_num = seq_hdr_info.n_min_num_dpb;
	p_decoder->n_y_cb_cr_size = seq_hdr_info.n_min_dpb_size;
	p_decoder->n_progressive_only = 1 - seq_hdr_info.n_progressive;
	if (!seq_hdr_info.n_img_size_x || !seq_hdr_info.n_img_size_y) {
		VIDC_LOGERR_STRING("FATAL: ZeroImageSize");
		ddl_client_fatal_cb(p_ddl_context);
		return b_process_further;
	}
	if (seq_hdr_info.n_data_partitioned == 0x1 &&
		p_decoder->codec_type.e_codec == VCD_CODEC_MPEG4 &&
		seq_hdr_info.n_img_size_x > DDL_MAX_DP_FRAME_WIDTH &&
		seq_hdr_info.n_img_size_y > DDL_MAX_DP_FRAME_HEIGHT)	{
		ddl_client_fatal_cb(p_ddl_context);
		return b_process_further;
	}
	ddl_getdec_profilelevel(p_decoder, seq_hdr_info.n_profile,
		seq_hdr_info.n_level);
	ddl_calculate_stride(&p_decoder->frame_size,
			!p_decoder->n_progressive_only);
	if (seq_hdr_info.n_crop_exists)	{
		p_decoder->frame_size.n_width -=
		(seq_hdr_info.n_crop_right_offset
		+ seq_hdr_info.n_crop_left_offset);
		p_decoder->frame_size.n_height -=
		(seq_hdr_info.n_crop_top_offset +
		seq_hdr_info.n_crop_bottom_offset);
	}
	ddl_set_default_decoder_buffer_req(p_decoder, FALSE);

	if (p_decoder->b_header_in_start) {
		p_decoder->client_frame_size = p_decoder->frame_size;
		p_decoder->client_output_buf_req =
			p_decoder->actual_output_buf_req;
		p_decoder->client_input_buf_req =
			p_decoder->actual_input_buf_req;
		p_ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS,
			NULL, 0, (u32 *) p_ddl,	p_ddl_context->p_client_data);
		DDL_IDLE(p_ddl_context);
	} else {
		DBG("%s(): n_width = %d client_frame_size.n_width = %d\n",
			__func__, p_decoder->frame_size.n_width,
			p_decoder->client_frame_size.n_width);
		DBG("%s(): n_height = %d client_frame_size.n_height = %d\n",
			__func__, p_decoder->frame_size.n_height,
			p_decoder->client_frame_size.n_height);
		DBG("%s(): n_size = %d client_frame_size n_size = %d\n",
			__func__, p_decoder->actual_output_buf_req.n_size,
			p_decoder->client_output_buf_req.n_size);
		DBG("%s(): n_min_dpb_num = %d n_actual_count = %d\n", __func__,
			p_decoder->n_min_dpb_num,
			p_decoder->client_output_buf_req.n_actual_count);

		p_input_vcd_frm = &(p_ddl->input_frame.vcd_frm);

		if (p_decoder->frame_size.n_width ==
			p_decoder->client_frame_size.n_width
			&& p_decoder->frame_size.n_height ==
			p_decoder->client_frame_size.n_height
			&& p_decoder->actual_output_buf_req.n_size <=
			p_decoder->client_output_buf_req.n_size
			&& p_decoder->n_min_dpb_num <=
			p_decoder->client_output_buf_req.n_actual_count)
			b_need_reconfig = FALSE;
		if ((p_input_vcd_frm->n_flags & VCD_FRAME_FLAG_CODECCONFIG) ||
				p_input_vcd_frm->n_data_len ==
				seq_hdr_info.n_dec_frm_size) {
			b_seq_hdr_only_frame = TRUE;
			p_input_vcd_frm->n_offset +=
				seq_hdr_info.n_dec_frm_size;
			p_input_vcd_frm->n_data_len -=
				seq_hdr_info.n_dec_frm_size;
			p_input_vcd_frm->n_flags |= VCD_FRAME_FLAG_CODECCONFIG;
			p_ddl->input_frame.b_frm_trans_end = !b_need_reconfig;
			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->p_ddl_context->p_client_data);
		}
		if (b_need_reconfig) {
			p_reconfig_payload = &p_ddl->input_frame;
			reconfig_payload_size =
				sizeof(struct ddl_frame_data_type_tag);
			p_decoder->client_frame_size = p_decoder->frame_size;
			p_decoder->client_output_buf_req =
				p_decoder->actual_output_buf_req;
			p_decoder->client_input_buf_req =
				p_decoder->actual_input_buf_req;
			if (b_seq_hdr_only_frame) {
				p_reconfig_payload = NULL;
				reconfig_payload_size = 0;
			}
			p_ddl_context->ddl_callback(VCD_EVT_IND_OUTPUT_RECONFIG,
					VCD_S_SUCCESS, p_reconfig_payload,
					reconfig_payload_size,
					(u32 *) p_ddl,
					p_ddl_context->p_client_data);
		}
		if (!b_need_reconfig && !b_seq_hdr_only_frame) {
			if (ddl_decode_set_buffers(p_ddl) == VCD_S_SUCCESS)
				b_process_further = FALSE;
			else
				ddl_client_fatal_cb(p_ddl_context);
		} else
			DDL_IDLE(p_ddl_context);
	}
	return b_process_further;
}
Ejemplo n.º 3
0
u32 ddl_decode_frame(u32 *ddl_handle,
     struct ddl_frame_data_tag *input_bits, void *client_data)
{
	u32 vcd_status = VCD_S_SUCCESS;
	struct ddl_client_context *ddl =
	    (struct ddl_client_context *)ddl_handle;
	struct ddl_context *ddl_context = ddl_get_context();

	if (!DDL_IS_INITIALIZED(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited");
		return VCD_ERR_ILLEGAL_OP;
	}
	if (DDL_IS_BUSY(ddl_context)) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy");
		return VCD_ERR_BUSY;
	}
	if (!ddl || !ddl->decoding) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle");
		return VCD_ERR_BAD_HANDLE;
	}
	if (!input_bits ||
	    ((!input_bits->vcd_frm.physical ||
	      !input_bits->vcd_frm.data_len) &&
	     (!(VCD_FRAME_FLAG_EOS & input_bits->vcd_frm.flags))
	    )
	    ) {
		VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param");
		return VCD_ERR_ILLEGAL_PARM;
	}

	DDL_BUSY(ddl_context);

	ddl_context->current_ddl = ddl;
	ddl_context->client_data = client_data;

	ddl->input_frame = *input_bits;

	if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
		ddl_decode_frame_run(ddl);
	} else {
		if (!ddl->codec_data.decoder.dp_buf.no_of_dec_pic_buf) {
			VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied");
			vcd_status = VCD_ERR_ILLEGAL_OP;
		} else if (DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPB)) {
			vcd_status = ddl_decode_set_buffers(ddl);
		} else
		    if (DDLCLIENT_STATE_IS
			(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) {
			ddl->codec_data.decoder.decode_config.
			    sequence_header =
			    ddl->input_frame.vcd_frm.physical;
			ddl->codec_data.decoder.decode_config.
			    sequence_header_len =
			    ddl->input_frame.vcd_frm.data_len;
			ddl_decode_init_codec(ddl);
		} else {
			VIDC_LOGERR_STRING("Dec_frame:Wrong_state");
			vcd_status = VCD_ERR_ILLEGAL_OP;
		}
		if (vcd_status)
			DDL_IDLE(ddl_context);
	}
	return vcd_status;
}
Ejemplo n.º 4
0
u32 ddl_decode_frame(u32 *ddl_handle,
                     struct ddl_frame_data_type_tag *p_input_bits, void *p_client_data)
{
    u32 vcd_status = VCD_S_SUCCESS;
    struct ddl_client_context_type *p_ddl =
        (struct ddl_client_context_type *)ddl_handle;
    struct ddl_context_type *p_ddl_context = ddl_get_context();

#ifdef CORE_TIMING_INFO
    ddl_get_core_start_time(0);
#endif

    if (!DDL_IS_INITIALIZED(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Not_inited");
        return VCD_ERR_ILLEGAL_OP;
    }
    if (DDL_IS_BUSY(p_ddl_context)) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Ddl_busy");
        return VCD_ERR_BUSY;
    }
    if (NULL == p_ddl || FALSE == p_ddl->b_decoding) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Bad_handle");
        return VCD_ERR_BAD_HANDLE;
    }
    if (NULL == p_input_bits ||
            ((0 == p_input_bits->vcd_frm.p_physical ||
              0 == p_input_bits->vcd_frm.n_data_len) &&
             (0 == (VCD_FRAME_FLAG_EOS & p_input_bits->vcd_frm.n_flags))
            )
       ) {
        VIDC_LOGERR_STRING("ddl_dec_frame:Bad_input_param");
        return VCD_ERR_ILLEGAL_PARM;
    }

    DDL_BUSY(p_ddl_context);

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

    p_ddl->input_frame = *p_input_bits;

    if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_FRAME)) {
        ddl_decode_frame_run(p_ddl);
    } else {
        if (0 == p_ddl->codec_data.decoder.dp_buf.n_no_of_dec_pic_buf) {
            VIDC_LOGERR_STRING("ddl_dec_frame:Dpbs_requied");
            vcd_status = VCD_ERR_ILLEGAL_OP;
        } else if (DDLCLIENT_STATE_IS(p_ddl, DDL_CLIENT_WAIT_FOR_DPB)) {
            vcd_status = ddl_decode_set_buffers(p_ddl);
        } else if (DDLCLIENT_STATE_IS
                   (p_ddl, DDL_CLIENT_WAIT_FOR_INITCODEC)) {
            p_ddl->codec_data.decoder.decode_config.
            p_sequence_header =
                p_ddl->input_frame.vcd_frm.p_physical;
            p_ddl->codec_data.decoder.decode_config.
            n_sequence_header_len =
                p_ddl->input_frame.vcd_frm.n_data_len;
            ddl_decode_init_codec(p_ddl);
        } else {
            VIDC_LOGERR_STRING("Dec_frame:Wrong_state");
            vcd_status = VCD_ERR_ILLEGAL_OP;
        }
        if (VCD_S_SUCCESS != vcd_status)
            DDL_IDLE(p_ddl_context);
    }
    return vcd_status;
}