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

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

/***************** 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值