u32 vid_enc_request_iframe(struct video_client_ctx *client_ctx) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_req_i_frame_type request; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx) return FALSE; vcd_property_hdr.prop_id = VCD_I_REQ_IFRAME; vcd_property_hdr.n_size = sizeof(struct vcd_property_req_i_frame_type); request.b_req_i_frame = 1; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &request); if (vcd_status) { ERR("%s(): Set VCD_I_REQ_IFRAME Failed\n", __func__); return FALSE; } return status; }
static u32 vid_dec_set_codec(struct video_client_ctx *client_ctx, enum vdec_codec *vdec_codec_type) { u32 result = TRUE; struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_codec_type codec_type; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !vdec_codec_type) return FALSE; vcd_property_hdr.prop_id = VCD_I_CODEC; vcd_property_hdr.n_size = sizeof(struct vcd_property_codec_type); switch (*vdec_codec_type) { case VDEC_CODECTYPE_MPEG4: codec_type.e_codec = VCD_CODEC_MPEG4; break; case VDEC_CODECTYPE_H264: codec_type.e_codec = VCD_CODEC_H264; break; case VDEC_CODECTYPE_DIVX_3: codec_type.e_codec = VCD_CODEC_DIVX_3; break; case VDEC_CODECTYPE_XVID: codec_type.e_codec = VCD_CODEC_XVID; break; case VDEC_CODECTYPE_H263: codec_type.e_codec = VCD_CODEC_H263; break; case VDEC_CODECTYPE_MPEG2: codec_type.e_codec = VCD_CODEC_MPEG2; break; case VDEC_CODECTYPE_VC1: codec_type.e_codec = VCD_CODEC_VC1; break; default: result = FALSE; break; } if (result) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &codec_type); if (vcd_status) result = FALSE; } return result; }
u32 vid_enc_set_get_live_mode(struct video_client_ctx *client_ctx, struct venc_switch *encoder_switch, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_live_type live_mode; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx) return FALSE; vcd_property_hdr.prop_id = VCD_I_LIVE; vcd_property_hdr.n_size = sizeof(struct vcd_property_live_type); if (set_flag) { live_mode.b_live = 1; if (!encoder_switch->status) live_mode.b_live = 0; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &live_mode); if (vcd_status) { ERR("%s(): Set VCD_I_LIVE Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &live_mode); if (vcd_status) { ERR("%s(): Get VCD_I_LIVE Failed\n", __func__); return FALSE; } else { encoder_switch->status = 1; if (!live_mode.b_live) encoder_switch->status = 0; } } return TRUE; }
u32 vid_enc_set_get_session_qp(struct video_client_ctx *client_ctx, struct venc_sessionqp *session_qp, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_session_qp_type qp_type; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !session_qp) return FALSE; vcd_property_hdr.prop_id = VCD_I_SESSION_QP; vcd_property_hdr.n_size = sizeof(struct vcd_property_session_qp_type); if (set_flag) { qp_type.n_i_frame_qp = session_qp->iframeqp; qp_type.n_p_frame_qp = session_qp->pframqp; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &qp_type); if (vcd_status) { ERR("%s(): Set VCD_I_SESSION_QP Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &qp_type); if (vcd_status) { ERR("%s(): Set VCD_I_SESSION_QP Failed\n", __func__); return FALSE; } else { session_qp->iframeqp = qp_type.n_i_frame_qp; session_qp->pframqp = qp_type.n_p_frame_qp; } } return TRUE; }
u32 vid_enc_set_get_qprange(struct video_client_ctx *client_ctx, struct venc_qprange *qprange, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_qp_range_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !qprange) return FALSE; vcd_property_hdr.prop_id = VCD_I_QP_RANGE; vcd_property_hdr.n_size = sizeof(struct vcd_property_qp_range_type); if (set_flag) { control_type.n_max_qp = qprange->maxqp; control_type.n_min_qp = qprange->minqp; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_QP_RANGE Failed\n", __func__); status = FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_QP_RANGE Failed\n", __func__); status = FALSE; } else { qprange->maxqp = control_type.n_max_qp; qprange->minqp = control_type.n_min_qp; } } return status; }
u32 vid_enc_set_get_short_header(struct video_client_ctx *client_ctx, struct venc_switch *encoder_switch, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_short_header_type short_header; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !encoder_switch) return FALSE; vcd_property_hdr.prop_id = VCD_I_SHORT_HEADER; vcd_property_hdr.n_size = sizeof(struct vcd_property_short_header_type); if (set_flag) { short_header.b_short_header = (u32) encoder_switch->status; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &short_header); if (vcd_status) { ERR("%s(): Set VCD_I_SHORT_HEADER Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &short_header); if (vcd_status) { ERR("%s(): Get VCD_I_SHORT_HEADER Failed\n", __func__); return FALSE; } else { encoder_switch->status = (u8) short_header.b_short_header; } } return TRUE; }
u32 vid_enc_set_get_framesize(struct video_client_ctx *client_ctx, u32 *height, u32 *width, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_frame_size_type frame_size; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !height || !width) return FALSE; vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; vcd_property_hdr.n_size = sizeof(struct vcd_property_frame_size_type); if (set_flag) { frame_size.n_height = *height; frame_size.n_width = *width; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &frame_size); if (vcd_status) { ERR("%s(): Set VCD_I_FRAME_SIZE Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &frame_size); if (vcd_status) { ERR("%s(): Get VCD_I_FRAME_SIZE Failed\n", __func__); return FALSE; } *height = frame_size.n_height; *width = frame_size.n_width; } return TRUE; }
u32 vid_enc_set_get_voptimingcfg(struct video_client_ctx *client_ctx, struct venc_voptimingcfg *voptimingcfg, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_vop_timing_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !voptimingcfg) return FALSE; vcd_property_hdr.prop_id = VCD_I_VOP_TIMING; vcd_property_hdr.n_size = sizeof(struct vcd_property_vop_timing_type); if (set_flag) { control_type.n_vop_time_resolution = voptimingcfg->voptime_resolution; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_VOP_TIMING Failed\n", __func__); status = FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_VOP_TIMING Failed\n", __func__); status = FALSE; } else voptimingcfg->voptime_resolution = control_type.n_vop_time_resolution; } return status; }
u32 vid_enc_set_get_framerate(struct video_client_ctx *client_ctx, struct venc_framerate *frame_rate, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_frame_rate_type vcd_frame_rate; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !frame_rate) return FALSE; vcd_property_hdr.prop_id = VCD_I_FRAME_RATE; vcd_property_hdr.n_size = sizeof(struct vcd_property_frame_rate_type); if (set_flag) { vcd_frame_rate.n_fps_denominator = frame_rate->fps_denominator; vcd_frame_rate.n_fps_numerator = frame_rate->fps_numerator; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &vcd_frame_rate); if (vcd_status) { ERR("%s(): Set VCD_I_FRAME_RATE Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &vcd_frame_rate); if (vcd_status) { ERR("%s(): Get VCD_I_FRAME_RATE Failed\n", __func__); return FALSE; } frame_rate->fps_denominator = vcd_frame_rate.n_fps_denominator; frame_rate->fps_numerator = vcd_frame_rate.n_fps_numerator; } return TRUE; }
u32 vid_enc_set_get_intraperiod(struct video_client_ctx *client_ctx, struct venc_intraperiod *intraperiod, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_i_period_type period_type; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !intraperiod) return FALSE; vcd_property_hdr.prop_id = VCD_I_INTRA_PERIOD; vcd_property_hdr.n_size = sizeof(struct vcd_property_i_period_type); if (set_flag) { period_type.n_p_frames = intraperiod->num_pframes; period_type.n_b_frames = 0; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &period_type); if (vcd_status) { ERR("%s(): Set VCD_I_INTRA_PERIOD Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &period_type); if (vcd_status) { ERR("%s(): Get VCD_I_INTRA_PERIOD Failed\n", __func__); return FALSE; } else intraperiod->num_pframes = period_type.n_p_frames; } return TRUE; }
static u32 vid_dec_set_output_format(struct video_client_ctx *client_ctx, enum vdec_output_fromat *output_format) { u32 result = TRUE; struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_buffer_format_type vcd_prop_buffer_format; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !output_format) return FALSE; vcd_property_hdr.prop_id = VCD_I_BUFFER_FORMAT;; vcd_property_hdr.n_size = sizeof(struct vcd_property_buffer_format_type); switch (*output_format) { case VDEC_YUV_FORMAT_NV12: vcd_prop_buffer_format.e_buffer_format = VCD_BUFFER_FORMAT_NV12; break; case VDEC_YUV_FORMAT_TILE_4x2: vcd_prop_buffer_format.e_buffer_format = VCD_BUFFER_FORMAT_TILE_4x2; break; default: result = FALSE; break; } if (result) vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &vcd_prop_buffer_format); if (vcd_status) return FALSE; else return TRUE; }
static u32 vid_dec_set_frame_resolution(struct video_client_ctx *client_ctx, struct vdec_picsize *video_resoultion) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_frame_size_type frame_resolution; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !video_resoultion) return FALSE; vcd_property_hdr.prop_id = VCD_I_FRAME_SIZE; vcd_property_hdr.n_size = sizeof(struct vcd_property_frame_size_type); frame_resolution.n_width = video_resoultion->frame_width; frame_resolution.n_height = video_resoultion->frame_height; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &frame_resolution); if (vcd_status) return FALSE; else return TRUE; }
u32 vid_enc_set_get_intrarefresh(struct video_client_ctx *client_ctx, struct venc_intrarefresh *intrarefresh, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_intra_refresh_mb_number_type control_type; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !intrarefresh) return FALSE; vcd_property_hdr.prop_id = VCD_I_INTRA_REFRESH; vcd_property_hdr.n_size = sizeof(struct vcd_property_intra_refresh_mb_number_type); if (set_flag) { control_type.n_cir_mb_number = intrarefresh->mbcount; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_INTRA_REFRESH Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_INTRA_REFRESH Failed\n", __func__); return FALSE; } else intrarefresh->mbcount = control_type.n_cir_mb_number; } return TRUE; }
u32 vid_enc_set_get_headerextension(struct video_client_ctx *client_ctx, struct venc_headerextension *headerextension, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; u32 control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !headerextension) return FALSE; vcd_property_hdr.prop_id = VCD_I_HEADER_EXTENSION; vcd_property_hdr.n_size = sizeof(u32); if (set_flag) { control_type = headerextension->header_extension; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_HEADER_EXTENSION Failed\n", __func__); status = FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_HEADER_EXTENSION Failed\n", __func__); status = FALSE; } else { headerextension->header_extension = control_type; } } return status; }
u32 vid_enc_set_get_bitrate(struct video_client_ctx *client_ctx, struct venc_targetbitrate *venc_bitrate, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_target_bitrate_type bit_rate; u32 vcd_status = VCD_ERR_FAIL; if (!client_ctx || !venc_bitrate) return FALSE; vcd_property_hdr.prop_id = VCD_I_TARGET_BITRATE; vcd_property_hdr.n_size = sizeof(struct vcd_property_target_bitrate_type); if (set_flag) { bit_rate.n_target_bitrate = venc_bitrate->target_bitrate; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &bit_rate); if (vcd_status) { ERR("%s(): Set VCD_I_TARGET_BITRATE Failed\n", __func__); return FALSE; } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &bit_rate); if (vcd_status) { ERR("%s(): Get VCD_I_TARGET_BITRATE Failed\n", __func__); return FALSE; } venc_bitrate->target_bitrate = bit_rate.n_target_bitrate; } return TRUE; }
u32 vid_enc_set_get_dbcfg(struct video_client_ctx *client_ctx, struct venc_dbcfg *dbcfg, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_db_config_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !dbcfg) return FALSE; vcd_property_hdr.prop_id = VCD_I_DEBLOCKING; vcd_property_hdr.n_size = sizeof(struct vcd_property_db_config_type); if (set_flag) { switch (dbcfg->db_mode) { case VEN_DB_DISABLE: control_type.e_db_config = VCD_DB_DISABLE; break; case VEN_DB_ALL_BLKG_BNDRY: control_type.e_db_config = VCD_DB_ALL_BLOCKING_BOUNDARY; break; case VEN_DB_SKIP_SLICE_BNDRY: control_type.e_db_config = VCD_DB_SKIP_SLICE_BOUNDARY; break; default: status = FALSE; break; } if (status) { control_type.n_slice_alpha_offset = dbcfg->slicealpha_offset; control_type.n_slice_beta_offset = dbcfg->slicebeta_offset; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_DEBLOCKING Failed\n", __func__); status = FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_DEBLOCKING Failed\n", __func__); status = FALSE; } else { switch (control_type.e_db_config) { case VCD_DB_ALL_BLOCKING_BOUNDARY: dbcfg->db_mode = VEN_DB_ALL_BLKG_BNDRY; break; case VCD_DB_DISABLE: dbcfg->db_mode = VEN_DB_DISABLE; break; case VCD_DB_SKIP_SLICE_BOUNDARY: dbcfg->db_mode = VEN_DB_SKIP_SLICE_BNDRY; break; default: status = FALSE; break; } dbcfg->slicealpha_offset = control_type.n_slice_alpha_offset; dbcfg->slicebeta_offset = control_type.n_slice_beta_offset; } } return status; }
u32 vid_enc_set_get_multiclicecfg(struct video_client_ctx *client_ctx, struct venc_multiclicecfg *multiclicecfg, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_multi_slice_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !multiclicecfg) return FALSE; vcd_property_hdr.prop_id = VCD_I_MULTI_SLICE; vcd_property_hdr.n_size = sizeof(struct vcd_property_multi_slice_type); if (set_flag) { switch (multiclicecfg->mslice_mode) { case VEN_MSLICE_OFF: control_type.e_m_slice_sel = VCD_MSLICE_OFF; break; case VEN_MSLICE_CNT_MB: control_type.e_m_slice_sel = VCD_MSLICE_BY_MB_COUNT; break; case VEN_MSLICE_CNT_BYTE: control_type.e_m_slice_sel = VCD_MSLICE_BY_BYTE_COUNT; break; case VEN_MSLICE_GOB: control_type.e_m_slice_sel = VCD_MSLICE_BY_GOB; break; default: status = FALSE; break; } if (status) { control_type.n_m_slice_size = multiclicecfg->mslice_size; vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_MULTI_SLICE Failed\n", __func__); status = FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_MULTI_SLICE Failed\n", __func__); status = FALSE; } else { multiclicecfg->mslice_size = control_type.n_m_slice_size; switch (control_type.e_m_slice_sel) { case VCD_MSLICE_OFF: multiclicecfg->mslice_mode = VEN_MSLICE_OFF; break; case VCD_MSLICE_BY_MB_COUNT: multiclicecfg->mslice_mode = VEN_MSLICE_CNT_MB; break; case VCD_MSLICE_BY_BYTE_COUNT: multiclicecfg->mslice_mode = VEN_MSLICE_CNT_BYTE; break; case VCD_MSLICE_BY_GOB: multiclicecfg->mslice_mode = VEN_MSLICE_GOB; break; default: status = FALSE; break; } } } return status; }
u32 vid_enc_set_get_ratectrlcfg(struct video_client_ctx *client_ctx, struct venc_ratectrlcfg *ratectrlcfg, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_rate_control_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !ratectrlcfg) return FALSE; vcd_property_hdr.prop_id = VCD_I_RATE_CONTROL; vcd_property_hdr.n_size = sizeof(struct vcd_property_rate_control_type); if (set_flag) { switch (ratectrlcfg->rcmode) { case VEN_RC_OFF: control_type.e_rate_control = VCD_RATE_CONTROL_OFF; break; case VEN_RC_CBR_VFR: control_type.e_rate_control = VCD_RATE_CONTROL_CBR_VFR; break; case VEN_RC_VBR_CFR: control_type.e_rate_control = VCD_RATE_CONTROL_VBR_CFR; break; case VEN_RC_VBR_VFR: control_type.e_rate_control = VCD_RATE_CONTROL_VBR_VFR; break; default: status = FALSE; break; } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_RATE_CONTROL Failed\n", __func__); status = FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_RATE_CONTROL Failed\n", __func__); status = FALSE; } else { switch (control_type.e_rate_control) { case VCD_RATE_CONTROL_OFF: ratectrlcfg->rcmode = VEN_RC_OFF; break; case VCD_RATE_CONTROL_CBR_VFR: ratectrlcfg->rcmode = VEN_RC_CBR_VFR; break; case VCD_RATE_CONTROL_VBR_CFR: ratectrlcfg->rcmode = VEN_RC_VBR_CFR; break; case VCD_RATE_CONTROL_VBR_VFR: ratectrlcfg->rcmode = VEN_RC_VBR_VFR; break; default: status = FALSE; break; } } } return status; }
u32 vid_enc_set_get_entropy_cfg(struct video_client_ctx *client_ctx, struct venc_entropycfg *entropy_cfg, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_entropy_control_type control_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !entropy_cfg) return FALSE; vcd_property_hdr.prop_id = VCD_I_ENTROPY_CTRL; vcd_property_hdr.n_size = sizeof(struct vcd_property_entropy_control_type); if (set_flag) { switch (entropy_cfg->cabacmodel) { case VEN_ENTROPY_MODEL_CAVLC: control_type.e_entropy_sel = VCD_ENTROPY_SEL_CAVLC; break; case VEN_ENTROPY_MODEL_CABAC: control_type.e_entropy_sel = VCD_ENTROPY_SEL_CABAC; break; default: status = FALSE; break; } if (status && entropy_cfg->cabacmodel == VCD_ENTROPY_SEL_CABAC) { switch (entropy_cfg->cabacmodel) { case VEN_CABAC_MODEL_0: control_type.e_cabac_model = VCD_CABAC_MODEL_NUMBER_0; break; case VEN_CABAC_MODEL_1: control_type.e_cabac_model = VCD_CABAC_MODEL_NUMBER_1; break; case VEN_CABAC_MODEL_2: control_type.e_cabac_model = VCD_CABAC_MODEL_NUMBER_2; break; default: status = FALSE; break; } } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Set VCD_I_ENTROPY_CTRL Failed\n", __func__); status = FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &control_type); if (vcd_status) { ERR("%s(): Get VCD_I_ENTROPY_CTRL Failed\n", __func__); status = FALSE; } else { switch (control_type.e_entropy_sel) { case VCD_ENTROPY_SEL_CABAC: entropy_cfg->cabacmodel = VEN_ENTROPY_MODEL_CABAC; break; case VCD_ENTROPY_SEL_CAVLC: entropy_cfg->cabacmodel = VEN_ENTROPY_MODEL_CAVLC; break; default: status = FALSE; break; } if (status && control_type.e_entropy_sel == VCD_ENTROPY_SEL_CABAC) { switch (control_type.e_cabac_model) { case VCD_CABAC_MODEL_NUMBER_0: entropy_cfg->cabacmodel = VEN_CABAC_MODEL_0; break; case VCD_CABAC_MODEL_NUMBER_1: entropy_cfg->cabacmodel = VEN_CABAC_MODEL_1; break; case VCD_CABAC_MODEL_NUMBER_2: entropy_cfg->cabacmodel = VEN_CABAC_MODEL_2; break; default: status = FALSE; break; } } } } return status; }
u32 vid_enc_set_get_inputformat(struct video_client_ctx *client_ctx, u32 *input_format, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_buffer_format_type format_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !input_format) return FALSE; vcd_property_hdr.prop_id = VCD_I_BUFFER_FORMAT; vcd_property_hdr.n_size = sizeof(struct vcd_property_buffer_format_type); if (set_flag) { switch (*input_format) { case VEN_INPUTFMT_NV12: format_type.e_buffer_format = VCD_BUFFER_FORMAT_NV12; break; case VEN_INPUTFMT_NV21: format_type.e_buffer_format = VCD_BUFFER_FORMAT_TILE_4x2; break; default: status = FALSE; break; } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &format_type); if (vcd_status) { status = FALSE; ERR("%s(): Set VCD_I_BUFFER_FORMAT Failed\n", __func__); } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &format_type); if (vcd_status) { status = FALSE; ERR("%s(): Get VCD_I_BUFFER_FORMAT Failed\n", __func__); } else { switch (format_type.e_buffer_format) { case VCD_BUFFER_FORMAT_NV12: *input_format = VEN_INPUTFMT_NV12; break; case VCD_BUFFER_FORMAT_TILE_4x2: *input_format = VEN_INPUTFMT_NV21; break; default: status = FALSE; break; } } } return status; }
u32 vid_enc_set_get_codec(struct video_client_ctx *client_ctx, u32 *codec_type, u32 set_flag) { struct vcd_property_codec_type vcd_property_codec; struct vcd_property_hdr_type vcd_property_hdr; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !codec_type) return FALSE; vcd_property_hdr.prop_id = VCD_I_CODEC; vcd_property_hdr.n_size = sizeof(struct vcd_property_codec_type); if (set_flag) { switch (*codec_type) { case VEN_CODEC_MPEG4: vcd_property_codec.e_codec = VCD_CODEC_MPEG4; break; case VEN_CODEC_H263: vcd_property_codec.e_codec = VCD_CODEC_H263; break; case VEN_CODEC_H264: vcd_property_codec.e_codec = VCD_CODEC_H264; break; default: status = FALSE; break; } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &vcd_property_codec); if (vcd_status) { status = FALSE; ERR("%s(): Set VCD_I_CODEC Failed\n", __func__); } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &vcd_property_codec); if (vcd_status) { status = FALSE; ERR("%s(): Get VCD_I_CODEC Failed\n", __func__); } else { switch (vcd_property_codec.e_codec) { case VCD_CODEC_H263: *codec_type = VEN_CODEC_H263; break; case VCD_CODEC_H264: *codec_type = VEN_CODEC_H264; break; case VCD_CODEC_MPEG4: *codec_type = VEN_CODEC_MPEG4; break; case VCD_CODEC_DIVX_3: case VCD_CODEC_DIVX_4: case VCD_CODEC_DIVX_5: case VCD_CODEC_DIVX_6: case VCD_CODEC_MPEG1: case VCD_CODEC_MPEG2: case VCD_CODEC_VC1: case VCD_CODEC_VC1_RCV: case VCD_CODEC_XVID: default: status = FALSE; break; } } } return status; }
u32 vid_enc_set_get_profile_level(struct video_client_ctx *client_ctx, struct ven_profilelevel *profile_level, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_level_type level_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !profile_level) return FALSE; vcd_property_hdr.prop_id = VCD_I_LEVEL; vcd_property_hdr.n_size = sizeof(struct vcd_property_level_type); if (set_flag) { switch (profile_level->level) { case VEN_LEVEL_MPEG4_0: level_type.e_level = VCD_LEVEL_MPEG4_0; break; case VEN_LEVEL_MPEG4_1: level_type.e_level = VCD_LEVEL_MPEG4_1; break; case VEN_LEVEL_MPEG4_2: level_type.e_level = VCD_LEVEL_MPEG4_2; break; case VEN_LEVEL_MPEG4_3: level_type.e_level = VCD_LEVEL_MPEG4_3; break; case VEN_LEVEL_MPEG4_4: level_type.e_level = VCD_LEVEL_MPEG4_4; break; case VEN_LEVEL_MPEG4_5: level_type.e_level = VCD_LEVEL_MPEG4_5; break; case VEN_LEVEL_MPEG4_3b: level_type.e_level = VCD_LEVEL_MPEG4_3b; break; case VEN_LEVEL_MPEG4_6: level_type.e_level = VCD_LEVEL_MPEG4_6; break; case VEN_LEVEL_H264_1: level_type.e_level = VCD_LEVEL_H264_1; break; case VEN_LEVEL_H264_1b: level_type.e_level = VCD_LEVEL_H264_1b; break; case VEN_LEVEL_H264_1p1: level_type.e_level = VCD_LEVEL_H264_1p1; break; case VEN_LEVEL_H264_1p2: level_type.e_level = VCD_LEVEL_H264_1p2; break; case VEN_LEVEL_H264_1p3: level_type.e_level = VCD_LEVEL_H264_1p3; break; case VEN_LEVEL_H264_2: level_type.e_level = VCD_LEVEL_H264_2; break; case VEN_LEVEL_H264_2p1: level_type.e_level = VCD_LEVEL_H264_2p1; break; case VEN_LEVEL_H264_2p2: level_type.e_level = VCD_LEVEL_H264_2p2; break; case VEN_LEVEL_H264_3: level_type.e_level = VCD_LEVEL_H264_3; break; case VEN_LEVEL_H264_3p1: level_type.e_level = VCD_LEVEL_H264_3p1; break; case VEN_LEVEL_H263_10: level_type.e_level = VCD_LEVEL_H263_10; break; case VEN_LEVEL_H263_20: level_type.e_level = VCD_LEVEL_H263_20; break; case VEN_LEVEL_H263_30: level_type.e_level = VCD_LEVEL_H263_30; break; case VEN_LEVEL_H263_40: level_type.e_level = VCD_LEVEL_H263_40; break; case VEN_LEVEL_H263_45: level_type.e_level = VCD_LEVEL_H263_45; break; case VEN_LEVEL_H263_50: level_type.e_level = VCD_LEVEL_H263_50; break; case VEN_LEVEL_H263_60: level_type.e_level = VCD_LEVEL_H263_60; break; case VEN_LEVEL_H263_70: level_type.e_level = VCD_LEVEL_H263_70; break; default: status = FALSE; break; } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &level_type); if (vcd_status) { ERR("%s(): Set VCD_I_LEVEL Failed\n", __func__); return FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &level_type); if (vcd_status) { ERR("%s(): Get VCD_I_LEVEL Failed\n", __func__); return FALSE; } else { switch (level_type.e_level) { case VCD_LEVEL_MPEG4_0: profile_level->level = VEN_LEVEL_MPEG4_0; break; case VCD_LEVEL_MPEG4_1: profile_level->level = VEN_LEVEL_MPEG4_1; break; case VCD_LEVEL_MPEG4_2: profile_level->level = VEN_LEVEL_MPEG4_2; break; case VCD_LEVEL_MPEG4_3: profile_level->level = VEN_LEVEL_MPEG4_3; break; case VCD_LEVEL_MPEG4_4: profile_level->level = VEN_LEVEL_MPEG4_4; break; case VCD_LEVEL_MPEG4_5: profile_level->level = VEN_LEVEL_MPEG4_5; break; case VCD_LEVEL_MPEG4_3b: profile_level->level = VEN_LEVEL_MPEG4_3b; break; case VCD_LEVEL_H264_1: profile_level->level = VEN_LEVEL_H264_1; break; case VCD_LEVEL_H264_1b: profile_level->level = VEN_LEVEL_H264_1b; break; case VCD_LEVEL_H264_1p1: profile_level->level = VEN_LEVEL_H264_1p1; break; case VCD_LEVEL_H264_1p2: profile_level->level = VEN_LEVEL_H264_1p2; break; case VCD_LEVEL_H264_1p3: profile_level->level = VEN_LEVEL_H264_1p3; break; case VCD_LEVEL_H264_2: profile_level->level = VEN_LEVEL_H264_2; break; case VCD_LEVEL_H264_2p1: profile_level->level = VEN_LEVEL_H264_2p1; break; case VCD_LEVEL_H264_2p2: profile_level->level = VEN_LEVEL_H264_2p2; break; case VCD_LEVEL_H264_3: profile_level->level = VEN_LEVEL_H264_3; break; case VCD_LEVEL_H264_3p1: profile_level->level = VEN_LEVEL_H264_3p1; break; case VCD_LEVEL_H264_3p2: status = FALSE; break; case VCD_LEVEL_H264_4: status = FALSE; break; case VCD_LEVEL_H263_10: profile_level->level = VEN_LEVEL_H263_10; break; case VCD_LEVEL_H263_20: profile_level->level = VEN_LEVEL_H263_20; break; case VCD_LEVEL_H263_30: profile_level->level = VEN_LEVEL_H263_30; break; case VCD_LEVEL_H263_40: profile_level->level = VEN_LEVEL_H263_40; break; case VCD_LEVEL_H263_45: profile_level->level = VEN_LEVEL_H263_45; break; case VCD_LEVEL_H263_50: profile_level->level = VEN_LEVEL_H263_50; break; case VCD_LEVEL_H263_60: profile_level->level = VEN_LEVEL_H263_60; break; case VCD_LEVEL_H263_70: status = FALSE; break; default: status = FALSE; break; } } } return status; }
u32 vid_enc_set_get_profile(struct video_client_ctx *client_ctx, struct venc_profile *profile, u32 set_flag) { struct vcd_property_hdr_type vcd_property_hdr; struct vcd_property_profile_type profile_type; u32 vcd_status = VCD_ERR_FAIL; u32 status = TRUE; if (!client_ctx || !profile) return FALSE; vcd_property_hdr.prop_id = VCD_I_PROFILE; vcd_property_hdr.n_size = sizeof(struct vcd_property_profile_type); if (set_flag) { switch (profile->profile) { case VEN_PROFILE_MPEG4_SP: profile_type.e_profile = VCD_PROFILE_MPEG4_SP; break; case VEN_PROFILE_MPEG4_ASP: profile_type.e_profile = VCD_PROFILE_MPEG4_ASP; break; case VEN_PROFILE_H264_BASELINE: profile_type.e_profile = VCD_PROFILE_H264_BASELINE; break; case VEN_PROFILE_H264_MAIN: profile_type.e_profile = VCD_PROFILE_H264_MAIN; break; case VEN_PROFILE_H264_HIGH: profile_type.e_profile = VCD_PROFILE_H264_HIGH; break; case VEN_PROFILE_H263_BASELINE: profile_type.e_profile = VCD_PROFILE_H263_BASELINE; break; default: status = FALSE; break; } if (status) { vcd_status = vcd_set_property(client_ctx->vcd_handle, &vcd_property_hdr, &profile_type); if (vcd_status) { ERR("%s(): Set VCD_I_PROFILE Failed\n", __func__); return FALSE; } } } else { vcd_status = vcd_get_property(client_ctx->vcd_handle, &vcd_property_hdr, &profile_type); if (vcd_status) { ERR("%s(): Get VCD_I_PROFILE Failed\n", __func__); return FALSE; } else { switch (profile_type.e_profile) { case VCD_PROFILE_H263_BASELINE: profile->profile = VEN_PROFILE_H263_BASELINE; break; case VCD_PROFILE_H264_BASELINE: profile->profile = VEN_PROFILE_H264_BASELINE; break; case VCD_PROFILE_H264_HIGH: profile->profile = VEN_PROFILE_H264_HIGH; break; case VCD_PROFILE_H264_MAIN: profile->profile = VEN_PROFILE_H264_MAIN; break; case VCD_PROFILE_MPEG4_ASP: profile->profile = VEN_PROFILE_MPEG4_ASP; break; case VCD_PROFILE_MPEG4_SP: profile->profile = VEN_PROFILE_MPEG4_SP; break; default: status = FALSE; break; } } } return status; }