summaryrefslogtreecommitdiff
path: root/omx
diff options
context:
space:
mode:
authorMasaki Sato <masaki.sato@motorola.com>2009-11-02 16:37:18 -0600
committerJames Dong <jdong@google.com>2009-11-10 10:18:50 -0800
commitd5cf09fb6e53cda5ce8796eb01230bfecdb917ff (patch)
tree3b236f5366d4aac16eceef75e5a19390e83bff64 /omx
parenta0a9d49a985501f2436bccd98853e69c51066321 (diff)
downloadomap3-d5cf09fb6e53cda5ce8796eb01230bfecdb917ff.tar.gz
Video decode memory leak fixes
bug 2100370 Originally from: https://partner.source.android.com/g/#change,1410 rebased...
Diffstat (limited to 'omx')
-rw-r--r--omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h3
-rw-r--r--omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c137
-rw-r--r--omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c107
3 files changed, 94 insertions, 153 deletions
diff --git a/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h b/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
index e507255..0f17067 100644
--- a/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
+++ b/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
@@ -21,6 +21,9 @@
#ifndef OMX_VIDDEC_UTILS__H
#define OMX_VIDDEC_UTILS__H
+#define newmalloc(x) malloc(x)
+#define newfree(z) free(z)
+
#ifdef ANDROID
/* Log for Android system*/
#include <utils/Log.h>
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
index 5e8d267..2efd5a8 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
@@ -2735,14 +2735,7 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
}
#endif
#endif
- if(pComponentPrivate->pUalgParams != NULL) {
- OMX_U8* pTemp = NULL;
- pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams);
- pTemp -= VIDDEC_PADDING_HALF;
- pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp;
- free(pComponentPrivate->pUalgParams);
- pComponentPrivate->pUalgParams = NULL;
- }
+ OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pUalgParams,OMX_PTR);
pComponentPrivate->bIsStopping = OMX_FALSE;
pComponentPrivate->eState = OMX_StateIdle;
@@ -2861,15 +2854,14 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
if (eError != OMX_ErrorNone) {
eError = OMX_ErrorHardware;
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus);
break;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (H264_Iualg_Cmd_SetStatus*)pTmp;
- free(pDynParams);
+
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -2949,6 +2941,7 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
eError,
0x0,
"LCML_ControlCodec function");
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams);
goto EXIT;
}
while(1) {
@@ -2960,10 +2953,7 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
}
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (MP2VDEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -3014,16 +3004,14 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
(void*)p);
if (eError != OMX_ErrorNone) {
eError = OMX_ErrorHardware;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams);
goto EXIT;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (SPARKVDEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -3625,16 +3613,8 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
- OMX_U8* pTemp = NULL;
pBuffHead = pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
- if(pBuffHead->pBuffer != NULL){
- pTemp = (OMX_U8*)(pBuffHead->pBuffer);
- pTemp -= VIDDEC_PADDING_HALF;
- pBuffHead->pBuffer = (OMX_U8*)pTemp;
- free(pBuffHead->pBuffer);
- pBuffHead->pBuffer = NULL;
- pTemp = NULL;
- }
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8);
}
}
}
@@ -3643,16 +3623,8 @@ OMX_ERRORTYPE VIDDEC_HandleCommand (OMX_HANDLETYPE phandle, OMX_U32 nParam1)
if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
- OMX_U8* pTemp = NULL;
pBuffHead = pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
- if(pBuffHead->pBuffer != NULL){
- pTemp = (OMX_U8*)(pBuffHead->pBuffer);
- pTemp -= VIDDEC_PADDING_HALF;
- pBuffHead->pBuffer = (OMX_U8*)pTemp;
- free(pBuffHead->pBuffer);
- pBuffHead->pBuffer = NULL;
- pTemp = NULL;
- }
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8);
}
}
}
@@ -4570,8 +4542,19 @@ OMX_ERRORTYPE VIDDEC_ParseVideo_H264(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate
nTotalInBytes = pBuffHead->nFilledLen;
nBitStream = (OMX_U8*)pBuffHead->pBuffer;/* + (OMX_U8*)pBuffHead->nOffset;*/
nRbspByte = (OMX_U8*)malloc(nTotalInBytes);
+ if ( nRbspByte == NULL )
+ {
+ eError = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
memset(nRbspByte, 0x0, nTotalInBytes);
sParserParam = (VIDDEC_AVC_ParserParam *)malloc(sizeof(VIDDEC_AVC_ParserParam));
+ if ( sParserParam == NULL )
+ {
+ eError = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
if (nType == 0) {
/* Start of Handle fragmentation of Config Buffer Code*/
@@ -4640,14 +4623,16 @@ OMX_ERRORTYPE VIDDEC_ParseVideo_H264(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate
/*Update filled length of current buffer */
pBuffHead->nFilledLen = pComponentPrivate->nInternalConfigBufferFilledAVC + pBuffHead->nFilledLen;
/*Free Internal Buffer used to temporarly hold the data*/
- free(pComponentPrivate->pInternalConfigBufferAVC);
+ if (pComponentPrivate->pInternalConfigBufferAVC != NULL)
+ free(pComponentPrivate->pInternalConfigBufferAVC);
/* Reset Internal Variables*/
pComponentPrivate->pInternalConfigBufferAVC = NULL;
pComponentPrivate->nInternalConfigBufferFilledAVC = 0;
nConfigBufferCounter = 0;
/* Update Buffer Variables before parsing */
nTotalInBytes = pBuffHead->nFilledLen;
- free(nRbspByte);
+ if ( nRbspByte != NULL )
+ free(nRbspByte);
nRbspByte = (OMX_U8*)malloc(nTotalInBytes);
if(nRbspByte == NULL){
eError = OMX_ErrorInsufficientResources;
@@ -4867,8 +4852,10 @@ OMX_ERRORTYPE VIDDEC_ParseVideo_H264(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate
eError = OMX_ErrorNone;
EXIT:
- free( nRbspByte);
- free( sParserParam);
+ if ( nRbspByte != NULL )
+ free( nRbspByte);
+ if ( sParserParam != NULL )
+ free( sParserParam);
return eError;
}
#endif
@@ -5836,14 +5823,7 @@ OMX_ERRORTYPE VIDDEC_HandleDataBuf_FromApp(VIDDEC_COMPONENT_PRIVATE *pComponentP
pComponentPrivate->iEndofInputSent = 1;
OMX_PRBUFFER1(pComponentPrivate->dbg, "Sending EOS Empty eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner);
if(pComponentPrivate->eFirstBuffer.bSaveFirstBuffer == OMX_FALSE){
- if(pComponentPrivate->pUalgParams != NULL){
- OMX_U8* pTemp = NULL;
- pTemp = (OMX_U8*)(pComponentPrivate->pUalgParams);
- pTemp -= VIDDEC_PADDING_HALF;
- pComponentPrivate->pUalgParams = (OMX_PTR*)pTemp;
- free(pComponentPrivate->pUalgParams);
- pComponentPrivate->pUalgParams = NULL;
- }
+ OMX_MEMFREE_STRUCT_DSPALIGN(pComponentPrivate->pUalgParams,OMX_PTR);
}
if (pComponentPrivate->pInPortDef->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) {
@@ -6968,7 +6948,8 @@ OMX_ERRORTYPE VIDDEC_InitDSP_WMVDec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
goto EXIT;
}
EXIT:
- free(pCreatePhaseArgs);
+ if ( pCreatePhaseArgs != NULL )
+ free(pCreatePhaseArgs);
pCreatePhaseArgs = NULL;
OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError);
@@ -7141,8 +7122,6 @@ OMX_ERRORTYPE VIDDEC_InitDSP_H264Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate
memcpy (pComponentPrivate->arr, pCreatePhaseArgs, sizeof(H264VDEC_SNCreatePhArg));
lcml_dsp->pCrPhArgs = pComponentPrivate->arr;
cb.LCML_Callback = (void *) VIDDEC_LCML_Callback;
- free(pCreatePhaseArgs);
- pCreatePhaseArgs = NULL;
if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload &&
pComponentPrivate->pLCML != NULL){
@@ -7158,6 +7137,10 @@ OMX_ERRORTYPE VIDDEC_InitDSP_H264Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate
goto EXIT;
}
EXIT:
+ if ( pCreatePhaseArgs != NULL )
+ free(pCreatePhaseArgs);
+ pCreatePhaseArgs = NULL;
+
OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError);
return eError;
}
@@ -7320,8 +7303,6 @@ OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg4Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(MP4VD_GPP_SN_Obj_CreatePhase));
lcml_dsp->pCrPhArgs = pComponentPrivate->arr;
cb.LCML_Callback = (void*) VIDDEC_LCML_Callback;
- free(pCreatePhaseArgs);
- pCreatePhaseArgs = NULL;
if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload &&
pComponentPrivate->pLCML != NULL){
@@ -7339,6 +7320,10 @@ OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg4Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
goto EXIT;
}
EXIT:
+ if ( pCreatePhaseArgs != NULL )
+ free(pCreatePhaseArgs);
+ pCreatePhaseArgs = NULL;
+
OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError);
return eError;
}
@@ -7499,8 +7484,6 @@ OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg2Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(MP2VDEC_SNCreatePhArg));
lcml_dsp->pCrPhArgs = pComponentPrivate->arr;
cb.LCML_Callback = (void*) VIDDEC_LCML_Callback;
- free(pCreatePhaseArgs);
- pCreatePhaseArgs = NULL;
if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload &&
pComponentPrivate->pLCML != NULL){
@@ -7516,6 +7499,10 @@ OMX_ERRORTYPE VIDDEC_InitDSP_Mpeg2Dec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
goto EXIT;
}
EXIT:
+ if ( pCreatePhaseArgs != NULL )
+ free(pCreatePhaseArgs);
+ pCreatePhaseArgs = NULL;
+
OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError);
return eError;
}
@@ -7686,8 +7673,6 @@ OMX_ERRORTYPE VIDDEC_InitDSP_SparkDec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
memcpy(pComponentPrivate->arr, pCreatePhaseArgs, sizeof(SPARKVD_GPP_SN_Obj_CreatePhase));
lcml_dsp->pCrPhArgs = pComponentPrivate->arr;
cb.LCML_Callback = (void*) VIDDEC_LCML_Callback;
- free(pCreatePhaseArgs);
- pCreatePhaseArgs = NULL;
if(pComponentPrivate->eLCMLState != VidDec_LCML_State_Unload &&
pComponentPrivate->pLCML != NULL){
@@ -7703,6 +7688,10 @@ OMX_ERRORTYPE VIDDEC_InitDSP_SparkDec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivat
goto EXIT;
}
EXIT:
+ if ( pCreatePhaseArgs != NULL )
+ free(pCreatePhaseArgs);
+ pCreatePhaseArgs = NULL;
+
OMX_PRDSP1(pComponentPrivate->dbg, "---EXITING(0x%x)\n",eError);
return eError;
}
@@ -8605,15 +8594,13 @@ OMX_ERRORTYPE VIDDEC_LoadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
if (eError != OMX_ErrorNone) {
eError = OMX_ErrorHardware;
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus);
goto EXIT;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (H264_Iualg_Cmd_SetStatus*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,H264_Iualg_Cmd_SetStatus);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -8692,6 +8679,7 @@ OMX_ERRORTYPE VIDDEC_LoadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
eError,
0x0,
"LCML_ControlCodec function");
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams);
goto EXIT;
}
while(1) {
@@ -8703,10 +8691,7 @@ OMX_ERRORTYPE VIDDEC_LoadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
}
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (MP2VDEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP2VDEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -8756,16 +8741,14 @@ OMX_ERRORTYPE VIDDEC_LoadCodec(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
(void*)p);
if (eError != OMX_ErrorNone) {
eError = OMX_ErrorHardware;
+ OMX_MEMFREE_STRUCT_DSPALIGN (pDynParams,SPARKVDEC_UALGDynamicParams);
goto EXIT;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (SPARKVDEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,SPARKVDEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -8958,6 +8941,7 @@ OMX_ERRORTYPE VIDDEC_Set_SN_StreamType(VIDDEC_COMPONENT_PRIVATE* pComponentPriva
OMX_TI_ErrorSevere,
"LCML_ControlCodec function");
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,WMV9DEC_UALGDynamicParams);
goto EXIT;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
@@ -8967,10 +8951,7 @@ OMX_ERRORTYPE VIDDEC_Set_SN_StreamType(VIDDEC_COMPONENT_PRIVATE* pComponentPriva
pComponentPrivate->bTransPause = OMX_FALSE;
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (WMV9DEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,WMV9DEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
@@ -9065,6 +9046,7 @@ OMX_ERRORTYPE VIDDEC_Set_Debocking(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
if (eError != OMX_ErrorNone) {
eError = OMX_ErrorHardware;
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP4VDEC_UALGDynamicParams);
goto EXIT;
}
VIDDEC_PTHREAD_MUTEX_WAIT(pComponentPrivate->sMutex);
@@ -9074,10 +9056,7 @@ OMX_ERRORTYPE VIDDEC_Set_Debocking(VIDDEC_COMPONENT_PRIVATE* pComponentPrivate)
pComponentPrivate->bTransPause = OMX_FALSE;
}
- pTmp = (char*)pDynParams;
- pTmp -= VIDDEC_PADDING_HALF;
- pDynParams = (MP4VDEC_UALGDynamicParams*)pTmp;
- free(pDynParams);
+ OMX_MEMFREE_STRUCT_DSPALIGN(pDynParams,MP4VDEC_UALGDynamicParams);
if (eError != OMX_ErrorNone) {
OMX_PRDSP4(pComponentPrivate->dbg, "Codec AlgCtrl 0x%x\n",eError);
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
index 22f4a4d..e03a5be 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
@@ -2479,38 +2479,37 @@ static OMX_ERRORTYPE VIDDEC_ComponentDeInit(OMX_HANDLETYPE hComponent)
OMX_ERROR4(pComponentPrivate->dbg, "Error returned from the Component\n");
}
+ if (pComponentPrivate->pInternalConfigBufferAVC != NULL)
+ free(pComponentPrivate->pInternalConfigBufferAVC);
+
for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) {
- if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
- if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
- OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
- OMX_U8* pTemp = NULL;
- pBuffHead = pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
- if(pBuffHead->pBuffer != NULL){
- pTemp = (OMX_U8*)(pBuffHead->pBuffer);
- pTemp -= VIDDEC_PADDING_HALF;
- pBuffHead->pBuffer = (OMX_U8*)pTemp;
- free(pBuffHead->pBuffer);
- pBuffHead->pBuffer = NULL;
- pTemp = NULL;
+ if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
+ OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
+ pBuffHead = pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
+ if(pBuffHead != NULL){
+ if(pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8);
}
+ free(pBuffHead);
+ pBuffHead = NULL;
+ pComponentPrivate->pCompPort[VIDDEC_INPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr = NULL;
}
}
}
+
for (iCount = 0; iCount < MAX_PRIVATE_BUFFERS; iCount++) {
- if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
- if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
- OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
- OMX_U8* pTemp = NULL;
- pBuffHead = pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
- if(pBuffHead->pBuffer != NULL){
- pTemp = (OMX_U8*)(pBuffHead->pBuffer);
- pTemp -= VIDDEC_PADDING_HALF;
- pBuffHead->pBuffer = (OMX_U8*)pTemp;
- free(pBuffHead->pBuffer);
- pBuffHead->pBuffer = NULL;
- pTemp = NULL;
+ if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr != NULL) {
+ OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
+ OMX_U8* pTemp = NULL;
+ pBuffHead = pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr;
+ if(pBuffHead != NULL){
+ if(pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->bAllocByComponent == OMX_TRUE){
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBuffHead->pBuffer,OMX_U8);
}
+ free(pBuffHead);
+ pBuffHead = NULL;
+ pComponentPrivate->pCompPort[VIDDEC_OUTPUT_PORT]->pBufferPrivate[iCount]->pBufferHdr = NULL;
}
}
}
@@ -2991,19 +2990,11 @@ static OMX_ERRORTYPE VIDDEC_FreeBuffer (OMX_IN OMX_HANDLETYPE hComponent,
if (pPortDefIn->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ||
pPortDefIn->format.video.eCompressionFormat == OMX_VIDEO_CodingH263) {
if (nPortIndex == pComponentPrivate->pInPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else if (nPortIndex == pComponentPrivate->pOutPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else {
@@ -3014,19 +3005,11 @@ static OMX_ERRORTYPE VIDDEC_FreeBuffer (OMX_IN OMX_HANDLETYPE hComponent,
#ifdef VIDDEC_SPARK_CODE
else if (VIDDEC_SPARKCHECK) {
if (nPortIndex == pComponentPrivate->pInPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else if (nPortIndex == pComponentPrivate->pOutPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else {
@@ -3037,19 +3020,11 @@ static OMX_ERRORTYPE VIDDEC_FreeBuffer (OMX_IN OMX_HANDLETYPE hComponent,
#endif
else if (pPortDefIn->format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG2) {
if (nPortIndex == pComponentPrivate->pInPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else if (nPortIndex == pComponentPrivate->pOutPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else {
@@ -3059,19 +3034,11 @@ static OMX_ERRORTYPE VIDDEC_FreeBuffer (OMX_IN OMX_HANDLETYPE hComponent,
}
else if (pPortDefIn->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC) {
if (nPortIndex == pComponentPrivate->pInPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else if (nPortIndex == pComponentPrivate->pOutPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else {
@@ -3081,19 +3048,11 @@ static OMX_ERRORTYPE VIDDEC_FreeBuffer (OMX_IN OMX_HANDLETYPE hComponent,
}
else if (pPortDefIn->format.video.eCompressionFormat == OMX_VIDEO_CodingWMV) {
if (nPortIndex == pComponentPrivate->pInPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else if (nPortIndex == pComponentPrivate->pOutPortFormat->nPortIndex) {
- pTemp = (OMX_U8*)(pBufferPrivate->pUalgParam);
- pTemp -= VIDDEC_PADDING_HALF;
- pBufferPrivate->pUalgParam = (OMX_PTR*)pTemp;
- free(pBufferPrivate->pUalgParam);
- pBufferPrivate->pUalgParam = NULL;
+ OMX_MEMFREE_STRUCT_DSPALIGN(pBufferPrivate->pUalgParam,OMX_PTR);
pBufferPrivate->nUalgParamSize = 0;
}
else {