summaryrefslogtreecommitdiffstats
path: root/camera/BufferSourceAdapter.cpp
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-06-01 19:04:53 -0500
committerDaniel Levin <dendy@ti.com>2012-10-10 18:55:50 +0300
commitf25f76de80ce7ff4f942d53867277815ef767f21 (patch)
treec0857def9d5801f16d8ce9f38e4b509ad4d9fa5d /camera/BufferSourceAdapter.cpp
parent5a1fc91d12042c7ccd09008cb264b40c89634230 (diff)
downloadhardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.tar.gz
hardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.tar.bz2
hardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.zip
camera: bsa: Calculate height for allocation
For allocating buffer list, calculate the height from stride, size, and format instead of using the passed height value. Image buffers were originally allocated from just size parameter when we were using MemoryManager. Now, ANW just uses width, height, and format. Change-Id: I1c743798426ea1e529e7c9ff6f09530e07bc1b86 Signed-off-by: Tyler Luu <tluu@ti.com> Signed-off-by: Vladimir Petrov <vppetrov@mm-sol.com>
Diffstat (limited to 'camera/BufferSourceAdapter.cpp')
-rw-r--r--camera/BufferSourceAdapter.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/camera/BufferSourceAdapter.cpp b/camera/BufferSourceAdapter.cpp
index 3088a0b..d63b117 100644
--- a/camera/BufferSourceAdapter.cpp
+++ b/camera/BufferSourceAdapter.cpp
@@ -96,6 +96,19 @@ static CameraFrame::FrameType formatToOutputFrameType(const char* format) {
return CameraFrame::RAW_FRAME;
}
+static int getHeightFromFormat(const char* format, int stride, int size) {
+ CAMHAL_ASSERT((NULL != format) && (0 <= stride) && (0 <= size));
+ switch (getANWFormat(format)) {
+ case HAL_PIXEL_FORMAT_TI_NV12:
+ return (size / (3 * stride)) * 2;
+ case HAL_PIXEL_FORMAT_TI_Y16:
+ return (size / stride) / 2;
+ default:
+ break;
+ }
+ return 0;
+}
+
/*--------------------BufferSourceAdapter Class STARTS here-----------------------------*/
@@ -292,7 +305,7 @@ void BufferSourceAdapter::destroy()
LOG_FUNCTION_NAME_EXIT;
}
-CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int height, const char* format,
+CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int dummyHeight, const char* format,
int &bytes, int numBufs)
{
LOG_FUNCTION_NAME;
@@ -342,6 +355,9 @@ CameraBuffer* BufferSourceAdapter::allocateBufferList(int width, int height, con
CAMHAL_LOGDB("Configuring %d buffers for ANativeWindow", numBufs);
mBufferCount = numBufs;
+ // re-calculate height depending on stride and size
+ int height = getHeightFromFormat(format, width, bytes);
+
// Set window geometry
err = mBufferSource->set_buffers_geometry(mBufferSource,
width, height,