解决三星ARM11开发板图片采集程序源码出现的Bug

来源:互联网 发布:sql select 两个字段 编辑:程序博客网 时间:2024/04/30 13:33

三星公司提供的图片采集程序源码是这个:

/***************** Capture Thread *****************/void capture_thread(void){    int start, ret;    int key;    start = 1;    ret = ioctl(cam_c_fp, VIDIOC_STREAMON, &start);    if (ret < 0) {        printf("V4L2 : ioctl on VIDIOC_STREAMON failed\n");        exit(1);    }    printf("\nc : Capture\n");    printf("x : Exit\n");    printf("Select ==> ");      while (1) {         fflush(stdin);        key = getchar();        if(key == 'c') {            cap_flag = TRUE;            }        else if(key == 'x'){            finished = 1;            pthread_exit(0);        }        if (cap_flag == TRUE) {            capture();            cap_flag = FALSE;        }    }    start = 0;    ret = ioctl(cam_c_fp, VIDIOC_STREAMOFF, &start);    if (ret < 0) {        printf("V4L2 : ioctl on VIDIOC_STREAMOFF failed\n");        exit(1);    }    pthread_exit(0);}

有同学会发现当连续输入”c“采集图片的时候会出现错误,而且每次都是第五次的时候出错”PP instance allocation is fail: No more instance“。这是为什么呢?
原来在三星提供的内核当中(经过查看内核发现这个问题)给出的摄像头采集图片的缓冲为4张图片,这里给出的方案为:
应为程序中出现了

ioctl(pp_fd, S3C_PP_ALLOC_KMEM, &alloc_info)

但是在 close之前没有释放这段内存,在close前增加

ioctl(pp_fd, S3C_PP_FREE_KMEM, &alloc_info) 

在SsbSipJPEGEncodeExe()中因为有open post processor所以在close之前close pp

0 0
原创粉丝点击