summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camera/CameraHal.cpp2
-rw-r--r--camera/CameraHalCommon.cpp23
-rw-r--r--camera/inc/CameraHal.h1
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: