Showing the changes to codec/decoder (11 of 12 files). Show all
Unified · Split
| @@ -144,7 +144,7 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx); · 143 unmodified lines | |||
| 144 | //update decoder statistics information | 144 | //update decoder statistics information |
| 145 | void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput); | 145 | void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput); |
| 146 | //Destroy picutre buffer | 146 | //Destroy picutre buffer |
| 147 | void DestroyPicBuff (PPicBuff* ppPicBuf); | 147 | void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa); |
| 148 | #ifdef __cplusplus | 148 | #ifdef __cplusplus |
| 149 | } | 149 | } |
| 150 | #endif//__cplusplus | 150 | #endif//__cplusplus |
| @@ -55,6 +55,7 @@ · 54 unmodified lines | |||
| 55 | #include "mb_cache.h" | 55 | #include "mb_cache.h" |
| 56 | #include "expand_pic.h" | 56 | #include "expand_pic.h" |
| 57 | #include "mc.h" | 57 | #include "mc.h" |
| 58 | #include "memory_align.h" | ||
| 58 | 59 | ||
| 59 | namespace WelsDec { | 60 | namespace WelsDec { |
| 60 | #define MAX_PRED_MODE_ID_I16x16 3 | 61 | #define MAX_PRED_MODE_ID_I16x16 3 |
| @@ -449,6 +450,7 @@ typedef struct TagWelsDecoderContext { · 388 unmodified lines | |||
| 449 | bool bDequantCoeff4x4Init; | 450 | bool bDequantCoeff4x4Init; |
| 450 | bool bSpsLatePps; | 451 | bool bSpsLatePps; |
| 451 | bool bUseScalingList; | 452 | bool bUseScalingList; |
| 453 | CMemoryAlign* pMemAlign; | ||
| 452 | } SWelsDecoderContext, *PWelsDecoderContext; | 454 | } SWelsDecoderContext, *PWelsDecoderContext; |
| 453 | 455 | ||
| 454 | static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) { | 456 | static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) { |
| @@ -43,6 +43,7 @@ · 42 unmodified lines | |||
| 43 | #include "typedefs.h" | 43 | #include "typedefs.h" |
| 44 | #include "wels_const.h" | 44 | #include "wels_const.h" |
| 45 | #include "parameter_sets.h" | 45 | #include "parameter_sets.h" |
| 46 | #include "memory_align.h" | ||
| 46 | 47 | ||
| 47 | namespace WelsDec { | 48 | namespace WelsDec { |
| 48 | 49 | ||
| @@ -73,7 +74,7 @@ uint8_t uiReserved[3]; // reserved padding bytes · 24 unmodified lines | |||
| 73 | * | 74 | * |
| 74 | * \return 0 - successful; none 0 - failed; | 75 | * \return 0 - successful; none 0 - failed; |
| 75 | */ | 76 | */ |
| 76 | int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight); | 77 | int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight, CMemoryAlign* pMa); |
| 77 | 78 | ||
| 78 | /*! | 79 | /*! |
| 79 | * \brief Uninitialize Wels Flexible Macroblock Ordering (FMO) list | 80 | * \brief Uninitialize Wels Flexible Macroblock Ordering (FMO) list |
| @@ -84,7 +85,7 @@ int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki · 4 unmodified lines | |||
| 84 | * | 85 | * |
| 85 | * \return NONE | 86 | * \return NONE |
| 86 | */ | 87 | */ |
| 87 | void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail); | 88 | void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail, CMemoryAlign* pMa); |
| 88 | 89 | ||
| 89 | /*! | 90 | /*! |
| 90 | * \brief update/insert FMO parameter unit | 91 | * \brief update/insert FMO parameter unit |
| @@ -96,7 +97,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail); · 5 unmodified lines | |||
| 96 | * | 97 | * |
| 97 | * \return true - update/insert successfully; false - failed; | 98 | * \return true - update/insert successfully; false - failed; |
| 98 | */ | 99 | */ |
| 99 | bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum); | 100 | bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum, CMemoryAlign* pMa); |
| 100 | 101 | ||
| 101 | /*! | 102 | /*! |
| 102 | * \brief Get successive mb to be processed with given current mb_xy | 103 | * \brief Get successive mb to be processed with given current mb_xy |
| @@ -44,19 +44,20 @@ · 43 unmodified lines | |||
| 44 | #include "typedefs.h" | 44 | #include "typedefs.h" |
| 45 | #include "wels_common_basis.h" | 45 | #include "wels_common_basis.h" |
| 46 | #include "nalu.h" | 46 | #include "nalu.h" |
| 47 | #include "memory_align.h" | ||
| 47 | 48 | ||
| 48 | namespace WelsDec { | 49 | namespace WelsDec { |
| 49 | 50 | ||
| 50 | int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize); | 51 | int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa); |
| 51 | 52 | ||
| 52 | int32_t MemFreeNalList (PAccessUnit* ppAu); | 53 | int32_t MemFreeNalList (PAccessUnit* ppAu, CMemoryAlign* pMa); |
| 53 | 54 | ||
| 54 | /* | 55 | /* |
| 55 | * MemGetNextNal | 56 | * MemGetNextNal |
| 56 | * Get next NAL Unit for using. | 57 | * Get next NAL Unit for using. |
| 57 | * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit | 58 | * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit |
| 58 | */ | 59 | */ |
| 59 | PNalUnit MemGetNextNal (PAccessUnit* ppAu); | 60 | PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa); |
| 60 | 61 | ||
| 61 | } // namespace WelsDec | 62 | } // namespace WelsDec |
| 62 | 63 | ||
| @@ -264,7 +264,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 263 unmodified lines | |||
| 264 | case NAL_UNIT_CODED_SLICE_IDR: { | 264 | case NAL_UNIT_CODED_SLICE_IDR: { |
| 265 | PAccessUnit pCurAu = NULL; | 265 | PAccessUnit pCurAu = NULL; |
| 266 | uint32_t uiAvailNalNum; | 266 | uint32_t uiAvailNalNum; |
| 267 | pCurNal = MemGetNextNal (&pCtx->pAccessUnitList); | 267 | pCurNal = MemGetNextNal (&pCtx->pAccessUnitList, pCtx->pMemAlign); |
| 268 | if (NULL == pCurNal) { | 268 | if (NULL == pCurNal) { |
| 269 | WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory."); | 269 | WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory."); |
| 270 | pCtx->iErrorCode |= dsOutOfMemory; | 270 | pCtx->iErrorCode |= dsOutOfMemory; |
| @@ -1138,7 +1138,9 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 867 unmodified lines | |||
| 1138 | 1138 | ||
| 1139 | //re-write subset SPS to SPS | 1139 | //re-write subset SPS to SPS |
| 1140 | SBitStringAux sSubsetSpsBs; | 1140 | SBitStringAux sSubsetSpsBs; |
| 1141 | uint8_t* pBsBuf = static_cast<uint8_t*> (WelsMallocz (SPS_PPS_BS_SIZE + 4, | 1141 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 1142 | |||
| 1143 | uint8_t* pBsBuf = static_cast<uint8_t*> (pMa->WelsMallocz (SPS_PPS_BS_SIZE + 4, | ||
| 1142 | "Temp buffer for parse only usage.")); //to reserve 4 bytes for UVLC writing buffer | 1144 | "Temp buffer for parse only usage.")); //to reserve 4 bytes for UVLC writing buffer |
| 1143 | if (NULL == pBsBuf) { | 1145 | if (NULL == pBsBuf) { |
| 1144 | pCtx->iErrorCode |= dsOutOfMemory; | 1146 | pCtx->iErrorCode |= dsOutOfMemory; |
| @@ -1188,7 +1190,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 43 unmodified lines | |||
| 1188 | RBSP2EBSP (pSpsBs->pSpsBsBuf + 5, sSubsetSpsBs.pStartBuf, iRbspSize); | 1190 | RBSP2EBSP (pSpsBs->pSpsBsBuf + 5, sSubsetSpsBs.pStartBuf, iRbspSize); |
| 1189 | pSpsBs->uiSpsBsLen = (uint16_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf + 5); | 1191 | pSpsBs->uiSpsBsLen = (uint16_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf + 5); |
| 1190 | if (pBsBuf) { | 1192 | if (pBsBuf) { |
| 1191 | WelsFree (pBsBuf, "pBsBuf for parse only usage"); | 1193 | pMa->WelsFree (pBsBuf, "pBsBuf for parse only usage"); |
| 1192 | } | 1194 | } |
| 1193 | } | 1195 | } |
| 1194 | } | 1196 | } |
| @@ -1572,7 +1574,7 @@ int32_t ResetFmoList (PWelsDecoderContext pCtx) { · 377 unmodified lines | |||
| 1572 | int32_t iCountNum = 0; | 1574 | int32_t iCountNum = 0; |
| 1573 | if (NULL != pCtx) { | 1575 | if (NULL != pCtx) { |
| 1574 | // Fixed memory leak due to PPS_ID might not be continuous sometimes, 1/5/2010 | 1576 | // Fixed memory leak due to PPS_ID might not be continuous sometimes, 1/5/2010 |
| 1575 | UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum); | 1577 | UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum, pCtx->pMemAlign); |
| 1576 | iCountNum = pCtx->iActiveFmoNum; | 1578 | iCountNum = pCtx->iActiveFmoNum; |
| 1577 | pCtx->iActiveFmoNum = 0; | 1579 | pCtx->iActiveFmoNum = 0; |
| 1578 | } | 1580 | } |
| @@ -57,7 +57,7 @@ namespace WelsDec { · 56 unmodified lines | |||
| 57 | 57 | ||
| 58 | extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight); | 58 | extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight); |
| 59 | 59 | ||
| 60 | extern void FreePicture (PPicture pPic); | 60 | extern void FreePicture (PPicture pPic, CMemoryAlign* pMa); |
| 61 | 61 | ||
| 62 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, | 62 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, |
| 63 | const int32_t kiPicWidth, const int32_t kiPicHeight) { | 63 | const int32_t kiPicWidth, const int32_t kiPicHeight) { |
| @@ -67,17 +67,19 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 3 unmodified lines | |||
| 67 | return 1; | 67 | return 1; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 70 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 71 | |||
| 72 | pPicBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | ||
| 71 | 73 | ||
| 72 | if (NULL == pPicBuf) { | 74 | if (NULL == pPicBuf) { |
| 73 | return 1; | 75 | return 1; |
| 74 | } | 76 | } |
| 75 | 77 | ||
| 76 | pPicBuf->ppPic = (PPicture*)WelsMallocz (kiSize * sizeof (PPicture), "PPicture*"); | 78 | pPicBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiSize * sizeof (PPicture), "PPicture*"); |
| 77 | 79 | ||
| 78 | if (NULL == pPicBuf->ppPic) { | 80 | if (NULL == pPicBuf->ppPic) { |
| 79 | pPicBuf->iCapacity = 0; | 81 | pPicBuf->iCapacity = 0; |
| 80 | DestroyPicBuff (&pPicBuf); | 82 | DestroyPicBuff (&pPicBuf, pMa); |
| 81 | return 1; | 83 | return 1; |
| 82 | } | 84 | } |
| 83 | 85 | ||
| @@ -86,7 +88,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines | |||
| 86 | if (NULL == pPic) { | 88 | if (NULL == pPic) { |
| 87 | // init capacity first for free memory | 89 | // init capacity first for free memory |
| 88 | pPicBuf->iCapacity = iPicIdx; | 90 | pPicBuf->iCapacity = iPicIdx; |
| 89 | DestroyPicBuff (&pPicBuf); | 91 | DestroyPicBuff (&pPicBuf, pMa); |
| 90 | return 1; | 92 | return 1; |
| 91 | } | 93 | } |
| 92 | pPicBuf->ppPic[iPicIdx] = pPic; | 94 | pPicBuf->ppPic[iPicIdx] = pPic; |
| @@ -109,17 +111,18 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines | |||
| 109 | return 1; | 111 | return 1; |
| 110 | } | 112 | } |
| 111 | 113 | ||
| 112 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 114 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 115 | pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | ||
| 113 | 116 | ||
| 114 | if (NULL == pPicNewBuf) { | 117 | if (NULL == pPicNewBuf) { |
| 115 | return 1; | 118 | return 1; |
| 116 | } | 119 | } |
| 117 | 120 | ||
| 118 | pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); | 121 | pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); |
| 119 | 122 | ||
| 120 | if (NULL == pPicNewBuf->ppPic) { | 123 | if (NULL == pPicNewBuf->ppPic) { |
| 121 | pPicNewBuf->iCapacity = 0; | 124 | pPicNewBuf->iCapacity = 0; |
| 122 | DestroyPicBuff (&pPicNewBuf); | 125 | DestroyPicBuff (&pPicNewBuf, pMa); |
| 123 | return 1; | 126 | return 1; |
| 124 | } | 127 | } |
| 125 | 128 | ||
| @@ -129,7 +132,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 3 unmodified lines | |||
| 129 | if (NULL == pPic) { | 132 | if (NULL == pPic) { |
| 130 | // Set maximum capacity as the new malloc memory at the tail | 133 | // Set maximum capacity as the new malloc memory at the tail |
| 131 | pPicNewBuf->iCapacity = iPicIdx; | 134 | pPicNewBuf->iCapacity = iPicIdx; |
| 132 | DestroyPicBuff (&pPicNewBuf); | 135 | DestroyPicBuff (&pPicNewBuf, pMa); |
| 133 | return 1; | 136 | return 1; |
| 134 | } | 137 | } |
| 135 | pPicNewBuf->ppPic[iPicIdx] = pPic; | 138 | pPicNewBuf->ppPic[iPicIdx] = pPic; |
| @@ -152,12 +155,12 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines | |||
| 152 | } | 155 | } |
| 153 | // remove old PicBuf | 156 | // remove old PicBuf |
| 154 | if (pPicOldBuf->ppPic != NULL) { | 157 | if (pPicOldBuf->ppPic != NULL) { |
| 155 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); | 158 | pMa->WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); |
| 156 | pPicOldBuf->ppPic = NULL; | 159 | pPicOldBuf->ppPic = NULL; |
| 157 | } | 160 | } |
| 158 | pPicOldBuf->iCapacity = 0; | 161 | pPicOldBuf->iCapacity = 0; |
| 159 | pPicOldBuf->iCurrentIdx = 0; | 162 | pPicOldBuf->iCurrentIdx = 0; |
| 160 | WelsFree (pPicOldBuf, "pPicOldBuf"); | 163 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 161 | pPicOldBuf = NULL; | 164 | pPicOldBuf = NULL; |
| 162 | return 0; | 165 | return 0; |
| 163 | } | 166 | } |
| @@ -171,17 +174,19 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 7 unmodified lines | |||
| 171 | return 1; | 174 | return 1; |
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | 177 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 178 | |||
| 179 | pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff"); | ||
| 175 | 180 | ||
| 176 | if (NULL == pPicNewBuf) { | 181 | if (NULL == pPicNewBuf) { |
| 177 | return 1; | 182 | return 1; |
| 178 | } | 183 | } |
| 179 | 184 | ||
| 180 | pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); | 185 | pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*"); |
| 181 | 186 | ||
| 182 | if (NULL == pPicNewBuf->ppPic) { | 187 | if (NULL == pPicNewBuf->ppPic) { |
| 183 | pPicNewBuf->iCapacity = 0; | 188 | pPicNewBuf->iCapacity = 0; |
| 184 | DestroyPicBuff (&pPicNewBuf); | 189 | DestroyPicBuff (&pPicNewBuf, pMa); |
| 185 | return 1; | 190 | return 1; |
| 186 | } | 191 | } |
| 187 | 192 | ||
| @@ -207,7 +212,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 19 unmodified lines | |||
| 207 | for (iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) { | 212 | for (iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) { |
| 208 | if (iPrevPicIdx != iPicIdx) { | 213 | if (iPrevPicIdx != iPicIdx) { |
| 209 | if (pPicOldBuf->ppPic[iPicIdx] != NULL) { | 214 | if (pPicOldBuf->ppPic[iPicIdx] != NULL) { |
| 210 | FreePicture (pPicOldBuf->ppPic[iPicIdx]); | 215 | FreePicture (pPicOldBuf->ppPic[iPicIdx], pMa); |
| 211 | pPicOldBuf->ppPic[iPicIdx] = NULL; | 216 | pPicOldBuf->ppPic[iPicIdx] = NULL; |
| 212 | } | 217 | } |
| 213 | } | 218 | } |
| @@ -226,18 +231,18 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 12 unmodified lines | |||
| 226 | } | 231 | } |
| 227 | // remove old PicBuf | 232 | // remove old PicBuf |
| 228 | if (pPicOldBuf->ppPic != NULL) { | 233 | if (pPicOldBuf->ppPic != NULL) { |
| 229 | WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); | 234 | pMa->WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue"); |
| 230 | pPicOldBuf->ppPic = NULL; | 235 | pPicOldBuf->ppPic = NULL; |
| 231 | } | 236 | } |
| 232 | pPicOldBuf->iCapacity = 0; | 237 | pPicOldBuf->iCapacity = 0; |
| 233 | pPicOldBuf->iCurrentIdx = 0; | 238 | pPicOldBuf->iCurrentIdx = 0; |
| 234 | WelsFree (pPicOldBuf, "pPicOldBuf"); | 239 | pMa->WelsFree (pPicOldBuf, "pPicOldBuf"); |
| 235 | pPicOldBuf = NULL; | 240 | pPicOldBuf = NULL; |
| 236 | 241 | ||
| 237 | return 0; | 242 | return 0; |
| 238 | } | 243 | } |
| 239 | 244 | ||
| 240 | void DestroyPicBuff (PPicBuff* ppPicBuf) { | 245 | void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { |
| 241 | PPicBuff pPicBuf = NULL; | 246 | PPicBuff pPicBuf = NULL; |
| 242 | 247 | ||
| 243 | if (NULL == ppPicBuf || NULL == *ppPicBuf) | 248 | if (NULL == ppPicBuf || NULL == *ppPicBuf) |
| @@ -249,20 +254,20 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { · 5 unmodified lines | |||
| 249 | while (iPicIdx < pPicBuf->iCapacity) { | 254 | while (iPicIdx < pPicBuf->iCapacity) { |
| 250 | PPicture pPic = pPicBuf->ppPic[iPicIdx]; | 255 | PPicture pPic = pPicBuf->ppPic[iPicIdx]; |
| 251 | if (pPic != NULL) { | 256 | if (pPic != NULL) { |
| 252 | FreePicture (pPic); | 257 | FreePicture (pPic, pMa); |
| 253 | } | 258 | } |
| 254 | pPic = NULL; | 259 | pPic = NULL; |
| 255 | ++ iPicIdx; | 260 | ++ iPicIdx; |
| 256 | } | 261 | } |
| 257 | 262 | ||
| 258 | WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); | 263 | pMa->WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); |
| 259 | 264 | ||
| 260 | pPicBuf->ppPic = NULL; | 265 | pPicBuf->ppPic = NULL; |
| 261 | } | 266 | } |
| 262 | pPicBuf->iCapacity = 0; | 267 | pPicBuf->iCapacity = 0; |
| 263 | pPicBuf->iCurrentIdx = 0; | 268 | pPicBuf->iCurrentIdx = 0; |
| 264 | 269 | ||
| 265 | WelsFree (pPicBuf, "pPicBuf"); | 270 | pMa->WelsFree (pPicBuf, "pPicBuf"); |
| 266 | 271 | ||
| 267 | pPicBuf = NULL; | 272 | pPicBuf = NULL; |
| 268 | *ppPicBuf = NULL; | 273 | *ppPicBuf = NULL; |
| @@ -270,10 +275,11 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { · 1 unmodified line | |||
| 270 | /* | 275 | /* |
| 271 | * fill data fields in default for decoder context | 276 | * fill data fields in default for decoder context |
| 272 | */ | 277 | */ |
| 273 | void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { | 278 | void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) { |
| 274 | int32_t iCpuCores = 1; | 279 | int32_t iCpuCores = 1; |
| 275 | memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first | 280 | memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first |
| 276 | pCtx->sLogCtx = *pLogCtx; | 281 | pCtx->sLogCtx = *pLogCtx; |
| 282 | pCtx->pMemAlign = pMa; | ||
| 277 | 283 | ||
| 278 | pCtx->pArgDec = NULL; | 284 | pCtx->pArgDec = NULL; |
| 279 | 285 | ||
| @@ -360,6 +366,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 80 unmodified lines | |||
| 360 | int32_t iListIdx = 0; //, mb_blocks = 0; | 366 | int32_t iListIdx = 0; //, mb_blocks = 0; |
| 361 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 367 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 362 | bool bNeedChangePicQueue = true; | 368 | bool bNeedChangePicQueue = true; |
| 369 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 363 | 370 | ||
| 364 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) | 371 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) |
| 365 | 372 | ||
| @@ -404,7 +411,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 38 unmodified lines | |||
| 404 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { | 411 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 405 | PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx]; | 412 | PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx]; |
| 406 | if (NULL != ppPic && NULL != *ppPic) { | 413 | if (NULL != ppPic && NULL != *ppPic) { |
| 407 | DestroyPicBuff (ppPic); | 414 | DestroyPicBuff (ppPic, pMa); |
| 408 | } | 415 | } |
| 409 | } | 416 | } |
| 410 | 417 | ||
| @@ -425,7 +432,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 14 unmodified lines | |||
| 425 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed | 432 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed |
| 426 | 433 | ||
| 427 | if (pCtx->pCabacDecEngine == NULL) | 434 | if (pCtx->pCabacDecEngine == NULL) |
| 428 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); | 435 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); |
| 429 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) | 436 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) |
| 430 | return ERR_NONE; | 437 | return ERR_NONE; |
| 431 | } | 438 | } |
| @@ -435,6 +442,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 3 unmodified lines | |||
| 435 | */ | 442 | */ |
| 436 | void WelsFreeMem (PWelsDecoderContext pCtx) { | 443 | void WelsFreeMem (PWelsDecoderContext pCtx) { |
| 437 | int32_t iListIdx = 0; | 444 | int32_t iListIdx = 0; |
| 445 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 438 | 446 | ||
| 439 | /* TODO: free memory blocks introduced in avc */ | 447 | /* TODO: free memory blocks introduced in avc */ |
| 440 | ResetFmoList (pCtx); | 448 | ResetFmoList (pCtx); |
| @@ -445,7 +453,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 4 unmodified lines | |||
| 445 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { | 453 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 446 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; | 454 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; |
| 447 | if (NULL != pPicBuff && NULL != *pPicBuff) { | 455 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| 448 | DestroyPicBuff (pPicBuff); | 456 | DestroyPicBuff (pPicBuff, pMa); |
| 449 | } | 457 | } |
| 450 | } | 458 | } |
| 451 | 459 | ||
| @@ -456,7 +464,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 4 unmodified lines | |||
| 456 | pCtx->iLastImgHeightInPixel = 0; | 464 | pCtx->iLastImgHeightInPixel = 0; |
| 457 | pCtx->bFreezeOutput = true; | 465 | pCtx->bFreezeOutput = true; |
| 458 | pCtx->bHaveGotMemory = false; | 466 | pCtx->bHaveGotMemory = false; |
| 459 | WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); | 467 | pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); |
| 460 | } | 468 | } |
| 461 | 469 | ||
| 462 | /*! | 470 | /*! |
| @@ -517,7 +525,9 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 54 unmodified lines | |||
| 517 | if (NULL == pCtx || NULL == kpParam) | 525 | if (NULL == pCtx || NULL == kpParam) |
| 518 | return 1; | 526 | return 1; |
| 519 | 527 | ||
| 520 | pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); | 528 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 529 | |||
| 530 | pCtx->pParam = (SDecodingParam*)pMa->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam"); | ||
| 521 | 531 | ||
| 522 | if (NULL == pCtx->pParam) | 532 | if (NULL == pCtx->pParam) |
| 523 | return 1; | 533 | return 1; |
| @@ -565,7 +575,7 @@ int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogCo · 41 unmodified lines | |||
| 565 | } | 575 | } |
| 566 | 576 | ||
| 567 | // default | 577 | // default |
| 568 | WelsDecoderDefaults (pCtx, pLogCtx); | 578 | WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign); |
| 569 | 579 | ||
| 570 | pCtx->bParseOnly = bParseOnly; | 580 | pCtx->bParseOnly = bParseOnly; |
| 571 | // open decoder | 581 | // open decoder |
| @@ -834,7 +844,10 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 262 unmodified lines | |||
| 834 | "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure."); | 844 | "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure."); |
| 835 | pCtx->iErrorCode = dsOutOfMemory; | 845 | pCtx->iErrorCode = dsOutOfMemory; |
| 836 | } | 846 | } |
| 837 | 847 | #if defined(MEMORY_MONITOR) | |
| 848 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", | ||
| 849 | static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); | ||
| 850 | #endif//MEMORY_MONITOR | ||
| 838 | return iErr; | 851 | return iErr; |
| 839 | } | 852 | } |
| 840 | 853 | ||
| @@ -456,27 +456,29 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 455 unmodified lines | |||
| 456 | if (pCtx == NULL) | 456 | if (pCtx == NULL) |
| 457 | return ERR_INFO_INVALID_PTR; | 457 | return ERR_INFO_INVALID_PTR; |
| 458 | 458 | ||
| 459 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 460 | |||
| 459 | pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM; | 461 | pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM; |
| 460 | if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte, | 462 | if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte, |
| 461 | "pCtx->sRawData.pHead"))) == NULL) { | 463 | "pCtx->sRawData.pHead"))) == NULL) { |
| 462 | return ERR_INFO_OUT_OF_MEMORY; | 464 | return ERR_INFO_OUT_OF_MEMORY; |
| 463 | } | 465 | } |
| 464 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; | 466 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; |
| 465 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; | 467 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; |
| 466 | if (pCtx->bParseOnly) { | 468 | if (pCtx->bParseOnly) { |
| 467 | pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo")); | 469 | pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo")); |
| 468 | if (pCtx->pParserBsInfo == NULL) { | 470 | if (pCtx->pParserBsInfo == NULL) { |
| 469 | return ERR_INFO_OUT_OF_MEMORY; | 471 | return ERR_INFO_OUT_OF_MEMORY; |
| 470 | } | 472 | } |
| 471 | memset (pCtx->pParserBsInfo, 0, sizeof (SParserBsInfo)); | 473 | memset (pCtx->pParserBsInfo, 0, sizeof (SParserBsInfo)); |
| 472 | pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t), | 474 | pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (pMa->WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t), |
| 473 | "pCtx->pParserBsInfo->pDstBuff")); | 475 | "pCtx->pParserBsInfo->pDstBuff")); |
| 474 | if (pCtx->pParserBsInfo->pDstBuff == NULL) { | 476 | if (pCtx->pParserBsInfo->pDstBuff == NULL) { |
| 475 | return ERR_INFO_OUT_OF_MEMORY; | 477 | return ERR_INFO_OUT_OF_MEMORY; |
| 476 | } | 478 | } |
| 477 | memset (pCtx->pParserBsInfo->pDstBuff, 0, MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t)); | 479 | memset (pCtx->pParserBsInfo->pDstBuff, 0, MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t)); |
| 478 | 480 | ||
| 479 | if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte, | 481 | if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte, |
| 480 | "pCtx->sSavedData.pHead"))) == NULL) { | 482 | "pCtx->sSavedData.pHead"))) == NULL) { |
| 481 | return ERR_INFO_OUT_OF_MEMORY; | 483 | return ERR_INFO_OUT_OF_MEMORY; |
| 482 | } | 484 | } |
| @@ -492,7 +494,8 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 9 unmodified lines | |||
| 492 | int32_t iExpandStepShift = 1; | 494 | int32_t iExpandStepShift = 1; |
| 493 | int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift)); | 495 | int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift)); |
| 494 | //allocate new bs buffer | 496 | //allocate new bs buffer |
| 495 | uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead")); | 497 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 498 | uint8_t* pNewBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead")); | ||
| 496 | if (pNewBsBuff == NULL) | 499 | if (pNewBsBuff == NULL) |
| 497 | return ERR_INFO_OUT_OF_MEMORY; | 500 | return ERR_INFO_OUT_OF_MEMORY; |
| 498 | 501 | ||
| @@ -510,7 +513,7 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 11 unmodified lines | |||
| 510 | pCtx->sRawData.pStartPos = pNewBsBuff + (pCtx->sRawData.pStartPos - pCtx->sRawData.pHead); | 513 | pCtx->sRawData.pStartPos = pNewBsBuff + (pCtx->sRawData.pStartPos - pCtx->sRawData.pHead); |
| 511 | pCtx->sRawData.pCurPos = pNewBsBuff + (pCtx->sRawData.pCurPos - pCtx->sRawData.pHead); | 514 | pCtx->sRawData.pCurPos = pNewBsBuff + (pCtx->sRawData.pCurPos - pCtx->sRawData.pHead); |
| 512 | pCtx->sRawData.pEnd = pNewBsBuff + iNewBuffLen; | 515 | pCtx->sRawData.pEnd = pNewBsBuff + iNewBuffLen; |
| 513 | WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData.pHead"); | 516 | pMa->WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData.pHead"); |
| 514 | pCtx->sRawData.pHead = pNewBsBuff; | 517 | pCtx->sRawData.pHead = pNewBsBuff; |
| 515 | return ERR_NONE; | 518 | return ERR_NONE; |
| 516 | } | 519 | } |
| @@ -545,7 +548,7 @@ int32_t WelsInitMemory (PWelsDecoderContext pCtx) { · 28 unmodified lines | |||
| 545 | return ERR_INFO_INVALID_PTR; | 548 | return ERR_INFO_INVALID_PTR; |
| 546 | } | 549 | } |
| 547 | 550 | ||
| 548 | if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU) != 0) | 551 | if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU, pCtx->pMemAlign) != 0) |
| 549 | return ERR_INFO_OUT_OF_MEMORY; | 552 | return ERR_INFO_OUT_OF_MEMORY; |
| 550 | 553 | ||
| 551 | if (InitBsBuffer (pCtx) != 0) | 554 | if (InitBsBuffer (pCtx) != 0) |
| @@ -566,16 +569,18 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 14 unmodified lines | |||
| 566 | if (pCtx == NULL) | 569 | if (pCtx == NULL) |
| 567 | return; | 570 | return; |
| 568 | 571 | ||
| 572 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 573 | |||
| 569 | if (NULL != pCtx->pParam) { | 574 | if (NULL != pCtx->pParam) { |
| 570 | WelsFree (pCtx->pParam, "pCtx->pParam"); | 575 | pMa->WelsFree (pCtx->pParam, "pCtx->pParam"); |
| 571 | 576 | ||
| 572 | pCtx->pParam = NULL; | 577 | pCtx->pParam = NULL; |
| 573 | } | 578 | } |
| 574 | 579 | ||
| 575 | MemFreeNalList (&pCtx->pAccessUnitList); | 580 | MemFreeNalList (&pCtx->pAccessUnitList, pMa); |
| 576 | 581 | ||
| 577 | if (pCtx->sRawData.pHead) { | 582 | if (pCtx->sRawData.pHead) { |
| 578 | WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData->pHead"); | 583 | pMa->WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData->pHead"); |
| 579 | } | 584 | } |
| 580 | pCtx->sRawData.pHead = NULL; | 585 | pCtx->sRawData.pHead = NULL; |
| 581 | pCtx->sRawData.pEnd = NULL; | 586 | pCtx->sRawData.pEnd = NULL; |
| @@ -583,7 +588,7 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 1 unmodified line | |||
| 583 | pCtx->sRawData.pCurPos = NULL; | 588 | pCtx->sRawData.pCurPos = NULL; |
| 584 | if (pCtx->bParseOnly) { | 589 | if (pCtx->bParseOnly) { |
| 585 | if (pCtx->sSavedData.pHead) { | 590 | if (pCtx->sSavedData.pHead) { |
| 586 | WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); | 591 | pMa->WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); |
| 587 | } | 592 | } |
| 588 | pCtx->sSavedData.pHead = NULL; | 593 | pCtx->sSavedData.pHead = NULL; |
| 589 | pCtx->sSavedData.pEnd = NULL; | 594 | pCtx->sSavedData.pEnd = NULL; |
| @@ -591,10 +596,10 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 1 unmodified line | |||
| 591 | pCtx->sSavedData.pCurPos = NULL; | 596 | pCtx->sSavedData.pCurPos = NULL; |
| 592 | if (pCtx->pParserBsInfo) { | 597 | if (pCtx->pParserBsInfo) { |
| 593 | if (pCtx->pParserBsInfo->pDstBuff) { | 598 | if (pCtx->pParserBsInfo->pDstBuff) { |
| 594 | WelsFree (pCtx->pParserBsInfo->pDstBuff, "pCtx->pParserBsInfo->pDstBuff"); | 599 | pMa->WelsFree (pCtx->pParserBsInfo->pDstBuff, "pCtx->pParserBsInfo->pDstBuff"); |
| 595 | pCtx->pParserBsInfo->pDstBuff = NULL; | 600 | pCtx->pParserBsInfo->pDstBuff = NULL; |
| 596 | } | 601 | } |
| 597 | WelsFree (pCtx->pParserBsInfo, "pCtx->pParserBsInfo"); | 602 | pMa->WelsFree (pCtx->pParserBsInfo, "pCtx->pParserBsInfo"); |
| 598 | pCtx->pParserBsInfo = NULL; | 603 | pCtx->pParserBsInfo = NULL; |
| 599 | } | 604 | } |
| 600 | } | 605 | } |
| @@ -640,7 +645,8 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) { · 39 unmodified lines | |||
| 640 | * Parse slice header of bitstream in avc for storing data structure | 645 | * Parse slice header of bitstream in avc for storing data structure |
| 641 | */ | 646 | */ |
| 642 | int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) { | 647 | int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) { |
| 643 | PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1]; | 648 | PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - |
| 649 | 1]; | ||
| 644 | 650 | ||
| 645 | PNalUnitHeaderExt pNalHeaderExt = NULL; | 651 | PNalUnitHeaderExt pNalHeaderExt = NULL; |
| 646 | PSliceHeader pSliceHead = NULL; | 652 | PSliceHeader pSliceHead = NULL; |
| @@ -970,7 +976,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 323 unmodified lines | |||
| 970 | } | 976 | } |
| 971 | 977 | ||
| 972 | bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3 | 978 | bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3 |
| 973 | && pPps->uiSliceGroupMapType <= 5); | 979 | && pPps->uiSliceGroupMapType <= 5); |
| 974 | if (kbExtensionFlag && bSgChangeCycleInvolved) | 980 | if (kbExtensionFlag && bSgChangeCycleInvolved) |
| 975 | bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID)); | 981 | bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID)); |
| 976 | if (bSgChangeCycleInvolved) { | 982 | if (bSgChangeCycleInvolved) { |
| @@ -1030,7 +1036,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 53 unmodified lines | |||
| 1030 | pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset; | 1036 | pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset; |
| 1031 | pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag); | 1037 | pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag); |
| 1032 | //memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage | 1038 | //memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage |
| 1033 | pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset); | 1039 | pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - |
| 1040 | (pos.iLeftOffset + pos.iRightOffset); | ||
| 1034 | pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) - | 1041 | pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) - |
| 1035 | (pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag); | 1042 | (pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag); |
| 1036 | } | 1043 | } |
| @@ -1218,68 +1225,75 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 181 unmodified lines | |||
| 1218 | && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped | 1225 | && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped |
| 1219 | return ERR_NONE; | 1226 | return ERR_NONE; |
| 1220 | 1227 | ||
| 1228 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 1221 | 1229 | ||
| 1222 | UninitialDqLayersContext (pCtx); | 1230 | UninitialDqLayersContext (pCtx); |
| 1223 | 1231 | ||
| 1224 | do { | 1232 | do { |
| 1225 | PDqLayer pDq = (PDqLayer)WelsMallocz (sizeof (SDqLayer), "PDqLayer"); | 1233 | PDqLayer pDq = (PDqLayer)pMa->WelsMallocz (sizeof (SDqLayer), "PDqLayer"); |
| 1226 | 1234 | ||
| 1227 | if (pDq == NULL) | 1235 | if (pDq == NULL) |
| 1228 | return ERR_INFO_OUT_OF_MEMORY; | 1236 | return ERR_INFO_OUT_OF_MEMORY; |
| 1229 | 1237 | ||
| 1230 | memset (pDq, 0, sizeof (SDqLayer)); | 1238 | memset (pDq, 0, sizeof (SDqLayer)); |
| 1231 | 1239 | ||
| 1232 | pCtx->sMb.pMbType[i] = (int16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t), | 1240 | pCtx->sMb.pMbType[i] = (int16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t), |
| 1233 | "pCtx->sMb.pMbType[]"); | 1241 | "pCtx->sMb.pMbType[]"); |
| 1234 | pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1242 | pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1235 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); | 1243 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); |
| 1236 | pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1244 | pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1237 | sizeof ( | 1245 | sizeof ( |
| 1238 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); | 1246 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1239 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1247 | pCtx->sMb.pLumaQp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1240 | "pCtx->sMb.pLumaQp[]"); | 1248 | "pCtx->sMb.pLumaQp[]"); |
| 1241 | pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1249 | pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1250 | sizeof ( | ||
| 1242 | bool), | 1251 | bool), |
| 1243 | "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); | 1252 | "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); |
| 1244 | pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), | 1253 | pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), |
| 1245 | "pCtx->sMb.pTransformSize8x8Flag[]"); | 1254 | "pCtx->sMb.pTransformSize8x8Flag[]"); |
| 1246 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2, | 1255 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1256 | int8_t) * 2, | ||
| 1247 | "pCtx->sMb.pChromaQp[]"); | 1257 | "pCtx->sMb.pChromaQp[]"); |
| 1248 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1258 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1249 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); | 1259 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); |
| 1250 | pCtx->sMb.pCbfDc[i] = (uint16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t), | 1260 | pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t), |
| 1251 | "pCtx->sMb.pCbfDc[]"); | 1261 | "pCtx->sMb.pCbfDc[]"); |
| 1252 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | 1262 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, |
| 1253 | "pCtx->sMb.pNzc[]"); | 1263 | "pCtx->sMb.pNzc[]"); |
| 1254 | pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | 1264 | pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, |
| 1255 | "pCtx->sMb.pNzcRs[]"); | 1265 | "pCtx->sMb.pNzcRs[]"); |
| 1256 | pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1266 | pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * |
| 1267 | pCtx->sMb.iMbHeight * | ||
| 1257 | sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); | 1268 | sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); |
| 1258 | pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1269 | pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1259 | int8_t) * 8, | 1270 | int8_t) * 8, |
| 1260 | "pCtx->sMb.pIntraPredMode[]"); | 1271 | "pCtx->sMb.pIntraPredMode[]"); |
| 1261 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1272 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * |
| 1273 | pCtx->sMb.iMbHeight * | ||
| 1262 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); | 1274 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); |
| 1263 | pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1275 | pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1276 | int8_t), | ||
| 1264 | "pCtx->sMb.pIntraNxNAvailFlag"); | 1277 | "pCtx->sMb.pIntraNxNAvailFlag"); |
| 1265 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1278 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1266 | "pCtx->sMb.pChromaPredMode[]"); | 1279 | "pCtx->sMb.pChromaPredMode[]"); |
| 1267 | pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1280 | pCtx->sMb.pCbp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1268 | "pCtx->sMb.pCbp[]"); | 1281 | "pCtx->sMb.pCbp[]"); |
| 1269 | pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1282 | pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1270 | sizeof ( | 1283 | sizeof ( |
| 1271 | int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); | 1284 | int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); |
| 1272 | pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), | 1285 | pCtx->sMb.pSliceIdc[i] = (int32_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), |
| 1273 | "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 | 1286 | "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 |
| 1274 | pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1287 | pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1275 | "pCtx->sMb.pResidualPredFlag[]"); | 1288 | "pCtx->sMb.pResidualPredFlag[]"); |
| 1276 | //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); | 1289 | //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) pMa->WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); |
| 1277 | pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1290 | pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1278 | int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); | 1291 | int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); |
| 1279 | 1292 | ||
| 1280 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), | 1293 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1294 | bool), | ||
| 1281 | "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); | 1295 | "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); |
| 1282 | pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), | 1296 | pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), |
| 1283 | "pCtx->pMbRefConcealedFlag[]"); | 1297 | "pCtx->pMbRefConcealedFlag[]"); |
| 1284 | 1298 | ||
| 1285 | // check memory block valid due above allocated.. | 1299 | // check memory block valid due above allocated.. |
| @@ -1322,6 +1336,7 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 36 unmodified lines | |||
| 1322 | 1336 | ||
| 1323 | void UninitialDqLayersContext (PWelsDecoderContext pCtx) { | 1337 | void UninitialDqLayersContext (PWelsDecoderContext pCtx) { |
| 1324 | int32_t i = 0; | 1338 | int32_t i = 0; |
| 1339 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 1325 | 1340 | ||
| 1326 | do { | 1341 | do { |
| 1327 | PDqLayer pDq = pCtx->pDqLayersList[i]; | 1342 | PDqLayer pDq = pCtx->pDqLayersList[i]; |
| @@ -1331,146 +1346,146 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 3 unmodified lines | |||
| 1331 | } | 1346 | } |
| 1332 | 1347 | ||
| 1333 | if (pCtx->sMb.pMbType[i]) { | 1348 | if (pCtx->sMb.pMbType[i]) { |
| 1334 | WelsFree (pCtx->sMb.pMbType[i], "pCtx->sMb.pMbType[]"); | 1349 | pMa->WelsFree (pCtx->sMb.pMbType[i], "pCtx->sMb.pMbType[]"); |
| 1335 | 1350 | ||
| 1336 | pCtx->sMb.pMbType[i] = NULL; | 1351 | pCtx->sMb.pMbType[i] = NULL; |
| 1337 | } | 1352 | } |
| 1338 | 1353 | ||
| 1339 | if (pCtx->sMb.pMv[i][0]) { | 1354 | if (pCtx->sMb.pMv[i][0]) { |
| 1340 | WelsFree (pCtx->sMb.pMv[i][0], "pCtx->sMb.pMv[][]"); | 1355 | pMa->WelsFree (pCtx->sMb.pMv[i][0], "pCtx->sMb.pMv[][]"); |
| 1341 | 1356 | ||
| 1342 | pCtx->sMb.pMv[i][0] = NULL; | 1357 | pCtx->sMb.pMv[i][0] = NULL; |
| 1343 | } | 1358 | } |
| 1344 | 1359 | ||
| 1345 | if (pCtx->sMb.pRefIndex[i][0]) { | 1360 | if (pCtx->sMb.pRefIndex[i][0]) { |
| 1346 | WelsFree (pCtx->sMb.pRefIndex[i][0], "pCtx->sMb.pRefIndex[][]"); | 1361 | pMa->WelsFree (pCtx->sMb.pRefIndex[i][0], "pCtx->sMb.pRefIndex[][]"); |
| 1347 | 1362 | ||
| 1348 | pCtx->sMb.pRefIndex[i][0] = NULL; | 1363 | pCtx->sMb.pRefIndex[i][0] = NULL; |
| 1349 | } | 1364 | } |
| 1350 | 1365 | ||
| 1351 | if (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i]) { | 1366 | if (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i]) { |
| 1352 | WelsFree (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i], "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); | 1367 | pMa->WelsFree (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i], "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]"); |
| 1353 | 1368 | ||
| 1354 | pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = NULL; | 1369 | pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = NULL; |
| 1355 | } | 1370 | } |
| 1356 | 1371 | ||
| 1357 | if (pCtx->sMb.pTransformSize8x8Flag[i]) { | 1372 | if (pCtx->sMb.pTransformSize8x8Flag[i]) { |
| 1358 | WelsFree (pCtx->sMb.pTransformSize8x8Flag[i], "pCtx->sMb.pTransformSize8x8Flag[]"); | 1373 | pMa->WelsFree (pCtx->sMb.pTransformSize8x8Flag[i], "pCtx->sMb.pTransformSize8x8Flag[]"); |
| 1359 | 1374 | ||
| 1360 | pCtx->sMb.pTransformSize8x8Flag[i] = NULL; | 1375 | pCtx->sMb.pTransformSize8x8Flag[i] = NULL; |
| 1361 | } | 1376 | } |
| 1362 | 1377 | ||
| 1363 | if (pCtx->sMb.pLumaQp[i]) { | 1378 | if (pCtx->sMb.pLumaQp[i]) { |
| 1364 | WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]"); | 1379 | pMa->WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]"); |
| 1365 | 1380 | ||
| 1366 | pCtx->sMb.pLumaQp[i] = NULL; | 1381 | pCtx->sMb.pLumaQp[i] = NULL; |
| 1367 | } | 1382 | } |
| 1368 | 1383 | ||
| 1369 | if (pCtx->sMb.pChromaQp[i]) { | 1384 | if (pCtx->sMb.pChromaQp[i]) { |
| 1370 | WelsFree (pCtx->sMb.pChromaQp[i], "pCtx->sMb.pChromaQp[]"); | 1385 | pMa->WelsFree (pCtx->sMb.pChromaQp[i], "pCtx->sMb.pChromaQp[]"); |
| 1371 | 1386 | ||
| 1372 | pCtx->sMb.pChromaQp[i] = NULL; | 1387 | pCtx->sMb.pChromaQp[i] = NULL; |
| 1373 | } | 1388 | } |
| 1374 | 1389 | ||
| 1375 | if (pCtx->sMb.pMvd[i][0]) { | 1390 | if (pCtx->sMb.pMvd[i][0]) { |
| 1376 | WelsFree (pCtx->sMb.pMvd[i][0], "pCtx->sMb.pMvd[][]"); | 1391 | pMa->WelsFree (pCtx->sMb.pMvd[i][0], "pCtx->sMb.pMvd[][]"); |
| 1377 | pCtx->sMb.pMvd[i][0] = NULL; | 1392 | pCtx->sMb.pMvd[i][0] = NULL; |
| 1378 | } | 1393 | } |
| 1379 | 1394 | ||
| 1380 | if (pCtx->sMb.pCbfDc[i]) { | 1395 | if (pCtx->sMb.pCbfDc[i]) { |
| 1381 | WelsFree (pCtx->sMb.pCbfDc[i], "pCtx->sMb.pCbfDc[]"); | 1396 | pMa->WelsFree (pCtx->sMb.pCbfDc[i], "pCtx->sMb.pCbfDc[]"); |
| 1382 | pCtx->sMb.pCbfDc[i] = NULL; | 1397 | pCtx->sMb.pCbfDc[i] = NULL; |
| 1383 | } | 1398 | } |
| 1384 | 1399 | ||
| 1385 | if (pCtx->sMb.pNzc[i]) { | 1400 | if (pCtx->sMb.pNzc[i]) { |
| 1386 | WelsFree (pCtx->sMb.pNzc[i], "pCtx->sMb.pNzc[]"); | 1401 | pMa->WelsFree (pCtx->sMb.pNzc[i], "pCtx->sMb.pNzc[]"); |
| 1387 | 1402 | ||
| 1388 | pCtx->sMb.pNzc[i] = NULL; | 1403 | pCtx->sMb.pNzc[i] = NULL; |
| 1389 | } | 1404 | } |
| 1390 | 1405 | ||
| 1391 | if (pCtx->sMb.pNzcRs[i]) { | 1406 | if (pCtx->sMb.pNzcRs[i]) { |
| 1392 | WelsFree (pCtx->sMb.pNzcRs[i], "pCtx->sMb.pNzcRs[]"); | 1407 | pMa->WelsFree (pCtx->sMb.pNzcRs[i], "pCtx->sMb.pNzcRs[]"); |
| 1393 | 1408 | ||
| 1394 | pCtx->sMb.pNzcRs[i] = NULL; | 1409 | pCtx->sMb.pNzcRs[i] = NULL; |
| 1395 | } | 1410 | } |
| 1396 | 1411 | ||
| 1397 | if (pCtx->sMb.pScaledTCoeff[i]) { | 1412 | if (pCtx->sMb.pScaledTCoeff[i]) { |
| 1398 | WelsFree (pCtx->sMb.pScaledTCoeff[i], "pCtx->sMb.pScaledTCoeff[]"); | 1413 | pMa->WelsFree (pCtx->sMb.pScaledTCoeff[i], "pCtx->sMb.pScaledTCoeff[]"); |
| 1399 | 1414 | ||
| 1400 | pCtx->sMb.pScaledTCoeff[i] = NULL; | 1415 | pCtx->sMb.pScaledTCoeff[i] = NULL; |
| 1401 | } | 1416 | } |
| 1402 | 1417 | ||
| 1403 | if (pCtx->sMb.pIntraPredMode[i]) { | 1418 | if (pCtx->sMb.pIntraPredMode[i]) { |
| 1404 | WelsFree (pCtx->sMb.pIntraPredMode[i], "pCtx->sMb.pIntraPredMode[]"); | 1419 | pMa->WelsFree (pCtx->sMb.pIntraPredMode[i], "pCtx->sMb.pIntraPredMode[]"); |
| 1405 | 1420 | ||
| 1406 | pCtx->sMb.pIntraPredMode[i] = NULL; | 1421 | pCtx->sMb.pIntraPredMode[i] = NULL; |
| 1407 | } | 1422 | } |
| 1408 | 1423 | ||
| 1409 | if (pCtx->sMb.pIntra4x4FinalMode[i]) { | 1424 | if (pCtx->sMb.pIntra4x4FinalMode[i]) { |
| 1410 | WelsFree (pCtx->sMb.pIntra4x4FinalMode[i], "pCtx->sMb.pIntra4x4FinalMode[]"); | 1425 | pMa->WelsFree (pCtx->sMb.pIntra4x4FinalMode[i], "pCtx->sMb.pIntra4x4FinalMode[]"); |
| 1411 | 1426 | ||
| 1412 | pCtx->sMb.pIntra4x4FinalMode[i] = NULL; | 1427 | pCtx->sMb.pIntra4x4FinalMode[i] = NULL; |
| 1413 | } | 1428 | } |
| 1414 | 1429 | ||
| 1415 | if (pCtx->sMb.pIntraNxNAvailFlag[i]) { | 1430 | if (pCtx->sMb.pIntraNxNAvailFlag[i]) { |
| 1416 | WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag"); | 1431 | pMa->WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag"); |
| 1417 | 1432 | ||
| 1418 | pCtx->sMb.pIntraNxNAvailFlag[i] = NULL; | 1433 | pCtx->sMb.pIntraNxNAvailFlag[i] = NULL; |
| 1419 | } | 1434 | } |
| 1420 | 1435 | ||
| 1421 | if (pCtx->sMb.pChromaPredMode[i]) { | 1436 | if (pCtx->sMb.pChromaPredMode[i]) { |
| 1422 | WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]"); | 1437 | pMa->WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]"); |
| 1423 | 1438 | ||
| 1424 | pCtx->sMb.pChromaPredMode[i] = NULL; | 1439 | pCtx->sMb.pChromaPredMode[i] = NULL; |
| 1425 | } | 1440 | } |
| 1426 | 1441 | ||
| 1427 | if (pCtx->sMb.pCbp[i]) { | 1442 | if (pCtx->sMb.pCbp[i]) { |
| 1428 | WelsFree (pCtx->sMb.pCbp[i], "pCtx->sMb.pCbp[]"); | 1443 | pMa->WelsFree (pCtx->sMb.pCbp[i], "pCtx->sMb.pCbp[]"); |
| 1429 | 1444 | ||
| 1430 | pCtx->sMb.pCbp[i] = NULL; | 1445 | pCtx->sMb.pCbp[i] = NULL; |
| 1431 | } | 1446 | } |
| 1432 | 1447 | ||
| 1433 | // if (pCtx->sMb.pMotionPredFlag[i]) | 1448 | // if (pCtx->sMb.pMotionPredFlag[i]) |
| 1434 | //{ | 1449 | //{ |
| 1435 | // WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" ); | 1450 | // pMa->WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" ); |
| 1436 | 1451 | ||
| 1437 | // pCtx->sMb.pMotionPredFlag[i] = NULL; | 1452 | // pCtx->sMb.pMotionPredFlag[i] = NULL; |
| 1438 | //} | 1453 | //} |
| 1439 | 1454 | ||
| 1440 | if (pCtx->sMb.pSubMbType[i]) { | 1455 | if (pCtx->sMb.pSubMbType[i]) { |
| 1441 | WelsFree (pCtx->sMb.pSubMbType[i], "pCtx->sMb.pSubMbType[]"); | 1456 | pMa->WelsFree (pCtx->sMb.pSubMbType[i], "pCtx->sMb.pSubMbType[]"); |
| 1442 | 1457 | ||
| 1443 | pCtx->sMb.pSubMbType[i] = NULL; | 1458 | pCtx->sMb.pSubMbType[i] = NULL; |
| 1444 | } | 1459 | } |
| 1445 | 1460 | ||
| 1446 | if (pCtx->sMb.pSliceIdc[i]) { | 1461 | if (pCtx->sMb.pSliceIdc[i]) { |
| 1447 | WelsFree (pCtx->sMb.pSliceIdc[i], "pCtx->sMb.pSliceIdc[]"); | 1462 | pMa->WelsFree (pCtx->sMb.pSliceIdc[i], "pCtx->sMb.pSliceIdc[]"); |
| 1448 | 1463 | ||
| 1449 | pCtx->sMb.pSliceIdc[i] = NULL; | 1464 | pCtx->sMb.pSliceIdc[i] = NULL; |
| 1450 | } | 1465 | } |
| 1451 | 1466 | ||
| 1452 | if (pCtx->sMb.pResidualPredFlag[i]) { | 1467 | if (pCtx->sMb.pResidualPredFlag[i]) { |
| 1453 | WelsFree (pCtx->sMb.pResidualPredFlag[i], "pCtx->sMb.pResidualPredFlag[]"); | 1468 | pMa->WelsFree (pCtx->sMb.pResidualPredFlag[i], "pCtx->sMb.pResidualPredFlag[]"); |
| 1454 | 1469 | ||
| 1455 | pCtx->sMb.pResidualPredFlag[i] = NULL; | 1470 | pCtx->sMb.pResidualPredFlag[i] = NULL; |
| 1456 | } | 1471 | } |
| 1457 | 1472 | ||
| 1458 | if (pCtx->sMb.pInterPredictionDoneFlag[i]) { | 1473 | if (pCtx->sMb.pInterPredictionDoneFlag[i]) { |
| 1459 | WelsFree (pCtx->sMb.pInterPredictionDoneFlag[i], "pCtx->sMb.pInterPredictionDoneFlag[]"); | 1474 | pMa->WelsFree (pCtx->sMb.pInterPredictionDoneFlag[i], "pCtx->sMb.pInterPredictionDoneFlag[]"); |
| 1460 | 1475 | ||
| 1461 | pCtx->sMb.pInterPredictionDoneFlag[i] = NULL; | 1476 | pCtx->sMb.pInterPredictionDoneFlag[i] = NULL; |
| 1462 | } | 1477 | } |
| 1463 | 1478 | ||
| 1464 | if (pCtx->sMb.pMbCorrectlyDecodedFlag[i]) { | 1479 | if (pCtx->sMb.pMbCorrectlyDecodedFlag[i]) { |
| 1465 | WelsFree (pCtx->sMb.pMbCorrectlyDecodedFlag[i], "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); | 1480 | pMa->WelsFree (pCtx->sMb.pMbCorrectlyDecodedFlag[i], "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); |
| 1466 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = NULL; | 1481 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = NULL; |
| 1467 | } | 1482 | } |
| 1468 | 1483 | ||
| 1469 | if (pCtx->sMb.pMbRefConcealedFlag[i]) { | 1484 | if (pCtx->sMb.pMbRefConcealedFlag[i]) { |
| 1470 | WelsFree (pCtx->sMb.pMbRefConcealedFlag[i], "pCtx->sMb.pMbRefConcealedFlag[]"); | 1485 | pMa->WelsFree (pCtx->sMb.pMbRefConcealedFlag[i], "pCtx->sMb.pMbRefConcealedFlag[]"); |
| 1471 | pCtx->sMb.pMbRefConcealedFlag[i] = NULL; | 1486 | pCtx->sMb.pMbRefConcealedFlag[i] = NULL; |
| 1472 | } | 1487 | } |
| 1473 | WelsFree (pDq, "pDq"); | 1488 | pMa->WelsFree (pDq, "pDq"); |
| 1474 | 1489 | ||
| 1475 | pDq = NULL; | 1490 | pDq = NULL; |
| 1476 | pCtx->pDqLayersList[i] = NULL; | 1491 | pCtx->pDqLayersList[i] = NULL; |
| @@ -2184,7 +2199,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 707 unmodified lines | |||
| 2184 | pLayerInfo.pSubsetSps = pShExt->pSubsetSps; | 2199 | pLayerInfo.pSubsetSps = pShExt->pSubsetSps; |
| 2185 | 2200 | ||
| 2186 | pCtx->pFmo = &pCtx->sFmoList[iPpsId]; | 2201 | pCtx->pFmo = &pCtx->sFmoList[iPpsId]; |
| 2187 | if (!FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum)) { | 2202 | if (!FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum, pCtx->pMemAlign)) { |
| 2188 | pCtx->iErrorCode |= dsBitstreamError; | 2203 | pCtx->iErrorCode |= dsBitstreamError; |
| 2189 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeCurrentAccessUnit(), FmoParamUpdate failed, eSliceType: %d.", | 2204 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeCurrentAccessUnit(), FmoParamUpdate failed, eSliceType: %d.", |
| 2190 | pSh->eSliceType); | 2205 | pSh->eSliceType); |
| @@ -2192,7 +2207,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1 unmodified line | |||
| 2192 | } | 2207 | } |
| 2193 | 2208 | ||
| 2194 | bFreshSliceAvailable = (iCurrIdD != iLastIdD | 2209 | bFreshSliceAvailable = (iCurrIdD != iLastIdD |
| 2195 | || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder | 2210 | || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder |
| 2196 | 2211 | ||
| 2197 | WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps); | 2212 | WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps); |
| 2198 | 2213 | ||
| @@ -116,7 +116,7 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in · 115 unmodified lines | |||
| 116 | * \return 0 - successful; none 0 - failed | 116 | * \return 0 - successful; none 0 - failed |
| 117 | */ | 117 | */ |
| 118 | static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, | 118 | static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, |
| 119 | const int32_t kiMbHeight) { | 119 | const int32_t kiMbHeight, CMemoryAlign* pMa) { |
| 120 | int32_t iNumMb = 0; | 120 | int32_t iNumMb = 0; |
| 121 | int32_t iErr = 0; | 121 | int32_t iErr = 0; |
| 122 | bool bResolutionChanged = false; | 122 | bool bResolutionChanged = false; |
| @@ -131,9 +131,8 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const · 8 unmodified lines | |||
| 131 | if (0 == iNumMb) | 131 | if (0 == iNumMb) |
| 132 | return 1; | 132 | return 1; |
| 133 | 133 | ||
| 134 | 134 | pMa->WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap"); | |
| 135 | WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap"); | 135 | pFmo->pMbAllocMap = (uint8_t*)pMa->WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap"); |
| 136 | pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap"); | ||
| 137 | WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory | 136 | WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory |
| 138 | 137 | ||
| 139 | pFmo->iCountMbNum = iNumMb; | 138 | pFmo->iCountMbNum = iNumMb; |
| @@ -186,8 +185,8 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const · 46 unmodified lines | |||
| 186 | * | 185 | * |
| 187 | * \return 0 - successful; none 0 - failed; | 186 | * \return 0 - successful; none 0 - failed; |
| 188 | */ | 187 | */ |
| 189 | int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight) { | 188 | int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight, CMemoryAlign* pMa) { |
| 190 | return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight); | 189 | return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight, pMa); |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | 192 | ||
| @@ -200,7 +199,7 @@ int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki · 6 unmodified lines | |||
| 200 | * | 199 | * |
| 201 | * \return NONE | 200 | * \return NONE |
| 202 | */ | 201 | */ |
| 203 | void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) { | 202 | void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail, CMemoryAlign* pMa) { |
| 204 | PFmo pIter = pFmo; | 203 | PFmo pIter = pFmo; |
| 205 | int32_t i = 0; | 204 | int32_t i = 0; |
| 206 | int32_t iFreeNodes = 0; | 205 | int32_t iFreeNodes = 0; |
| @@ -211,7 +210,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) { · 4 unmodified lines | |||
| 211 | while (i < kiCnt) { | 210 | while (i < kiCnt) { |
| 212 | if (pIter != NULL && pIter->bActiveFlag) { | 211 | if (pIter != NULL && pIter->bActiveFlag) { |
| 213 | if (NULL != pIter->pMbAllocMap) { | 212 | if (NULL != pIter->pMbAllocMap) { |
| 214 | WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap"); | 213 | pMa->WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap"); |
| 215 | 214 | ||
| 216 | pIter->pMbAllocMap = NULL; | 215 | pIter->pMbAllocMap = NULL; |
| 217 | } | 216 | } |
| @@ -258,7 +257,7 @@ bool FmoParamSetsChanged (PFmo pFmo, const int32_t kiCountNumMb, const int32_t k · 40 unmodified lines | |||
| 258 | * | 257 | * |
| 259 | * \return true - update/insert successfully; false - failed; | 258 | * \return true - update/insert successfully; false - failed; |
| 260 | */ | 259 | */ |
| 261 | bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) { | 260 | bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum, CMemoryAlign* pMa) { |
| 262 | const uint32_t kuiMbWidth = pSps->iMbWidth; | 261 | const uint32_t kuiMbWidth = pSps->iMbWidth; |
| 263 | const uint32_t kuiMbHeight = pSps->iMbHeight; | 262 | const uint32_t kuiMbHeight = pSps->iMbHeight; |
| 264 | 263 | ||
| @@ -267,7 +266,7 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) { · 2 unmodified lines | |||
| 267 | pPps->uiSliceGroupMapType, | 266 | pPps->uiSliceGroupMapType, |
| 268 | pPps->uiNumSliceGroups)) { | 267 | pPps->uiNumSliceGroups)) { |
| 269 | 268 | ||
| 270 | if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight)) { | 269 | if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight, pMa)) { |
| 271 | return false; | 270 | return false; |
| 272 | } else { | 271 | } else { |
| 273 | if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) { | 272 | if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) { |
| @@ -43,7 +43,7 @@ · 42 unmodified lines | |||
| 43 | 43 | ||
| 44 | namespace WelsDec { | 44 | namespace WelsDec { |
| 45 | 45 | ||
| 46 | int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { | 46 | int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa) { |
| 47 | uint32_t uiIdx = 0; | 47 | uint32_t uiIdx = 0; |
| 48 | uint8_t* pBase = NULL, *pPtr = NULL; | 48 | uint8_t* pBase = NULL, *pPtr = NULL; |
| 49 | const uint32_t kuiSizeAu = sizeof (SAccessUnit); | 49 | const uint32_t kuiSizeAu = sizeof (SAccessUnit); |
| @@ -55,10 +55,10 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { · 5 unmodified lines | |||
| 55 | return 1; | 55 | return 1; |
| 56 | 56 | ||
| 57 | if (*ppAu != NULL) { | 57 | if (*ppAu != NULL) { |
| 58 | MemFreeNalList (ppAu); | 58 | MemFreeNalList (ppAu, pMa); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | pBase = (uint8_t*)WelsMallocz (kuiCountSize, "Access Unit"); | 61 | pBase = (uint8_t*)pMa->WelsMallocz (kuiCountSize, "Access Unit"); |
| 62 | if (pBase == NULL) | 62 | if (pBase == NULL) |
| 63 | return 1; | 63 | return 1; |
| 64 | pPtr = pBase; | 64 | pPtr = pBase; |
| @@ -82,11 +82,11 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { · 17 unmodified lines | |||
| 82 | return 0; | 82 | return 0; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | int32_t MemFreeNalList (PAccessUnit* ppAu) { | 85 | int32_t MemFreeNalList (PAccessUnit* ppAu, CMemoryAlign* pMa) { |
| 86 | if (ppAu != NULL) { | 86 | if (ppAu != NULL) { |
| 87 | PAccessUnit pAu = *ppAu; | 87 | PAccessUnit pAu = *ppAu; |
| 88 | if (pAu != NULL) { | 88 | if (pAu != NULL) { |
| 89 | WelsFree (pAu, "Access Unit"); | 89 | pMa->WelsFree (pAu, "Access Unit"); |
| 90 | *ppAu = NULL; | 90 | *ppAu = NULL; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| @@ -94,14 +94,14 @@ int32_t MemFreeNalList (PAccessUnit* ppAu) { · 1 unmodified line | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize) { | 97 | int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize, CMemoryAlign* pMa) { |
| 98 | if (kiExpSize <= kiOrgSize) | 98 | if (kiExpSize <= kiOrgSize) |
| 99 | return 1; | 99 | return 1; |
| 100 | else { | 100 | else { |
| 101 | PAccessUnit pTmp = NULL; | 101 | PAccessUnit pTmp = NULL; |
| 102 | int32_t iIdx = 0; | 102 | int32_t iIdx = 0; |
| 103 | 103 | ||
| 104 | if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding | 104 | if (MemInitNalList (&pTmp, kiExpSize, pMa)) // request new list with expanding |
| 105 | return 1; | 105 | return 1; |
| 106 | 106 | ||
| 107 | do { | 107 | do { |
| @@ -115,7 +115,7 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int · 7 unmodified lines | |||
| 115 | pTmp->uiEndPos = (*ppAu)->uiEndPos; | 115 | pTmp->uiEndPos = (*ppAu)->uiEndPos; |
| 116 | pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag; | 116 | pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag; |
| 117 | 117 | ||
| 118 | MemFreeNalList (ppAu); // free old list | 118 | MemFreeNalList (ppAu, pMa); // free old list |
| 119 | *ppAu = pTmp; | 119 | *ppAu = pTmp; |
| 120 | return 0; | 120 | return 0; |
| 121 | } | 121 | } |
| @@ -126,13 +126,13 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int · 4 unmodified lines | |||
| 126 | * Get next NAL Unit for using. | 126 | * Get next NAL Unit for using. |
| 127 | * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit | 127 | * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit |
| 128 | */ | 128 | */ |
| 129 | PNalUnit MemGetNextNal (PAccessUnit* ppAu) { | 129 | PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa) { |
| 130 | PAccessUnit pAu = *ppAu; | 130 | PAccessUnit pAu = *ppAu; |
| 131 | PNalUnit pNu = NULL; | 131 | PNalUnit pNu = NULL; |
| 132 | 132 | ||
| 133 | if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list | 133 | if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list |
| 134 | const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1); | 134 | const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1); |
| 135 | if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize)) | 135 | if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize, pMa)) |
| 136 | return NULL; // out of memory | 136 | return NULL; // out of memory |
| 137 | pAu = *ppAu; | 137 | pAu = *ppAu; |
| 138 | } | 138 | } |
| @@ -44,7 +44,7 @@ · 43 unmodified lines | |||
| 44 | 44 | ||
| 45 | namespace WelsDec { | 45 | namespace WelsDec { |
| 46 | 46 | ||
| 47 | void FreePicture (PPicture pPic); | 47 | void FreePicture (PPicture pPic, CMemoryAlign* pMa); |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | ///////////////////////////////////Recycled queue management for pictures/////////////////////////////////// | 50 | ///////////////////////////////////Recycled queue management for pictures/////////////////////////////////// |
| @@ -68,8 +68,9 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 17 unmodified lines | |||
| 68 | int32_t iPicChromaHeight = 0; | 68 | int32_t iPicChromaHeight = 0; |
| 69 | int32_t iLumaSize = 0; | 69 | int32_t iLumaSize = 0; |
| 70 | int32_t iChromaSize = 0; | 70 | int32_t iChromaSize = 0; |
| 71 | CMemoryAlign* pMa = pCtx->pMemAlign; | ||
| 71 | 72 | ||
| 72 | pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture"); | 73 | pPic = (PPicture) pMa->WelsMallocz (sizeof (SPicture), "PPicture"); |
| 73 | WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); | 74 | WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); |
| 74 | 75 | ||
| 75 | memset (pPic, 0, sizeof (SPicture)); | 76 | memset (pPic, 0, sizeof (SPicture)); |
| @@ -88,9 +89,9 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 12 unmodified lines | |||
| 88 | pPic->iLinesize[0] = iPicWidth; | 89 | pPic->iLinesize[0] = iPicWidth; |
| 89 | pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; | 90 | pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; |
| 90 | } else { | 91 | } else { |
| 91 | pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */ | 92 | pPic->pBuffer[0] = static_cast<uint8_t*> (pMa->WelsMallocz (iLumaSize /* luma */ |
| 92 | + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]")); | 93 | + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]")); |
| 93 | WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic)); | 94 | WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic, pMa)); |
| 94 | 95 | ||
| 95 | memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1))); | 96 | memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1))); |
| 96 | pPic->iLinesize[0] = iPicWidth; | 97 | pPic->iLinesize[0] = iPicWidth; |
| @@ -110,14 +111,14 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 13 unmodified lines | |||
| 110 | return pPic; | 111 | return pPic; |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | void FreePicture (PPicture pPic) { | 114 | void FreePicture (PPicture pPic, CMemoryAlign* pMa) { |
| 114 | if (NULL != pPic) { | 115 | if (NULL != pPic) { |
| 115 | 116 | ||
| 116 | if (pPic->pBuffer[0]) { | 117 | if (pPic->pBuffer[0]) { |
| 117 | WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]"); | 118 | pMa->WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]"); |
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | WelsFree (pPic, "pPic"); | 121 | pMa->WelsFree (pPic, "pPic"); |
| 121 | 122 | ||
| 122 | pPic = NULL; | 123 | pPic = NULL; |
| 123 | } | 124 | } |
| @@ -219,11 +219,19 @@ void CWelsDecoder::UninitDecoder (void) { · 218 unmodified lines | |||
| 219 | if (NULL == m_pDecContext) | 219 | if (NULL == m_pDecContext) |
| 220 | return; | 220 | return; |
| 221 | 221 | ||
| 222 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::uninit_decoder(), openh264 codec version = %s.", | 222 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoder(), openh264 codec version = %s.", |
| 223 | VERSION_NUMBER); | 223 | VERSION_NUMBER); |
| 224 | 224 | ||
| 225 | WelsEndDecoder (m_pDecContext); | 225 | WelsEndDecoder (m_pDecContext); |
| 226 | 226 | ||
| 227 | if (m_pDecContext->pMemAlign != NULL) { | ||
| 228 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, | ||
| 229 | "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..", | ||
| 230 | m_pDecContext->pMemAlign->WelsGetMemoryUsage()); | ||
| 231 | delete m_pDecContext->pMemAlign; | ||
| 232 | m_pDecContext->pMemAlign = NULL; | ||
| 233 | } | ||
| 234 | |||
| 227 | if (NULL != m_pDecContext) { | 235 | if (NULL != m_pDecContext) { |
| 228 | WelsFree (m_pDecContext, "m_pDecContext"); | 236 | WelsFree (m_pDecContext, "m_pDecContext"); |
| 229 | 237 | ||
| @@ -243,6 +251,9 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) { · 13 unmodified lines | |||
| 243 | m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); | 251 | m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); |
| 244 | if (NULL == m_pDecContext) | 252 | if (NULL == m_pDecContext) |
| 245 | return cmMallocMemeError; | 253 | return cmMallocMemeError; |
| 254 | int32_t iCacheLineSize = 16; // on chip cache line size in byte | ||
| 255 | m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize); | ||
| 256 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == m_pDecContext->pMemAlign), UninitDecoder()) | ||
| 246 | 257 | ||
| 247 | return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx); | 258 | return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx); |
| 248 | } | 259 | } |
| @@ -409,10 +420,10 @@ DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc, · 160 unmodified lines | |||
| 409 | //ppTmpDst[2] = ppDst[2]; | 420 | //ppTmpDst[2] = ppDst[2]; |
| 410 | iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo); | 421 | iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo); |
| 411 | //if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) { | 422 | //if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) { |
| 412 | //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo)); | 423 | //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo)); |
| 413 | //ppDst[0] = ppTmpDst[0]; | 424 | //ppDst[0] = ppTmpDst[0]; |
| 414 | //ppDst[1] = ppTmpDst[1]; | 425 | //ppDst[1] = ppTmpDst[1]; |
| 415 | //ppDst[2] = ppTmpDst[2]; | 426 | //ppDst[2] = ppTmpDst[2]; |
| 416 | //} | 427 | //} |
| 417 | 428 | ||
| 418 | return (DECODING_STATE) iRet; | 429 | return (DECODING_STATE) iRet; |