static HI_S32 SampleDisableEncodeH264(VENC_GRP VeGroup, VENC_CHN VeChn) { HI_S32 s32Ret; s32Ret = HI_MPI_VENC_StopRecvPic(VeChn); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_StartRecvPic err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_UnRegisterChn(VeChn); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyChn(VeChn); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyGroup(VeGroup); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyGroup err 0x%x\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 PCIV_Slave_StopGrp(PCIV_MSGHEAD_S *pMsg) { HI_S32 s32Ret; VENC_GRP vencGrp; PCIV_GRPCMD_DESTROY_S *pCmd = (PCIV_GRPCMD_DESTROY_S *)pMsg->cMsgBody; PCIV_GRPCMD_ECHO_S *pCmdEcho = (PCIV_GRPCMD_ECHO_S *)pMsg->cMsgBody; /* Start the VI first */ vencGrp = pCmd->vencGrp; s32Ret = HI_MPI_VENC_UnbindInput(vencGrp); HI_ASSERT((HI_SUCCESS == s32Ret)); /* Create new group first */ s32Ret = HI_MPI_VENC_DestroyGroup(vencGrp); HI_ASSERT((HI_SUCCESS == s32Ret)); /* Echo the cmd */ pMsg->enMsgType = PCIV_MSGTYPE_CMDECHO; pMsg->enDevType = PCIV_DEVTYPE_GROUP; pMsg->u32Target = 0; pMsg->u32MsgLen = sizeof(PCIV_GRPCMD_ECHO_S); pCmdEcho->vencGrp = vencGrp; pCmdEcho->s32Echo = HI_SUCCESS; s32Ret = PCIV_SendMsg(0, PCIV_MSGPORT_USERCMD, pMsg); HI_ASSERT((HI_FAILURE != s32Ret)); return HI_SUCCESS; }
static int enc_release_h264_stream(int vin, int stream) { SDK_ENC_H264_STREAM_ATTR_t* stream_attr = &_sdk_enc.attr.video_stream_attr[vin][stream]; if(vin < HI_VENC_CH_BACKLOG_REF && stream < HI_VENC_STREAM_BACKLOG_REF){ if(ENC_H264_STREAM_ATTR_MAGIC == stream_attr->magic){ int const venc_group = vin; int const venc_ch = vin * HI_VENC_STREAM_BACKLOG_REF + stream; SOC_TRACE("Release video encode (%d,%d)", vin, stream); SOC_CHECK(HI_MPI_VENC_StopRecvPic(venc_ch)); SOC_CHECK(HI_MPI_VENC_UnRegisterChn(venc_ch)); SOC_CHECK(HI_MPI_VENC_DestroyChn(venc_ch)); if(0 == stream){ SOC_CHECK(HI_MPI_VENC_UnbindInput(venc_group)); SOC_CHECK(HI_MPI_VENC_DestroyGroup(venc_group)); } // clear the magic stream_attr->magic = 0; return SDK_SUCCESS; } } return SDK_FAILURE; }
HI_S32 SampleDisable1D1Mjpeg1CifH264(HI_VOID) { HI_S32 s32Ret; s32Ret = HI_MPI_VENC_StopRecvPic(1); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_StartRecvPic err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_StopRecvPic(0); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_StartRecvPic err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_UnRegisterChn(1); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_UnRegisterChn(0); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_UnRegisterChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyChn(1); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyChn(0); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyGroup(0); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyGroup err 0x%x\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
HI_S32 SampleDestroySnapChn(VENC_GRP VeGroup,VENC_CHN SnapChn) { HI_S32 s32Ret; s32Ret = HI_MPI_VENC_DestroyChn(SnapChn); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyChn err 0x%x\n",s32Ret); return HI_FAILURE; } s32Ret = HI_MPI_VENC_DestroyGroup(VeGroup); if (s32Ret != HI_SUCCESS) { printf("HI_MPI_VENC_DestroyGroup err 0x%x\n",s32Ret); return HI_FAILURE; } return HI_SUCCESS; }
bool HimppVencChan::disableObject() { HI_S32 s32Ret; GROUP_CROP_CFG_S dis_crop = { .bEnable = HI_FALSE }; MPP_CHN_S dst_chn = { .enModId = HI_ID_GROUP, .s32DevId = _grpid, .s32ChnId = 0 }; if ((s32Ret = HI_MPI_SYS_UnBind(*source(), &dst_chn)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_SYS_UnBind %d failed [%#x]\n", _chnid, s32Ret); } if ((s32Ret = HI_MPI_VENC_StopRecvPic(_chnid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_StopRecvPic %d failed [%#x]\n", _chnid, s32Ret); } if ((s32Ret = HI_MPI_VENC_SetGrpCrop(_grpid, &dis_crop)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_SetGrpCrop [%d] failed [%#x]!\n", _grpid, s32Ret); } if ((s32Ret = HI_MPI_VENC_UnRegisterChn(_chnid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_UnRegisterChn %d failed [%#x]\n", _chnid, s32Ret); } if ((s32Ret = HI_MPI_VENC_DestroyChn(_chnid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_DestroyChn %d failed [%#x]\n", _chnid, s32Ret); } if ((s32Ret = HI_MPI_VENC_DestroyGroup(_grpid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_DestroyGroup %d failed [%#x]\n", _grpid, s32Ret); } return true; }
static int enc_release_h264_stream(int vin, int stream) { SDK_ENC_H264_STREAM_ATTR_t* stream_attr = &_sdk_enc.attr.video_stream_attr[vin][stream]; if(stream_attr && vin < HI_VENC_CH_BACKLOG_REF && stream < HI_VENC_STREAM_BACKLOG_REF){ if(ENC_H264_STREAM_ATTR_MAGIC == stream_attr->magic){ int const venc_ch = __HI_VENC_CH(vin, stream); int const venc_group = venc_ch; int const vpss_group = vin; int const vpss_ch = (venc_ch % HI_VENC_STREAM_BACKLOG_REF); MPP_CHN_S mpp_chn_vpss; MPP_CHN_S mpp_chn_venc; memset(&mpp_chn_vpss, 0, sizeof(mpp_chn_vpss)); memset(&mpp_chn_venc, 0, sizeof(mpp_chn_venc)); // unbind venc to vpss mpp_chn_vpss.enModId = HI_ID_VPSS; mpp_chn_vpss.s32DevId = vpss_group; mpp_chn_vpss.s32ChnId = vpss_ch; mpp_chn_venc.enModId = HI_ID_GROUP; mpp_chn_venc.s32DevId = venc_group; mpp_chn_venc.s32ChnId = venc_ch; SOC_TRACE("Stoping recv venc %d", venc_ch); SOC_CHECK(HI_MPI_VENC_StopRecvPic(venc_ch)); SOC_CHECK(HI_MPI_SYS_UnBind(&mpp_chn_vpss, &mpp_chn_venc)); SOC_CHECK(HI_MPI_VENC_UnRegisterChn(venc_ch)); SOC_CHECK(HI_MPI_VENC_DestroyChn(venc_ch)); SOC_CHECK(HI_MPI_VENC_DestroyGroup(venc_group)); // clear the magic stream_attr->magic = 0; return SDK_SUCCESS; } } return SDK_FAILURE; }
bool HimppVencChan::enableObject() { HI_S32 s32Ret; GROUP_CROP_CFG_S dis_crop = { .bEnable = HI_FALSE }; if ((s32Ret = HI_MPI_VENC_CreateGroup(_grpid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_CreateGroup %d failed [%#x]\n", _grpid, s32Ret); return false; } VENC_CHN_ATTR_S attr; prepareVencChnAttr(attr); if ((s32Ret = HI_MPI_VENC_CreateChn(_chnid, &attr)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_CreateChn %d faild [%#x]\n", _chnid, s32Ret); goto err_destroy_grp; } if ((s32Ret = HI_MPI_VENC_SetMaxStreamCnt(_chnid, 4)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_SetMaxStreamCnt %d failed [%#x]\n", _chnid, s32Ret); } if ((s32Ret = HI_MPI_VENC_RegisterChn(_grpid, _chnid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_RegisterChn %d-%d failed [%#x]\n", _grpid, _chnid, s32Ret); goto err_destroy_chn; } if ((s32Ret = HI_MPI_VENC_SetGrpCrop(_grpid, &_crop_cfg)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_SetGrpCrop [%d] faild [%#x]!\n", _grpid, s32Ret); goto err_unregister_chn; } if ((s32Ret = HI_MPI_VENC_StartRecvPic(_chnid)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_VENC_StartRecvPic %d failed [%#x]\n", _chnid, s32Ret); goto err_disable_crop; } MPP_CHN_S dst_chn; dst_chn.enModId = HI_ID_GROUP; dst_chn.s32DevId = _grpid; dst_chn.s32ChnId = 0; if ((s32Ret = HI_MPI_SYS_Bind(*source(), &dst_chn)) != HI_SUCCESS) { HIMPP_PRINT("HI_MPI_SYS_Bind %d failed [%#x]\n", _chnid, s32Ret); goto err_stop_recv_pic; } return true; err_stop_recv_pic: HI_MPI_VENC_StopRecvPic(_chnid); err_disable_crop: HI_MPI_VENC_SetGrpCrop(_grpid, &dis_crop); err_unregister_chn: HI_MPI_VENC_UnRegisterChn(_chnid); err_destroy_chn: HI_MPI_VENC_DestroyChn(_chnid); err_destroy_grp: HI_MPI_VENC_DestroyGroup(_grpid); return false; }