海思动态修改分辨率及码率控制方式

int Hisi_set_video_fmt(HX_MEDIA_SYS_PARAM * pMediaSys, int iMediaId, int enVideoFmt, int enRCMode,  int bitstream)
{
	HI_S32 s32Ret = HI_SUCCESS;
	PIC_SIZE_E enSize = PIC_HD1080;
	HX_VIDEO_ATTR * pVideoAttr = NULL;
	int rcMode = HX_VENC_RC_MODE_H264VBR;
	pVideoAttr = &pMediaSys->mediaAttr[iMediaId].videoAttr;

	s32Ret = SAMPLE_COMM_VENC_Stop(iMediaId);
	if(HI_SUCCESS != s32Ret)
	{
		printf("SAMPLE_COMM_VENC_StopSAMPLE_COMM_VENC_StopSAMPLE_COMM_VENC_StopSAMPLE_COMM_VENC_Stop failed!!!\n");
		return s32Ret;
	}

	switch(enVideoFmt)
	{
		case VIDEO_FMT_1080P:
			enSize = PIC_HD1080;
			
			pVideoAttr->iPicWidth = 1920;
			pVideoAttr->iPicHeight = 1080;
			break;
			
		case VIDEO_FMT_720P:
			enSize = PIC_HD720;
				
			pVideoAttr->iPicWidth = 1280;
			pVideoAttr->iPicHeight = 720;
			break;
			
		case VIDEO_FMT_4CIF:
			enSize = PIC_D1;

			pVideoAttr->iPicWidth = 704;
			pVideoAttr->iPicHeight = 576;
			break;
			
		case VIDEO_FMT_CIF:
			enSize = PIC_CIF;

			pVideoAttr->iPicWidth = 352;
			pVideoAttr->iPicHeight = 288;
			break;

		default:
			printf("UNKOWN video fomat type!!!\n");
			break;
	}

	if(enRCMode == RATE_MODE_VBR)
	{
		printf("HX_VENC_RC_MODE_H264VBR/HX_VENC_RC_MODE_H264FIXQP set.\n");
		rcMode = HX_VENC_RC_MODE_H264VBR;
		pVideoAttr->rcMode = HX_VENC_RC_MODE_H264VBR;
	}
	else
	{
		printf("HX_VENC_RC_MODE_H264CBR set.\n");
		rcMode = HX_VENC_RC_MODE_H264CBR;
		pVideoAttr->rcMode = HX_VENC_RC_MODE_H264CBR;
	}
	
	s32Ret = SAMPLE_COMM_VENC_Start(iMediaId, Hisi_GetCodeType(pVideoAttr->encType), pMediaSys->videoNorm, enSize, rcMode, bitstream, 0);
	if(HI_SUCCESS != s32Ret)
	{
		printf("SAMPLE_COMM_VENC_StartSAMPLE_COMM_VENC_StartSAMPLE_COMM_VENC_StartSAMPLE_COMM_VENC_Start failed!!!\n");
		return s32Ret;
	}

	return s32Ret;
}


你可能感兴趣的:(音视频)