diff options
author | Tyler Luu <tluu@ti.com> | 2012-06-07 19:32:52 -0500 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-11-26 18:22:46 +0200 |
commit | 7010ab636a1ab73307463ff63daf1ebb40a6ea62 (patch) | |
tree | e80862958d931890c27686ccaa37bfcdc3bc5bc8 | |
parent | 2e7b99d9a2565380afcf938d59bcc5937c99804d (diff) | |
download | hardware_ti_omap4-7010ab636a1ab73307463ff63daf1ebb40a6ea62.tar.gz hardware_ti_omap4-7010ab636a1ab73307463ff63daf1ebb40a6ea62.tar.bz2 hardware_ti_omap4-7010ab636a1ab73307463ff63daf1ebb40a6ea62.zip |
camera: Account for bpp in stride
Need to account for bytes per pixel when sending stride received
from CameraAdapter to BufferProvider. CameraAdapter will send stride
in bytes but BufferProvider expects stride in pixels.
Change-Id: I80512e888b385a42cc9345da34c77fb0e2c19f78
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
-rw-r--r-- | camera/CameraHal.cpp | 2 | ||||
-rw-r--r-- | camera/CameraHalCommon.cpp | 23 | ||||
-rw-r--r-- | camera/inc/CameraHal.h | 1 |
3 files changed, 16 insertions, 10 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 7998f3f..1c04ffe 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -3121,7 +3121,7 @@ status_t CameraHal::__takePicture(const char *params) if ( NO_ERROR == ret ) { - ret = allocImageBufs(frame.mAlignment, + ret = allocImageBufs(frame.mAlignment / getBPP(mParameters.getPictureFormat()), frame.mHeight, frame.mLength, mParameters.getPictureFormat(), diff --git a/camera/CameraHalCommon.cpp b/camera/CameraHalCommon.cpp index f98b3ba..06f6656 100644 --- a/camera/CameraHalCommon.cpp +++ b/camera/CameraHalCommon.cpp @@ -120,18 +120,14 @@ void CameraHal::PPM(const char* str, struct timeval* ppm_first, ...){ /** Common utility function definitions used all over the HAL */ -void CameraHal::getXYFromOffset(unsigned int *x, unsigned int *y, - unsigned int offset, unsigned int stride, - const char* format) -{ - uint8_t bytesPerPixel; - - CAMHAL_ASSERT( x && y && format && (0U < stride) ); +unsigned int CameraHal::getBPP(const char* format) { + unsigned int bytesPerPixel; // Calculate bytes per pixel based on the pixel format if (strcmp(format, android::CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { bytesPerPixel = 2; - } else if (strcmp(format, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0) { + } else if (strcmp(format, android::CameraParameters::PIXEL_FORMAT_RGB565) == 0 || + strcmp(format, android::CameraParameters::PIXEL_FORMAT_BAYER_RGGB) == 0) { bytesPerPixel = 2; } else if (strcmp(format, android::CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { bytesPerPixel = 1; @@ -139,7 +135,16 @@ void CameraHal::getXYFromOffset(unsigned int *x, unsigned int *y, bytesPerPixel = 1; } - *x = (offset % stride) / bytesPerPixel; + return bytesPerPixel; +} + +void CameraHal::getXYFromOffset(unsigned int *x, unsigned int *y, + unsigned int offset, unsigned int stride, + const char* format) +{ + CAMHAL_ASSERT( x && y && format && (0U < stride) ); + + *x = (offset % stride) / getBPP(format); *y = (offset / stride); } diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index f750c59..2da2cd4 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -1239,6 +1239,7 @@ public: static void getXYFromOffset(unsigned int *x, unsigned int *y, unsigned int offset, unsigned int stride, const char* format); + static unsigned int getBPP(const char* format); /*--------------------Internal Member functions - Private---------------------------------*/ private: |