m4v_h263_enc: Use uint32_t for ULong

ULong is used in the encoder code as 32-bit unsigned integer type.
But it has been defined as an unsigned long, which will be 64-bit
on 64-bit platforms. This causes many problems including output
mismatch between 32-bit and 64-bit code and crash in certain cases.

This patch defines ULong as uint32_t. In addition, it uses uintptr_t
at places where an address is cast to an integer to check for alignment.

Change-Id: I2b0086824a5985b9fc4628ce6fbe81db156e37d2
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
index da5b785..bf77f4a 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
@@ -721,7 +721,7 @@
             vin.uChan = vin.yChan + vin.height * vin.pitch;
             vin.vChan = vin.uChan + ((vin.height * vin.pitch) >> 2);
 
-            unsigned long modTimeMs = 0;
+            ULong modTimeMs = 0;
             int32_t nLayer = 0;
             MP4HintTrack hintTrack;
             if (!PVEncodeVideoFrame(mHandle, &vin, &vout,
diff --git a/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h b/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
index a54fd8b..9451479 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/include/mp4enc_api.h
@@ -29,7 +29,7 @@
 typedef unsigned short UShort;
 typedef short Short;
 typedef unsigned int Bool;
-typedef unsigned long ULong;
+typedef uint32_t ULong;
 
 #define PV_CODEC_INIT  0
 #define PV_CODEC_STOP  1
diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp b/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp
index 06e8926..9a967c2 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/src/motion_comp.cpp
@@ -363,7 +363,7 @@
     /* initialize offset to adjust pixel counter */
     /*    the next row; full-pel resolution      */
 
-    tmp = (ULong)prev & 0x3;
+    tmp = (uintptr_t)prev & 0x3;
 
     if (tmp == 0)  /* word-aligned */
     {
@@ -466,7 +466,7 @@
     /* Branch based on pixel location (half-pel or full-pel) for x and y */
     rec -= 12; /* preset */
 
-    tmp = (ULong)prev & 3;
+    tmp = (uintptr_t)prev & 3;
     mask = 254;
     mask |= (mask << 8);
     mask |= (mask << 16); /* 0xFEFEFEFE */
@@ -791,7 +791,7 @@
     /* Branch based on pixel location (half-pel or full-pel) for x and y */
     rec -= 12; /* preset */
 
-    tmp = (ULong)prev & 3;
+    tmp = (uintptr_t)prev & 3;
     mask = 254;
     mask |= (mask << 8);
     mask |= (mask << 16); /* 0xFEFEFEFE */
@@ -1140,7 +1140,7 @@
     mask |= (mask << 8);
     mask |= (mask << 16); /* 0x3f3f3f3f */
 
-    tmp = (ULong)prev & 3;
+    tmp = (uintptr_t)prev & 3;
 
     rec -= 4; /* preset */
 
diff --git a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
index 0d5a3e8..2d44482 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/src/mp4def.h
@@ -60,7 +60,7 @@
 typedef short Short;
 typedef short int SInt;
 typedef unsigned int Bool;
-typedef unsigned long   ULong;
+typedef uint32_t ULong;
 typedef void Void;
 
 #define PV_CODEC_INIT       0