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

📄 test_ipipe.c

📁 德州仪器新推出的达芬奇技术dm355的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
        g_param->ipipe_vsz = 479;
        g_param->ipipe_hsz = 639;
        g_param->rsz_rsc_param[0].rsz_o_vsz = 239;
        g_param->rsz_rsc_param[0].rsz_o_hsz = 319;
        g_param->rsz_rsc_param[0].rsz_v_dif = 512;
        g_param->rsz_rsc_param[0].rsz_h_dif = 512;
        g_param->ext_mem_param[0].rsz_sdr_oft = 640;
        ret = ioctl(fd, IPIPE_SET_PARAM,g_param);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }
#endif

        /* request for 1 input buffer */
        reqbufs.buf_type = IPIPE_BUF_IN;
        reqbufs.size = 2* 640 * 480;
        reqbufs.count = 1;
        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;

        }
         /* request for 1 output buffer */
        reqbufs.buf_type = IPIPE_BUF_OUT;
        /*resize ratio will be 1*/
        reqbufs.size =  2 * 320 * 240;
        reqbufs.count = 1;

        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;
        }

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_IN;
        /*query buffer for input buffer*/
        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
                goto free;

        }
        in_buff.index = 0;
        in_buff.offset = temp_buff.offset;

        buff[0].length = temp_buff.size;

        buff[0].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
				 fd,(temp_buff.offset ));

        if (buff[0].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                goto free;
        }

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_OUT;
        /*query buffer for output buffer*/

        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
        }
        printf("add_app = %x\n",temp_buff.offset);

        out_buff.index = 0;
        out_buff.offset = temp_buff.offset;

        buff[1].length = temp_buff.size;
        buff[1].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
                                        fd, temp_buff.offset );
         if (buff[1].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                munmap(buff[0].addr, buff[0].length);
                goto free;
        }
        /*copy the image to mapped virtual address */

        fread(buff[0].addr,1,640 * 480 * 2, fccdc);
        fclose(fccdc);
        /*inaddr/SE and outaddr contains the mapped addresses */
        inadr = buff[0].addr;
        outadr = buff[1].addr;

        convert.in_buff.index = convert.out_buff.index = 0;
        printf("ipipe_start\n");

        if ((ret = ioctl(fd, IPIPE_START, &convert)) < 0){

                printf("IPIPE_START fail\n");
		 goto out;
        }

        fc = fopen("out_yuv16.yuv", "w");

        if (fc == NULL)
        {
                printf("error in file out_yuv16.yuv\n");
                goto out;
        }
        fwrite(buff[1].addr,1, 320 * 240 * 2,fc);
	fclose(fc);

out:
        munmap(buff[0].addr, buff[0].length);
        munmap(buff[1].addr, buff[1].length);
free:
        close(fd);
        free(g_param);
        printf("file closed");
        return ret;
}
/* 6 */
int yuy_upscale_rsz0(struct ipipe_params* g_param)
{
	//struct ipipe_cropsize crop;
        char *inadr, *outadr;
        int fd;
        int *addr = NULL;
        FILE *fp,*fc;
        int cy = 0, ccb = 0, ccr = 0,i,j;
        struct ipipe_reqbufs reqbufs;
        struct ipipe_buffer temp_buff,in_buff, out_buff;
        struct buffer buff[2];
        struct ipipe_convert convert;
        FILE *fccdc ;
        int ret = 0;

        /*** Output Device name ***/
        if ((fd = open(DR_NAME, O_RDWR)) < 0)
        {
                printf("\nError opening ipipe device;");
                free(g_param);
                return -1;
        }
        printf("device opened\n");
        fccdc = fopen("in_yuv.yuv","r+b");
        if (fccdc == NULL)
        {
                printf("error in in_yuv.yuv\n");
                goto free;
		 return -1;
        }
#if 1
        printf("fd = %d\n",fd);
        ret = ioctl(fd, IPIPE_SET_PARAM,NULL);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }

        ret = ioctl(fd, IPIPE_GET_PARAM,g_param);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }

        g_param->ipipeif_param.source = SDRAM_YUV;
        g_param->ipipeif_param.glob_hor_size = 648;
        g_param->ipipeif_param.glob_ver_size = 490;
        g_param->ipipeif_param.hnum = 640;
        g_param->ipipeif_param.vnum = 480;
        g_param->ipipeif_param.adofs = 1280;
        g_param->ipipe_dpaths_fmt = YUV2YUV;
        g_param->ipipe_vsz = 479;
        g_param->ipipe_hsz = 639;
        g_param->rsz_rsc_param[0].rsz_o_vsz = 479;
        g_param->rsz_rsc_param[0].rsz_o_hsz = 1280;
        g_param->rsz_rsc_param[0].rsz_v_dif = 256;
        g_param->rsz_rsc_param[0].rsz_h_dif = 128;
        g_param->ext_mem_param[0].rsz_sdr_oft = 1280 * 2;
        //g_param->rsz_en[0] = ENABLE;
        ret = ioctl(fd, IPIPE_SET_PARAM,g_param);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }
#endif

        /* request for 1 input buffer */
        reqbufs.buf_type = IPIPE_BUF_IN;
        reqbufs.size = 2* 640 * 480;
        reqbufs.count = 1;
        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;

        }
         /* request for 1 output buffer */
        reqbufs.buf_type = IPIPE_BUF_OUT;
        /*resize ratio will be 1*/
        reqbufs.size =  2 * 1280 * 480;
        reqbufs.count = 1;

        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;
        }
//      printf("req_buf_out\n");

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_IN;
        /*query buffer for input buffer*/
        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
                goto free;

        }
        in_buff.index = 0;
        in_buff.offset = temp_buff.offset;

        buff[0].length = temp_buff.size;

        buff[0].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
				 fd,(temp_buff.offset ));

        if (buff[0].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                goto free;
        }

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_OUT;
        /*query buffer for output buffer*/

        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
        }

        out_buff.index = 0;
        out_buff.offset = temp_buff.offset;

        buff[1].length = temp_buff.size;
        buff[1].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
                                        fd, temp_buff.offset );
         if (buff[1].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                munmap(buff[0].addr, buff[0].length);
                goto free;
        }
        /*copy the image to mapped virtual address */

        fread(buff[0].addr,1,640 * 480 * 2, fccdc);
        fclose(fccdc);
        inadr = buff[0].addr;
        outadr = buff[1].addr;

        convert.in_buff.index = convert.out_buff.index = 0;
        printf("ipipe_start\n");

        if ((ret = ioctl(fd, IPIPE_START, &convert)) < 0){

                printf("IPIPE_START fail\n");
		 goto out;
        }

        fc = fopen("out_yuv16.yuv", "w");

        if (fc == NULL)
        {
                printf("error in file out_yuv16.yuv\n");
                goto out;
        }
        fwrite(buff[1].addr,1, 1280 * 480 * 2,fc);
	fclose(fc);

out:
        munmap(buff[0].addr, buff[0].length);
        munmap(buff[1].addr, buff[1].length);
free:
        close(fd);
        free(g_param);
        printf("file closed");
        return ret;
}
/* 7 */
int yuy_downscale_rsz1(struct ipipe_params* g_param)
{
	//struct ipipe_cropsize crop;
        char *inadr, *outadr;
        int fd;
        int *addr = NULL;
        FILE *fp,*fc;
        int cy = 0, ccb = 0, ccr = 0,i,j;
        struct ipipe_reqbufs reqbufs;
        struct ipipe_buffer temp_buff,in_buff, out_buff;
        struct buffer buff[2];
        struct ipipe_convert convert;
        FILE *fccdc ;
        int ret = 0;

        /*** Output Device name ***/
        if ((fd = open(DR_NAME, O_RDWR)) < 0)
        {
                printf("\nError opening ipipe device;");
                free(g_param);
                return -1;
        }
        printf("device opened\n");
        fccdc = fopen("in_yuv.yuv","r+b");
        if (fccdc == NULL)
        {
                printf("error in in_yuv.yuv\n");
                goto free;
		 return -1;
        }
#if 1
        printf("fd = %d\n",fd);
        ret = ioctl(fd, IPIPE_SET_PARAM,NULL);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }

        ret = ioctl(fd, IPIPE_GET_PARAM,g_param);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }

        g_param->ipipeif_param.source = SDRAM_YUV;
        g_param->ipipeif_param.glob_hor_size = 648;
        g_param->ipipeif_param.glob_ver_size = 490;
        g_param->ipipeif_param.hnum = 640;
        g_param->ipipeif_param.vnum = 480;
        g_param->ipipeif_param.adofs = 1280;
        g_param->ipipe_dpaths_fmt = YUV2YUV;
        g_param->ipipe_vsz = 479;
        g_param->ipipe_hsz = 639;
        g_param->rsz_rsc_param[1].rsz_o_vsz = 239;
        g_param->rsz_rsc_param[1].rsz_o_hsz = 319;
        g_param->rsz_rsc_param[1].rsz_v_dif = 512;
        g_param->rsz_rsc_param[1].rsz_h_dif = 512;
        g_param->ext_mem_param[1].rsz_sdr_oft = 640;
        g_param->rsz_en[0] = DISABLE;
        g_param->rsz_en[1] = ENABLE;
        //g_param->rsz_en[0] = ENABLE;
        ret = ioctl(fd, IPIPE_SET_PARAM,g_param);
        if (ret < 0) {
                printf("IPIPE_SET_PARAM fail\n");
                goto free;
        }
#endif

        /* request for 1 input buffer */
        reqbufs.buf_type = IPIPE_BUF_IN;
        reqbufs.size = 2* 640 * 480;
        reqbufs.count = 1;
        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;

        }
         /* request for 1 output buffer */
        reqbufs.buf_type = IPIPE_BUF_OUT;
        /*resize ratio will be 1*/
        reqbufs.size =  2 * 320 * 240;
        reqbufs.count = 1;

        if ((ret = ioctl(fd, IPIPE_REQBUF, &reqbufs)) < 0){
                printf("IPIPE_REQBUF fail\n");
                goto free;
        }
//      printf("req_buf_out\n");

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_IN;
        /*query buffer for input buffer*/
        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
                goto free;

        }
        in_buff.index = 0;
        in_buff.offset = temp_buff.offset;

        buff[0].length = temp_buff.size;

        buff[0].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
				 fd,(temp_buff.offset ));

        if (buff[0].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                goto free;
        }

        temp_buff.index = 0;
        temp_buff.buf_type = IPIPE_BUF_OUT;
        /*query buffer for output buffer*/

        if ((ret = ioctl(fd,IPIPE_QUERYBUF,&temp_buff)) < 0){
                printf("IPIPE_QUERYBUF fail\n");
        }

        out_buff.index = 0;
        out_buff.offset = temp_buff.offset;

        buff[1].length = temp_buff.size;
        buff[1].addr = mmap(NULL, temp_buff.size, PROT_READ | PROT_WRITE, MAP_SHARED,
                                        fd, temp_buff.offset );
         if (buff[1].addr == MAP_FAILED) {
                printf("\ncannot mmap buffer\n");
                munmap(buff[0].addr, buff[0].length);
                goto free;
        }
        /*copy the image to mapped virtual address */

        fread(buff[0].addr,1,640 * 480 * 2, fccdc);
        fclose(fccdc);
        /*inaddr/SE and outaddr contains the mapped addresses */
        inadr = buff[0].addr;
        outadr = buff[1].addr;

        convert.in_buff.index = convert.out_buff.index = 0;
        printf("ipipe_start\n");

        if ((ret = ioctl(fd, IPIPE_START, &convert)) < 0){

                printf("IPIPE_START fail\n");
		 goto out;
        }

        fc = fopen("out_yuv16.yuv", "w");

        if (fc == NULL)
        {
                printf("error in file out_yuv16.yuv\n");
                goto out;
        }
        fwrite(buff[1].addr,1, 320 * 240 * 2,fc);
	fclose(fc);

out:
        munmap(buff[0].addr, buff[0].length);
        munmap(buff[1].addr, buff[1].length);
free:
        close(fd);
        free(g_param);
        printf("file closed");
        return ret;
}
/*8*/
int yuy_upscale_rsz1(struct ipipe_params* g_param)
{
	//struct ipipe_cropsize crop;
        char *inadr, *outadr;
        int fd;
        int *addr = NULL;
        FILE *fp,*fc;
        int cy = 0, ccb = 0, ccr = 0,i,j;
        struct ipipe_reqbufs reqbufs;
        struct ipipe_buffer temp_buff,in_buff, out_buff;
        struct buffer buff[2];
        struct ipipe_convert convert;
        FILE *fccdc ;
        int ret = 0;

        /*** Output Device name ***/
        if ((fd = open(DR_NAME, O_RDWR)) < 0)
        {
                printf("\nError opening ipipe device;");
                free(g_param);
                return -1;
        }
        printf("device opened\n");
        fccdc = fopen("in_yuv16.yuv","r+b");
        if (fccdc == NULL)
        {
                printf("error in yuv16.yuv\n");
                goto free;
		 return -1;
        }
#if 1
        printf("fd = %d\n",fd);
        ret = ioctl(fd, IPIPE_SET_PARAM,NULL);

⌨️ 快捷键说明

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