From 325dd1ce32a59db6bd3f29c8b2003a6015c576c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 24 Jan 2014 14:02:43 +0200 Subject: [PATCH 1/3] Make a function typedef actually use the right type All functions that are assigned to function pointers with this typedef (WelsHadamardQuant2x2Skip_c and WelsHadamardQuant2x2Skip_mmx) use int32_t instead of BOOL_T for the return value. --- codec/encoder/core/inc/wels_func_ptr_def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec/encoder/core/inc/wels_func_ptr_def.h b/codec/encoder/core/inc/wels_func_ptr_def.h index 12cd0dcd..82249d02 100644 --- a/codec/encoder/core/inc/wels_func_ptr_def.h +++ b/codec/encoder/core/inc/wels_func_ptr_def.h @@ -64,7 +64,7 @@ typedef void (*PTransformHadamard4x4Func) (int16_t* pLumaDc, int16_t* pDct); typedef void (*PQuantizationFunc) (int16_t* pDct, const int16_t* pFF, const int16_t* pMF); typedef void (*PQuantizationMaxFunc) (int16_t* pDct, const int16_t* pFF, const int16_t* pMF, int16_t* pMax); typedef void (*PQuantizationDcFunc) (int16_t* pDct, int16_t iFF, int16_t iMF); -typedef BOOL_T (*PQuantizationSkipFunc) (int16_t* pDct, int16_t iFF, int16_t iMF); +typedef int32_t (*PQuantizationSkipFunc) (int16_t* pDct, int16_t iFF, int16_t iMF); typedef int32_t (*PQuantizationHadamardFunc) (int16_t* pRes, const int16_t kiFF, int16_t iMF, int16_t* pDct, int16_t* pBlock); From d1341554ddb40de6b7a9893d9532ea64eb6ff56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 24 Jan 2014 13:59:54 +0200 Subject: [PATCH 2/3] Remove an unnecessary cast when setting function pointers By removing the casts we make sure that the function signature actually matches and isn't silenced by the cast. --- codec/encoder/core/src/encoder.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codec/encoder/core/src/encoder.cpp b/codec/encoder/core/src/encoder.cpp index 17f642de..a7cff0db 100644 --- a/codec/encoder/core/src/encoder.cpp +++ b/codec/encoder/core/src/encoder.cpp @@ -150,11 +150,11 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki void WelsInitBGDFunc (SWelsFuncPtrList* pFuncList, const bool_t kbEnableBackgroundDetection) { if (kbEnableBackgroundDetection) { - pFuncList->pfInterMdBackgroundDecision = (PInterMdBackgroundDecisionFunc)WelsMdInterJudgeBGDPskip; - pFuncList->pfInterMdBackgroundInfoUpdate = (PInterMdBackgroundInfoUpdateFunc)WelsMdInterUpdateBGDInfo; + pFuncList->pfInterMdBackgroundDecision = WelsMdInterJudgeBGDPskip; + pFuncList->pfInterMdBackgroundInfoUpdate = WelsMdInterUpdateBGDInfo; } else { - pFuncList->pfInterMdBackgroundDecision = (PInterMdBackgroundDecisionFunc)WelsMdInterJudgeBGDPskipFalse; - pFuncList->pfInterMdBackgroundInfoUpdate = (PInterMdBackgroundInfoUpdateFunc)WelsMdInterUpdateBGDInfoNULL; + pFuncList->pfInterMdBackgroundDecision = WelsMdInterJudgeBGDPskipFalse; + pFuncList->pfInterMdBackgroundInfoUpdate = WelsMdInterUpdateBGDInfoNULL; } } From 44dfad22171967267a6c9f541068e88b68c780a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 24 Jan 2014 14:47:15 +0200 Subject: [PATCH 3/3] Make the function signatures actually match when used as function pointer Hiding the function signature mismatch with a cast can lead to more concrete breakage being missed. --- codec/encoder/core/inc/svc_base_layer_md.h | 2 +- codec/encoder/core/src/svc_base_layer_md.cpp | 2 +- codec/encoder/core/src/svc_encode_slice.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codec/encoder/core/inc/svc_base_layer_md.h b/codec/encoder/core/inc/svc_base_layer_md.h index 7115876c..8e24a657 100644 --- a/codec/encoder/core/inc/svc_base_layer_md.h +++ b/codec/encoder/core/inc/svc_base_layer_md.h @@ -69,7 +69,7 @@ int32_t WelsMdP8x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pWe void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache); BOOL_T WelsMdFirstIntraMode (void* pEnc, void* pMd, SMB* pCurMb, SMbCache* pMbCache); //BOOL_T svc_md_first_intra_mode_constrained(void* pEnc, void* pMd, SMB* pCurMb, SMbCache *pMbCache); -void WelsMdInterMb (void* pEncCtx, void* pWelsMd, SSlice* pSlice, SMB* pCurMb); +void WelsMdInterMb (void* pEncCtx, void* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pUnused); //both used in BL and EL //void wels_md_inter_init ( SWelsMD* pMd, const uint8_t ref_idx, const bool_t is_highest_dlayer_flag ); diff --git a/codec/encoder/core/src/svc_base_layer_md.cpp b/codec/encoder/core/src/svc_base_layer_md.cpp index 0a165aaf..e901cb14 100644 --- a/codec/encoder/core/src/svc_base_layer_md.cpp +++ b/codec/encoder/core/src/svc_base_layer_md.cpp @@ -1628,7 +1628,7 @@ BOOL_T WelsMdFirstIntraMode (void* pEnc, void* pMd, SMB* pCurMb, SMbCache* pMbCa return FALSE; } -void WelsMdInterMb (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb) { +void WelsMdInterMb (void* pEnc, void* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pUnused) { sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pEnc; SWelsMD* pWelsMd = (SWelsMD*)pMd; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; diff --git a/codec/encoder/core/src/svc_encode_slice.cpp b/codec/encoder/core/src/svc_encode_slice.cpp index 731fb32c..8cfc872d 100644 --- a/codec/encoder/core/src/svc_encode_slice.cpp +++ b/codec/encoder/core/src/svc_encode_slice.cpp @@ -647,10 +647,10 @@ void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //MD switch if (kbBaseAvail && kbHighestSpatial) { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = (PInterMdFunc)WelsMdInterMbEnhancelayer; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; } else { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = (PInterMdFunc)WelsMdInterMb; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; } WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial); } @@ -665,10 +665,10 @@ void WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //MD switch if (kbBaseAvail && kbHighestSpatial) { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = (PInterMdFunc)WelsMdInterMbEnhancelayer; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer; } else { //initial pMd pointer - pEncCtx->pFuncList->pfInterMd = (PInterMdFunc)WelsMdInterMb; + pEncCtx->pFuncList->pfInterMd = WelsMdInterMb; } WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial); }