⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 video_vo.c

📁 sample on embedded linux
💻 C
📖 第 1 页 / 共 2 页
字号:
    memset(&chn_attr, 0, sizeof(VO_CHN_ATTR_S));    if( HI_VO_GetChnAttr(0, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_GetChnAttr error\n");    }    chn_attr.enable = HI_TRUE;    chn_attr.rectangle.width = 352;    chn_attr.rectangle.height = 288;    chn_attr.zoom_enable =  HI_TRUE;    if(oout[0])    {        chn_attr.rectangle.x = 0;        chn_attr.rectangle.y = 0;        if ( HI_VO_SetChnAttr(0, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }    }    if(oout[1])    {        chn_attr.rectangle.x = 352;        chn_attr.rectangle.y = 0;        if ( HI_VO_SetChnAttr(1, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }    }    if(oout[2])    {        chn_attr.rectangle.x = 0;        chn_attr.rectangle.y = 288;        if ( HI_VO_SetChnAttr(2, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }    }    if(oout[3])    {        chn_attr.rectangle.x = 352;        chn_attr.rectangle.y = 288;        if ( HI_VO_SetChnAttr(3, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }    }    return ;}/*VO close*/void vo_test_close(void){    VO_CHN_ATTR_S  l_chn_attr ;    if ( HI_VO_GetChnAttr(0,&l_chn_attr)!= HI_SUCCESS)    {        printf("\n\r HI_VO_GetChnAttr error");    }    l_chn_attr.enable = HI_FALSE;    if(oout[0])    {        if( HI_VO_SetChnAttr(0,&l_chn_attr)!= HI_SUCCESS)        {            printf("\n\r HI_VO_SetChnAttr error");        }    }        if(oout[1])    {        if( HI_VO_SetChnAttr(1,&l_chn_attr)!= HI_SUCCESS)        {            printf("\n\r HI_VO_SetChnAttr error");        }    }        if(oout[2])    {        if( HI_VO_SetChnAttr(2,&l_chn_attr)!= HI_SUCCESS)        {            printf("\n\r HI_VO_SetChnAttr error");        }    }        if(oout[3])    {        if( HI_VO_SetChnAttr(3,&l_chn_attr)!= HI_SUCCESS)        {            printf("\n\r HI_VO_SetChnAttr error");        }    }        VO_PUBLIC_ATTR_S  l_pub_attr ;    if( HI_VO_GetPublicAttr(&l_pub_attr) != HI_SUCCESS)    {        printf("\n\r  HI_VO_GetPublicAttr error");        return;    }    l_pub_attr.enable = HI_FALSE ;    if( HI_VO_SetPublicAttr(&l_pub_attr) != HI_SUCCESS)    {        printf("\n\r  HI_VO_SetPublicAttr error");        return;    }    return ;}void vo_test(void){//    pthread_t thread1;    pthread_t thread2;//    pthread_create(&thread1, NULL, vo_setattr_thread, NULL);    pthread_create(&thread2, NULL, vo_test_Video_Decoder_MultiChannel, NULL);   }static void vo_test_enable(char enable){    VO_PUBLIC_ATTR_S  pub_attr ;    if(HI_VO_GetPublicAttr(&pub_attr) != HI_SUCCESS)    {        printf("HI_VO_GetPublicAttr error\n");        return;    }    if(enable)        pub_attr.enable = HI_TRUE;    else        pub_attr.enable = HI_FALSE;        if(HI_VO_SetPublicAttr(&pub_attr) != HI_SUCCESS)    {        printf("HI_VO_SetPublicAttr error\n");        return;    }}static void vo_test_ch_enable(int chn, char enable){    VO_CHN_ATTR_S  chn_attr ;    if( (chn<0) || (chn >= VO_MAX_CHN_NUM) )    {        printf("invalid vo chn[%d]!\n", chn);        return ;    }    if( HI_VO_GetChnAttr(chn, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_GetChnAttr error\n");    }    if(enable)    {        chn_attr.enable = HI_TRUE;        if ( HI_VO_SetChnAttr(chn, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }        fprintf(stderr, "VO[%d] disable->enable......", chn);        fflush(stderr);        usleep(400000);        fprintf(stderr, "done!\n");                oout[chn] = 1;    }    else    {        chn_attr.enable = HI_FALSE;        oout[chn] = 0;        fprintf(stderr, "VO[%d] enable->disable......", chn);        fflush(stderr);        usleep(400000);        fprintf(stderr, "done!\n");        if ( HI_VO_SetChnAttr(chn, &chn_attr)!= HI_SUCCESS)        {            printf("HI_VO_SetChnAttr error\n");        }    }    /* wait data from vdec; release buffer for vdec*/}static void vo_test_ch_pos(int chn, int x, int y){    VO_CHN_ATTR_S  chn_attr ;    if( (chn<0) || (chn >= VO_MAX_CHN_NUM) )    {        printf("invalid vo chn[%d]!\n", chn);        return ;    }    if( HI_VO_GetChnAttr(chn, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_GetChnAttr error\n");    }    chn_attr.rectangle.x = x;    chn_attr.rectangle.y = y;    if ( HI_VO_SetChnAttr(chn, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_SetChnAttr error\n");    }}static void vo_test_ch_size(int chn, int w, int h){    VO_CHN_ATTR_S  chn_attr ;    if( (chn<0) || (chn >= VO_MAX_CHN_NUM) )    {        printf("invalid vo chn[%d]!\n", chn);        return ;    }    if( HI_VO_GetChnAttr(chn, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_GetChnAttr error\n");    }    chn_attr.rectangle.width = w;    chn_attr.rectangle.height = h;    if ( HI_VO_SetChnAttr(chn, &chn_attr)!= HI_SUCCESS)    {        printf("HI_VO_SetChnAttr error\n");    }}extern HI_S32 HI_MPI_VO_GetAttr (VO_CHN  VoChn, VO_CH_ATTR_S *pAttr);extern HI_S32 HI_MPI_VO_SetAttr (VO_CHN  VoChn,  VO_CH_ATTR_S *pAttr);static void vo_test_ch_priority(int chn, int priority){    VO_CH_ATTR_S  ch_attr;    memset(&ch_attr, 0, sizeof(VO_CH_ATTR_S));    if( HI_MPI_VO_GetAttr(chn, &ch_attr) != HI_SUCCESS)    {        printf("HI_ERR_VO_IOCTL_ERROR\n");        return ;    }    ch_attr.priority = priority;    if( HI_MPI_VO_SetAttr(chn, &ch_attr) != HI_SUCCESS)    {        printf("HI_ERR_VO_IOCTL_ERROR\n");        return ;    }    return ;}/*parameter parse*/static void parsearg(int argc){    if(0 == strcmp("vp", args[0]) && 2 == argc)    {        /* vp  compose_mode */        vo_test_open((VIDEO_NORM_E)(atoi(args[1])));    }    else if(0 == strcmp("vt", args[0]) && 3 == argc)    {        /* vt vdec_chnum xx */        vo_test();    }    else if( (0 == strcmp("voe", args[0]) ) && (2 == argc) )    {        /* voe enable */        vo_test_enable(atoi(args[1]));    }    else if( (0 == strcmp("voche", args[0]) ) && (3 == argc) )    {        /* voche chn enable */        vo_test_ch_enable(atoi(args[1]), atoi(args[2]));    }    else if( (0 == strcmp("vochpos", args[0]) ) && (4 == argc) )    {        /* vochpos chn x y */        vo_test_ch_pos(atoi(args[1]), atoi(args[2]), atoi(args[3]) );    }        else if( (0 == strcmp("vochsz", args[0]) ) && (4 == argc) )    {        /* vochpos chn width height */        vo_test_ch_size(atoi(args[1]), atoi(args[2]), atoi(args[3]));    }    else if( (0 == strcmp("vochpr", args[0]) ) && (3 == argc) )    {        /* vochpos chn width height */        vo_test_ch_priority(atoi(args[1]), atoi(args[2]));    }        else    {        printf("vp [norm]          : vo open of pal(norm=0) or ntsc(norm=1)\n"               "vt [vdec_num] [xx] : vdec->vo test. vdec_num max set to 4. xx not care\n"               "voe [open_close]   : vo open(1) or close(0)\n"               "voche [vochn] [open_close] : vo chn open(1) or close(0)\n"               "vochpos [vochn] [x] [y]    : change vo chn position\n"               "vochsz [vochn] [w] [h]     : change vo chn show size\n" );    }    }/*adjust input parameter*/static int adjust_str(char *ptr){	int i;	while(*ptr==' ' && *ptr++ != '\0');	for(i=strlen(ptr);i>0;i--)	{		if(*(ptr+i-1) == 0x0a || *(ptr+i-1) == ' ')			*(ptr+i-1) = '\0';		else			break;	}	for(i=0;i<10;i++)	{		int j = 0;		while(*ptr==' ' && *ptr++ != '\0');		while((*ptr !=' ') && (*ptr!='\0'))		{			args[i][j++] = *ptr++;		}		args[i][j] = '\0';		if('\0' == *ptr)		{			i++;			break;		}		args[i][j] = '\0';	}	return i;}int main(int argc, char* argv[]){    char buffer[256];    char *ptr;    VENC_INIT_S    venc_init;    HI_S32 ret;    /*open vo device */    ret = HI_VDEC_Open();    if ( ret != HI_SUCCESS )    {        printf("HI_VDEC_Open failed!\n");        return ret;    }        /*step 1: open video encoder*///    vo_test_open();    for(;;)    {        printf("> ");        ptr = fgets(buffer, 255, stdin);        memset(args, 0, sizeof(args));        argc = adjust_str(ptr);        if(0 == strcmp("q", args[0]) || 0 == strcmp("Q", args[0]))        {            vo_test_close();               HI_VDEC_Close();            return 0;        }        parsearg(argc);    }    return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -