Android Camera预览过程数据流浅析
ret = ioctl(fp, VIDIOC_REQBUFS, &req);
mPreviewHeap = mGetMemoryCb((int)mV4L2Camera->getCameraFd(), aligned_buffer_size, kBufferCount, 0);
if (mPreviewWindow && mGrallocHal) { buffer_handle_t *buf_handle; int stride; if (0 != mPreviewWindow->dequeue_buffer(mPreviewWindow, &buf_handle, &stride)) { ALOGE("Could not dequeue gralloc buffer!\n"); goto callbacks; } void *vaddr; if (!mGrallocHal->lock(mGrallocHal, *buf_handle, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, width, height, &vaddr)) { char *frame = ((char *)mPreviewHeap->data) + offset; // the code below assumes YUV, not RGB { int h; char *src = frame; char *ptr = (char *)vaddr; memcpy(ptr, src, frame_size); //YUY2toYV12(frame, vaddr, width, height); } mGrallocHal->unlock(mGrallocHal, *buf_handle); } else ALOGE("%s: could not obtain gralloc buffer", __func__); if (0 != mPreviewWindow->enqueue_buffer(mPreviewWindow, buf_handle)) { ALOGE("Could not enqueue gralloc buffer!\n"); goto callbacks; } }
ret = ioctl(win->fd, VIDIOC_REQBUFS, &reqbuf);
*len = buf.length; *start = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset);
for (unsigned int i = 0; i < cur_layer->visibleRegionScreen.numRects; i++) { uint8_t *cur_dst_addr = dst_addr; uint8_t *cur_src_addr = src_addr; for (int j = 0; j < h ; j++) { memcpy(cur_dst_addr, cur_src_addr, cpy_size); cur_dst_addr = &cur_dst_addr[cpy_size]; cur_src_addr = &cur_src_addr[(cur_layer->displayFrame.right - cur_layer->displayFrame.left) * (prev_handle->uiBpp / 8)]; } cur_rect++; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。