diff options
author | Tyler Luu <tluu@ti.com> | 2011-11-11 14:46:40 -0600 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-07-25 08:55:37 -0500 |
commit | 011e176967b3275582b8d8f0170aadb3c42334c8 (patch) | |
tree | 47bc432258721a5532072bccf5eeba2ff3e11220 | |
parent | 9c16a59fbce6400c13053128621f6b4750b5dc5b (diff) | |
download | hardware_ti_omap4-011e176967b3275582b8d8f0170aadb3c42334c8.zip hardware_ti_omap4-011e176967b3275582b8d8f0170aadb3c42334c8.tar.gz hardware_ti_omap4-011e176967b3275582b8d8f0170aadb3c42334c8.tar.bz2 |
CameraHal: Assign string constant for pixel format
In appcallbacknotifier, use the string constant instead
savings return from CameraParameters::get. The return value
from CameraParameters::get is from the String8 memory pool
which can be invalidated by other String8 commands. Never
save these pointers expecting to use them at a later time!!!!!
Change-Id: Ib62ff582ff1989b3f5dc9a9333cf7ffc1fe55c41
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: Emilian Peev <epeev@mm-sol.com>
-rw-r--r-- | camera/AppCallbackNotifier.cpp | 29 | ||||
-rw-r--r-- | camera/inc/CameraHal.h | 1 |
2 files changed, 25 insertions, 5 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index 64166ff..df8a8de 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -453,7 +453,7 @@ static void copy2Dto1D(void *dst, unsigned int *y_uv = (unsigned int *)src; CAMHAL_LOGVB("copy2Dto1D() y= %p ; uv=%p.",y_uv[0], y_uv[1]); - CAMHAL_LOGVB("pixelFormat,= %d; offset=%d",*pixelFormat,offset); + CAMHAL_LOGVB("pixelFormat = %s; offset=%d",pixelFormat,offset); if (pixelFormat!=NULL) { if (strcmp(pixelFormat, CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { @@ -1365,10 +1365,10 @@ size_t AppCallbackNotifier::calculateBufferSize(size_t width, size_t height, con if(strcmp(pixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { res = width*height*2; - } else if(strcmp(mPreviewPixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || - strcmp(mPreviewPixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { + } else if(strcmp(pixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || + strcmp(pixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { res = (width*height*3)/2; - } else if(strcmp(mPreviewPixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_RGB565) == 0) { + } else if(strcmp(pixelFormat, (const char *) CameraParameters::PIXEL_FORMAT_RGB565) == 0) { res = width*height*2; } @@ -1376,6 +1376,25 @@ size_t AppCallbackNotifier::calculateBufferSize(size_t width, size_t height, con return res; } + +const char* AppCallbackNotifier::getContstantForPixelFormat(const char *pixelFormat) { + if (!pixelFormat) { + // returning NV12 as default + return CameraParameters::PIXEL_FORMAT_YUV420SP; + } + + if(strcmp(pixelFormat, CameraParameters::PIXEL_FORMAT_YUV422I) == 0) { + return CameraParameters::PIXEL_FORMAT_YUV422I; + } else if(strcmp(pixelFormat, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0 || + strcmp(pixelFormat, CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { + return CameraParameters::PIXEL_FORMAT_YUV420SP; + } else if(strcmp(pixelFormat, CameraParameters::PIXEL_FORMAT_RGB565) == 0) { + return CameraParameters::PIXEL_FORMAT_RGB565; + } else { + // returning NV12 as default + return CameraParameters::PIXEL_FORMAT_YUV420SP; + } +} status_t AppCallbackNotifier::startPreviewCallbacks(CameraParameters ¶ms, void *buffers, uint32_t *offsets, int fd, size_t length, size_t count) { sp<MemoryHeapBase> heap; @@ -1404,7 +1423,7 @@ status_t AppCallbackNotifier::startPreviewCallbacks(CameraParameters ¶ms, vo params.getPreviewSize(&w, &h); //Get the preview pixel format - mPreviewPixelFormat = params.getPreviewFormat(); + mPreviewPixelFormat = getContstantForPixelFormat(params.getPreviewFormat()); size = calculateBufferSize(w, h, mPreviewPixelFormat); mPreviewMemory = mRequestMemory(-1, size, AppCallbackNotifier::MAX_BUFFERS, NULL); diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 34b50b3..9f3230b 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -618,6 +618,7 @@ private: void copyAndSendPictureFrame(CameraFrame* frame, int32_t msgType); void copyAndSendPreviewFrame(CameraFrame* frame, int32_t msgType); size_t calculateBufferSize(size_t width, size_t height, const char *pixelFormat); + const char* getContstantForPixelFormat(const char *pixelFormat); private: mutable Mutex mLock; |