Enable video encode 64bit

BZ: 178724

Enable video encode 64bit

Change-Id: Ia74c37fed4e6e84ebba294b91cce7c4c8ba95515
Signed-off-by: gji2 <guoliang.ji@intel.com>
diff --git a/test/BSClient.cpp b/test/BSClient.cpp
index 0c3cb77..334e371 100755
--- a/test/BSClient.cpp
+++ b/test/BSClient.cpp
@@ -95,7 +95,7 @@
                 return 1;
             }
 #else
-            mb1->SetValue((int32_t)Buffer1->pointer());
+            mb1->SetValue((intptr_t)Buffer1->pointer());
 #endif
             ret = mb1->SetValueInfo(&vi);
             ret = mb1->Serialize(bytes, size);
@@ -131,7 +131,7 @@
                 return 1;
             }
 #else
-            mb1->SetValue((int32_t)graphicBuffer->handle);
+            mb1->SetValue((intptr_t)graphicBuffer->handle);
 #endif
             ret = mb1->SetValueInfo(&vi);
             ret = mb1->Serialize(bytes, size);
@@ -165,7 +165,7 @@
         }
 
         IntelMetadataBuffer mb1;
-	    int32_t value;
+	intptr_t value;
         IMB_Result res;
         res = mb1.UnSerialize(bytes,size);
 	
diff --git a/test/btest.cpp b/test/btest.cpp
index 2806d36..a62664e 100644
--- a/test/btest.cpp
+++ b/test/btest.cpp
@@ -15,11 +15,11 @@
 
     IntelMetadataBufferType t1 = IntelMetadataBufferTypeCameraSource;
     IntelMetadataBufferType t2;
-    int32_t v1 = 0x00000010;
-    int32_t v2 = 0;
+    intptr_t v1 = 0x00000010;
+    intptr_t v2 = 0;
     ValueInfo vi1, *vi2 = NULL;
-    int32_t ev1[10];
-    int32_t *ev2 = NULL;
+    intptr_t ev1[10];
+    intptr_t *ev2 = NULL;
     unsigned int count;
 
     if (argc > 1)
diff --git a/test/mix_encoder.cpp b/test/mix_encoder.cpp
index 75a3f5a..be38a27 100644
--- a/test/mix_encoder.cpp
+++ b/test/mix_encoder.cpp
@@ -76,7 +76,7 @@
 static sp<IGraphicBufferAlloc> gGraphicBufferAlloc;
 static sp<GraphicBuffer> gGraphicBuffer[gSrcFrames];
 
-static int ev1[10];
+static intptr_t ev1[10];
 
 struct VideoConfigTypeIDRReq: VideoParamConfigSet {
 
@@ -370,7 +370,7 @@
     {
         gUsrptr[i] = (uint8_t*)malloc(size);
 
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (int32_t)gUsrptr[i]);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (intptr_t)gUsrptr[i]);
 
         gIMB[i]->SetValueInfo(vinfo);
     }
@@ -397,9 +397,9 @@
     for(int i = 0; i < gSrcFrames; i ++)
     {
         gMallocPtr[i] = (uint8_t*)malloc(size + 4095);
-        gUsrptr[i] = (uint8_t*)((((uint32_t )gMallocPtr[i] + 4095) / 4096 ) * 4096);
+        gUsrptr[i] = (uint8_t*)((((intptr_t )gMallocPtr[i] + 4095) / 4096 ) * 4096);
 
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (int32_t)gUsrptr[i]);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (intptr_t)gUsrptr[i]);
 
         gIMB[i]->SetValueInfo(vinfo);
     }
@@ -431,7 +431,7 @@
         gUsrptr[i] = paramsUsrptrBuffer.usrPtr;
         gSrcStride = paramsUsrptrBuffer.stride;
 
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeEncoder, (int32_t)gUsrptr[i]);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeEncoder, (intptr_t)gUsrptr[i]);
     }
 
 }
@@ -577,7 +577,7 @@
     {
         gUsrptr[i] = (uint8_t*)malloc(size);
 
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (int32_t)gUsrptr[i]);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (intptr_t)gUsrptr[i]);
 
         gIMB[i]->SetValueInfo(vinfo);
     }
@@ -603,7 +603,7 @@
 
         gGraphicBuffer[i] = graphicBuffer;
         graphicBuffer->lock(usage | GraphicBuffer::USAGE_SW_WRITE_OFTEN, (void**)(&gUsrptr[i]));
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (int32_t)gGraphicBuffer[i]->handle);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (intptr_t)gGraphicBuffer[i]->handle);
         graphicBuffer->unlock();
 
         IMG_native_handle_t* h = (IMG_native_handle_t*) gGraphicBuffer[i]->handle;
@@ -627,7 +627,7 @@
     {
         gfx_alloc(gSrcWidth, gSrcHeight, format, usage, &handle, (int32_t*)&gSrcStride);
         gfx_lock(handle, usage | GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, gSrcWidth, gSrcHeight, (void**)(&gUsrptr[i]));
-        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (int32_t)handle);
+        gIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (intptr_t)handle);
         gfx_unlock(handle);
         IMG_native_handle_t* h = (IMG_native_handle_t*) handle;
         gSrcHeight = h->iHeight;
@@ -958,7 +958,7 @@
             {
                 if (gIMB[i] != NULL)
                 {
-                    gIMB[i]->GetValue((int32_t&)handle);
+                    gIMB[i]->GetValue((intptr_t&)handle);
                     gfx_free(handle);
                 }
             }
diff --git a/test/mix_encoder2.cpp b/test/mix_encoder2.cpp
index 002fc20..f4e407c 100755
--- a/test/mix_encoder2.cpp
+++ b/test/mix_encoder2.cpp
@@ -294,7 +294,7 @@
         if (mMetadata)
             memcpy ((*buffer)->data(), data, size);
         else {
-            offset = ((int)((*buffer)->data() + 0x0FFF) & ~0x0FFF) - (int)(*buffer)->data();
+            offset = ((intptr_t)((*buffer)->data() + 0x0FFF) & ~0x0FFF) - (intptr_t)(*buffer)->data();
             memcpy ((*buffer)->data() + offset, data, size);
         }
         (*buffer)->set_range(offset, size);
@@ -396,8 +396,8 @@
             mMallocPtr[i] = (uint8_t*) malloc(size + 4095);
 
             //keep address 4K aligned
-            mUsrptr[i] = (uint8_t*)((((uint32_t )mMallocPtr[i] + 4095) / 4096 ) * 4096);
-            mIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (int32_t) mUsrptr[i]);
+            mUsrptr[i] = (uint8_t*)((((intptr_t)mMallocPtr[i] + 4095) / 4096 ) * 4096);
+            mIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeCameraSource, (intptr_t) mUsrptr[i]);
             mIMB[i]->SetValueInfo(&vinfo);
 //            LOG("Malloc address=%x\n", mUsrptr[i]);
         }
@@ -447,7 +447,7 @@
         {
             mBuffers[i] = new MemoryBase(mHeap, i * size, size);
 
-            mUsrptr[i] = (uint8_t*) ((int) (mBuffers[i]->pointer() + 0x0FFF) & ~0x0FFF);
+            mUsrptr[i] = (uint8_t*) ((intptr_t) (mBuffers[i]->pointer() + 0x0FFF) & ~0x0FFF);
 
             mIMB[i] = new IntelMetadataBuffer();
             mIMB[i]->SetType(IntelMetadataBufferTypeCameraSource);
@@ -455,10 +455,10 @@
             mIMB[i]->SetSessionFlag(mSessionFlag);
             mIMB[i]->ShareValue(mBuffers[i]);
 #else
-            mIMB[i]->SetValue((int32_t)mUsrptr[i]);
+            mIMB[i]->SetValue((intptr_t)mUsrptr[i]);
 #endif
             mIMB[i]->SetValueInfo(&vinfo);
-            LOG("MemHeap local address=%x\n", mUsrptr[i]);
+            LOG("MemHeap local address=%p\n", mUsrptr[i]);
         }
 
         return OK;
@@ -575,7 +575,7 @@
         ValueInfo vinfo;
         memset(&vinfo, 0, sizeof(ValueInfo));
         vinfo.mode = MEM_MODE_SURFACE;
-        vinfo.handle = (uint32_t) mVADisplay;
+        vinfo.handle = (intptr_t) mVADisplay;
         vinfo.size = 0;
         vinfo.width = mWidth;
         vinfo.height = mHeight;
@@ -679,7 +679,7 @@
             mIMB[i]->SetSessionFlag(mSessionFlag);
             mIMB[i]->ShareValue(mGraphicBuffer[i]);
 #else
-            mIMB[i]->SetValue((int32_t)mGraphicBuffer[i]->handle);
+            mIMB[i]->SetValue((intptr_t)mGraphicBuffer[i]->handle);
 #endif
             mIMB[i]->SetValueInfo(&vinfo);
 
@@ -734,7 +734,7 @@
             if (gfx_alloc(mWidth, mHeight, mColorFormat, usage, &mHandle[i], (int32_t*)&mStride) != 0)
                 return UNKNOWN_ERROR;
 
-            mIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (int32_t)mHandle[i]);
+            mIMB[i] = new IntelMetadataBuffer(IntelMetadataBufferTypeGrallocSource, (intptr_t)mHandle[i]);
             IMG_native_handle_t* h = (IMG_native_handle_t*) mHandle[i];
 //            mWidth = h->iWidth;
             mHeight = h->iHeight;
diff --git a/videoencoder/IntelMetadataBuffer.cpp b/videoencoder/IntelMetadataBuffer.cpp
index 4d58904..e275637 100644
--- a/videoencoder/IntelMetadataBuffer.cpp
+++ b/videoencoder/IntelMetadataBuffer.cpp
@@ -42,8 +42,8 @@
 
 struct ShareMemMap {
     uint32_t sessionflag;
-    int32_t value;
-    int32_t value_backup;
+    intptr_t value;
+    intptr_t value_backup;
     uint32_t type;
     sp<MemoryBase> membase;
     sp<GraphicBuffer> gbuffer;
@@ -67,7 +67,7 @@
 #define REMOTE_PROVIDER 0x80000000
 #define REMOTE_CONSUMER 0x40000000
 
-static ShareMemMap* ReadMemObjFromBinder(const Parcel& data, uint32_t sessionflag, uint32_t value) {
+static ShareMemMap* ReadMemObjFromBinder(const Parcel& data, uint32_t sessionflag, intptr_t value) {
 
     uint32_t type = data.readInt32();
     if (type >= ST_MAX)
@@ -96,12 +96,12 @@
             return NULL;
         }
 
-        map->value = (int32_t) ((int) ( mem->pointer() + 0x0FFF) & ~0x0FFF);
+        map->value = (intptr_t)( mem->pointer() + 0x0FFF) & ~0x0FFF;
         map->membase = mem;
 
 #ifdef TEST
         ALOGI("membase heapID:%d, pointer:%x data:%x, aligned value:%x", \
-           heap->getHeapID(), mem->pointer(), *((int *)(mem->pointer())), map->value);
+           heap->getHeapID(), mem->pointer(), *((intptr_t *)(mem->pointer())), map->value);
 #endif
 
     }
@@ -115,14 +115,14 @@
         }
         data.read(*buffer);
 
-        map->value = (uint32_t)buffer->handle;
+        map->value = (intptr_t)buffer->handle;
         map->gbuffer = buffer;
 
 #ifdef TEST
         void* usrptr[3];
         buffer->lock(GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_SW_READ_OFTEN, &usrptr[0]);
         buffer->unlock();
-        ALOGI("gfx handle:%x data:%x", (int32_t)buffer->handle, *((int *)usrptr[0]));
+        ALOGI("gfx handle:%p data:%x", (intptr_t)buffer->handle, *((intptr_t *)usrptr[0]));
 #endif
     }
 
@@ -182,7 +182,7 @@
     gShareMemMapListLock.unlock();
 }
 
-static ShareMemMap* FindShareMem(uint32_t sessionflag, int32_t value, bool isBackup)
+static ShareMemMap* FindShareMem(uint32_t sessionflag, intptr_t value, bool isBackup)
 {
     List<ShareMemMap *>::iterator node;
 
@@ -208,7 +208,7 @@
     return NULL;
 }
 
-static ShareMemMap* PopShareMem(uint32_t sessionflag, int32_t value)
+static ShareMemMap* PopShareMem(uint32_t sessionflag, intptr_t value)
 {
     List<ShareMemMap *>::iterator node;
 
@@ -261,6 +261,7 @@
 
 status_t IntelBufferSharingService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
 
+    //TODO: if pid is int32?
     pid_t pid = data.readInt32();
     uint32_t sessionflag = data.readInt32();
 
@@ -275,7 +276,7 @@
                 return UNKNOWN_ERROR;
             }
 
-            int32_t value = data.readInt32();
+            intptr_t value = data.readIntPtr();
 
 //            LOGI("onTransact SHARE_MEM value=%x", value);
 
@@ -284,7 +285,7 @@
             if (map == NULL)
                 return UNKNOWN_ERROR;
 
-            reply->writeInt32(map->value);
+            reply->writeIntPtr(map->value);
 
             return NO_ERROR;
         }
@@ -311,7 +312,7 @@
                 return UNKNOWN_ERROR;
             }
 
-            int32_t value = data.readInt32();
+            intptr_t value = data.readIntPtr();
 
 //            LOGI("onTransact GET_MEM value=%x", value);
 
@@ -345,7 +346,7 @@
 #endif
 }
 
-IntelMetadataBuffer::IntelMetadataBuffer(IntelMetadataBufferType type, int32_t value)
+IntelMetadataBuffer::IntelMetadataBuffer(IntelMetadataBufferType type, intptr_t value)
 {
     mType = type;
     mValue = value;
@@ -384,8 +385,8 @@
 
     if (imb.mExtraValues)
     {
-        mExtraValues = new int32_t[mExtraValues_Count];
-        memcpy(mExtraValues, imb.mExtraValues, 4 * mExtraValues_Count);
+        mExtraValues = new intptr_t[mExtraValues_Count];
+        memcpy(mExtraValues, imb.mExtraValues, sizeof(mValue) * mExtraValues_Count);
     }
 
     if (imb.mBytes)
@@ -413,8 +414,8 @@
 
     if (imb.mExtraValues)
     {
-        mExtraValues = new int32_t[mExtraValues_Count];
-        memcpy(mExtraValues, imb.mExtraValues, 4 * mExtraValues_Count);
+        mExtraValues = new intptr_t[mExtraValues_Count];
+        memcpy(mExtraValues, imb.mExtraValues, sizeof(mValue) * mExtraValues_Count);
     }
 
     if (imb.mBytes)
@@ -443,7 +444,7 @@
     return IMB_SUCCESS;
 }
 
-IMB_Result IntelMetadataBuffer::GetValue(int32_t& value)
+IMB_Result IntelMetadataBuffer::GetValue(intptr_t& value)
 {
     value = mValue;
 
@@ -471,9 +472,10 @@
 
     //send pid, sessionflag, and memtype
     pid_t pid = getpid();
+    //TODO: if pid is int32?
     data.writeInt32(pid);
     data.writeInt32(mSessionFlag);
-    data.writeInt32(mValue);
+    data.writeIntPtr(mValue);
 
     //do transcation
     if (binder->transact(GET_MEM, data, &reply) != NO_ERROR)
@@ -490,7 +492,7 @@
 #endif
 }
 
-IMB_Result IntelMetadataBuffer::SetValue(int32_t value)
+IMB_Result IntelMetadataBuffer::SetValue(intptr_t value)
 {
     mValue = value;
 
@@ -519,7 +521,7 @@
     return IMB_SUCCESS;
 }
 
-IMB_Result IntelMetadataBuffer::GetExtraValues(int32_t* &values, uint32_t& num)
+IMB_Result IntelMetadataBuffer::GetExtraValues(intptr_t* &values, uint32_t& num)
 {
     values = mExtraValues;
     num = mExtraValues_Count;
@@ -527,7 +529,7 @@
     return IMB_SUCCESS;
 }
 
-IMB_Result IntelMetadataBuffer::SetExtraValues(int32_t* values, uint32_t num)
+IMB_Result IntelMetadataBuffer::SetExtraValues(intptr_t* values, uint32_t num)
 {
     if (values && num > 0)
     {
@@ -538,9 +540,9 @@
         }
 
         if (mExtraValues == NULL)
-            mExtraValues = new int32_t[num];
+            mExtraValues = new intptr_t[num];
 
-        memcpy(mExtraValues, values, sizeof(int32_t) * num);
+        memcpy(mExtraValues, values, sizeof(intptr_t) * num);
         mExtraValues_Count = num;
     }
     else
@@ -555,16 +557,16 @@
         return IMB_INVAL_PARAM;
 
     IntelMetadataBufferType type;
-    int32_t value;
-    uint32_t extrasize = size - 8;
+    intptr_t value;
+    uint32_t extrasize = size - sizeof(type) - sizeof(value);
     ValueInfo* info = NULL;
-    int32_t* ExtraValues = NULL;
+    intptr_t* ExtraValues = NULL;
     uint32_t ExtraValues_Count = 0;
 
-    memcpy(&type, data, 4);
-    data += 4;
-    memcpy(&value, data, 4);
-    data += 4;
+    memcpy(&type, data, sizeof(type));
+    data += sizeof(type);
+    memcpy(&value, data, sizeof(value));
+    data += sizeof(value);
 
     switch (type)
     {
@@ -577,9 +579,9 @@
 
             if (extrasize > sizeof(ValueInfo)) //has extravalues
             {
-                if ( (extrasize - sizeof(ValueInfo)) % 4 != 0 )
+                if ( (extrasize - sizeof(ValueInfo)) % sizeof(mValue) != 0 )
                     return IMB_INVAL_BUFFER;
-                ExtraValues_Count = (extrasize - sizeof(ValueInfo)) / 4;
+                ExtraValues_Count = (extrasize - sizeof(ValueInfo)) / sizeof(mValue);
             }
 
             if (extrasize > 0)
@@ -591,8 +593,8 @@
 
             if (ExtraValues_Count > 0)
             {
-                ExtraValues = new int32_t[ExtraValues_Count];
-                memcpy(ExtraValues, data, ExtraValues_Count * 4);
+                ExtraValues = new intptr_t[ExtraValues_Count];
+                memcpy(ExtraValues, data, ExtraValues_Count * sizeof(mValue));
             }
 
             break;
@@ -631,20 +633,20 @@
             return IMB_INVAL_PARAM;
 
         //assemble bytes according members
-        mSize = 8;
+        mSize = sizeof(mType) + sizeof(mValue);
         if (mInfo)
         {
             mSize += sizeof(ValueInfo);
             if (mExtraValues)
-                mSize += 4 * mExtraValues_Count;
+                mSize += sizeof(mValue) * mExtraValues_Count;
         }
 
         mBytes = new uint8_t[mSize];
         uint8_t *ptr = mBytes;
-        memcpy(ptr, &mType, 4);
-        ptr += 4;
-        memcpy(ptr, &mValue, 4);
-        ptr += 4;
+        memcpy(ptr, &mType, sizeof(mType));
+        ptr += sizeof(mType);
+        memcpy(ptr, &mValue, sizeof(mValue));
+        ptr += sizeof(mValue);
 
         if (mInfo)
         {
@@ -655,7 +657,7 @@
             ptr += sizeof(ValueInfo);
 
             if (mExtraValues)
-                memcpy(ptr, mExtraValues, mExtraValues_Count * 4);
+                memcpy(ptr, mExtraValues, mExtraValues_Count * sizeof(mValue));
         }
     }
 
@@ -687,7 +689,7 @@
 
 IMB_Result IntelMetadataBuffer::ShareValue(sp<MemoryBase> mem)
 {
-    mValue = (int32_t)((int) ( mem->pointer() + 0x0FFF) & ~0x0FFF);
+    mValue = (intptr_t)((intptr_t) ( mem->pointer() + 0x0FFF) & ~0x0FFF);
 
     if (mSessionFlag == 0) //no sharing
         return IMB_SUCCESS;
@@ -703,9 +705,10 @@
 
         //send pid, sessionflag, and value
         pid_t pid = getpid();
+        //TODO: if pid is int32?
         data.writeInt32(pid);
         data.writeInt32(mSessionFlag);
-        data.writeInt32(mValue);
+        data.writeIntPtr(mValue);
 
         //send type/obj (offset/size/MemHeap)
         ShareMemMap smem;
@@ -719,7 +722,7 @@
             return IMB_SERVICE_FAIL;
 
         //set new value gotten from peer
-        mValue = reply.readInt32();
+        mValue = reply.readIntPtr();
 //        LOGI("ShareValue(membase) Get reply from sevice, new value:%x\n", mValue);
     }
     else  //is local provider , direct access list
@@ -739,7 +742,7 @@
 
 IMB_Result IntelMetadataBuffer::ShareValue(sp<GraphicBuffer> gbuffer)
 {
-    mValue = (int32_t)gbuffer->handle;
+    mValue = (intptr_t)gbuffer->handle;
 
     if (mSessionFlag == 0) //no sharing
         return IMB_SUCCESS;
@@ -754,9 +757,10 @@
 
         //send pid, sessionflag, and memtype
         pid_t pid = getpid();
+        //TODO: if pid is int32 ?
         data.writeInt32(pid);
         data.writeInt32(mSessionFlag);
-        data.writeInt32(mValue);
+        data.writeIntPtr(mValue);
 
         //send value/graphicbuffer obj
         ShareMemMap smem;
@@ -770,7 +774,7 @@
             return IMB_SERVICE_FAIL;
 
         //set new value gotten from peer
-        mValue = reply.readInt32();
+        mValue = reply.readIntPtr();
 //        LOGI("ShareValue(gfx) Get reply from sevice, new value:%x\n", mValue);
     }
     else //is local provider, direct access list
@@ -810,6 +814,7 @@
 
         //send pid and sessionflag
         pid_t pid = getpid();
+        //TODO: if pid is int32?
         data.writeInt32(pid);
         data.writeInt32(sessionflag);
 
diff --git a/videoencoder/IntelMetadataBuffer.h b/videoencoder/IntelMetadataBuffer.h
index ba0c9ba..2fbc1fe 100644
--- a/videoencoder/IntelMetadataBuffer.h
+++ b/videoencoder/IntelMetadataBuffer.h
@@ -61,7 +61,7 @@
 
 typedef struct {
         MemMode mode; 			//memory type, vasurface/malloc/gfx/ion/v4l2/ci etc
-        uint32_t handle;		//handle
+        intptr_t handle;		//handle
         uint32_t size;      		//memory size
         uint32_t width;			//picture width
         uint32_t height;		//picture height
@@ -87,7 +87,7 @@
 class IntelMetadataBuffer {
 public:
     IntelMetadataBuffer();                                          //for generator
-    IntelMetadataBuffer(IntelMetadataBufferType type, int32_t value);    //for quick generator
+    IntelMetadataBuffer(IntelMetadataBufferType type, intptr_t value);    //for quick generator
     ~IntelMetadataBuffer();
 
     IntelMetadataBuffer(const IntelMetadataBuffer& imb);
@@ -95,12 +95,12 @@
 
     IMB_Result GetType(IntelMetadataBufferType &type);
     IMB_Result SetType(IntelMetadataBufferType type);
-    IMB_Result GetValue(int32_t &value);
-    IMB_Result SetValue(int32_t value);
+    IMB_Result GetValue(intptr_t &value);
+    IMB_Result SetValue(intptr_t value);
     IMB_Result GetValueInfo(ValueInfo* &info);
     IMB_Result SetValueInfo(ValueInfo *info);
-    IMB_Result GetExtraValues(int32_t* &values, uint32_t &num);
-    IMB_Result SetExtraValues(int32_t *values, uint32_t num);
+    IMB_Result GetExtraValues(intptr_t* &values, uint32_t &num);
+    IMB_Result SetExtraValues(intptr_t *values, uint32_t num);
 
     //New API for bytes input/ouput, UnSerialize=SetBytes, Serialize=GetBytes
     IMB_Result UnSerialize(uint8_t* data, uint32_t size);
@@ -111,10 +111,10 @@
 
 private:
     IntelMetadataBufferType mType;
-    int32_t mValue;
+    intptr_t mValue;
     ValueInfo* mInfo;
 
-    int32_t* mExtraValues;
+    intptr_t* mExtraValues;
     uint32_t mExtraValues_Count;
 
     uint8_t* mBytes;
diff --git a/videoencoder/VideoEncoderAVC.cpp b/videoencoder/VideoEncoderAVC.cpp
index 7b234b1..63205c6 100644
--- a/videoencoder/VideoEncoderAVC.cpp
+++ b/videoencoder/VideoEncoderAVC.cpp
@@ -386,7 +386,7 @@
     dataRemaining = bufSize - pos + 1;
 
     while ((dataRemaining > 0) && (zeroByteCount < 3)) {
-        if (((((uint32_t)dataPtr) & 0xF ) == 0) && (0 == zeroByteCount)
+        if (((((intptr_t)dataPtr) & 0xF ) == 0) && (0 == zeroByteCount)
                && (dataRemaining > 0xF)) {
 
             __asm__  (
diff --git a/videoencoder/VideoEncoderBase.cpp b/videoencoder/VideoEncoderBase.cpp
index 00fe25d..9ab50e4 100644
--- a/videoencoder/VideoEncoderBase.cpp
+++ b/videoencoder/VideoEncoderBase.cpp
@@ -1532,7 +1532,7 @@
 
     map->setVASurface(surface);  //special case, vasuface is set, so nothing do in doMapping
 //    map->setType(MetadataBufferTypeEncoder);
-    map->setValue((int32_t)*usrptr);
+    map->setValue((intptr_t)*usrptr);
     ValueInfo vinfo;
     memset(&vinfo, 0, sizeof(ValueInfo));
     vinfo.mode = (MemMode)MEM_MODE_USRPTR;
@@ -1576,7 +1576,7 @@
         ValueInfo vinfo;
         memset(&vinfo, 0, sizeof(ValueInfo));
         vinfo.mode = (MemMode)upStreamBuffer->bufferMode;
-        vinfo.handle = (uint32_t)upStreamBuffer->display;
+        vinfo.handle = (intptr_t)upStreamBuffer->display;
         vinfo.size = 0;
         if (upStreamBuffer->bufAttrib) {
             vinfo.width = upStreamBuffer->bufAttrib->realWidth;
@@ -1602,10 +1602,10 @@
 
     Encode_Status ret = ENCODE_SUCCESS;
     IntelMetadataBufferType type;
-    int32_t value;
+    intptr_t value;
     ValueInfo vinfo;
     ValueInfo *pvinfo = &vinfo;
-    int32_t *extravalues = NULL;
+    intptr_t *extravalues = NULL;
     unsigned int extravalues_count = 0;
 
     IntelMetadataBuffer imb;
@@ -1630,7 +1630,7 @@
         }
 
         type = IntelMetadataBufferTypeUser;
-        value = (int32_t)inBuffer->data;
+        value = (intptr_t)inBuffer->data;
     }
 
 #ifdef INTEL_VIDEO_XPROC_SHARING
diff --git a/videoencoder/VideoEncoderUtils.cpp b/videoencoder/VideoEncoderUtils.cpp
index 0612ce6..0ccbb3b 100644
--- a/videoencoder/VideoEncoderUtils.cpp
+++ b/videoencoder/VideoEncoderUtils.cpp
@@ -159,7 +159,7 @@
     return err;
 }
 
-Encode_Status GetGfxBufferInfo(int32_t handle, ValueInfo& vinfo){
+Encode_Status GetGfxBufferInfo(intptr_t handle, ValueInfo& vinfo){
 
     /* only support OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar
                                 HAL_PIXEL_FORMAT_NV12
@@ -204,7 +204,7 @@
 }
 
 #ifdef GFX_DUMP
-void DumpGfx(int32_t handle, char* filename) {
+void DumpGfx(intptr_t handle, char* filename) {
     ValueInfo vinfo;
     void* vaddr[3];
     FILE* fp;
@@ -306,8 +306,8 @@
                 if (gfx_alloc(width, height, HAL_PIXEL_FORMAT_NV12, usage, &mGfxHandle, &stride) != 0)
                     return ENCODE_DRIVER_FAIL;
 
-                LOG_I("Create an new gfx buffer handle 0x%08x for color convert, width=%d, height=%d, stride=%d\n",
-                           (unsigned int)mGfxHandle, width, height, stride);
+                LOG_I("Create an new gfx buffer handle 0x%p for color convert, width=%d, height=%d, stride=%d\n",
+                           mGfxHandle, width, height, stride);
             }
 
         #else
@@ -333,7 +333,7 @@
         #ifdef IMG_GFX
             if (mGfxHandle != NULL) {
                 //map new gfx handle to vasurface
-                ret = MappingGfxHandle((int32_t)mGfxHandle);
+                ret = MappingGfxHandle((intptr_t)mGfxHandle);
                 CHECK_ENCODE_STATUS_RETURN("MappingGfxHandle");
                 LOGI("map new allocated gfx handle to vaSurface\n");
             } else
@@ -368,7 +368,7 @@
         LOG_I("VASurface is already set before, nothing to do here\n");
         return ENCODE_SUCCESS;
     }
-    LOG_I("MappingToVASurface mode=%d, value=%x\n", mVinfo.mode, mValue);
+    LOG_I("MappingToVASurface mode=%d, value=%p\n", mVinfo.mode, (void*)mValue);
 
     const char *mode = NULL;
     switch (mVinfo.mode) {
@@ -399,12 +399,12 @@
     }
 
     LOG_I("%s: Format=%x, lumaStride=%d, width=%d, height=%d\n", mode, mVinfo.format, mVinfo.lumaStride, mVinfo.width, mVinfo.height);
-    LOG_I("vaSurface 0x%08x is created for value = 0x%08x", mVASurface, mValue);
+    LOG_I("vaSurface 0x%08x is created for value = 0x%p\n", mVASurface, (void*)mValue);
 
     return ret;
 }
 
-Encode_Status VASurfaceMap::MappingSurfaceID(int32_t value) {
+Encode_Status VASurfaceMap::MappingSurfaceID(intptr_t value) {
 
     VAStatus vaStatus = VA_STATUS_SUCCESS;
     VASurfaceID surface;
@@ -425,7 +425,7 @@
             &lumaOffset, &chromaUOffset, &chromaVOffset, &kBufHandle, NULL);
 
     CHECK_VA_STATUS_RETURN("vaLockSurface");
-    LOG_I("Surface incoming = 0x%08x\n", value);
+    LOG_I("Surface incoming = 0x%p\n", (void*)value);
     LOG_I("lumaStride = %d, chromaUStride = %d, chromaVStride=%d\n", lumaStride, chromaUStride, chromaVStride);
     LOG_I("lumaOffset = %d, chromaUOffset = %d, chromaVOffset = %d\n", lumaOffset, chromaUOffset, chromaVOffset);
     LOG_I("kBufHandle = 0x%08x, fourCC = %d\n", kBufHandle, fourCC);
@@ -446,9 +446,9 @@
     return ENCODE_SUCCESS;
 }
 
-Encode_Status VASurfaceMap::MappingGfxHandle(int32_t value) {
+Encode_Status VASurfaceMap::MappingGfxHandle(intptr_t value) {
 
-    LOG_I("MappingGfxHandle %x......\n", value);
+    LOG_I("MappingGfxHandle %p......\n", (void*)value);
     LOG_I("format = 0x%08x, lumaStride = %d in ValueInfo\n", mVinfo.format, mVinfo.lumaStride);
 
     //default value for all HW platforms, maybe not accurate
@@ -482,9 +482,9 @@
     return ENCODE_SUCCESS;
 }
 
-Encode_Status VASurfaceMap::MappingKbufHandle(int32_t value) {
+Encode_Status VASurfaceMap::MappingKbufHandle(intptr_t value) {
 
-    LOG_I("MappingKbufHandle value=%d\n", value);
+    LOG_I("MappingKbufHandle value=%p\n", (void*)value);
 
     mVinfo.size = mVinfo.lumaStride * mVinfo.height * 1.5;
     mVASurface = CreateSurfaceFromExternalBuf(value, mVinfo);
@@ -498,7 +498,7 @@
     return ENCODE_SUCCESS;
 }
 
-Encode_Status VASurfaceMap::MappingMallocPTR(int32_t value) {
+Encode_Status VASurfaceMap::MappingMallocPTR(intptr_t value) {
 
     mVASurface = CreateSurfaceFromExternalBuf(value, mVinfo);
     if (mVASurface == VA_INVALID_SURFACE)
@@ -518,7 +518,7 @@
 
     uint32_t width = 0, height = 0, stride = 0;
     uint8_t *pSrcBuffer, *pDestBuffer;
-    int32_t handle = 0;
+    intptr_t handle = 0;
 
     LOG_I("Copying Src Buffer data to VASurface\n");
 
@@ -553,7 +553,7 @@
         ValueInfo tmp;
 
         if (mGfxHandle)
-            handle = (int32_t) mGfxHandle;
+            handle = (intptr_t) mGfxHandle;
         else
             handle = mValue;
 
@@ -659,7 +659,7 @@
   #ifdef GFX_DUMP
     LOG_I("dumpping gfx data.....\n");
     DumpGfx(mValue, "/data/dump.rgb");
-    DumpGfx((int32_t)mGfxHandle, "/data/dump.yuv");
+    DumpGfx((intptr_t)mGfxHandle, "/data/dump.yuv");
   #endif
     return ENCODE_SUCCESS;
 
@@ -668,7 +668,7 @@
 #endif
 }
 
-VASurfaceID VASurfaceMap::CreateSurfaceFromExternalBuf(int32_t value, ValueInfo& vinfo) {
+VASurfaceID VASurfaceMap::CreateSurfaceFromExternalBuf(intptr_t value, ValueInfo& vinfo) {
 
     VAStatus vaStatus;
     VASurfaceAttribExternalBuffers extbuf;
diff --git a/videoencoder/VideoEncoderUtils.h b/videoencoder/VideoEncoderUtils.h
index 786a63b..f421022 100644
--- a/videoencoder/VideoEncoderUtils.h
+++ b/videoencoder/VideoEncoderUtils.h
@@ -20,11 +20,11 @@
 
     Encode_Status doMapping();
     VASurfaceID getVASurface() {return mVASurface;}
-    int32_t getValue() {return mValue;}
+    intptr_t getValue() {return mValue;}
     ValueInfo* getValueInfo() {return &mVinfo;}
 
     void setVASurface(VASurfaceID surface) {mVASurface = surface;}
-    void setValue(int32_t value) {mValue = value;}
+    void setValue(intptr_t value) {mValue = value;}
     void setValueInfo(ValueInfo& vinfo) {memcpy(&mVinfo, &vinfo, sizeof(ValueInfo));}
     void setTracked() {mTracked = true;}
     void setAction(int32_t action) {mAction = action;}
@@ -33,15 +33,15 @@
     Encode_Status doActionCopy();
     Encode_Status doActionColConv();
     Encode_Status MappingToVASurface();
-    Encode_Status MappingSurfaceID(int32_t value);
-    Encode_Status MappingGfxHandle(int32_t value);
-    Encode_Status MappingKbufHandle(int32_t value);
-    Encode_Status MappingMallocPTR(int32_t value);
-    VASurfaceID CreateSurfaceFromExternalBuf(int32_t value, ValueInfo& vinfo);
+    Encode_Status MappingSurfaceID(intptr_t value);
+    Encode_Status MappingGfxHandle(intptr_t value);
+    Encode_Status MappingKbufHandle(intptr_t value);
+    Encode_Status MappingMallocPTR(intptr_t value);
+    VASurfaceID CreateSurfaceFromExternalBuf(intptr_t value, ValueInfo& vinfo);
 
     VADisplay mVADisplay;
 
-    int32_t mValue;
+    intptr_t mValue;
 
     VASurfaceID mVASurface;
     int32_t mVASurfaceWidth;