media: 64 bit compile issues

- change internal sized types to use stdint.h
- printf & scanf formats
- size_t or unsigned int for iterators

Change-Id: Id993a70d8bf54c667c5d652b34179a2c727ed446
diff --git a/libvideoeditor/lvpp/DummyVideoSource.cpp b/libvideoeditor/lvpp/DummyVideoSource.cpp
index b06f937..6dbcf2a 100755
--- a/libvideoeditor/lvpp/DummyVideoSource.cpp
+++ b/libvideoeditor/lvpp/DummyVideoSource.cpp
@@ -16,6 +16,7 @@
 
 //#define LOG_NDEBUG 0
 #define LOG_TAG "DummyVideoSource"
+#include <inttypes.h>
 #include <stdlib.h>
 #include <utils/Log.h>
 #include <media/stagefright/foundation/ADebug.h>
@@ -146,7 +147,7 @@
     if (mIsFirstImageFrame) {
         M4OSA_clockGetTime(&mImagePlayStartTime, kTimeScale);
         mFrameTimeUs =  (mImageSeekTime + 1);
-        ALOGV("read: jpg 1st frame timeUs = %lld, begin cut time = %ld",
+        ALOGV("read: jpg 1st frame timeUs = %lld, begin cut time = %" PRIu32,
             mFrameTimeUs, mImageSeekTime);
 
         mIsFirstImageFrame = false;
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index cb4b23e..91dc590 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
+
 #define LOG_NDEBUG 1
 #define LOG_TAG "VideoEditorAudioPlayer"
 #include <utils/Log.h>
@@ -372,7 +374,7 @@
 
         // Get the duration in time of the audio BT
         if ( result == M4NO_ERROR ) {
-         ALOGV("VEAP: channels = %d freq = %d",
+         ALOGV("VEAP: channels = %" PRIu32 " freq = %" PRIu32,
          mAudioMixSettings->uiNbChannels,  mAudioMixSettings->uiSamplingFrequency);
 
             // No trim
@@ -440,7 +442,7 @@
                 // do nothing
             }
 
-            ALOGV("VideoEditorAudioPlayer::startTime %d", startTime);
+            ALOGV("VideoEditorAudioPlayer::startTime %" PRIu32, startTime);
             seekTimeStamp = 0;
             if (startTime) {
                 if (startTime >= mBGAudioPCMFileDuration) {
diff --git a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
index e24fcf4..0c12aac 100755
--- a/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
+++ b/libvideoeditor/lvpp/VideoEditorBGAudioProcessing.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
+
 //#define LOG_NDEBUG 0
 #define LOG_TAG "VideoEditorBGAudioProcessing"
 #include <utils/Log.h>
@@ -50,8 +52,8 @@
         void *backgroundTrackBuffer,
         void *outBuffer) {
 
-    ALOGV("mixAndDuck: track buffers (primary: 0x%x and background: 0x%x) "
-            "and out buffer 0x%x",
+    ALOGV("mixAndDuck: track buffers (primary: %p and background: %p) "
+            "and out buffer %p",
             primaryTrackBuffer, backgroundTrackBuffer, outBuffer);
 
     M4AM_Buffer16* pPrimaryTrack   = (M4AM_Buffer16*)primaryTrackBuffer;
@@ -217,7 +219,7 @@
     mDoDucking            = 0;
     mDuckingFactor        = 1.0;
 
-    ALOGV("ducking enable 0x%x lowVolume %f threshold %d "
+    ALOGV("ducking enable 0x%x lowVolume %f threshold %" PRIu32 " "
             "fPTVolLevel %f BTVolLevel %f",
             mDucking_enable, mDucking_lowVolume, mDucking_threshold,
             mPTVolLevel, mPTVolLevel);
diff --git a/libvideoeditor/osal/inc/M4OSA_Types.h b/libvideoeditor/osal/inc/M4OSA_Types.h
index 92a68d8..ee258a0 100755
--- a/libvideoeditor/osal/inc/M4OSA_Types.h
+++ b/libvideoeditor/osal/inc/M4OSA_Types.h
@@ -36,13 +36,13 @@
 #endif
 
 
-typedef signed char     M4OSA_Bool;
-typedef unsigned char   M4OSA_UInt8;
-typedef signed char     M4OSA_Int8;
-typedef unsigned short  M4OSA_UInt16;
-typedef signed short    M4OSA_Int16;
-typedef unsigned long   M4OSA_UInt32;
-typedef signed long     M4OSA_Int32;
+typedef int8_t     M4OSA_Bool;
+typedef uint8_t    M4OSA_UInt8;
+typedef int8_t     M4OSA_Int8;
+typedef uint16_t   M4OSA_UInt16;
+typedef int16_t    M4OSA_Int16;
+typedef uint32_t   M4OSA_UInt32;
+typedef int32_t    M4OSA_Int32;
 
 typedef signed char     M4OSA_Char;
 typedef unsigned char   M4OSA_UChar;
diff --git a/libvideoeditor/osal/src/M4OSA_Thread.c b/libvideoeditor/osal/src/M4OSA_Thread.c
index db54245..3e82fb3 100755
--- a/libvideoeditor/osal/src/M4OSA_Thread.c
+++ b/libvideoeditor/osal/src/M4OSA_Thread.c
@@ -524,7 +524,7 @@
    M4OSA_TRACE2_2("M4OSA_SetThreadSyncPriority\t\tM4OSA_Context 0x%x\t"
                   "M4OSA_DataOption 0x%x", context, optionValue);
 
-   if((M4OSA_UInt32)optionValue>M4OSA_kThreadLowestPriority)
+   if((M4OSA_UInt32)(uintptr_t)optionValue>M4OSA_kThreadLowestPriority)
    {
       return M4ERR_PARAMETER;
    }
@@ -590,7 +590,7 @@
    M4OSA_TRACE2_2("M4OSA_SetThreadSyncStackSize\t\tM4OSA_Context 0x%x\t"
                   "M4OSA_DataOption 0x%x", context, optionValue);
 
-   threadContext->stackSize = (M4OSA_UInt32)optionValue;
+   threadContext->stackSize = (M4OSA_UInt32)(uintptr_t)optionValue;
 
    return M4NO_ERROR;
 }
diff --git a/libvideoeditor/osal/src/M4PSW_DebugTrace.c b/libvideoeditor/osal/src/M4PSW_DebugTrace.c
index 0fcba94..850ed91 100755
--- a/libvideoeditor/osal/src/M4PSW_DebugTrace.c
+++ b/libvideoeditor/osal/src/M4PSW_DebugTrace.c
@@ -25,6 +25,7 @@
 */
 
 
+#include <inttypes.h>
 #include <stdio.h> /*for printf */
 
 #include "M4OSA_Types.h"
@@ -65,9 +66,9 @@
     }
 
 #ifdef NO_FILE
-    printf("Error: %li, on %s: %s\n",err,cond,msg);
+    printf("Error: %" PRIu32 ", on %s: %s\n",err,cond,msg);
 #else /* NO_FILE     */
-    printf("Error: %li, on %s: %s Line %lu in: %s\n",err,cond,msg,line,file);
+    printf("Error: %" PRIu32 ", on %s: %s Line %" PRIu32 " in: %s\n",err,cond,msg,line,file);
 #endif /* NO_FILE     */
 
 }
diff --git a/libvideoeditor/vss/src/M4PCMR_CoreReader.c b/libvideoeditor/vss/src/M4PCMR_CoreReader.c
index 3343254..19f07dd 100755
--- a/libvideoeditor/vss/src/M4PCMR_CoreReader.c
+++ b/libvideoeditor/vss/src/M4PCMR_CoreReader.c
@@ -690,7 +690,7 @@
     switch(optionID)
     {
         case M4PCMR_kPCMblockSize:
-            c->m_blockSize = (M4OSA_UInt32)Value;
+            c->m_blockSize = (M4OSA_UInt32)(uintptr_t)Value;
             break;
 
         default:
diff --git a/libvideoeditor/vss/src/M4READER_Amr.c b/libvideoeditor/vss/src/M4READER_Amr.c
index 0859157..71f0e28 100755
--- a/libvideoeditor/vss/src/M4READER_Amr.c
+++ b/libvideoeditor/vss/src/M4READER_Amr.c
@@ -303,7 +303,7 @@
     pStreamHandler->m_decoderSpecificInfoSize = streamDesc.decoderSpecificInfoSize;
     pStreamHandler->m_streamId                = streamDesc.streamID;
     pStreamHandler->m_duration                = streamDesc.duration;
-    pStreamHandler->m_pUserData               = (void*)streamDesc.timeScale; /*trick to change*/
+    pStreamHandler->m_pUserData               = (void*)(intptr_t)streamDesc.timeScale; /*trick to change*/
 
     if (streamDesc.duration > pC->m_maxDuration)
     {
@@ -704,7 +704,7 @@
 
     if (err == M4NO_ERROR)
     {
-        timeScale = (M4OSA_Float)(M4OSA_Int32)(pStreamHandler->m_pUserData)/1000;
+        timeScale = (M4OSA_Float)(M4OSA_Int32)(intptr_t)(pStreamHandler->m_pUserData)/1000;
         pAccessUnit->m_dataAddress = (M4OSA_MemAddr8)pAu->dataAddress;
         pAccessUnit->m_size = pAu->size;
         pAccessUnit->m_CTS  = (M4_MediaTime)pAu->CTS/*/timeScale*/;
diff --git a/libvideoeditor/vss/src/M4READER_Pcm.c b/libvideoeditor/vss/src/M4READER_Pcm.c
index 833930b..392367f 100755
--- a/libvideoeditor/vss/src/M4READER_Pcm.c
+++ b/libvideoeditor/vss/src/M4READER_Pcm.c
@@ -386,7 +386,7 @@
     pC->m_pAudioStream->m_decoderSpecificInfoSize = streamDesc.decoderSpecificInfoSize;
     pC->m_pAudioStream->m_streamId                = streamDesc.streamID;
     pC->m_pAudioStream->m_pUserData               =
-        (void*)streamDesc.timeScale; /*trick to change*/
+        (void*)(intptr_t)streamDesc.timeScale; /*trick to change*/
     pC->m_pAudioStream->m_averageBitRate          = streamDesc.averageBitrate;
     pC->m_pAudioStream->m_maxAUSize               =
          pAudioStreamHandler->m_byteFrameLength*pAudioStreamHandler->m_byteSampleSize\
diff --git a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
index cc67e72..fb83952 100755
--- a/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
+++ b/libvideoeditor/vss/src/M4VD_EXTERNAL_BitstreamParser.c
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <inttypes.h>
+
 #include "utils/Log.h"
 #include "M4OSA_Types.h"
 #include "M4OSA_Debug.h"
@@ -505,7 +507,7 @@
     }
 
     constraintSet3 = (pDSI[index+2] & 0x10);
-    ALOGV("getAVCProfileAndLevel profile_byte %d, level_byte: %d constrain3flag",
+    ALOGV("getAVCProfileAndLevel profile_byte %d, level_byte: %d constrain3flag: %d",
           pDSI[index+1], pDSI[index+3], constraintSet3);
 
     switch (pDSI[index+1]) {
@@ -586,7 +588,8 @@
         default:
             *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
     }
-    ALOGV("getAVCProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    ALOGV("getAVCProfileAndLevel profile %" PRId32 " level %" PRId32,
+          *pProfile, *pLevel);
     return M4NO_ERROR;
 }
 
@@ -606,7 +609,7 @@
         *pLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
         return M4ERR_PARAMETER;
     }
-    ALOGV("getH263ProfileAndLevel profile_byte %d, level_byte",
+    ALOGV("getH263ProfileAndLevel profile_byte %d, level_byte %d",
           pDSI[6], pDSI[5]);
     /* get the H263 level */
     switch (pDSI[5]) {
@@ -670,7 +673,8 @@
         default:
            *pProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
     }
-    ALOGV("getH263ProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    ALOGV("getH263ProfileAndLevel profile %" PRId32 " level %" PRId32,
+          *pProfile, *pLevel);
     return M4NO_ERROR;
 }
 
@@ -693,6 +697,7 @@
             break;
         }
     }
-    ALOGV("getMPEG4ProfileAndLevel profile %ld level %ld", *pProfile, *pLevel);
+    ALOGV("getMPEG4ProfileAndLevel profile %" PRId32 " level %" PRId32,
+          *pProfile, *pLevel);
     return M4NO_ERROR;
 }
diff --git a/libvideoeditor/vss/src/M4xVSS_internal.c b/libvideoeditor/vss/src/M4xVSS_internal.c
index 64a6f40..84959ec 100755
--- a/libvideoeditor/vss/src/M4xVSS_internal.c
+++ b/libvideoeditor/vss/src/M4xVSS_internal.c
@@ -4156,12 +4156,12 @@
 
     M4VIFI_ImagePlane boxPlane[3];
 
-    if(M4xVSS_kVideoEffectType_ZoomOut == (M4OSA_UInt32)pFunctionContext)
+    if((M4OSA_Void *)M4xVSS_kVideoEffectType_ZoomOut == pFunctionContext)
     {
         //ratio = 16 - (15 * pProgress->uiProgress)/1000;
         ratio = 16 - pProgress->uiProgress / 66 ;
     }
-    else if(M4xVSS_kVideoEffectType_ZoomIn == (M4OSA_UInt32)pFunctionContext)
+    else if((M4OSA_Void *)M4xVSS_kVideoEffectType_ZoomIn == pFunctionContext)
     {
         //ratio = 1 + (15 * pProgress->uiProgress)/1000;
         ratio = 1 + pProgress->uiProgress / 66 ;
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c b/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
index f4cfa7c..5a7b28e 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorBuffer.c
@@ -22,6 +22,8 @@
 #undef M4OSA_TRACE_LEVEL
 #define M4OSA_TRACE_LEVEL 1
 
+#include <inttypes.h>
+
 #include "VideoEditorBuffer.h"
 #include "utils/Log.h"
 
@@ -55,7 +57,7 @@
     VIDEOEDITOR_BUFFER_Pool* pool;
     M4OSA_UInt32 index;
 
-    ALOGV("VIDEOEDITOR_BUFFER_allocatePool : ppool = 0x%x nbBuffers = %d ",
+    ALOGV("VIDEOEDITOR_BUFFER_allocatePool : ppool = %p nbBuffers = %" PRIu32,
         ppool, nbBuffers);
 
     pool = M4OSA_NULL;
@@ -131,7 +133,7 @@
     M4OSA_ERR err;
     M4OSA_UInt32  j = 0;
 
-    ALOGV("VIDEOEDITOR_BUFFER_freePool : ppool = 0x%x", ppool);
+    ALOGV("VIDEOEDITOR_BUFFER_freePool : ppool = %p", ppool);
 
     err = M4NO_ERROR;
 
@@ -200,7 +202,7 @@
     /* case where a buffer has been found */
     *pNXPBuffer = &(ppool->pNXPBuffer[ibuf]);
 
-    ALOGV("VIDEOEDITOR_BUFFER_getBuffer: idx = %d", ibuf);
+    ALOGV("VIDEOEDITOR_BUFFER_getBuffer: idx = %" PRIu32, ibuf);
 
     return(err);
 }
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
index 4787680..ca7db68 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoEncoder.cpp
@@ -857,7 +857,7 @@
         ALOGV("VideoEditorVideoEncoder_processOutputBuffer : buffer is empty");
         goto cleanUp;
     }
-    VIDEOEDITOR_CHECK(0 == ((M4OSA_UInt32)buffer->data())%4, M4ERR_PARAMETER);
+    VIDEOEDITOR_CHECK(0 == (((intptr_t)buffer->data())%4), M4ERR_PARAMETER);
     VIDEOEDITOR_CHECK(buffer->meta_data().get(), M4ERR_PARAMETER);
     if ( buffer->meta_data()->findInt32(kKeyIsCodecConfig, &i32Tmp) && i32Tmp ){
         {   // Display the DSI