diff options
author | Vishal Bhoj <vishal.bhoj@linaro.org> | 2011-11-11 18:09:08 +0530 |
---|---|---|
committer | Vishal Bhoj <vishal.bhoj@linaro.org> | 2011-11-11 19:15:47 +0530 |
commit | 120c22ceb513ca37685854e467fb4cb482840d1c (patch) | |
tree | bea205b17fb99bb2b943dc1c515e1c9400901f8b /libcamera/V4L2Camera.cpp | |
parent | 9f3cf8400b6c7e43b8ca434efb61acdbd42b3fa6 (diff) |
camera: modified to support recordinglinaro_android_2.3.7linaro_android_2.3.5
The cameraHardware implementation has been
modified for recording and also to support
multipple resolutions.It also has additional
cameraParameters which are tried to access
by linphone application.
Note:Moving ahead we may have to add other
cameraparameters since there are a whole set
of parameters which application can querry
Change-Id: I7e3eee472c9ae0ca330d763b7272081962efb15b
Signed-off-by: Vishal Bhoj <vishal.bhoj@linaro.org>
Diffstat (limited to 'libcamera/V4L2Camera.cpp')
-rw-r--r-- | libcamera/V4L2Camera.cpp | 93 |
1 files changed, 1 insertions, 92 deletions
diff --git a/libcamera/V4L2Camera.cpp b/libcamera/V4L2Camera.cpp index 6c0ed4b..78e17b0 100644 --- a/libcamera/V4L2Camera.cpp +++ b/libcamera/V4L2Camera.cpp @@ -13,7 +13,6 @@ #include <utils/threads.h> #include <fcntl.h> -#include "converter.h" #include "V4L2Camera.h" extern "C" { /* Android jpeglib.h missed extern "C" */ @@ -204,8 +203,6 @@ void V4L2Camera::GrabPreviewFrame (void *previewBuffer) unsigned char *tmpBuffer; int ret; - tmpBuffer = (unsigned char *) calloc (1, videoIn->width * videoIn->height * 2); - videoIn->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; videoIn->buf.memory = V4L2_MEMORY_MMAP; @@ -218,11 +215,7 @@ void V4L2Camera::GrabPreviewFrame (void *previewBuffer) } nDequeued++; - //memcpy (tmpBuffer, videoIn->mem[videoIn->buf.index], (size_t) videoIn->buf.bytesused); - memcpy (tmpBuffer, videoIn->mem[videoIn->buf.index], (size_t) videoIn->buf.bytesused); - //convertYUYVtoYUV422SP((uint8_t *)tmpBuffer, (uint8_t *)previewBuffer, videoIn->width, videoIn->height); - convert((unsigned char *)tmpBuffer, (unsigned char *)previewBuffer, videoIn->width, videoIn->height); - + memcpy (previewBuffer, videoIn->mem[videoIn->buf.index], (size_t) videoIn->buf.bytesused); ret = ioctl(fd, VIDIOC_QBUF, &videoIn->buf); if (ret < 0) { LOGE("GrabPreviewFrame: VIDIOC_QBUF Failed"); @@ -231,42 +224,8 @@ void V4L2Camera::GrabPreviewFrame (void *previewBuffer) nQueued++; - free(tmpBuffer); } -void V4L2Camera::GrabRecordFrame (void *recordBuffer) -{ - unsigned char *tmpBuffer; - int ret; - - tmpBuffer = (unsigned char *) calloc (1, videoIn->width * videoIn->height * 2); - - videoIn->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - videoIn->buf.memory = V4L2_MEMORY_MMAP; - - /* DQ */ - ret = ioctl(fd, VIDIOC_DQBUF, &videoIn->buf); - if (ret < 0) { - LOGE("GrabRecordFrame: VIDIOC_DQBUF Failed"); - - return; - } - nDequeued++; - - memcpy (tmpBuffer, videoIn->mem[videoIn->buf.index], (size_t) videoIn->buf.bytesused); - - yuyv422_to_yuv420((unsigned char *)tmpBuffer, (unsigned char *)recordBuffer, videoIn->width, videoIn->height); - - ret = ioctl(fd, VIDIOC_QBUF, &videoIn->buf); - if (ret < 0) { - LOGE("GrabRecordFrame: VIDIOC_QBUF Failed"); - return; - } - - nQueued++; - - free(tmpBuffer); -} sp<IMemory> V4L2Camera::GrabRawFrame () { @@ -452,54 +411,4 @@ int V4L2Camera::saveYUYVtoJPEG (unsigned char *inputBuffer, int width, int heigh return fileSize; } -void V4L2Camera::convert(unsigned char *buf, unsigned char *rgb, int width, int height) -{ - int x,y,z=0; - int blocks; - - blocks = (width * height) * 2; - - for (y = 0; y < blocks; y+=4) { - unsigned char Y1, Y2, U, V; - - Y1 = buf[y + 0]; - U = buf[y + 1]; - Y2 = buf[y + 2]; - V = buf[y + 3]; - - yuv_to_rgb16(Y1, U, V, &rgb[y]); - yuv_to_rgb16(Y2, U, V, &rgb[y + 2]); - } - -} - -void V4L2Camera::yuv_to_rgb16(unsigned char y, unsigned char u, unsigned char v, unsigned char *rgb) -{ - int r,g,b; - int z; - int rgb16; - - z = 0; - - r = 1.164 * (y - 16) + 1.596 * (v - 128); - g = 1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u -128); - b = 1.164 * (y - 16) + 2.018 * (u - 128); - - if (r > 255) r = 255; - if (g > 255) g = 255; - if (b > 255) b = 255; - - if (r < 0) r = 0; - if (g < 0) g = 0; - if (b < 0) b = 0; - - rgb16 = (int)(((r >> 3)<<11) | ((g >> 2) << 5)| ((b >> 3) << 0)); - - *rgb = (unsigned char)(rgb16 & 0xFF); - rgb++; - *rgb = (unsigned char)((rgb16 & 0xFF00) >> 8); - -} - - }; // namespace android |