author | xiaoyu.yuan <xiaoyu.yuan@droid05.amlogic.com> | 2014-02-10 02:16:53 (GMT) |
---|---|---|
committer | tao.dong <tao.dong@amlogic.com> | 2014-02-11 08:31:04 (GMT) |
commit | 6478f94e1a9cc1bb002940d5f32153a9226ace98 (patch) | |
tree | dcad3e77a652276cef9b2f2640c976a6430bd10c | |
parent | e17fd9d7d2e0a90d79478e2f1d0e5b23334bc089 (diff) | |
download | camera-6478f94e1a9cc1bb002940d5f32153a9226ace98.zip camera-6478f94e1a9cc1bb002940d5f32153a9226ace98.tar.gz camera-6478f94e1a9cc1bb002940d5f32153a9226ace98.tar.bz2 |
PD#86787 capture with mjpeg for usb camera to reduce bandwidth requirement
-rwxr-xr-x | V4LCameraAdapter/V4LCameraAdapter.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/V4LCameraAdapter/V4LCameraAdapter.cpp b/V4LCameraAdapter/V4LCameraAdapter.cpp index 85730ab..0ec6f8d 100755 --- a/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -887,7 +887,10 @@ status_t V4LCameraAdapter::UseBuffersCapture(void* bufArr, int num) mCaptureWidth = width; mCaptureHeight = height; #ifdef AMLOGIC_USB_CAMERA_SUPPORT - mSensorFormat = V4L2_PIX_FMT_YUYV; + if((mUseMJPEG == true)&&(mSupportMJPEG == true)&&(width>=640)&&(height>=480)) + mSensorFormat = V4L2_PIX_FMT_MJPEG; + else + mSensorFormat = V4L2_PIX_FMT_YUYV; #else if(mIoctlSupport & IOCTL_MASK_ROTATE){ int temp = 0; @@ -985,7 +988,6 @@ int V4LCameraAdapter::beginAutoFocusThread(void *cookie) break; } } - CAMHAL_LOGVB("auto focus cost %s ms\n", i*30); } c->setState(CAMERA_CANCEL_AUTOFOCUS); @@ -1850,7 +1852,7 @@ int V4LCameraAdapter::pictureThread() unsigned int canvas_id = 0; char *fp = this->GetFrame(index,&canvas_id); #ifdef AMLOGIC_USB_CAMERA_SUPPORT - while((mVideoInfo->buf.length != mVideoInfo->buf.bytesused)&&(dqTryNum>0)){ + while((dqTryNum>0)){ if(NULL != fp){ mVideoInfo->buf.index = 0; mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -1916,10 +1918,15 @@ int V4LCameraAdapter::pictureThread() mCaptureBuf, dest, fp,index, width, height, mVideoInfo->buf.length, mVideoInfo->buf.bytesused); - //if(mSensorFormat == V4L2_PIX_FMT_MIPEG){ - // memcpy(dest,src,mVideoInfo->buf.length); - //}else - if(DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT == V4L2_PIX_FMT_RGB24){ // rgb24 + if(mSensorFormat == V4L2_PIX_FMT_MJPEG){ + if(jpeg_decode(&dest,src,width,height,V4L2_PIX_FMT_NV21) != 0){ // output format is nv21 + //fillThisBuffer(mCaptureBuf, CameraFrame::IMAGE_FRAME); + CAMHAL_LOGEA("jpeg decode failed"); + } + frame.mLength = width*height*3/2; + frame.mQuirks = CameraFrame::ENCODE_RAW_YUV420SP_TO_JPEG | CameraFrame::HAS_EXIF_DATA; + + }else if(DEFAULT_IMAGE_CAPTURE_PIXEL_FORMAT == V4L2_PIX_FMT_RGB24){ // rgb24 frame.mLength = width*height*3; frame.mQuirks = CameraFrame::ENCODE_RAW_RGB24_TO_JPEG | CameraFrame::HAS_EXIF_DATA; #ifdef AMLOGIC_USB_CAMERA_SUPPORT |