Example #1
0
HI_S32 SampleViVoClipD1to4Cif_SD(VI_DEV ViDev, VI_CHN ViChn, VO_DEV VoDev)
{
    HI_S32 s32Ret, i;

    SAMPLE_StartVi_SD(4, PIC_D1);
    SAMPLE_StartVo_SD(4, VoDev);

    for(i=0; i<4; i++)
    {
        VO_ZOOM_ATTR_S stZoom;
        stZoom.enField = (i <= 1) ? VIDEO_FIELD_TOP : VIDEO_FIELD_BOTTOM;
        stZoom.stZoomRect.s32X = ( i & 1) ? 0 : 352;
        stZoom.stZoomRect.s32Y = 0;
        stZoom.stZoomRect.u32Height = 288;
        stZoom.stZoomRect.u32Width  = 352;

        s32Ret = HI_MPI_VO_SetZoomInWindow(VoDev, i, &stZoom);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VO_SetZoomInWindow err 0x%x\n", s32Ret);
            return HI_FAILURE;
        }

        s32Ret = HI_MPI_VI_BindOutput(ViDev, ViChn, VoDev, i);
        if (s32Ret != HI_SUCCESS)
        {
            printf("HI_MPI_VI_BindOutput err 0x%x\n", s32Ret);
            return HI_FAILURE;
        }

    }

    return HI_SUCCESS;
}
Example #2
0
HI_S32 CODEC_1D1_H264(HI_VOID)
{
    SampleInitViMScreen(1);
    SampleInitVoMScreen(1);

    if (HI_TRUE == g_bPreviewOnly)
    {
        CHECK(HI_MPI_VI_BindOutput(0, 0, 0),"HI_MPI_VI_BindOutput");
        while (getchar() != 'q')
        {
        }
        CHECK(HI_MPI_VI_UnBindOutput(0, 0, 0),"HI_MPI_VI_UnBindOutput");
    }
    else
    {
        g_bVencStopFlag = HI_FALSE;

        /* we use VOCHN 0 as decode destination                                 */
        CHECK(SampleStartVdecChn(0, VDEC_SIZE_D1),"SampleStartVdecChn D1 failed!");

        /* we use VIDEV 0, VICHN 0 as encode source                              */
        CHECK(SampleEncodeH264(0, 0, VDEC_SIZE_D1),"SampleEncodeH264 D1 failed!");

        SampleDestroyVdecChn(0);
    }

    CHECK(SampleDisableVi(1),"SampleDisableVi(1)");
    CHECK(SampleDisableVo(1),"SampleDisableVo(1)");

    return HI_SUCCESS;
}
Example #3
0
static void video_DisplayD1(int nVoDev, int nChn, unsigned char bDisplay)
{
	static int s_nDispViDev = -1;
	static int s_nDispViChn = -1;
	VI_CHN_ATTR_S stViChnAttr;
	if(bDisplay){
		int i = 0;
		for(i = 0; i < MAX_CAM_CH; ++i){
			DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, i));
		}
	}
	if(bDisplay){
		static int s_nLastFull = -1; // prevent to bind twice
		if(-1 == s_nLastFull || nChn != s_nLastFull){
			int fd = open(VIDEO_DEV, O_RDWR);
			VIDEO_TRACE("%s fd = %d", __func__, fd);
			if(fd > 0){
				// set ad configuration
				video_preview_t stPreview = {0};
				stPreview.chn = nChn; // switch to this channel @ ad
				ioctl(fd, VIDEO_DRV_SET_LIVE_CHN, &stPreview);
				close(fd);
				fd = -1;
			}
		}
		// unbind last full channel first
		if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){
			DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH));
		}
		// bind to d1 special live connect
		s_nDispViDev = 2;
		s_nDispViChn = 0;
		DVR_ASSERT(HI_MPI_VO_ClearChnBuffer(nVoDev, MAX_CAM_CH, HI_TRUE));
		if(s_stVideo.nLossStat & (1<<nChn)){
			DVR_ASSERT(HI_MPI_VO_SENDFRAME(nVoDev, MAX_CAM_CH, VIDEO_GetUserPic(nChn)));
		}else{
			DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			VI_D1_ATTR_CONF(&stViChnAttr);
			DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			DVR_ASSERT(HI_MPI_VI_BindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH));
		}
		usleep(40000);
		DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, MAX_CAM_CH));
		video_CheckDigitalZoomD1(nChn);
	}else{
		if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){
			DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, MAX_CAM_CH));
//			printf("unbind output (%d,%d) to (%d,%d)", s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH);
			DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, MAX_CAM_CH));
			DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			VI_CIF_ATTR_CONF(&stViChnAttr);
			DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			s_nDispViDev = -1;
			s_nDispViChn = -1;
		}
	}
}
Example #4
0
HI_S32 SampleEnableViVo1D1(VI_DEV ViDev,VI_CHN ViChn,VO_CHN VoChn)
{
	VI_PUB_ATTR_S ViAttr;
	VI_CHN_ATTR_S ViChnAttr;
	VO_PUB_ATTR_S VoAttr;
	VO_CHN_ATTR_S VoChnAttr;

	memset(&ViAttr, 0, sizeof(VI_PUB_ATTR_S));
	memset(&ViChnAttr, 0, sizeof(VI_CHN_ATTR_S));

	memset(&VoAttr, 0, sizeof(VO_PUB_ATTR_S));
	memset(&VoChnAttr, 0, sizeof(VO_CHN_ATTR_S));

	ViAttr.enInputMode = VI_MODE_BT656;
	ViAttr.enWorkMode = VI_WORK_MODE_2D1;
	ViChnAttr.enCapSel = VI_CAPSEL_BOTH;
	ViChnAttr.stCapRect.u32Height = 288;
	ViChnAttr.stCapRect.u32Width = 720;
	ViChnAttr.stCapRect.s32X = 0;
	ViChnAttr.stCapRect.s32Y = 0;
	ViChnAttr.bDownScale = HI_FALSE;
	ViChnAttr.bChromaResample = HI_FALSE;
	ViChnAttr.enViPixFormat = PIXEL_FORMAT_YUV_SEMIPLANAR_420;

	VoAttr.stTvConfig.stComposeMode = VIDEO_ENCODING_MODE_PAL;
	VoAttr.u32BgColor = 10;
	VoChnAttr.bZoomEnable = HI_TRUE;
	VoChnAttr.u32Priority = 1;
	VoChnAttr.stRect.s32X = 0;
	VoChnAttr.stRect.s32Y = 0;
	VoChnAttr.stRect.u32Height = 576;
	VoChnAttr.stRect.u32Width = 720;

	if (HI_SUCCESS != SampleEnableVi(ViDev, ViChn, &ViAttr, &ViChnAttr))
	{
		return HI_FAILURE;
	}

	if (HI_SUCCESS != SampleEnableVo(VoChn, &VoAttr, &VoChnAttr))
	{
		return HI_FAILURE;
	}

    if (HI_SUCCESS != HI_MPI_VI_BindOutput(ViDev, ViChn, VoChn))
	{
		printf("HI_MPI_VI_BindOutput failed !\n");
		return HI_FAILURE;
	}

	return HI_SUCCESS;
}
Example #5
0
HI_S32 SampleViBindVo(HI_U32 ScreenCnt)
{
    HI_U32 i;

    if (1 == ScreenCnt)
    {
        printf("We have no vi2vo D1 preview!\n");
        return HI_SUCCESS;
    }

    for (i = 0; i < ScreenCnt - 1; i++)
    {
        CHECK(HI_MPI_VI_BindOutput(i/2, i%2, i), "HI_MPI_VI_BindOutput");
    }

    return HI_SUCCESS;
}
Example #6
0
HI_S32 SamplePreview4Screen(HI_VOID)
{
	HI_U32 i;

	if(HI_SUCCESS!=SampleEnableVi4HD1())
	{
		return HI_FAILURE;
	}

	if(HI_SUCCESS!=SampleEnableVo4Cif())
	{
	    return HI_FAILURE;
	}

	for(i=0;i<4;i++)
	{
		HI_MPI_VI_BindOutput(i/2, i%2, i);
	}

	return HI_SUCCESS;
}
Example #7
0
static void video_DisplayD1(int nVoDev, int nChn, unsigned char bDisplay)
{
	int i = 0, ii = 0;
	static int s_nDispViDev = -1;
	static int s_nDispViChn = -1;
	VI_CHN_ATTR_S stViChnAttr;
	if(bDisplay){
		for(i = 0; i < VIDEO_GetMaxDiv(); ++i){
			DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, i));
		}
	}
	if(bDisplay){
		// unbind last full channel first
		if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){
			DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH));
		}
		DVR_ASSERT(HI_MPI_VO_ClearChnBuffer(nVoDev, SPECIAL_D1_CH, HI_TRUE));
		if(nChn < 16){
			int fd = open(VIDEO_DEV, O_RDWR);
			if(fd > 0){
				// set ad configuration
				video_preview_t stPreview = {0};
				stPreview.chn = nChn; // switch to this channel @ ad
				ioctl(fd, VIDEO_DRV_SET_LIVE_CHN, &stPreview);
				close(fd);
				fd = -1;
			}
			// redefine device
			s_nDispViDev = 1;
			s_nDispViChn = 0;
		}else if(nChn < 24){
			// reset field to both not downscale
			if(0 == VIMAP_Get(nChn, &s_nDispViDev, &s_nDispViChn)){
			}
		}else{
			;
		}
		if(s_stVideo.nLossStat & (1<<nChn)){
//			VIDEO_TRACE("Send User Pic");
			DVR_ASSERT(HI_MPI_VO_SENDFRAME(nVoDev, SPECIAL_D1_CH, VIDEO_GetUserPic(nChn)));
		}else{
			DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			VI_D1_ATTR_CONF(&stViChnAttr);
			DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			DVR_ASSERT(HI_MPI_VI_BindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH));
			usleep(40000);
		}
		DVR_ASSERT(HI_MPI_VO_ChnShow(nVoDev, SPECIAL_D1_CH));
	}else{
		if(!(-1 == s_nDispViDev && -1 == s_nDispViChn)){
			DVR_ASSERT(HI_MPI_VI_GetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			VI_CIF_ATTR_CONF(&stViChnAttr);
			DVR_ASSERT(HI_MPI_VI_SetChnAttr(s_nDispViDev, s_nDispViChn, &stViChnAttr));
			DVR_ASSERT(HI_MPI_VI_UnBindOutput(s_nDispViDev, s_nDispViChn, nVoDev, SPECIAL_D1_CH));
			DVR_ASSERT(HI_MPI_VO_ChnHide(nVoDev, SPECIAL_D1_CH));
			if(nVoDev > 0){
				s_nDispViDev = -1;
				s_nDispViChn = -1;
			}
		}
	}
}