static void v4l2_prepare(struct frame *f) { if (pixconv) { struct v4l2_buffer buf; dqbuf(&buf); cur_buf = &vid_buffers[buf.index]; pixconv->convert(cur_buf->data, f->vdata, NULL, NULL); } else if (f->x != crop.c.left || f->y != crop.c.top) { crop.c.left = f->x; crop.c.top = f->y; ioctl(vid_fd, VIDIOC_S_CROP, &crop); } }
static void v4l2_show(struct frame *f) { if (pixconv) { pixconv->finish(); ioctl(vid_fd, VIDIOC_QBUF, &cur_buf->buf); cur_buf = NULL; ofbp_put_frame(f); } else { struct v4l2_buffer buf; ioctl(vid_fd, VIDIOC_QBUF, &vid_buffers[f->frame_num].buf); dqbuf(&buf); ofbp_put_frame(&vid_frames[buf.index]); } }
int V4L2VideoNode::grabFrame(struct v4l2_buffer_info *buf) { LOG2("@%s", __FUNCTION__); int ret(0); if (mState != DEVICE_STARTED) { LOGE("%s invalid device state %d",__FUNCTION__, mState); return -1; } if (buf == NULL) { LOGE("%s: invalid parameter buf is NULL",__FUNCTION__); return -1; } ret = dqbuf(buf); if (ret < 0) return ret; // inc frame counter but do no wrap to negative numbers mFrameCounter++; mFrameCounter &= INT_MAX; // atomisp_frame_status is a proprietary extension to v4l2_buffer flags // that driver places into reserved keyword // translate error flag into corrupt frame if (buf->vbuffer.flags & V4L2_BUF_FLAG_ERROR) buf->vbuffer.reserved = (unsigned int) ATOMISP_FRAME_STATUS_CORRUPTED; // translate initial skips into corrupt frame if (mInitialSkips > 0) { buf->vbuffer.reserved = (unsigned int) ATOMISP_FRAME_STATUS_CORRUPTED; mInitialSkips--; } LOG2("@%s, index:%d, addr:%p", __FUNCTION__, buf->vbuffer.index, (void *)buf->vbuffer.m.userptr); return buf->vbuffer.index; }