Fix for issue 4133431 "Remove OSAL layer" in engine part

Change-Id: I98f98691048a5afc6f691b0cc3cec92e458e8f44
diff --git a/libvideoeditor/lvpp/DummyVideoSource.cpp b/libvideoeditor/lvpp/DummyVideoSource.cpp
old mode 100644
new mode 100755
index 42a732b..8081660
--- a/libvideoeditor/lvpp/DummyVideoSource.cpp
+++ b/libvideoeditor/lvpp/DummyVideoSource.cpp
@@ -96,7 +96,7 @@
 

     LOG2("DummyVideoSource::stop START");

     if (mImageBuffer != NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mImageBuffer);

+        free(mImageBuffer);

         mImageBuffer = NULL;

     }

     LOG2("DummyVideoSource::stop END");

diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp
index 2064004..552e1cd 100755
--- a/libvideoeditor/lvpp/PreviewPlayer.cpp
+++ b/libvideoeditor/lvpp/PreviewPlayer.cpp
@@ -230,7 +230,7 @@
     reset();
 
     if(mResizedVideoBuffer != NULL) {
-        M4OSA_free((M4OSA_MemAddr32)(mResizedVideoBuffer->data()));
+        free((mResizedVideoBuffer->data()));
         mResizedVideoBuffer = NULL;
     }
 
@@ -450,7 +450,7 @@
     mIsVideoSourceJpg = false;
     mFrameRGBBuffer = NULL;
     if(mFrameYUVBuffer != NULL) {
-        M4OSA_free((M4OSA_MemAddr32)mFrameYUVBuffer);
+        free(mFrameYUVBuffer);
         mFrameYUVBuffer = NULL;
     }
 }
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index 2fbb573..a83e7b6 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -496,7 +496,7 @@
 
                         LOGV("mix with background malloc to do len %d", len);
 
-                        bgFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_malloc( len, 1,
+                        bgFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_32bitAlignedMalloc( len, 1,
                                                        (M4OSA_Char*)"bgFrame");
                         if (NULL == bgFrame.m_dataAddress) {
                             LOGE("mBackgroundAudioSetting Malloc failed");
@@ -504,7 +504,7 @@
 
                         bgFrame.m_bufferSize = len;
 
-                        mixFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_malloc(len, 1,
+                        mixFrame.m_dataAddress = (M4OSA_UInt16*)M4OSA_32bitAlignedMalloc(len, 1,
                                                     (M4OSA_Char*)"mixFrame");
                         if (NULL == mixFrame.m_dataAddress) {
                             LOGE("mBackgroundAudioSetting Malloc failed");
@@ -602,10 +602,10 @@
                             }
                         }
                         if (bgFrame.m_dataAddress) {
-                            M4OSA_free((M4OSA_MemAddr32)bgFrame.m_dataAddress);
+                            free(bgFrame.m_dataAddress);
                         }
                         if (mixFrame.m_dataAddress) {
-                            M4OSA_free((M4OSA_MemAddr32)mixFrame.m_dataAddress);
+                            free(mixFrame.m_dataAddress);
                         }
                     } else {
                         // No mixing;
diff --git a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
index 164e2b3..b12d8fe 100755
--- a/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
+++ b/libvideoeditor/lvpp/VideoEditorPreviewController.cpp
@@ -99,29 +99,27 @@
         for(i=0;i<mNumberClipsInStoryBoard;i++)

         {

             if(mClipList[i]->pFile != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)mClipList[i]->pFile);

+                free(mClipList[i]->pFile);

                 mClipList[i]->pFile = NULL;

             }

 

-            M4OSA_free((M4OSA_MemAddr32)mClipList[i]);

+            free(mClipList[i]);

         }

-        M4OSA_free((M4OSA_MemAddr32)mClipList);

+        free(mClipList);

         mClipList = NULL;

     }

 

     if(mEffectsSettings) {

         for(i=0;i<mNumberEffects;i++) {

             if(mEffectsSettings[i].xVSS.pFramingBuffer != NULL) {

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

 

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                 mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

             }

         }

-        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+        free(mEffectsSettings);

         mEffectsSettings = NULL;

     }

 

@@ -131,7 +129,7 @@
     }

 

     if (mBackgroundAudioSetting != NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mBackgroundAudioSetting);

+        free(mBackgroundAudioSetting);

         mBackgroundAudioSetting = NULL;

     }

 

@@ -170,7 +168,7 @@
     }

 

     if(mBackgroundAudioSetting != NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mBackgroundAudioSetting);

+        free(mBackgroundAudioSetting);

         mBackgroundAudioSetting = NULL;

     }

 

@@ -179,29 +177,27 @@
         for(i=0;i<mNumberClipsInStoryBoard;i++)

         {

             if(mClipList[i]->pFile != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)mClipList[i]->pFile);

+                free(mClipList[i]->pFile);

                 mClipList[i]->pFile = NULL;

             }

 

-            M4OSA_free((M4OSA_MemAddr32)mClipList[i]);

+            free(mClipList[i]);

         }

-        M4OSA_free((M4OSA_MemAddr32)mClipList);

+        free(mClipList);

         mClipList = NULL;

     }

 

     if(mEffectsSettings) {

         for(i=0;i<mNumberEffects;i++) {

             if(mEffectsSettings[i].xVSS.pFramingBuffer != NULL) {

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer->pac_data);

 

-                M4OSA_free(

-                (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                 mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

             }

         }

-        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+        free(mEffectsSettings);

         mEffectsSettings = NULL;

     }

 

@@ -209,7 +205,7 @@
         mNumberClipsInStoryBoard = pSettings->uiClipNumber;

         LOGV("loadEditSettings: # of Clips = %d", mNumberClipsInStoryBoard);

 

-        mClipList = (M4VSS3GPP_ClipSettings**)M4OSA_malloc(

+        mClipList = (M4VSS3GPP_ClipSettings**)M4OSA_32bitAlignedMalloc(

          sizeof(M4VSS3GPP_ClipSettings*)*pSettings->uiClipNumber, M4VS,

          (M4OSA_Char*)"LvPP, copy of pClipList");

 

@@ -224,7 +220,7 @@
 

             // Allocate current clip

             mClipList[i] =

-             (M4VSS3GPP_ClipSettings*)M4OSA_malloc(

+             (M4VSS3GPP_ClipSettings*)M4OSA_32bitAlignedMalloc(

               sizeof(M4VSS3GPP_ClipSettings),M4VS,(M4OSA_Char*)"clip settings");

 

             if(mClipList[i] == NULL) {

@@ -238,7 +234,7 @@
              sizeof(M4VSS3GPP_ClipSettings));

 

             if(NULL != pSettings->pClipList[i]->pFile) {

-                mClipList[i]->pFile = (M4OSA_Char*)M4OSA_malloc(

+                mClipList[i]->pFile = (M4OSA_Char*)M4OSA_32bitAlignedMalloc(

                 pSettings->pClipList[i]->filePathSize, M4VS,

                 (M4OSA_Char*)"pClipSettingsDest->pFile");

 

@@ -270,7 +266,7 @@
         LOGV("loadEditSettings: mNumberEffects = %d", mNumberEffects);

 

         if(mNumberEffects != 0) {

-            mEffectsSettings = (M4VSS3GPP_EffectSettings*)M4OSA_malloc(

+            mEffectsSettings = (M4VSS3GPP_EffectSettings*)M4OSA_32bitAlignedMalloc(

              mNumberEffects*sizeof(M4VSS3GPP_EffectSettings),

              M4VS, (M4OSA_Char*)"effects settings");

 

@@ -296,12 +292,12 @@
                  (M4VSS3GPP_VideoEffectType)M4xVSS_kVideoEffectType_Framing) {

                     // Allocate the pFraming RGB buffer

                     mEffectsSettings[i].xVSS.pFramingBuffer =

-                    (M4VIFI_ImagePlane *)M4OSA_malloc(sizeof(M4VIFI_ImagePlane),

+                    (M4VIFI_ImagePlane *)M4OSA_32bitAlignedMalloc(sizeof(M4VIFI_ImagePlane),

                      M4VS, (M4OSA_Char*)"lvpp framing buffer");

 

                     if(mEffectsSettings[i].xVSS.pFramingBuffer == NULL) {

                         LOGE("loadEffectsSettings:Alloc error for pFramingBuf");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

                         return M4ERR_ALLOC;

                     }

@@ -320,20 +316,19 @@
                     }

                     else {

                         LOGE("loadEffectsSettings: wrong RGB type");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

                         return M4ERR_PARAMETER;

                     }

 

-                    tmp = (M4VIFI_UInt8 *)M4OSA_malloc(rgbSize, M4VS,

+                    tmp = (M4VIFI_UInt8 *)M4OSA_32bitAlignedMalloc(rgbSize, M4VS,

                      (M4OSA_Char*)"framing buffer pac_data");

 

                     if(tmp == NULL) {

                         LOGE("loadEffectsSettings:Alloc error pFramingBuf pac");

-                        M4OSA_free((M4OSA_MemAddr32)mEffectsSettings);

+                        free(mEffectsSettings);

                         mEffectsSettings = NULL;

-                        M4OSA_free(

-                        (M4OSA_MemAddr32)mEffectsSettings[i].xVSS.pFramingBuffer);

+                        free(mEffectsSettings[i].xVSS.pFramingBuffer);

 

                         mEffectsSettings[i].xVSS.pFramingBuffer = NULL;

                         return M4ERR_ALLOC;

@@ -381,7 +376,7 @@
 

     if (mBackgroundAudioSetting == NULL) {

 

-        mBackgroundAudioSetting = (M4xVSS_AudioMixingSettings*)M4OSA_malloc(

+        mBackgroundAudioSetting = (M4xVSS_AudioMixingSettings*)M4OSA_32bitAlignedMalloc(

         sizeof(M4xVSS_AudioMixingSettings), M4VS,

         (M4OSA_Char*)"LvPP, copy of bgmSettings");

 

@@ -699,7 +694,7 @@
 

     // If image file playing, then free the buffer pointer

     if(mFrameStr.pBuffer != M4OSA_NULL) {

-        M4OSA_free((M4OSA_MemAddr32)mFrameStr.pBuffer);

+        free(mFrameStr.pBuffer);

         mFrameStr.pBuffer = M4OSA_NULL;

     }

 

@@ -883,7 +878,7 @@
                 LOGE("renderPreviewFrame: applyVideoEffect error 0x%x", (unsigned int)err);

                 delete mTarget;

                 mTarget = NULL;

-                M4OSA_free((M4OSA_MemAddr32)pixelArray);

+                free(pixelArray);

                 pixelArray = NULL;

                 return err;

            }

@@ -899,7 +894,7 @@
                 LOGE("renderPreviewFrame:doImageRenderingMode error 0x%x", (unsigned int)err);

                 delete mTarget;

                 mTarget = NULL;

-                M4OSA_free((M4OSA_MemAddr32)pixelArray);

+                free(pixelArray);

                 pixelArray = NULL;

                 return err;

             }

@@ -915,7 +910,7 @@
             LOGE("renderPreviewFrame: doImageRenderingMode error 0x%x", (unsigned int)err);

             delete mTarget;

             mTarget = NULL;

-            M4OSA_free((M4OSA_MemAddr32)pixelArray);

+            free(pixelArray);

             pixelArray = NULL;

             return err;

         }

@@ -1166,7 +1161,7 @@
                 ((M4OSA_UInt32)pController->mCurrentClipNumber !=

                 (pController->mNumberClipsToPreview-1))) {

                 VideoEditorCurretEditInfo *pEditInfo =

-                    (VideoEditorCurretEditInfo*)M4OSA_malloc(sizeof(VideoEditorCurretEditInfo),

+                    (VideoEditorCurretEditInfo*)M4OSA_32bitAlignedMalloc(sizeof(VideoEditorCurretEditInfo),

                     M4VS, (M4OSA_Char*)"Current Edit info");

                 pEditInfo->overlaySettingsIndex = ext2;

                 pEditInfo->clipIndex = pController->mCurrentClipNumber;

@@ -1175,7 +1170,7 @@
                         pController->mJniCallback(pController->mJniCookie,

                             MSG_TYPE_OVERLAY_CLEAR, pEditInfo);

                 }

-                M4OSA_free((M4OSA_MemAddr32)pEditInfo);

+                free(pEditInfo);

             }

             {

                 Mutex::Autolock autoLock(pController->mLockSem);

@@ -1246,7 +1241,7 @@
             LOGV("VIDEO PLAYBACK, Update Overlay");

             int overlayIndex = ext2;

             VideoEditorCurretEditInfo *pEditInfo =

-                    (VideoEditorCurretEditInfo*)M4OSA_malloc(sizeof(VideoEditorCurretEditInfo),

+                    (VideoEditorCurretEditInfo*)M4OSA_32bitAlignedMalloc(sizeof(VideoEditorCurretEditInfo),

                     M4VS, (M4OSA_Char*)"Current Edit info");

             //ext1 = 1; start the overlay display

             //     = 2; Clear the overlay.

@@ -1264,7 +1259,7 @@
                         MSG_TYPE_OVERLAY_CLEAR, pEditInfo);

                 }

             }

-            M4OSA_free((M4OSA_MemAddr32)pEditInfo);

+            free(pEditInfo);

             break;

         }

         default:

diff --git a/libvideoeditor/lvpp/VideoEditorTools.cpp b/libvideoeditor/lvpp/VideoEditorTools.cpp
index 6e86139..9a43896 100755
--- a/libvideoeditor/lvpp/VideoEditorTools.cpp
+++ b/libvideoeditor/lvpp/VideoEditorTools.cpp
@@ -1063,7 +1063,7 @@
 

     /**

      * Allocate output YUV planes */

-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

     if(framingCtx->FramingYuv == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1073,7 +1073,7 @@
     framingCtx->FramingYuv[0].u_height = framingCtx->FramingRgb->u_height;

     framingCtx->FramingYuv[0].u_topleft = 0;

     framingCtx->FramingYuv[0].u_stride = framingCtx->FramingRgb->u_width;

-    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

+    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1128,7 +1128,7 @@
 

     /**

      * Allocate output YUV planes */

-    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

+    framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

     if(framingCtx->FramingYuv == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1138,7 +1138,7 @@
     framingCtx->FramingYuv[0].u_height = framingCtx->FramingRgb->u_height;

     framingCtx->FramingYuv[0].u_topleft = 0;

     framingCtx->FramingYuv[0].u_stride = framingCtx->FramingRgb->u_width;

-    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

+    framingCtx->FramingYuv[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc((framingCtx->FramingYuv[0].u_width*framingCtx->FramingYuv[0].u_height*3)>>1, M4VS, (M4OSA_Char*)"Alloc for the Convertion output YUV");;

     if(framingCtx->FramingYuv[0].pac_data == M4OSA_NULL)

     {

         M4OSA_TRACE1_0("Allocation error in M4xVSS_internalConvertRGBtoYUV");

@@ -1900,20 +1900,20 @@
             pImagePlanesTemp[2].pac_data = M4OSA_NULL;

 

             /* Allocates plan in local image plane structure */

-            pImagePlanesTemp[0].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[0].u_width * pImagePlanesTemp[0].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferY") ;

+            pImagePlanesTemp[0].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[0].u_width * pImagePlanesTemp[0].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferY") ;

             if(pImagePlanesTemp[0].pac_data == M4OSA_NULL)

             {

                 M4OSA_TRACE1_0("Error alloc in applyRenderingMode");

                 return M4ERR_ALLOC;

             }

-            pImagePlanesTemp[1].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[1].u_width * pImagePlanesTemp[1].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferU") ;

+            pImagePlanesTemp[1].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[1].u_width * pImagePlanesTemp[1].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferU") ;

             if(pImagePlanesTemp[1].pac_data == M4OSA_NULL)

             {

 

                 M4OSA_TRACE1_0("Error alloc in applyRenderingMode");

                 return M4ERR_ALLOC;

             }

-            pImagePlanesTemp[2].pac_data = (M4OSA_UInt8*)M4OSA_malloc(pImagePlanesTemp[2].u_width * pImagePlanesTemp[2].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferV") ;

+            pImagePlanesTemp[2].pac_data = (M4OSA_UInt8*)M4OSA_32bitAlignedMalloc(pImagePlanesTemp[2].u_width * pImagePlanesTemp[2].u_height, M4VS, (M4OSA_Char*)"applyRenderingMode: temporary plane bufferV") ;

             if(pImagePlanesTemp[2].pac_data == M4OSA_NULL)

             {

 

@@ -2016,7 +2016,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -2034,7 +2034,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -2050,7 +2050,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -2082,7 +2082,7 @@
             {

                 if(pImagePlanesTemp[i].pac_data != M4OSA_NULL)

                 {

-                    M4OSA_free((M4OSA_MemAddr32)pImagePlanesTemp[i].pac_data);

+                    free(pImagePlanesTemp[i].pac_data);

                     pImagePlanesTemp[i].pac_data = M4OSA_NULL;

                 }

             }

@@ -2186,7 +2186,7 @@
     *pContext = M4OSA_NULL ;

 

     /* Internal Context creation */

-    pC = (M4AIR_InternalContext*)M4OSA_malloc(sizeof(M4AIR_InternalContext), M4AIR, (M4OSA_Char*)"AIR internal context") ;

+    pC = (M4AIR_InternalContext*)M4OSA_32bitAlignedMalloc(sizeof(M4AIR_InternalContext), M4AIR, (M4OSA_Char*)"AIR internal context") ;

     M4ERR_CHECK_NULL_RETURN_VALUE(M4ERR_ALLOC, pC) ;

 

 

@@ -2219,7 +2219,7 @@
     /* Error management : we destroy the context if needed */

     if(M4OSA_NULL != pC)

     {

-        M4OSA_free((M4OSA_MemAddr32)pC) ;

+        free(pC) ;

     }

 

     *pContext = M4OSA_NULL ;

@@ -2251,7 +2251,7 @@
     {

         return M4ERR_STATE;

     }

-    M4OSA_free((M4OSA_MemAddr32)pC) ;

+    free(pC) ;

 

     return M4NO_ERROR ;

 

@@ -3029,7 +3029,7 @@
     M4OSA_Context lImageFileFp  = M4OSA_NULL;

     M4OSA_ERR err = M4NO_ERROR;

 

-    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_malloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");

+    M4OSA_UInt8 *pTmpData = (M4OSA_UInt8*) M4OSA_32bitAlignedMalloc(frameSize_argb, M4VS, (M4OSA_Char*)"Image argb data");

     if(pTmpData == M4OSA_NULL) {

         LOGE("Failed to allocate memory for Image clip");

         return M4ERR_ALLOC;

@@ -3041,7 +3041,7 @@
     if((lerr != M4NO_ERROR) || (lImageFileFp == M4OSA_NULL))

     {

         LOGE("LVPreviewController: Can not open the file ");

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return M4ERR_FILE_NOT_FOUND;

     }

     lerr = M4OSA_fileReadData(lImageFileFp, (M4OSA_MemAddr8)pTmpData, &frameSize_argb);

@@ -3049,17 +3049,17 @@
     {

         LOGE("LVPreviewController: can not read the data ");

         M4OSA_fileReadClose(lImageFileFp);

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return lerr;

     }

     M4OSA_fileReadClose(lImageFileFp);

 

     M4OSA_UInt32 frameSize = (width * height * 3); //Size of YUV420 data.

-    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS, (M4OSA_Char*)"Image clip RGB888 data");

+    rgbPlane.pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS, (M4OSA_Char*)"Image clip RGB888 data");

     if(rgbPlane.pac_data == M4OSA_NULL)

     {

         LOGE("Failed to allocate memory for Image clip");

-        M4OSA_free((M4OSA_MemAddr32)pTmpData);

+        free(pTmpData);

         return M4ERR_ALLOC;

     }

 

@@ -3069,7 +3069,7 @@
         rgbPlane.pac_data[j] = pTmpData[i];

         j++;

     }

-    M4OSA_free((M4OSA_MemAddr32)pTmpData);

+    free(pTmpData);

 

 #ifdef FILE_DUMP

     FILE *fp = fopen("/sdcard/Input/test_rgb.raw", "wb");

@@ -3085,13 +3085,13 @@
         rgbPlane.u_stride = width*3;

         rgbPlane.u_topleft = 0;

 

-        yuvPlane = (M4VIFI_ImagePlane*)M4OSA_malloc(3*sizeof(M4VIFI_ImagePlane),

+        yuvPlane = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(3*sizeof(M4VIFI_ImagePlane),

                 M4VS, (M4OSA_Char*)"M4xVSS_internalConvertRGBtoYUV: Output plane YUV");

         yuvPlane[0].u_height = height;

         yuvPlane[0].u_width = width;

         yuvPlane[0].u_stride = width;

         yuvPlane[0].u_topleft = 0;

-        yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_malloc(yuvPlane[0].u_height * yuvPlane[0].u_width * 1.5, M4VS, (M4OSA_Char*)"imageClip YUV data");

+        yuvPlane[0].pac_data = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(yuvPlane[0].u_height * yuvPlane[0].u_width * 1.5, M4VS, (M4OSA_Char*)"imageClip YUV data");

 

         yuvPlane[1].u_height = yuvPlane[0].u_height >>1;

         yuvPlane[1].u_width = yuvPlane[0].u_width >> 1;

@@ -3112,7 +3112,7 @@
         {

             LOGE("error when converting from RGB to YUV: 0x%x\n", (unsigned int)err);

         }

-        M4OSA_free((M4OSA_MemAddr32)rgbPlane.pac_data);

+        free(rgbPlane.pac_data);

 

         //LOGE("RGB to YUV done");

 #ifdef FILE_DUMP

@@ -3125,7 +3125,7 @@
         }

 #endif

         *pBuffer = yuvPlane[0].pac_data;

-        M4OSA_free((M4OSA_MemAddr32)yuvPlane);

+        free(yuvPlane);

         return M4NO_ERROR;

 

 }

@@ -3292,7 +3292,7 @@
     framingCtx->previousClipTime = -1;

 

     framingCtx->alphaBlendingStruct =

-     (M4xVSS_internalEffectsAlphaBlending*)M4OSA_malloc(

+     (M4xVSS_internalEffectsAlphaBlending*)M4OSA_32bitAlignedMalloc(

       sizeof(M4xVSS_internalEffectsAlphaBlending), M4VS,

       (M4OSA_Char*)"alpha blending struct");

 

@@ -3316,7 +3316,7 @@
 

         // If YUV buffer exists, delete it

         if(overlayYUV != NULL) {

-           M4OSA_free((M4OSA_MemAddr32)overlayYUV);

+           free(overlayYUV);

            overlayYUV = NULL;

         }

     if(effectsSettings[index].xVSS.rgbType == M4VSS3GPP_kRGB565) {

@@ -3338,7 +3338,7 @@
     }

     else {

         LOGV(" YUV buffer reuse");

-        framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_malloc(

+        framingCtx->FramingYuv = (M4VIFI_ImagePlane*)M4OSA_32bitAlignedMalloc(

             3*sizeof(M4VIFI_ImagePlane), M4VS, (M4OSA_Char*)"YUV");

 

         if(framingCtx->FramingYuv == M4OSA_NULL) {

@@ -3392,11 +3392,11 @@
             colorEffect, err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1 = NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2 = NULL;

         }

         return err;

@@ -3422,11 +3422,11 @@
         LOGE("M4VFL_modifyLumaWithScale(%d) error %d", videoEffect, (int)err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1= NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2= NULL;

         }

         return err;

@@ -3453,11 +3453,11 @@
         LOGE("M4VFL_applyCurtain(%d) error %d", videoEffect, (int)err);

 

         if(NULL != buffer1) {

-            M4OSA_free((M4OSA_MemAddr32)buffer1);

+            free(buffer1);

             buffer1= NULL;

         }

         if(NULL != buffer2) {

-            M4OSA_free((M4OSA_MemAddr32)buffer2);

+            free(buffer2);

             buffer2 = NULL;

         }

         return err;

@@ -3485,7 +3485,7 @@
 

     frameSize = (params->videoWidth*params->videoHeight*3) >> 1;

 

-    finalOutputBuffer = (M4VIFI_UInt8*)M4OSA_malloc(frameSize, M4VS,

+    finalOutputBuffer = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(frameSize, M4VS,

      (M4OSA_Char*)("lvpp finalOutputBuffer"));

 

     if(finalOutputBuffer == NULL) {

@@ -3494,13 +3494,13 @@
     }

 

     // allocate the tempOutputBuffer

-    tempOutputBuffer = (M4VIFI_UInt8*)M4OSA_malloc(

+    tempOutputBuffer = (M4VIFI_UInt8*)M4OSA_32bitAlignedMalloc(

      ((params->videoHeight*params->videoWidth*3)>>1), M4VS, (M4OSA_Char*)("lvpp colorBuffer"));

 

     if(tempOutputBuffer == NULL) {

         LOGE("applyEffectsAndRenderingMode: malloc error tempOutputBuffer");

         if(NULL != finalOutputBuffer) {

-            M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+            free(finalOutputBuffer);

             finalOutputBuffer = NULL;

         }

         return M4ERR_ALLOC;

@@ -3625,11 +3625,11 @@
                 LOGE("M4VSS3GPP_externalVideoEffectFifties error 0x%x", (unsigned int)err);

 

                 if(NULL != finalOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+                    free(finalOutputBuffer);

                     finalOutputBuffer = NULL;

                 }

                 if(NULL != tempOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+                    free(tempOutputBuffer);

                     tempOutputBuffer = NULL;

                 }

                 return err;

@@ -3671,10 +3671,10 @@
                       M4xVSS_kVideoEffectType_Framing);

             }

 

-            M4OSA_free((M4OSA_MemAddr32)framingCtx.alphaBlendingStruct);

+            free(framingCtx.alphaBlendingStruct);

 

             if(framingCtx.FramingYuv != NULL) {

-                M4OSA_free((M4OSA_MemAddr32)framingCtx.FramingYuv);

+                free(framingCtx.FramingYuv);

                 framingCtx.FramingYuv = NULL;

             }

             //If prepareFramingStructure / M4VSS3GPP_externalVideoEffectFraming

@@ -3682,11 +3682,11 @@
             if(err != M4NO_ERROR) {

 

                 if(NULL != finalOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+                    free(finalOutputBuffer);

                     finalOutputBuffer = NULL;

                 }

                 if(NULL != tempOutputBuffer) {

-                    M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+                    free(tempOutputBuffer);

                     tempOutputBuffer = NULL;

                 }

                 return err;

@@ -3825,11 +3825,11 @@
     err = applyRenderingMode(planeIn, planeOut, params->renderingMode);

 

     if(M4OSA_NULL != finalOutputBuffer) {

-        M4OSA_free((M4OSA_MemAddr32)finalOutputBuffer);

+        free(finalOutputBuffer);

         finalOutputBuffer= M4OSA_NULL;

     }

     if(M4OSA_NULL != tempOutputBuffer) {

-        M4OSA_free((M4OSA_MemAddr32)tempOutputBuffer);

+        free(tempOutputBuffer);

         tempOutputBuffer = M4OSA_NULL;

     }

     if(err != M4NO_ERROR) {