海思的旋转图像方法,使用cat /proc/vpss等命令测试查看各个设置项的参数
具体的设置步骤如下
1,从proc分析,vpss的grp需要设置为1280x720,
2,VPSS PHY CHN MODE里面的宽高,也设置为1280x720,3,然后设置为vpss通道0,通道1,旋转90度,
4,然后看下VPSS CHN OUTPUT RESOLUTION里面的宽高状态,是不是已经变成720x1280了?
5,如果第4步ok的话,venc设置为720x1280,应该就可以了。
6,还需要设置图像格式为非压缩
特别注意第六步设置,在05版本之前的必须设置要设置为非压缩的才行的,之后版本目前还未接触,还需等待验证
之后才可以。具体的代码如下
VpssChn = 0;
stVpssChnMode.enChnMode = VPSS_CHN_MODE_USER;
stVpssChnMode.bDouble = HI_FALSE;
stVpssChnMode.enPixelFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;
stVpssChnMode.u32Width = pstSize.u32Width;
stVpssChnMode.u32Height = pstSize.u32Height;
stVpssChnMode.enCompressMode = COMPRESS_MODE_NONE;
memset(&stVpssChnAttr, 0, sizeof(stVpssChnAttr));
stVpssChnAttr.s32SrcFrameRate = -1;
stVpssChnAttr.s32DstFrameRate = -1;
s32Ret= Hi_LiteOs_Comm_Vpss_EnableChn( VpssGrp, VpssChn, &stVpssChnAttr, &stVpssChnMode, HI_NULL);
if(s32Ret != HI_SUCCESS)
{
goto END_VENC_STEP_4;
}
在使能Vpss通道的时候,需将该通道设置为非压缩,注意绿色代码,此时并没有去设置旋转的参数,长和宽依旧是原来分辨率的长宽。
进入上面使能函数设置图像个码流参数,在该函数中就需要设置旋转参数,调用旋转API,代码如下
if (VpssChn < VPSS_MAX_PHY_CHN_NUM)
{
enRotate = ROTATE_90;
s32Ret = HI_MPI_VPSS_SetRotate(VpssGrp, VpssChn, enRotate);
if(s32Ret != HI_SUCCESS)
{
PRINTF("HI_MPI_VPSS_SetRotate failed with %#x\n", s32Ret);
return HI_FAILURE;
}
}
到这里Vpss通道的旋转属性就设置完成了,注意旋转的通道号的设置。
接下来便是Venc通道的设置,也就是上述的第五步骤,在创建Venc通道时分辨率需要改变,即调整对应的高宽如下
设置其他相应的码流参数,具体如下。
stVencChnAttr.stVeAttr.enType = enType;
switch(enType)
{
case PT_H264:
{
stH264Attr.u32MaxPicWidth = stPicSize.u32Height;
stH264Attr.u32MaxPicHeight = stPicSize.u32Width;
stH264Attr.u32PicWidth = stPicSize.u32Height;/*the picture width*/
stH264Attr.u32PicHeight = stPicSize.u32Width;/*the picture height*/
stH264Attr.u32BufSize = stPicSize.u32Width * stPicSize.u32Height;/*stream buffer size*/
stH264Attr.u32Profile = u32Profile;/*0: baseline; 1:MP; 2:HP; 3:svc_t */
stH264Attr.bByFrame = HI_TRUE;/*get stream mode is slice mode or frame mode?*/
stH264Attr.u32BFrameNum = 0;/* 0: not support B frame; >=1: number of B frames */
stH264Attr.u32RefNum = 0;// 1;/* 0: default; number of refrence frame*/
memcpy(&stVencChnAttr.stVeAttr.stAttrH264e, &stH264Attr, sizeof(VENC_ATTR_H264_S));
}
**********
********
******
****
**
*
}
实现上述接口API即可让3518EV200的图像旋转成功。
记述只是为了不要忘记,或许说不定也能帮到一些人。