diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-08-19 20:34:10 +0200 |
---|---|---|
committer | Amit Pundir <amit.pundir@linaro.org> | 2013-07-25 18:11:41 +0530 |
commit | 8ea7f852151796d802340fbc2c5b353ff2ddf4cc (patch) | |
tree | 659f461005c64be2a67c0de8e09d858295206c86 | |
parent | 9de6f63884aff5b0a99c8b7ca1f5712ebebef0b0 (diff) | |
download | omap4xxx-linaro_android_4.4.2.tar.gz |
omap4xxx: Fix aliasing violations, optimizelinaro_android_4.4.2linaro_android_4.4linaro_android_4.3.1linaro_android_4.3
Fix some violations of aliasing rules and optimize the code while at it:
There's no reason to use size_t/ssize_t (typically 64-bit values) for
the size of objects in pixels.
Change-Id: I0af70a2847f070754b734e82c6f76fe01d0ea298
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | camera/AppCallbackNotifier.cpp | 6 | ||||
-rw-r--r-- | camera/CameraHalUtilClasses.cpp | 38 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMX3A.cpp | 12 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXFocus.cpp | 12 | ||||
-rw-r--r-- | camera/inc/CameraHal.h | 104 | ||||
-rwxr-xr-x | domx/omx_core/inc/OMX_Types.h | 13 |
6 files changed, 93 insertions, 92 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index c6dfffa..bbb75d5 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -1061,13 +1061,13 @@ void AppCallbackNotifier::notifyFrame() void *y_uv[2]; mapper.lock((buffer_handle_t)vBuf, CAMHAL_GRALLOC_USAGE, bounds, y_uv); - structConvImage input = {frame->mWidth, - frame->mHeight, + structConvImage input = {(int)frame->mWidth, + (int)frame->mHeight, 4096, IC_FORMAT_YCbCr420_lp, (mmByte *)frame->mYuv[0], (mmByte *)frame->mYuv[1], - frame->mOffset}; + (int)frame->mOffset}; structConvImage output = {mVideoWidth, mVideoHeight, diff --git a/camera/CameraHalUtilClasses.cpp b/camera/CameraHalUtilClasses.cpp index 073c2b8..c74ca60 100644 --- a/camera/CameraHalUtilClasses.cpp +++ b/camera/CameraHalUtilClasses.cpp @@ -117,15 +117,15 @@ int EventProvider::disableEventNotification(int32_t frameTypes) /*--------------------CameraArea Class STARTS here-----------------------------*/ -status_t CameraArea::transfrom(size_t width, - size_t height, - size_t &top, - size_t &left, - size_t &areaWidth, - size_t &areaHeight) +status_t CameraArea::transfrom(uint32_t width, + uint32_t height, + int32_t &top, + int32_t &left, + uint32_t &areaWidth, + uint32_t &areaHeight) { status_t ret = NO_ERROR; - size_t hRange, vRange; + uint32_t hRange, vRange; double hScale, vScale; LOG_FUNCTION_NAME @@ -147,11 +147,11 @@ status_t CameraArea::transfrom(size_t width, return ret; } -status_t CameraArea::checkArea(ssize_t top, - ssize_t left, - ssize_t bottom, - ssize_t right, - ssize_t weight) +status_t CameraArea::checkArea(int32_t top, + int32_t left, + int32_t bottom, + int32_t right, + int32_t weight) { //Handles the invalid regin corner case. @@ -198,7 +198,7 @@ status_t CameraArea::checkArea(ssize_t top, } status_t CameraArea::parseAreas(const char *area, - size_t areaLength, + uint32_t areaLength, Vector< sp<CameraArea> > &areas) { status_t ret = NO_ERROR; @@ -209,7 +209,7 @@ status_t CameraArea::parseAreas(const char *area, const char *startToken = "("; const char endToken = ')'; const char sep = ','; - ssize_t top, left, bottom, right, weight; + int32_t top, left, bottom, right, weight; char *tmpBuffer = NULL; sp<CameraArea> currentArea; @@ -243,7 +243,7 @@ status_t CameraArea::parseAreas(const char *area, } else { - left = static_cast<ssize_t>(strtol(pStart, &pEnd, 10)); + left = static_cast<int32_t>(strtol(pStart, &pEnd, 10)); } if ( sep != *pEnd ) @@ -254,7 +254,7 @@ status_t CameraArea::parseAreas(const char *area, } else { - top = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10)); + top = static_cast<int32_t>(strtol(pEnd+1, &pEnd, 10)); } if ( sep != *pEnd ) @@ -265,7 +265,7 @@ status_t CameraArea::parseAreas(const char *area, } else { - right = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10)); + right = static_cast<int32_t>(strtol(pEnd+1, &pEnd, 10)); } if ( sep != *pEnd ) @@ -276,7 +276,7 @@ status_t CameraArea::parseAreas(const char *area, } else { - bottom = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10)); + bottom = static_cast<int32_t>(strtol(pEnd+1, &pEnd, 10)); } if ( sep != *pEnd ) @@ -287,7 +287,7 @@ status_t CameraArea::parseAreas(const char *area, } else { - weight = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10)); + weight = static_cast<int32_t>(strtol(pEnd+1, &pEnd, 10)); } if ( endToken != *pEnd ) diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index 4cb4607..b1c7178 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -1525,12 +1525,12 @@ status_t OMXCameraAdapter::setMeteringAreas(Gen3A_settings& Gen3A) for ( unsigned int n = 0; n < mMeteringAreas.size(); n++) { // transform the coordinates to 3A-type coordinates - mMeteringAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth, - (size_t)mPreviewData->mHeight, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nTop, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nLeft, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nWidth, - (size_t&)meteringAreas[0]->tAlgoAreas[n].nHeight); + mMeteringAreas.itemAt(n)->transfrom(mPreviewData->mWidth, + mPreviewData->mHeight, + meteringAreas[0]->tAlgoAreas[n].nTop, + meteringAreas[0]->tAlgoAreas[n].nLeft, + meteringAreas[0]->tAlgoAreas[n].nWidth, + meteringAreas[0]->tAlgoAreas[n].nHeight); meteringAreas[0]->tAlgoAreas[n].nLeft = ( meteringAreas[0]->tAlgoAreas[n].nLeft * METERING_AREAS_RANGE ) / mPreviewData->mWidth; diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index be1dfc5..32478af 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -729,12 +729,12 @@ status_t OMXCameraAdapter::setTouchFocus() for ( unsigned int n = 0; n < mFocusAreas.size(); n++) { // transform the coordinates to 3A-type coordinates - mFocusAreas.itemAt(n)->transfrom((size_t)mPreviewData->mWidth, - (size_t)mPreviewData->mHeight, - (size_t&)focusAreas[0]->tAlgoAreas[n].nTop, - (size_t&)focusAreas[0]->tAlgoAreas[n].nLeft, - (size_t&)focusAreas[0]->tAlgoAreas[n].nWidth, - (size_t&)focusAreas[0]->tAlgoAreas[n].nHeight); + mFocusAreas.itemAt(n)->transfrom(mPreviewData->mWidth, + mPreviewData->mHeight, + focusAreas[0]->tAlgoAreas[n].nTop, + focusAreas[0]->tAlgoAreas[n].nLeft, + focusAreas[0]->tAlgoAreas[n].nWidth, + focusAreas[0]->tAlgoAreas[n].nHeight); focusAreas[0]->tAlgoAreas[n].nLeft = ( focusAreas[0]->tAlgoAreas[n].nLeft * TOUCH_FOCUS_RANGE ) / mPreviewData->mWidth; diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 8b8392a..010cb4f 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -130,27 +130,27 @@ class CameraArea : public RefBase { public: - CameraArea(ssize_t top, - ssize_t left, - ssize_t bottom, - ssize_t right, - size_t weight) : mTop(top), + CameraArea(int32_t top, + int32_t left, + int32_t bottom, + int32_t right, + uint32_t weight) : mTop(top), mLeft(left), mBottom(bottom), mRight(right), mWeight(weight) {} - status_t transfrom(size_t width, - size_t height, - size_t &top, - size_t &left, - size_t &areaWidth, - size_t &areaHeight); + status_t transfrom(uint32_t width, + uint32_t height, + int32_t &top, + int32_t &left, + uint32_t &areaWidth, + uint32_t &areaHeight); bool isValid() - { + { return ( ( 0 != mTop ) || ( 0 != mLeft ) || ( 0 != mBottom ) || ( 0 != mRight) ); - } + } bool isZeroArea() { @@ -158,38 +158,38 @@ public: && ( 0 == mRight ) && ( 0 == mWeight )); } - size_t getWeight() - { + uint32_t getWeight() + { return mWeight; - } + } bool compare(const sp<CameraArea> &area); static status_t parseAreas(const char *area, - size_t areaLength, + uint32_t areaLength, Vector< sp<CameraArea> > &areas); - static status_t checkArea(ssize_t top, - ssize_t left, - ssize_t bottom, - ssize_t right, - ssize_t weight); + static status_t checkArea(int32_t top, + int32_t left, + int32_t bottom, + int32_t right, + int32_t weight); static bool areAreasDifferent(Vector< sp<CameraArea> > &, Vector< sp<CameraArea> > &); protected: - static const ssize_t TOP = -1000; - static const ssize_t LEFT = -1000; - static const ssize_t BOTTOM = 1000; - static const ssize_t RIGHT = 1000; - static const ssize_t WEIGHT_MIN = 1; - static const ssize_t WEIGHT_MAX = 1000; - - ssize_t mTop; - ssize_t mLeft; - ssize_t mBottom; - ssize_t mRight; - size_t mWeight; + static const int32_t TOP = -1000; + static const int32_t LEFT = -1000; + static const int32_t BOTTOM = 1000; + static const int32_t RIGHT = 1000; + static const int32_t WEIGHT_MIN = 1; + static const int32_t WEIGHT_MAX = 1000; + + int32_t mTop; + int32_t mLeft; + int32_t mBottom; + int32_t mRight; + uint32_t mWeight; }; class CameraFDResult : public RefBase @@ -215,11 +215,11 @@ public: camera_frame_metadata_t *getFaceResult() { return mFaceData; }; - static const ssize_t TOP = -1000; - static const ssize_t LEFT = -1000; - static const ssize_t BOTTOM = 1000; - static const ssize_t RIGHT = 1000; - static const ssize_t INVALID_DATA = -2000; + static const int32_t TOP = -1000; + static const int32_t LEFT = -1000; + static const int32_t BOTTOM = 1000; + static const int32_t RIGHT = 1000; + static const int32_t INVALID_DATA = -2000; private: @@ -300,7 +300,7 @@ class CameraFrame uint32_t mOffset; unsigned int mAlignment; int mFd; - size_t mLength; + uint32_t mLength; unsigned mFrameMask; unsigned int mQuirks; unsigned int mYuv[2]; @@ -359,11 +359,11 @@ public: } ZoomEventData; typedef struct FaceData_t { - ssize_t top; - ssize_t left; - ssize_t bottom; - ssize_t right; - size_t score; + int32_t top; + int32_t left; + int32_t bottom; + int32_t right; + uint32_t score; } FaceData; typedef sp<CameraFDResult> FaceEventData; @@ -545,7 +545,7 @@ public: //All sub-components of Camera HAL call this whenever any error happens virtual void errorNotify(int error); - status_t startPreviewCallbacks(CameraParameters ¶ms, void *buffers, uint32_t *offsets, int fd, size_t length, size_t count); + status_t startPreviewCallbacks(CameraParameters ¶ms, void *buffers, uint32_t *offsets, int fd, uint32_t length, uint32_t count); status_t stopPreviewCallbacks(); status_t enableMsgType(int32_t msgType); @@ -577,7 +577,7 @@ public: //Notifications from CameraHal for video recording case status_t startRecording(); status_t stopRecording(); - status_t initSharedVideoBuffers(void *buffers, uint32_t *offsets, int fd, size_t length, size_t count, void *vidBufs); + status_t initSharedVideoBuffers(void *buffers, uint32_t *offsets, int fd, uint32_t length, uint32_t count, void *vidBufs); status_t releaseRecordingFrame(const void *opaque); status_t useMetaDataBufferMode(bool enable); @@ -732,9 +732,9 @@ public: void *mBuffers; uint32_t *mOffsets; int mFd; - size_t mLength; - size_t mCount; - size_t mMaxQueueable; + uint32_t mLength; + uint32_t mCount; + uint32_t mMaxQueueable; } BuffersDescriptor; enum CameraCommands @@ -1110,7 +1110,7 @@ private: void insertSupportedParams(); /** Allocate preview data buffers */ - status_t allocPreviewDataBufs(size_t size, size_t bufferCount); + status_t allocPreviewDataBufs(uint32_t size, uint32_t bufferCount); /** Free preview data buffers */ status_t freePreviewDataBufs(); @@ -1122,7 +1122,7 @@ private: status_t allocVideoBufs(uint32_t width, uint32_t height, uint32_t bufferCount); /** Allocate image capture buffers */ - status_t allocImageBufs(unsigned int width, unsigned int height, size_t length, const char* previewFormat, unsigned int bufferCount); + status_t allocImageBufs(unsigned int width, unsigned int height, uint32_t length, const char* previewFormat, unsigned int bufferCount); /** Free preview buffers */ status_t freePreviewBufs(); diff --git a/domx/omx_core/inc/OMX_Types.h b/domx/omx_core/inc/OMX_Types.h index 31be916..d56d50a 100755 --- a/domx/omx_core/inc/OMX_Types.h +++ b/domx/omx_core/inc/OMX_Types.h @@ -34,6 +34,7 @@ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#include <stdint.h> /** The OMX_API and OMX_APIENTRY are platform specific definitions used * to declare OMX function prototypes. They are modified to meet the @@ -130,22 +131,22 @@ extern "C" { */ /** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */ -typedef unsigned char OMX_U8; +typedef uint8_t OMX_U8; /** OMX_S8 is an 8 bit signed quantity that is byte aligned */ -typedef signed char OMX_S8; +typedef int8_t OMX_S8; /** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ -typedef unsigned short OMX_U16; +typedef uint16_t OMX_U16; /** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */ -typedef signed short OMX_S16; +typedef int16_t OMX_S16; /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ -typedef unsigned long OMX_U32; +typedef uint32_t OMX_U32; /** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */ -typedef signed long OMX_S32; +typedef int32_t OMX_S32; /* Users with compilers that cannot accept the "long long" designation should |