summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorEmilian Peev <epeev@mm-sol.com>2012-05-08 12:47:30 +0300
committerEino-Ville Talvala <etalvala@google.com>2012-05-10 10:36:01 -0700
commitd822531f1f2b4c0fea1cd971d28bd1e552ed67ba (patch)
tree9700fbfa48b841de211baa465be0f20483b4e4cc /camera
parent1e67b5ff2e8016d506cb29900b476435f03cb3a3 (diff)
downloadhardware_ti_omap4xxx-d822531f1f2b4c0fea1cd971d28bd1e552ed67ba.zip
hardware_ti_omap4xxx-d822531f1f2b4c0fea1cd971d28bd1e552ed67ba.tar.gz
hardware_ti_omap4xxx-d822531f1f2b4c0fea1cd971d28bd1e552ed67ba.tar.bz2
CameraHAL: Aligns UV planes during YV12 preview callbacks
- UV planes stride should be multiple of 16. The buffer size should also be updated accordingly. Bug: 6447707 Change-Id: If436801fbb2750523a3207878f611c8094667367 Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Diffstat (limited to 'camera')
-rw-r--r--camera/AppCallbackNotifier.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp
index 678b719..c6dfffa 100644
--- a/camera/AppCallbackNotifier.cpp
+++ b/camera/AppCallbackNotifier.cpp
@@ -450,6 +450,21 @@ void AppCallbackNotifier::notifyEvent()
}
+static void alignYV12(int width,
+ int height,
+ int &yStride,
+ int &uvStride,
+ int &ySize,
+ int &uvSize,
+ int &size)
+{
+ yStride = ( width + 0xF ) & ~0xF;
+ uvStride = ( yStride / 2 + 0xF ) & ~0xF;
+ ySize = yStride * height;
+ uvSize = uvStride * height / 2;
+ size = ySize + uvSize * 2;
+}
+
static void copy2Dto1D(void *dst,
void *src,
int width,
@@ -599,8 +614,12 @@ static void copy2Dto1D(void *dst,
// camera adapter to support YV12. Need to address for
// USBCamera
- bufferDst_V = (uint16_t *) (((uint8_t*)dst)+row*height);
- bufferDst_U = (uint16_t *) (((uint8_t*)dst)+row*height+row*height/4);
+ int yStride, uvStride, ySize, uvSize, size;
+ alignYV12(width, height, yStride, uvStride, ySize, uvSize, size);
+
+ bufferDst_V = (uint16_t *) (((uint8_t*)dst) + ySize);
+ bufferDst_U = (uint16_t *) (((uint8_t*)dst) + ySize + uvSize);
+ int inc = (uvStride - width/2)/2;
for (int i = 0 ; i < height/2 ; i++, bufferSrc_UV += alignedRow/2) {
int n = width;
@@ -644,7 +663,11 @@ static void copy2Dto1D(void *dst,
: [src_stride] "r" (stride_bytes)
: "cc", "memory", "q0", "q1"
);
+
+ bufferDst_U += inc;
+ bufferDst_V += inc;
}
+
}
return ;
@@ -1416,7 +1439,7 @@ status_t AppCallbackNotifier::startPreviewCallbacks(CameraParameters &params, vo
sp<MemoryHeapBase> heap;
sp<MemoryBase> buffer;
unsigned int *bufArr;
- size_t size = 0;
+ int size = 0;
LOG_FUNCTION_NAME;
@@ -1458,7 +1481,8 @@ status_t AppCallbackNotifier::startPreviewCallbacks(CameraParameters &params, vo
}
else if(strcmp(mPreviewPixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV420P) == 0)
{
- size = (w*h*3)/2;
+ int yStride, uvStride, ySize, uvSize;
+ alignYV12(w, h, yStride, uvStride, ySize, uvSize, size);
mPreviewPixelFormat = CameraParameters::PIXEL_FORMAT_YUV420P;
}