SAMPLE_COMM_VENC_SetVuiInfo源码
时间: 2023-08-21 14:06:13 浏览: 65
SAMPLE_COMM_VENC_SetVuiInfo是海思编码器示例程序中的一个函数,用于设置H.264视频编码器的VUI(Video Usability Information)参数。具体的源码实现如下:
```c
HI_S32 SAMPLE_COMM_VENC_SetVuiInfo(HI_MPI_VENC_ATTR_H264_S *pstAttr)
{
HI_S32 s32Ret;
HI_MPI_VENC_PARAM_H264_VUI_S stVuiParam;
memset(&stVuiParam, 0, sizeof(HI_MPI_VENC_PARAM_H264_VUI_S));
stVuiParam.bAspectRatioInfoPresentFlag = HI_TRUE;
stVuiParam.u32AspectRatioIdc = 1;
stVuiParam.u16SarWidth = 1;
stVuiParam.u16SarHeight = 1;
pstAttr->stVuiPara.bEnable = HI_TRUE;
pstAttr->stVuiPara.stAttr.stVuiPara.h264Vui.bAspectRatioInfoPresentFlag = stVuiParam.bAspectRatioInfoPresentFlag;
pstAttr->stVuiPara.stAttr.stVuiPara.h264Vui.u32AspectRatioIdc = stVuiParam.u32AspectRatioIdc;
pstAttr->stVuiPara.stAttr.stVuiPara.h264Vui.u16SarWidth = stVuiParam.u16SarWidth;
pstAttr->stVuiPara.stAttr.stVuiPara.h264Vui.u16SarHeight = stVuiParam.u16SarHeight;
s32Ret = HI_MPI_VENC_SetH264VuiCfg(0, &pstAttr->stVuiPara.stAttr.stVuiPara.h264Vui);
if (HI_SUCCESS != s32Ret)
{
printf("HI_MPI_VENC_SetH264VuiCfg failed with %#x!\n", s32Ret);
return HI_FAILURE;
}
return HI_SUCCESS;
}
```
该函数中首先创建一个HI_MPI_VENC_PARAM_H264_VUI_S类型的结构体变量stVuiParam,并将其成员变量全部初始化为0。接着,设置stVuiParam的几个关键成员变量,包括bAspectRatioInfoPresentFlag、u32AspectRatioIdc、u16SarWidth和u16SarHeight。这些变量分别表示视频比例信息是否存在、比例信息标识符、样本宽度和样本高度等信息。
接下来,将pstAttr的stVuiPara成员变量的相关字段设置为和stVuiParam相同的值。其中,pstAttr是HI_MPI_VENC_ATTR_H264_S类型的结构体变量,代表H.264编码器的参数。通过设置pstAttr的stVuiPara字段,可以将VUI参数传递给编码器。
最后,使用HI_MPI_VENC_SetH264VuiCfg函数将VUI参数设置到编码器中。该函数的第一个参数代表编码通道号,这里设置为0。第二个参数则是VUI参数的具体值。如果设置成功,该函数返回HI_SUCCESS;否则返回HI_FAILURE。
需要注意的是,上述代码中只设置了VUI参数中的一部分字段,而实际应用中可能需要根据具体需求设置更多的VUI参数。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)