static void ddl_decoder_input_done_callback( struct ddl_client_context *ddl, u32 frame_transact_end) { struct vidc_720p_dec_disp_info *dec_disp_info = &(ddl->codec_data.decoder.dec_disp_info); struct vcd_frame_data *input_vcd_frm = &(ddl->input_frame.vcd_frm); ddl_get_frame(input_vcd_frm, dec_disp_info-> input_frame); input_vcd_frm->interlaced = (dec_disp_info-> input_is_interlace); input_vcd_frm->offset += dec_disp_info->input_bytes_consumed; input_vcd_frm->data_len -= dec_disp_info->input_bytes_consumed; ddl->input_frame.frm_trans_end = frame_transact_end; if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_IP_TIME); ddl->ddl_context->ddl_callback( VCD_EVT_RESP_INPUT_DONE, VCD_S_SUCCESS, &ddl->input_frame, sizeof(struct ddl_frame_data_tag), (void *)ddl, ddl->ddl_context->client_data); }
static u32 ddl_dpb_buffers_set_done_callback( struct ddl_context *ddl_context) { struct ddl_client_context *ddl; u32 channel_inst_id, ret_status = true; DDL_MSG_MED("ddl_dpb_buffers_set_done_callback"); vidc_1080p_get_returned_channel_inst_id(&channel_inst_id); vidc_1080p_clear_returned_channel_inst_id(); ddl = ddl_get_current_ddl_client_for_command(ddl_context, DDL_CMD_DECODE_SET_DPB); if (ddl) { ddl->cmd_state = DDL_CMD_INVALID; if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE)) { DDL_MSG_ERROR("STATE-CRITICAL-DPBDONE"); ddl_client_fatal_cb(ddl); } else { DDL_MSG_LOW("INTR_DPBDONE"); DDL_MSG_LOW("ddl_state_transition: %s ~~>" "DDL_CLIENT_WAIT_FOR_FRAME", ddl_get_state_string(ddl->client_state)); if (vidc_msg_timing) { ddl_calc_core_proc_time(__func__, DEC_OP_TIME); ddl_reset_core_time_variables(DEC_OP_TIME); } ddl->client_state = DDL_CLIENT_WAIT_FOR_FRAME; ddl_vidc_decode_frame_run(ddl); ret_status = false; } } return ret_status; }
static void ddl_decoder_input_done_callback( struct ddl_client_context *ddl, u32 frame_transact_end) { struct ddl_context *ddl_context = ddl->ddl_context; struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); struct vidc_1080p_dec_disp_info *dec_disp_info = &decoder->dec_disp_info; struct vcd_frame_data *input_vcd_frm = &(ddl->input_frame.vcd_frm); u32 is_interlaced; vidc_1080p_get_decoded_frame_size( &dec_disp_info->input_bytes_consumed); vidc_sm_set_start_byte_number(&ddl->shared_mem [ddl->command_channel], 0); vidc_1080p_get_decode_frame(&dec_disp_info->input_frame); ddl_get_decoded_frame(input_vcd_frm, dec_disp_info->input_frame); vidc_1080p_get_decode_frame_result(dec_disp_info); is_interlaced = (dec_disp_info->decode_coding == VIDC_1080P_DISPLAY_CODING_INTERLACED); if (decoder->output_order == VCD_DEC_ORDER_DECODE) { dec_disp_info->tag_bottom = is_interlaced ? dec_disp_info->tag_top : VCD_FRAMETAG_INVALID; dec_disp_info->tag_top = input_vcd_frm->ip_frm_tag; } input_vcd_frm->interlaced = is_interlaced; input_vcd_frm->offset += dec_disp_info->input_bytes_consumed; input_vcd_frm->data_len -= dec_disp_info->input_bytes_consumed; ddl->input_frame.frm_trans_end = frame_transact_end; if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_IP_TIME); 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); }
static u32 ddl_encoder_seq_done_callback(struct ddl_context *ddl_context, struct ddl_client_context *ddl) { struct ddl_encoder_data *encoder; DDL_MSG_MED("ddl_encoder_seq_done_callback"); if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { DDL_MSG_ERROR("STATE-CRITICAL-INITCODEC"); ddl_client_fatal_cb(ddl); return true; } if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, ENC_OP_TIME); ddl->cmd_state = DDL_CMD_INVALID; 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_MSG_LOW("INIT_CODEC_DONE"); encoder = &ddl->codec_data.encoder; vidc_1080p_get_encoder_sequence_header_size( &encoder->seq_header_length); if ((encoder->codec.codec == VCD_CODEC_H264) && (encoder->profile.profile == VCD_PROFILE_H264_BASELINE)) if ((encoder->seq_header.align_virtual_addr) && (encoder->seq_header_length > 6)) encoder->seq_header.align_virtual_addr[6] = 0xC0; ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, NULL, 0, (u32 *) ddl, ddl->client_data); ddl_release_command_channel(ddl_context, ddl->command_channel); return true; }
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); }
static u32 ddl_channel_set_callback(struct ddl_context *ddl_context, u32 instance_id) { struct ddl_client_context *ddl; u32 ret = false; DDL_MSG_MED("ddl_channel_open_callback"); ddl = ddl_get_current_ddl_client_for_command(ddl_context, DDL_CMD_CHANNEL_SET); if (ddl) { ddl->cmd_state = DDL_CMD_INVALID; if (!DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHDONE)) { DDL_MSG_ERROR("STATE-CRITICAL-CHSET"); ddl_release_command_channel(ddl_context, ddl->command_channel); } else { DDL_MSG_LOW("CH_SET_DONE"); DDL_MSG_LOW("ddl_state_transition: %s ~~>" "DDL_CLIENT_WAIT_FOR_INITCODEC", ddl_get_state_string(ddl->client_state)); ddl->client_state = DDL_CLIENT_WAIT_FOR_INITCODEC; ddl->instance_id = instance_id; if (ddl->decoding) { if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_OP_TIME); if (ddl->codec_data.decoder.header_in_start) ddl_vidc_decode_init_codec(ddl); else { ddl_context->ddl_callback( VCD_EVT_RESP_START, VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, ddl->client_data); ddl_release_command_channel( ddl_context, ddl->command_channel); ret = true; } } else ddl_vidc_encode_init_codec(ddl); } } return ret; }
static u32 ddl_channel_set_callback(struct ddl_context *ddl_context) { struct ddl_client_context *ddl = ddl_context->current_ddl; u32 return_status = false; ddl_move_command_state(ddl_context, DDL_CMD_INVALID); VIDC_DEBUG_REGISTER_LOG; if (!ddl || !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_CHDONE) ) { VIDC_LOG_STRING("STATE-CRITICAL-CHSET"); DDL_IDLE(ddl_context); return return_status; } VIDC_LOG_STRING("Channel-set"); ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_INITCODEC); if (ddl->decoding) { if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_OP_TIME); if (ddl->codec_data.decoder.header_in_start) { ddl_decode_init_codec(ddl); } else { ddl_context->ddl_callback(VCD_EVT_RESP_START, VCD_S_SUCCESS, NULL, 0, (u32 *) ddl, ddl_context->client_data); DDL_IDLE(ddl_context); return_status = true; } } else { ddl_encode_init_codec(ddl); } return return_status; }
static u32 ddl_dpb_buffers_set_done_callback(struct ddl_context *ddl_context) { struct ddl_client_context *ddl = ddl_context->current_ddl; ddl_move_command_state(ddl_context, DDL_CMD_INVALID); if (!ddl || !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_DPBDONE) ) { VIDC_LOG_STRING("STATE-CRITICAL-DPBDONE"); ddl_client_fatal_cb(ddl_context); return true; } if (vidc_msg_timing) { ddl_calc_core_proc_time(__func__, DEC_OP_TIME); ddl_reset_core_time_variables(DEC_OP_TIME); } VIDC_LOG_STRING("INTR_DPBDONE"); ddl_move_client_state(ddl, DDL_CLIENT_WAIT_FOR_FRAME); ddl->codec_data.decoder.dec_disp_info.img_size_x = 0; ddl->codec_data.decoder.dec_disp_info.img_size_y = 0; ddl_decode_frame_run(ddl); return false; }
static u32 ddl_decoder_output_done_callback( struct ddl_client_context *ddl, u32 frame_transact_end) { struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); struct vidc_720p_dec_disp_info *dec_disp_info = &(decoder->dec_disp_info); struct ddl_frame_data_tag *output_frame = &ddl->output_frame; struct vcd_frame_data *output_vcd_frm = &(output_frame->vcd_frm); u32 vcd_status; u32 free_luma_dpb = 0; output_vcd_frm->physical = (u8 *)dec_disp_info->y_addr; if (decoder->codec.codec == VCD_CODEC_MPEG4 || decoder->codec.codec == VCD_CODEC_VC1 || decoder->codec.codec == VCD_CODEC_VC1_RCV || (decoder->codec.codec >= VCD_CODEC_DIVX_3 && decoder->codec.codec <= VCD_CODEC_XVID)){ vidc_720p_decode_skip_frm_details(&free_luma_dpb); if (free_luma_dpb) output_vcd_frm->physical = (u8 *) free_luma_dpb; } vcd_status = ddl_decoder_dpb_transact( decoder, output_frame, DDL_DPB_OP_MARK_BUSY); if (vcd_status != VCD_S_SUCCESS) { VIDC_LOGERR_STRING("CorruptedOutputBufferAddress"); ddl_hw_fatal_cb(ddl->ddl_context); return vcd_status; } output_vcd_frm->ip_frm_tag = dec_disp_info->tag_top; if (dec_disp_info->crop_exists == 0x1) { output_vcd_frm->dec_op_prop.disp_frm.left = dec_disp_info->crop_left_offset; output_vcd_frm->dec_op_prop.disp_frm.top = dec_disp_info->crop_top_offset; output_vcd_frm->dec_op_prop.disp_frm.right = dec_disp_info->img_size_x - dec_disp_info->crop_right_offset; output_vcd_frm->dec_op_prop.disp_frm.bottom = dec_disp_info->img_size_y - dec_disp_info->crop_bottom_offset; } else { output_vcd_frm->dec_op_prop.disp_frm.left = 0; output_vcd_frm->dec_op_prop.disp_frm.top = 0; output_vcd_frm->dec_op_prop.disp_frm.right = dec_disp_info->img_size_x; output_vcd_frm->dec_op_prop.disp_frm.bottom = dec_disp_info->img_size_y; } if (!dec_disp_info->disp_is_interlace) { output_vcd_frm->interlaced = false; output_vcd_frm->intrlcd_ip_frm_tag = VCD_FRAMETAG_INVALID; } else { output_vcd_frm->interlaced = true; output_vcd_frm->intrlcd_ip_frm_tag = dec_disp_info->tag_bottom; } output_vcd_frm->offset = 0; output_vcd_frm->data_len = decoder->y_cb_cr_size; if (free_luma_dpb) { output_vcd_frm->data_len = 0; output_vcd_frm->flags |= VCD_FRAME_FLAG_DECODEONLY; } output_vcd_frm->flags |= VCD_FRAME_FLAG_ENDOFFRAME; ddl_process_decoder_metadata(ddl); output_frame->frm_trans_end = frame_transact_end; if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_OP_TIME); ddl->ddl_context->ddl_callback( VCD_EVT_RESP_OUTPUT_DONE, vcd_status, output_frame, sizeof(struct ddl_frame_data_tag), (void *)ddl, ddl->ddl_context->client_data); return vcd_status; }
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; }
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); } } }
static u32 ddl_decoder_seq_done_callback(struct ddl_context *ddl_context, struct ddl_client_context *ddl) { struct ddl_decoder_data *decoder = &ddl->codec_data.decoder; struct vidc_1080p_seq_hdr_info seq_hdr_info; u32 process_further = true; struct ddl_profile_info_type disp_profile_info; /*HTC_START Fix Klocwork issue*/ seq_hdr_info.profile = 0; seq_hdr_info.level = 0; /*HTC_END*/ DDL_MSG_MED("ddl_decoder_seq_done_callback"); if (!ddl->decoding || !DDLCLIENT_STATE_IS(ddl, DDL_CLIENT_WAIT_FOR_INITCODECDONE)) { DDL_MSG_ERROR("STATE-CRITICAL-HDDONE"); ddl_client_fatal_cb(ddl); } else { if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_OP_TIME); ddl->cmd_state = DDL_CMD_INVALID; DDL_MSG_LOW("ddl_state_transition: %s ~~>" "DDL_CLIENT_WAIT_FOR_DPB", ddl_get_state_string(ddl->client_state)); ddl->client_state = DDL_CLIENT_WAIT_FOR_DPB; DDL_MSG_LOW("HEADER_DONE"); vidc_1080p_get_decode_seq_start_result(&seq_hdr_info); parse_hdr_size_data(ddl, &seq_hdr_info); if (!seq_hdr_info.img_size_x || !seq_hdr_info.img_size_y) { DDL_MSG_ERROR("FATAL:ZeroImageSize"); ddl_client_fatal_cb(ddl); return process_further; } vidc_sm_get_profile_info(&ddl->shared_mem [ddl->command_channel], &disp_profile_info); disp_profile_info.pic_profile = seq_hdr_info.profile; disp_profile_info.pic_level = seq_hdr_info.level; ddl_get_dec_profile_level(decoder, seq_hdr_info.profile, seq_hdr_info.level); switch (decoder->codec.codec) { case VCD_CODEC_H264: if (decoder->profile.profile == VCD_PROFILE_H264_HIGH || decoder->profile.profile == VCD_PROFILE_UNKNOWN) { if ((disp_profile_info.chroma_format_idc > VIDC_1080P_IDCFORMAT_420) || (disp_profile_info.bit_depth_luma_minus8 || disp_profile_info. bit_depth_chroma_minus8)) { DDL_MSG_ERROR("Unsupported H.264 " "feature: IDC " "format : %d, Bitdepth: %d", disp_profile_info. chroma_format_idc, (disp_profile_info. bit_depth_luma_minus8 || disp_profile_info. bit_depth_chroma_minus8)); ddl_client_fatal_cb(ddl); return process_further; } } break; case VCD_CODEC_MPEG4: case VCD_CODEC_DIVX_4: case VCD_CODEC_DIVX_5: case VCD_CODEC_DIVX_6: case VCD_CODEC_XVID: if (seq_hdr_info.data_partition) if ((seq_hdr_info.img_size_x * seq_hdr_info.img_size_y) > (720 * 576)) { DDL_MSG_ERROR("Unsupported DP clip"); ddl_client_fatal_cb(ddl); return process_further; } break; default: break; } ddl_calculate_stride(&decoder->frame_size, !decoder->progressive_only); decoder->frame_size.scan_lines = DDL_ALIGN(decoder->frame_size.height, DDL_TILE_ALIGN_HEIGHT); decoder->frame_size.stride = DDL_ALIGN(decoder->frame_size.width, DDL_TILE_ALIGN_WIDTH); parse_hdr_crop_data(ddl, &seq_hdr_info); if (decoder->codec.codec == VCD_CODEC_H264 && seq_hdr_info.level > VIDC_1080P_H264_LEVEL4) { DDL_MSG_ERROR("WARNING: H264MaxLevelExceeded : %d", seq_hdr_info.level); } ddl_set_default_decoder_buffer_req(decoder, false); if (decoder->header_in_start) { if (!(decoder->cont_mode) || (decoder->min_dpb_num > decoder->client_output_buf_req.min_count) || (decoder->actual_output_buf_req.sz > decoder->client_output_buf_req.sz)) { 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->client_data); ddl_release_command_channel(ddl_context, ddl->command_channel); } else { u32 seq_hdr_only_frame = false; u32 need_reconfig = false; struct vcd_frame_data *input_vcd_frm = &ddl->input_frame.vcd_frm; need_reconfig = ddl_check_reconfig(ddl); DDL_MSG_HIGH("%s : need_reconfig = %u\n", __func__, need_reconfig); if (input_vcd_frm->flags & VCD_FRAME_FLAG_EOS) { need_reconfig = false; } if (((input_vcd_frm->flags & VCD_FRAME_FLAG_CODECCONFIG) && (!(input_vcd_frm->flags & VCD_FRAME_FLAG_SYNCFRAME))) || input_vcd_frm->data_len <= seq_hdr_info.dec_frm_size) { seq_hdr_only_frame = true; input_vcd_frm->offset += seq_hdr_info.dec_frm_size; input_vcd_frm->data_len = 0; input_vcd_frm->flags |= VCD_FRAME_FLAG_CODECCONFIG; 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->client_data); } else { if (decoder->codec.codec == VCD_CODEC_VC1_RCV) { vidc_sm_set_start_byte_number( &ddl->shared_mem [ddl->command_channel], seq_hdr_info.dec_frm_size); } } if (need_reconfig) { struct ddl_frame_data_tag *payload = &ddl->input_frame; u32 payload_size = sizeof(struct ddl_frame_data_tag); 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) { payload = NULL; payload_size = 0; } DDL_MSG_HIGH("%s : sending port reconfig\n", __func__); ddl_context->ddl_callback( VCD_EVT_IND_OUTPUT_RECONFIG, VCD_S_SUCCESS, payload, payload_size, (u32 *) ddl, ddl->client_data); } if (!need_reconfig && !seq_hdr_only_frame) { if (!ddl_vidc_decode_set_buffers(ddl)) process_further = false; else { DDL_MSG_ERROR("ddl_vidc_decode_set_" "buffers failed"); ddl_client_fatal_cb(ddl); } } else ddl_release_command_channel(ddl_context, ddl->command_channel); } } return process_further; }
static u32 ddl_decoder_output_done_callback( struct ddl_client_context *ddl, u32 frame_transact_end) { struct ddl_context *ddl_context = ddl->ddl_context; struct ddl_decoder_data *decoder = &(ddl->codec_data.decoder); struct vidc_1080p_dec_disp_info *dec_disp_info = &(decoder->dec_disp_info); struct ddl_frame_data_tag *output_frame = &(ddl->output_frame); struct vcd_frame_data *output_vcd_frm = &(output_frame->vcd_frm); u32 vcd_status, free_luma_dpb = 0, disp_pict = 0, is_interlaced; get_dec_op_done_data(dec_disp_info, decoder->output_order, &output_vcd_frm->physical, &is_interlaced); decoder->progressive_only = !(is_interlaced); output_vcd_frm->frame = VCD_FRAME_YUV; if (decoder->codec.codec == VCD_CODEC_MPEG4 || decoder->codec.codec == VCD_CODEC_VC1 || decoder->codec.codec == VCD_CODEC_VC1_RCV || (decoder->codec.codec >= VCD_CODEC_DIVX_3 && decoder->codec.codec <= VCD_CODEC_XVID)) { vidc_sm_get_displayed_picture_frame(&ddl->shared_mem [ddl->command_channel], &disp_pict); if (decoder->output_order == VCD_DEC_ORDER_DISPLAY) { if (!disp_pict) { output_vcd_frm->frame = VCD_FRAME_NOTCODED; vidc_sm_get_available_luma_dpb_address( &ddl->shared_mem[ddl->command_channel], &free_luma_dpb); } } else { if (dec_disp_info->input_frame == VIDC_1080P_DECODE_FRAMETYPE_NOT_CODED) { output_vcd_frm->frame = VCD_FRAME_NOTCODED; vidc_sm_get_available_luma_dpb_dec_order_address( &ddl->shared_mem[ddl->command_channel], &free_luma_dpb); } } if (free_luma_dpb) output_vcd_frm->physical = (u8 *)(free_luma_dpb << 11); } vcd_status = ddl_decoder_dpb_transact(decoder, output_frame, DDL_DPB_OP_MARK_BUSY); if (vcd_status) { DDL_MSG_ERROR("CORRUPTED_OUTPUT_BUFFER_ADDRESS"); ddl_hw_fatal_cb(ddl); } else { vidc_sm_get_metadata_status(&ddl->shared_mem [ddl->command_channel], &decoder->meta_data_exists); if (decoder->output_order == VCD_DEC_ORDER_DISPLAY) vidc_sm_get_frame_tags(&ddl->shared_mem [ddl->command_channel], &dec_disp_info->tag_top, &dec_disp_info->tag_bottom); output_vcd_frm->ip_frm_tag = dec_disp_info->tag_top; vidc_sm_get_picture_times(&ddl->shared_mem [ddl->command_channel], &dec_disp_info->pic_time_top, &dec_disp_info->pic_time_bottom); get_dec_op_done_crop(decoder->output_order, dec_disp_info, &output_vcd_frm->dec_op_prop.disp_frm, &output_vcd_frm->dec_op_prop.frm_size, &decoder->frame_size, &ddl->shared_mem[ddl_context->response_cmd_ch_id]); if ((decoder->cont_mode) && ((output_vcd_frm->dec_op_prop.frm_size.width != decoder->frame_size.width) || (output_vcd_frm->dec_op_prop.frm_size.height != decoder->frame_size.height) || (decoder->frame_size.width != decoder->client_frame_size.width) || (decoder->frame_size.height != decoder->client_frame_size.height))) { DDL_MSG_LOW("%s o/p width = %u o/p height = %u" "decoder width = %u decoder height = %u ", __func__, output_vcd_frm->dec_op_prop.frm_size.width, output_vcd_frm->dec_op_prop.frm_size.height, decoder->frame_size.width, decoder->frame_size.height); DDL_MSG_HIGH("%s Sending INFO_OP_RECONFIG event\n", __func__); ddl_context->ddl_callback( VCD_EVT_IND_INFO_OUTPUT_RECONFIG, VCD_S_SUCCESS, NULL, 0, (u32 *)ddl, ddl->client_data); decoder->frame_size = output_vcd_frm->dec_op_prop.frm_size; decoder->client_frame_size = decoder->frame_size; decoder->y_cb_cr_size = ddl_get_yuv_buffer_size(&decoder->frame_size, &decoder->buf_format, (!decoder->progressive_only), decoder->codec.codec, NULL); decoder->actual_output_buf_req.sz = decoder->y_cb_cr_size + decoder->suffix; decoder->min_output_buf_req = decoder->actual_output_buf_req; DDL_MSG_LOW("%s y_cb_cr_size = %u " "actual_output_buf_req.sz = %u" "min_output_buf_req.sz = %u\n", decoder->y_cb_cr_size, decoder->actual_output_buf_req.sz, decoder->min_output_buf_req.sz); vidc_sm_set_chroma_addr_change( &ddl->shared_mem[ddl->command_channel], false); } output_vcd_frm->interlaced = is_interlaced; output_vcd_frm->intrlcd_ip_frm_tag = (!is_interlaced || !dec_disp_info->tag_bottom) ? VCD_FRAMETAG_INVALID : dec_disp_info->tag_bottom; output_vcd_frm->offset = 0; output_vcd_frm->data_len = decoder->y_cb_cr_size; if (free_luma_dpb) { output_vcd_frm->data_len = 0; output_vcd_frm->flags |= VCD_FRAME_FLAG_DECODEONLY; } output_vcd_frm->flags |= VCD_FRAME_FLAG_ENDOFFRAME; output_frame->frm_trans_end = frame_transact_end; if (vidc_msg_timing) ddl_calc_core_proc_time(__func__, DEC_OP_TIME); ddl_process_decoder_metadata(ddl); ddl_context->ddl_callback(VCD_EVT_RESP_OUTPUT_DONE, vcd_status, output_frame, sizeof(struct ddl_frame_data_tag), (u32 *)ddl, ddl->client_data); } return vcd_status; }