|
发表于 2014-12-20 11:35:19
只看该作者
11#
看来跟分辨率没关系,我觉得应该跟数据的frame format 像素格式有关。楼主可以试一下这里:
hardware/rk29/camera/CameraHal/CameraUSBAdapter.cpp
- //define the frame info ,such as w, h ,fmt
- int CameraUSBAdapter::reprocessFrame(FramInfo_s* frame)
- {
- int ret = 0;
- // usb camera may do something
- #if (IOMMU_ENABLED == 1)
- int phy_addr = mPreviewBufProvider->getBufShareFd(frame->frame_index);
- #else
- int phy_addr = mPreviewBufProvider->getBufPhyAddr(frame->frame_index);
- #endif
- if( frame->frame_fmt == V4L2_PIX_FMT_MJPEG){
- char *srcbuf = frame->vir_addr;
- if((srcbuf[0] == 0xff) && (srcbuf[1] == 0xd8) && (srcbuf[2] == 0xff)){
- //decoder to NV12
- VPU_FRAME outbuf;
- unsigned int output_len;
- unsigned int input_len;
- output_len = 0;
- input_len = frame->frame_size;
- ret = mMjpegDecoder.decode(mMjpegDecoder.decoder,
- (unsigned char*)&outbuf, &output_len,
- (unsigned char*)frame->vir_addr, &input_len,
- phy_addr);
- if (ret < 0){
- LOGE("%s(%d): mjpeg stream is error!",__FUNCTION__,__LINE__);
- }
- }else{
- LOGE("mjpeg data error!!");
- return -1;
- }
- }else if(frame->frame_fmt == V4L2_PIX_FMT_YUYV){
- ret = cameraFormatConvert(V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_NV12, NULL,
- (char*)frame->vir_addr, (char*)mPreviewBufProvider->getBufVirAddr(frame->frame_index),
- 0,0,frame->frame_size,
- frame->frame_width, frame->frame_height, frame->frame_width,
- frame->frame_width, frame->frame_height, frame->frame_width,
- false);
- if (ret < 0){
- LOGE("%s(%d): yuyv convert to nv12 error!",__FUNCTION__,__LINE__);
- }
- }else{
- LOGE("camerahal not support this format %d",frame->frame_fmt);
- ret = -1;
- }
- frame->frame_fmt = V4L2_PIX_FMT_NV12;
- frame->phy_addr = phy_addr;
- frame->vir_addr = mPreviewBufProvider->getBufVirAddr(frame->frame_index);
- frame->zoom_value = mZoomVal;
-
- int w,h;
- w = frame->frame_width;
- h = frame->frame_height;
- if((w&0x0f) || (h&0x0f)){
- char *buf = malloc(w*h*3/2);
- if(buf != NULL){
- memcpy(buf,frame->vir_addr,w*h);
- memcpy(buf+w*h,frame->vir_addr+((w+15)&0xfff0)*((h+15)&0xfff0), w*h/2);
- memcpy(frame->vir_addr,buf,w*h*3/2);
- free(buf);
- }
- }
- //do zoom here?
- return ret;
-
- }
复制代码
这个函数里面好像要处理不同的像素格式的。 |
|