diff options
author | Tyler Luu <tluu@ti.com> | 2012-06-01 19:04:53 -0500 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-10-10 18:55:50 +0300 |
commit | f25f76de80ce7ff4f942d53867277815ef767f21 (patch) | |
tree | c0857def9d5801f16d8ce9f38e4b509ad4d9fa5d | |
parent | 5a1fc91d12042c7ccd09008cb264b40c89634230 (diff) | |
download | hardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.zip hardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.tar.gz hardware_ti_omap4-f25f76de80ce7ff4f942d53867277815ef767f21.tar.bz2 |
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>
-rw-r--r-- | camera/BufferSourceAdapter.cpp | 18 | ||||
-rw-r--r-- | camera/inc/BufferSourceAdapter.h | 2 |
2 files changed, 18 insertions, 2 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, diff --git a/camera/inc/BufferSourceAdapter.h b/camera/inc/BufferSourceAdapter.h index ce91146..436d2e5 100644 --- a/camera/inc/BufferSourceAdapter.h +++ b/camera/inc/BufferSourceAdapter.h @@ -142,7 +142,7 @@ public: virtual status_t setSnapshotTimeRef(struct timeval *refTime = NULL) { return NO_ERROR; } #endif virtual bool supportsExternalBuffering(); - virtual CameraBuffer * allocateBufferList(int width, int height, const char* format, int &bytes, int numBufs); + virtual CameraBuffer * allocateBufferList(int width, int dummyHeight, const char* format, int &bytes, int numBufs); virtual CameraBuffer *getBufferList(int *numBufs); virtual uint32_t * getOffsets() ; virtual int getFd() ; |