summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
Diffstat (limited to 'camera')
-rw-r--r--camera/BufferSourceAdapter.cpp18
-rw-r--r--camera/inc/BufferSourceAdapter.h2
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() ;