Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 54 files). Show all
Unified · Split
| @@ -450,7 +450,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 449 unmodified lines | |||
| 450 | WelsLog (pLogCtx, WELS_LOG_DEBUG, | 450 | WelsLog (pLogCtx, WELS_LOG_DEBUG, |
| 451 | "ParamValidationExt(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!", | 451 | "ParamValidationExt(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!", |
| 452 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum); | 452 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum); |
| 453 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 453 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 454 | break; | 454 | break; |
| 455 | } | 455 | } |
| 456 | if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom | 456 | if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom |
| @@ -477,8 +477,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 20 unmodified lines | |||
| 477 | } | 477 | } |
| 478 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting | 478 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 479 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { | 479 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 480 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 480 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 481 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; | 481 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; |
| 482 | break; | 482 | break; |
| 483 | } | 483 | } |
| 484 | } | 484 | } |
| @@ -515,7 +515,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 30 unmodified lines | |||
| 515 | if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum == 1) { | 515 | if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum == 1) { |
| 516 | WelsLog (pLogCtx, WELS_LOG_WARNING, | 516 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 517 | "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!"); | 517 | "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!"); |
| 518 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 518 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 519 | break; | 519 | break; |
| 520 | } | 520 | } |
| 521 | if ((pCodingParam->iRCMode != RC_OFF_MODE) && pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1) { | 521 | if ((pCodingParam->iRCMode != RC_OFF_MODE) && pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum > 1) { |
| @@ -523,8 +523,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 1 unmodified line | |||
| 523 | } | 523 | } |
| 524 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting | 524 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 525 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { | 525 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 526 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 526 | pSpatialLayer->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 527 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; | 527 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = 1; |
| 528 | break; | 528 | break; |
| 529 | } | 529 | } |
| 530 | } | 530 | } |
| @@ -540,7 +540,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 9 unmodified lines | |||
| 540 | iMbHeight, MAX_SLICES_NUM); | 540 | iMbHeight, MAX_SLICES_NUM); |
| 541 | return ENC_RETURN_UNSUPPORTED_PARA; | 541 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 542 | } | 542 | } |
| 543 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight; | 543 | pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight; |
| 544 | 544 | ||
| 545 | if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0) { | 545 | if (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum <= 0) { |
| 546 | WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!", | 546 | WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!", |
| @@ -682,7 +682,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 135 unmodified lines | |||
| 682 | if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx) | 682 | if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx) |
| 683 | return 1; | 683 | return 1; |
| 684 | 684 | ||
| 685 | iNumDependencyLayers = pParam->iSpatialLayerNum; | 685 | iNumDependencyLayers = pParam->iSpatialLayerNum; |
| 686 | 686 | ||
| 687 | do { | 687 | do { |
| 688 | SSpatialLayerConfig* pDLayer = &pParam->sSpatialLayers[iDIndex]; | 688 | SSpatialLayerConfig* pDLayer = &pParam->sSpatialLayers[iDIndex]; |
| @@ -748,7 +748,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 59 unmodified lines | |||
| 748 | if (NULL != pCountLayers) | 748 | if (NULL != pCountLayers) |
| 749 | *pCountLayers = iCountNumLayers; | 749 | *pCountLayers = iCountNumLayers; |
| 750 | if (NULL != pCountNals) | 750 | if (NULL != pCountNals) |
| 751 | *pCountNals = iCountNumNals; | 751 | *pCountNals = iCountNumNals; |
| 752 | return 0; | 752 | return 0; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| @@ -874,7 +874,7 @@ int32_t AllocMbCacheAligned (SMbCache* pMbCache, CMemoryAlign* pMa) { · 119 unmodified lines | |||
| 874 | pMbCache->pPrevIntra4x4PredModeFlag = (bool*)pMa->WelsMalloc (16 * sizeof (bool), | 874 | pMbCache->pPrevIntra4x4PredModeFlag = (bool*)pMa->WelsMalloc (16 * sizeof (bool), |
| 875 | "pMbCache->pPrevIntra4x4PredModeFlag"); | 875 | "pMbCache->pPrevIntra4x4PredModeFlag"); |
| 876 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pPrevIntra4x4PredModeFlag)); | 876 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pPrevIntra4x4PredModeFlag)); |
| 877 | pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t), | 877 | pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t), |
| 878 | "pMbCache->pRemIntra4x4PredModeFlag"); | 878 | "pMbCache->pRemIntra4x4PredModeFlag"); |
| 879 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pRemIntra4x4PredModeFlag)); | 879 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pRemIntra4x4PredModeFlag)); |
| 880 | pMbCache->pDct = (SDCTCoeff*)pMa->WelsMalloc (sizeof (SDCTCoeff), "pMbCache->pDct"); | 880 | pMbCache->pDct = (SDCTCoeff*)pMa->WelsMalloc (sizeof (SDCTCoeff), "pMbCache->pDct"); |
| @@ -1001,7 +1001,7 @@ int32_t FindExistingSps (SWelsSvcCodingParam* pParam, const bool kbUseSubsetSps, · 120 unmodified lines | |||
| 1001 | const int32_t iDlayerCount, const int32_t iSpsNumInUse, | 1001 | const int32_t iDlayerCount, const int32_t iSpsNumInUse, |
| 1002 | SWelsSPS* pSpsArray, | 1002 | SWelsSPS* pSpsArray, |
| 1003 | SSubsetSps* pSubsetArray, bool bSVCBaseLayer) { | 1003 | SSubsetSps* pSubsetArray, bool bSVCBaseLayer) { |
| 1004 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; | 1004 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; |
| 1005 | 1005 | ||
| 1006 | assert (iSpsNumInUse <= MAX_SPS_COUNT); | 1006 | assert (iSpsNumInUse <= MAX_SPS_COUNT); |
| 1007 | if (!kbUseSubsetSps) { | 1007 | if (!kbUseSubsetSps) { |
| @@ -1096,7 +1096,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 88 unmodified lines | |||
| 1096 | const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME) ? 0 : | 1096 | const int32_t kiNeedFeatureStorage = (pParam->iUsageType != SCREEN_CONTENT_REAL_TIME) ? 0 : |
| 1097 | ((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF)); | 1097 | ((kiFeatureStrategyIndex << 16) + ((kiMe16x16 & 0x00FF) << 8) + (kiMe8x8 & 0x00FF)); |
| 1098 | 1098 | ||
| 1099 | iDlayerIndex = 0; | 1099 | iDlayerIndex = 0; |
| 1100 | while (iDlayerIndex < iDlayerCount) { | 1100 | while (iDlayerIndex < iDlayerCount) { |
| 1101 | SRefList* pRefList = NULL; | 1101 | SRefList* pRefList = NULL; |
| 1102 | uint32_t i = 0; | 1102 | uint32_t i = 0; |
| @@ -1111,21 +1111,21 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 8 unmodified lines | |||
| 1111 | WelsGetEncBlockStrideOffset ((*ppCtx)->pStrideTab->pStrideEncBlockOffset[iDlayerIndex], iPicWidth, iPicChromaWidth); | 1111 | WelsGetEncBlockStrideOffset ((*ppCtx)->pStrideTab->pStrideEncBlockOffset[iDlayerIndex], iPicWidth, iPicChromaWidth); |
| 1112 | 1112 | ||
| 1113 | // pRef list | 1113 | // pRef list |
| 1114 | pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList"); | 1114 | pRefList = (SRefList*)pMa->WelsMallocz (sizeof (SRefList), "pRefList"); |
| 1115 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx)) | 1115 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList), FreeMemorySvc (ppCtx)) |
| 1116 | do { | 1116 | do { |
| 1117 | pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, | 1117 | pRefList->pRef[i] = AllocPicture (pMa, kiWidth, kiHeight, true, |
| 1118 | (iDlayerIndex == iDlayerCount - 1) ? kiNeedFeatureStorage : 0); // to use actual size of current layer | 1118 | (iDlayerIndex == iDlayerCount - 1) ? kiNeedFeatureStorage : 0); // to use actual size of current layer |
| 1119 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx)) | 1119 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pRefList->pRef[i]), FreeMemorySvc (ppCtx)) |
| 1120 | ++ i; | 1120 | ++ i; |
| 1121 | } while (i < 1 + iNumRef); | 1121 | } while (i < 1 + iNumRef); |
| 1122 | 1122 | ||
| 1123 | pRefList->pNextBuffer = pRefList->pRef[0]; | 1123 | pRefList->pNextBuffer = pRefList->pRef[0]; |
| 1124 | (*ppCtx)->ppRefPicListExt[iDlayerIndex] = pRefList; | 1124 | (*ppCtx)->ppRefPicListExt[iDlayerIndex] = pRefList; |
| 1125 | ++ iDlayerIndex; | 1125 | ++ iDlayerIndex; |
| 1126 | } | 1126 | } |
| 1127 | 1127 | ||
| 1128 | iDlayerIndex = 0; | 1128 | iDlayerIndex = 0; |
| 1129 | while (iDlayerIndex < iDlayerCount) { | 1129 | while (iDlayerIndex < iDlayerCount) { |
| 1130 | SDqLayer* pDqLayer = NULL; | 1130 | SDqLayer* pDqLayer = NULL; |
| 1131 | SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; | 1131 | SSpatialLayerConfig* pDlayer = &pParam->sSpatialLayers[iDlayerIndex]; |
| @@ -1158,8 +1158,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 26 unmodified lines | |||
| 1158 | pDqLayer->iMbWidth = kiMbW; | 1158 | pDqLayer->iMbWidth = kiMbW; |
| 1159 | pDqLayer->iMbHeight = kiMbH; | 1159 | pDqLayer->iMbHeight = kiMbH; |
| 1160 | { | 1160 | { |
| 1161 | int32_t iSliceIdx = 0; | 1161 | int32_t iSliceIdx = 0; |
| 1162 | pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); | 1162 | pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); |
| 1163 | 1163 | ||
| 1164 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx)) | 1164 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx)) |
| 1165 | if (iMaxSliceNum > 1) { | 1165 | if (iMaxSliceNum > 1) { |
| @@ -1201,20 +1201,20 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 35 unmodified lines | |||
| 1201 | if (SM_SINGLE_SLICE == pDlayer->sSliceCfg.uiSliceMode) { | 1201 | if (SM_SINGLE_SLICE == pDlayer->sSliceCfg.uiSliceMode) { |
| 1202 | //iLoopFilterDisableIdc: will be 0 or 1 under single_slice | 1202 | //iLoopFilterDisableIdc: will be 0 or 1 under single_slice |
| 1203 | if (2 == pParam->iLoopFilterDisableIdc) { | 1203 | if (2 == pParam->iLoopFilterDisableIdc) { |
| 1204 | pDqLayer->iLoopFilterDisableIdc = 0; | 1204 | pDqLayer->iLoopFilterDisableIdc = 0; |
| 1205 | } | 1205 | } |
| 1206 | //bDeblockingParallelFlag | 1206 | //bDeblockingParallelFlag |
| 1207 | pDqLayer->bDeblockingParallelFlag = false; | 1207 | pDqLayer->bDeblockingParallelFlag = false; |
| 1208 | } else { | 1208 | } else { |
| 1209 | //multi-pSlice | 1209 | //multi-pSlice |
| 1210 | if (0 == pDqLayer->iLoopFilterDisableIdc) { | 1210 | if (0 == pDqLayer->iLoopFilterDisableIdc) { |
| 1211 | pDqLayer->bDeblockingParallelFlag = false; | 1211 | pDqLayer->bDeblockingParallelFlag = false; |
| 1212 | } | 1212 | } |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | // | 1215 | // |
| 1216 | if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) { | 1216 | if (kiNeedFeatureStorage && iDlayerIndex == iDlayerCount - 1) { |
| 1217 | pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof ( | 1217 | pDqLayer->pFeatureSearchPreparation = static_cast<SFeatureSearchPreparation*> (pMa->WelsMallocz (sizeof ( |
| 1218 | SFeatureSearchPreparation), "pFeatureSearchPreparation")); | 1218 | SFeatureSearchPreparation), "pFeatureSearchPreparation")); |
| 1219 | WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx)); | 1219 | WELS_VERIFY_RETURN_PROC_IF (1, NULL == pDqLayer->pFeatureSearchPreparation, FreeMemorySvc (ppCtx)); |
| 1220 | int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iVideoWidth, pDlayer->iVideoHeight, | 1220 | int32_t iReturn = RequestFeatureSearchPreparation (pMa, pDlayer->iVideoWidth, pDlayer->iVideoHeight, |
| @@ -1225,7 +1225,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 4 unmodified lines | |||
| 1225 | pDqLayer->pFeatureSearchPreparation = NULL; | 1225 | pDqLayer->pFeatureSearchPreparation = NULL; |
| 1226 | } | 1226 | } |
| 1227 | 1227 | ||
| 1228 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; | 1228 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; |
| 1229 | 1229 | ||
| 1230 | ++ iDlayerIndex; | 1230 | ++ iDlayerIndex; |
| 1231 | } | 1231 | } |
| @@ -1233,10 +1233,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 1 unmodified line | |||
| 1233 | // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010 | 1233 | // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010 |
| 1234 | const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum(); | 1234 | const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum(); |
| 1235 | const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum(); | 1235 | const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum(); |
| 1236 | (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray"); | 1236 | (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray"); |
| 1237 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx)) | 1237 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx)) |
| 1238 | if (kiNeededSubsetSpsNum > 0) { | 1238 | if (kiNeededSubsetSpsNum > 0) { |
| 1239 | (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray"); | 1239 | (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray"); |
| 1240 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx)) | 1240 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx)) |
| 1241 | } else { | 1241 | } else { |
| 1242 | (*ppCtx)->pSubsetArray = NULL; | 1242 | (*ppCtx)->pSubsetArray = NULL; |
| @@ -1256,7 +1256,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 13 unmodified lines | |||
| 1256 | 1256 | ||
| 1257 | // PPS | 1257 | // PPS |
| 1258 | const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum(); | 1258 | const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum(); |
| 1259 | (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray"); | 1259 | (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray"); |
| 1260 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx)) | 1260 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx)) |
| 1261 | 1261 | ||
| 1262 | // copy from existing if the pointer exists | 1262 | // copy from existing if the pointer exists |
| @@ -1272,17 +1272,17 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 9 unmodified lines | |||
| 1272 | (*ppCtx)->pPSOVector = NULL; | 1272 | (*ppCtx)->pPSOVector = NULL; |
| 1273 | } | 1273 | } |
| 1274 | 1274 | ||
| 1275 | (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap"); | 1275 | (*ppCtx)->pDqIdcMap = (SDqIdc*)pMa->WelsMallocz (iDlayerCount * sizeof (SDqIdc), "pDqIdcMap"); |
| 1276 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pDqIdcMap), FreeMemorySvc (ppCtx)) | 1276 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pDqIdcMap), FreeMemorySvc (ppCtx)) |
| 1277 | 1277 | ||
| 1278 | iDlayerIndex = 0; | 1278 | iDlayerIndex = 0; |
| 1279 | while (iDlayerIndex < iDlayerCount) { | 1279 | while (iDlayerIndex < iDlayerCount) { |
| 1280 | SDqIdc* pDqIdc = & (*ppCtx)->pDqIdcMap[iDlayerIndex]; | 1280 | SDqIdc* pDqIdc = & (*ppCtx)->pDqIdcMap[iDlayerIndex]; |
| 1281 | const bool bUseSubsetSps = (!pParam->bSimulcastAVC) && (iDlayerIndex > BASE_DEPENDENCY_ID); | 1281 | const bool bUseSubsetSps = (!pParam->bSimulcastAVC) && (iDlayerIndex > BASE_DEPENDENCY_ID); |
| 1282 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; | 1282 | SSpatialLayerConfig* pDlayerParam = &pParam->sSpatialLayers[iDlayerIndex]; |
| 1283 | bool bSvcBaselayer = (!pParam->bSimulcastAVC) && (iDlayerCount > BASE_DEPENDENCY_ID) | 1283 | bool bSvcBaselayer = (!pParam->bSimulcastAVC) && (iDlayerCount > BASE_DEPENDENCY_ID) |
| 1284 | && (iDlayerIndex == BASE_DEPENDENCY_ID); | 1284 | && (iDlayerIndex == BASE_DEPENDENCY_ID); |
| 1285 | pDqIdc->uiSpatialId = iDlayerIndex; | 1285 | pDqIdc->uiSpatialId = iDlayerIndex; |
| 1286 | 1286 | ||
| 1287 | if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) { | 1287 | if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) { |
| 1288 | WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex, | 1288 | WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex, |
| @@ -1337,7 +1337,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 48 unmodified lines | |||
| 1337 | } | 1337 | } |
| 1338 | 1338 | ||
| 1339 | if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) { | 1339 | if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) { |
| 1340 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; | 1340 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; |
| 1341 | // initialize pPps | 1341 | // initialize pPps |
| 1342 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); | 1342 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); |
| 1343 | } else { | 1343 | } else { |
| @@ -1353,7 +1353,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 9 unmodified lines | |||
| 1353 | pPps = & ((*ppCtx)->pPPSArray[kiFoundPpsId]); | 1353 | pPps = & ((*ppCtx)->pPPSArray[kiFoundPpsId]); |
| 1354 | } else { | 1354 | } else { |
| 1355 | iPpsId = ((*ppCtx)->sPSOVector.uiInUsePpsNum++); | 1355 | iPpsId = ((*ppCtx)->sPSOVector.uiInUsePpsNum++); |
| 1356 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; | 1356 | pPps = & (*ppCtx)->pPPSArray[iPpsId]; |
| 1357 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); | 1357 | WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0); |
| 1358 | } | 1358 | } |
| 1359 | } | 1359 | } |
| @@ -1372,10 +1372,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 12 unmodified lines | |||
| 1372 | FreeMemorySvc (ppCtx); | 1372 | FreeMemorySvc (ppCtx); |
| 1373 | return iResult; | 1373 | return iResult; |
| 1374 | } | 1374 | } |
| 1375 | (*ppCtx)->ppDqLayerList[iDlayerIndex]->pSliceEncCtx = & (*ppCtx)->pSliceCtxList[iDlayerIndex]; | 1375 | (*ppCtx)->ppDqLayerList[iDlayerIndex]->pSliceEncCtx = & (*ppCtx)->pSliceCtxList[iDlayerIndex]; |
| 1376 | } | 1376 | } |
| 1377 | pDqIdc->iSpsId = iSpsId; | 1377 | pDqIdc->iSpsId = iSpsId; |
| 1378 | pDqIdc->iPpsId = iPpsId; | 1378 | pDqIdc->iPpsId = iPpsId; |
| 1379 | 1379 | ||
| 1380 | (*ppCtx)->sPSOVector.bPpsIdMappingIntoSubsetsps[iPpsId] = bUseSubsetSps; | 1380 | (*ppCtx)->sPSOVector.bPpsIdMappingIntoSubsetsps[iPpsId] = bUseSubsetSps; |
| 1381 | 1381 | ||
| @@ -1438,7 +1438,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 56 unmodified lines | |||
| 1438 | return 1; | 1438 | return 1; |
| 1439 | (*ppCtx)->pStrideTab = pPtr; | 1439 | (*ppCtx)->pStrideTab = pPtr; |
| 1440 | 1440 | ||
| 1441 | iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1; | 1441 | iCntTid = pParam->iTemporalLayerNum > 1 ? 2 : 1; |
| 1442 | 1442 | ||
| 1443 | iSpatialIdx = 0; | 1443 | iSpatialIdx = 0; |
| 1444 | while (iSpatialIdx < kiNumSpatialLayers) { | 1444 | while (iSpatialIdx < kiNumSpatialLayers) { |
| @@ -1459,11 +1459,11 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 14 unmodified lines | |||
| 1459 | // Adaptive size_cs, size_fdec by implementation dependency | 1459 | // Adaptive size_cs, size_fdec by implementation dependency |
| 1460 | iTemporalIdx = 0; | 1460 | iTemporalIdx = 0; |
| 1461 | while (iTemporalIdx < iCntTid) { | 1461 | while (iTemporalIdx < iCntTid) { |
| 1462 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); | 1462 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); |
| 1463 | 1463 | ||
| 1464 | iSpatialIdx = 0; | 1464 | iSpatialIdx = 0; |
| 1465 | while (iSpatialIdx < kiNumSpatialLayers) { | 1465 | while (iSpatialIdx < kiNumSpatialLayers) { |
| 1466 | SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iSpatialIdx]; | 1466 | SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iSpatialIdx]; |
| 1467 | 1467 | ||
| 1468 | const int32_t kiWidthPad = WELS_ALIGN (fDlp->iVideoWidth, 16) + (PADDING_LENGTH << 1); | 1468 | const int32_t kiWidthPad = WELS_ALIGN (fDlp->iVideoWidth, 16) + (PADDING_LENGTH << 1); |
| 1469 | iLineSizeY[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN (kiWidthPad, 32); | 1469 | iLineSizeY[iSpatialIdx][kbBaseTemporalFlag] = WELS_ALIGN (kiWidthPad, 32); |
| @@ -1492,7 +1492,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 22 unmodified lines | |||
| 1492 | 1492 | ||
| 1493 | iTemporalIdx = 0; | 1493 | iTemporalIdx = 0; |
| 1494 | while (iTemporalIdx < iCntTid) { | 1494 | while (iTemporalIdx < iCntTid) { |
| 1495 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); | 1495 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); |
| 1496 | 1496 | ||
| 1497 | iSpatialIdx = 0; | 1497 | iSpatialIdx = 0; |
| 1498 | while (iSpatialIdx < iCountLayersNeedCs[kbBaseTemporalFlag]) { | 1498 | while (iSpatialIdx < iCountLayersNeedCs[kbBaseTemporalFlag]) { |
| @@ -1502,7 +1502,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 3 unmodified lines | |||
| 1502 | 1502 | ||
| 1503 | WelsGetEncBlockStrideOffset ((int32_t*)pBaseDec, kiLumaWidth, kiChromaWidth); | 1503 | WelsGetEncBlockStrideOffset ((int32_t*)pBaseDec, kiLumaWidth, kiChromaWidth); |
| 1504 | 1504 | ||
| 1505 | pPtr->pStrideDecBlockOffset[kiActualSpatialIdx][kbBaseTemporalFlag] = (int32_t*)pBaseDec; | 1505 | pPtr->pStrideDecBlockOffset[kiActualSpatialIdx][kbBaseTemporalFlag] = (int32_t*)pBaseDec; |
| 1506 | pBaseDec += kiUnit1Size; | 1506 | pBaseDec += kiUnit1Size; |
| 1507 | 1507 | ||
| 1508 | ++ iSpatialIdx; | 1508 | ++ iSpatialIdx; |
| @@ -1511,7 +1511,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 2 unmodified lines | |||
| 1511 | } | 1511 | } |
| 1512 | iTemporalIdx = 0; | 1512 | iTemporalIdx = 0; |
| 1513 | while (iTemporalIdx < iCntTid) { | 1513 | while (iTemporalIdx < iCntTid) { |
| 1514 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); | 1514 | const bool kbBaseTemporalFlag = (iTemporalIdx == 0); |
| 1515 | 1515 | ||
| 1516 | iSpatialIdx = 0; | 1516 | iSpatialIdx = 0; |
| 1517 | while (iSpatialIdx < kiNumSpatialLayers) { | 1517 | while (iSpatialIdx < kiNumSpatialLayers) { |
| @@ -1523,12 +1523,12 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 5 unmodified lines | |||
| 1523 | while (i < iCountLayersNeedCs[kbBaseTemporalFlag]) { | 1523 | while (i < iCountLayersNeedCs[kbBaseTemporalFlag]) { |
| 1524 | const int32_t kiActualIdx = iMapSpatialIdx[i][kbBaseTemporalFlag]; | 1524 | const int32_t kiActualIdx = iMapSpatialIdx[i][kbBaseTemporalFlag]; |
| 1525 | if (kiActualIdx == iSpatialIdx) { | 1525 | if (kiActualIdx == iSpatialIdx) { |
| 1526 | bInMap = true; | 1526 | bInMap = true; |
| 1527 | break; | 1527 | break; |
| 1528 | } | 1528 | } |
| 1529 | if (!bMatchFlag) { | 1529 | if (!bMatchFlag) { |
| 1530 | iMatchIndex = kiActualIdx; | 1530 | iMatchIndex = kiActualIdx; |
| 1531 | bMatchFlag = true; | 1531 | bMatchFlag = true; |
| 1532 | } | 1532 | } |
| 1533 | ++ i; | 1533 | ++ i; |
| 1534 | } | 1534 | } |
| @@ -1539,7 +1539,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 4 unmodified lines | |||
| 1539 | } | 1539 | } |
| 1540 | 1540 | ||
| 1541 | // not in spatial map and assign match one to it | 1541 | // not in spatial map and assign match one to it |
| 1542 | pPtr->pStrideDecBlockOffset[iSpatialIdx][kbBaseTemporalFlag] = | 1542 | pPtr->pStrideDecBlockOffset[iSpatialIdx][kbBaseTemporalFlag] = |
| 1543 | pPtr->pStrideDecBlockOffset[iMatchIndex][kbBaseTemporalFlag]; | 1543 | pPtr->pStrideDecBlockOffset[iMatchIndex][kbBaseTemporalFlag]; |
| 1544 | 1544 | ||
| 1545 | ++ iSpatialIdx; | 1545 | ++ iSpatialIdx; |
| @@ -1615,7 +1615,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 69 unmodified lines | |||
| 1615 | } | 1615 | } |
| 1616 | 1616 | ||
| 1617 | memset (pRowY, 0, iRowSize); | 1617 | memset (pRowY, 0, iRowSize); |
| 1618 | iMaxMbHeight = sMbSizeMap[kiNumSpatialLayers - 1].iCountMbNum / sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; | 1618 | iMaxMbHeight = sMbSizeMap[kiNumSpatialLayers - 1].iCountMbNum / sMbSizeMap[kiNumSpatialLayers - 1].iMbWidth; |
| 1619 | i = 0; | 1619 | i = 0; |
| 1620 | for (;;) { | 1620 | for (;;) { |
| 1621 | ENFORCE_STACK_ALIGN_1D (int16_t, t, 4, 16) | 1621 | ENFORCE_STACK_ALIGN_1D (int16_t, t, 4, 16) |
| @@ -1761,18 +1761,18 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 139 unmodified lines | |||
| 1761 | while (iIndex < pParam->iSpatialLayerNum) { | 1761 | while (iIndex < pParam->iSpatialLayerNum) { |
| 1762 | SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iIndex]; | 1762 | SSpatialLayerConfig* fDlp = &pParam->sSpatialLayers[iIndex]; |
| 1763 | 1763 | ||
| 1764 | fCompressRatioThr = COMPRESS_RATIO_THR; | 1764 | fCompressRatioThr = COMPRESS_RATIO_THR; |
| 1765 | 1765 | ||
| 1766 | iLayerBsSize = WELS_ROUND (((3 * fDlp->iVideoWidth * fDlp->iVideoHeight) >> 1) * fCompressRatioThr) + | 1766 | iLayerBsSize = WELS_ROUND (((3 * fDlp->iVideoWidth * fDlp->iVideoHeight) >> 1) * fCompressRatioThr) + |
| 1767 | MAX_MACROBLOCK_SIZE_IN_BYTE_x2; | 1767 | MAX_MACROBLOCK_SIZE_IN_BYTE_x2; |
| 1768 | iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged | 1768 | iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged |
| 1769 | iVclLayersBsSizeCount += iLayerBsSize; | 1769 | iVclLayersBsSizeCount += iLayerBsSize; |
| 1770 | ++ iIndex; | 1770 | ++ iIndex; |
| 1771 | } | 1771 | } |
| 1772 | iTargetSpatialBsSize = iLayerBsSize; | 1772 | iTargetSpatialBsSize = iLayerBsSize; |
| 1773 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; | 1773 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; |
| 1774 | 1774 | ||
| 1775 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, | 1775 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, |
| 1776 | (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | 1776 | (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : |
| 1777 | MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | 1777 | MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); |
| 1778 | 1778 | ||
| @@ -1791,15 +1791,15 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 12 unmodified lines | |||
| 1791 | 1791 | ||
| 1792 | if (pParam->iMultipleThreadIdc > 1) { | 1792 | if (pParam->iMultipleThreadIdc > 1) { |
| 1793 | const int32_t iTotalLength = iCountBsLen + (iTargetSpatialBsSize * ((*ppCtx)->iMaxSliceCount - 1)); | 1793 | const int32_t iTotalLength = iCountBsLen + (iTargetSpatialBsSize * ((*ppCtx)->iMaxSliceCount - 1)); |
| 1794 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); | 1794 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); |
| 1795 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) | 1795 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1796 | (*ppCtx)->iFrameBsSize = iTotalLength; | 1796 | (*ppCtx)->iFrameBsSize = iTotalLength; |
| 1797 | } else { | 1797 | } else { |
| 1798 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); | 1798 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); |
| 1799 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) | 1799 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1800 | (*ppCtx)->iFrameBsSize = iCountBsLen; | 1800 | (*ppCtx)->iFrameBsSize = iCountBsLen; |
| 1801 | } | 1801 | } |
| 1802 | (*ppCtx)->iPosBsBuffer = 0; | 1802 | (*ppCtx)->iPosBsBuffer = 0; |
| 1803 | 1803 | ||
| 1804 | // for pSlice bs buffers | 1804 | // for pSlice bs buffers |
| 1805 | if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iTargetSpatialBsSize)) { | 1805 | if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iTargetSpatialBsSize)) { |
| @@ -1824,12 +1824,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 18 unmodified lines | |||
| 1824 | (pMa->WelsMallocz (iCountMaxMbNum * 2 * MB_BLOCK8x8_NUM * sizeof (int8_t), "pRefIndexBlock4x4")); | 1824 | (pMa->WelsMallocz (iCountMaxMbNum * 2 * MB_BLOCK8x8_NUM * sizeof (int8_t), "pRefIndexBlock4x4")); |
| 1825 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pRefIndexBlock4x4), FreeMemorySvc (ppCtx)) | 1825 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pRefIndexBlock4x4), FreeMemorySvc (ppCtx)) |
| 1826 | 1826 | ||
| 1827 | (*ppCtx)->pSadCostMb = static_cast<int32_t*> | 1827 | (*ppCtx)->pSadCostMb = static_cast<int32_t*> |
| 1828 | (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); | 1828 | (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); |
| 1829 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) | 1829 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) |
| 1830 | 1830 | ||
| 1831 | (*ppCtx)->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR | 1831 | (*ppCtx)->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR |
| 1832 | (*ppCtx)->iGlobalQp = 26; // global qp in default | 1832 | (*ppCtx)->iGlobalQp = 26; // global qp in default |
| 1833 | 1833 | ||
| 1834 | (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState"); | 1834 | (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState"); |
| 1835 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pLtr), FreeMemorySvc (ppCtx)) | 1835 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pLtr), FreeMemorySvc (ppCtx)) |
| @@ -1838,14 +1838,14 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 2 unmodified lines | |||
| 1838 | ResetLtrState (& (*ppCtx)->pLtr[i]); | 1838 | ResetLtrState (& (*ppCtx)->pLtr[i]); |
| 1839 | } | 1839 | } |
| 1840 | 1840 | ||
| 1841 | (*ppCtx)->ppRefPicListExt = (SRefList**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SRefList*), "ppRefPicListExt"); | 1841 | (*ppCtx)->ppRefPicListExt = (SRefList**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SRefList*), "ppRefPicListExt"); |
| 1842 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppRefPicListExt), FreeMemorySvc (ppCtx)) | 1842 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppRefPicListExt), FreeMemorySvc (ppCtx)) |
| 1843 | 1843 | ||
| 1844 | // pSlice context list | 1844 | // pSlice context list |
| 1845 | (*ppCtx)->pSliceCtxList = (SSliceCtx*)pMa->WelsMallocz (kiNumDependencyLayers * sizeof (SSliceCtx), "pSliceCtxList"); | 1845 | (*ppCtx)->pSliceCtxList = (SSliceCtx*)pMa->WelsMallocz (kiNumDependencyLayers * sizeof (SSliceCtx), "pSliceCtxList"); |
| 1846 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceCtxList), FreeMemorySvc (ppCtx)) | 1846 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceCtxList), FreeMemorySvc (ppCtx)) |
| 1847 | 1847 | ||
| 1848 | (*ppCtx)->ppDqLayerList = (SDqLayer**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SDqLayer*), "ppDqLayerList"); | 1848 | (*ppCtx)->ppDqLayerList = (SDqLayer**)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SDqLayer*), "ppDqLayerList"); |
| 1849 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppDqLayerList), FreeMemorySvc (ppCtx)) | 1849 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->ppDqLayerList), FreeMemorySvc (ppCtx)) |
| 1850 | 1850 | ||
| 1851 | // stride tables | 1851 | // stride tables |
| @@ -1863,7 +1863,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 11 unmodified lines | |||
| 1863 | 1863 | ||
| 1864 | //pVaa memory allocation | 1864 | //pVaa memory allocation |
| 1865 | if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { | 1865 | if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { |
| 1866 | (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); | 1866 | (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); |
| 1867 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | 1867 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) |
| 1868 | if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iMaxNumRefFrame, iCountMaxMbNum << 2)) { | 1868 | if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iMaxNumRefFrame, iCountMaxMbNum << 2)) { |
| 1869 | WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); | 1869 | WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); |
| @@ -1871,7 +1871,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 1 unmodified line | |||
| 1871 | return 1; | 1871 | return 1; |
| 1872 | } | 1872 | } |
| 1873 | } else { | 1873 | } else { |
| 1874 | (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); | 1874 | (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); |
| 1875 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | 1875 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) |
| 1876 | } | 1876 | } |
| 1877 | 1877 | ||
| @@ -1939,12 +1939,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 61 unmodified lines | |||
| 1939 | MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? | 1939 | MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? |
| 1940 | 1940 | ||
| 1941 | if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL) | 1941 | if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL) |
| 1942 | (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; | 1942 | (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; |
| 1943 | else | 1943 | else |
| 1944 | (*ppCtx)->pDecPic = NULL; // error here | 1944 | (*ppCtx)->pDecPic = NULL; // error here |
| 1945 | 1945 | ||
| 1946 | (*ppCtx)->pSps = & (*ppCtx)->pSpsArray[0]; | 1946 | (*ppCtx)->pSps = & (*ppCtx)->pSpsArray[0]; |
| 1947 | (*ppCtx)->pPps = & (*ppCtx)->pPPSArray[0]; | 1947 | (*ppCtx)->pPps = & (*ppCtx)->pPPSArray[0]; |
| 1948 | 1948 | ||
| 1949 | return 0; | 1949 | return 0; |
| 1950 | } | 1950 | } |
| @@ -1957,10 +1957,10 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 6 unmodified lines | |||
| 1957 | */ | 1957 | */ |
| 1958 | void FreeMemorySvc (sWelsEncCtx** ppCtx) { | 1958 | void FreeMemorySvc (sWelsEncCtx** ppCtx) { |
| 1959 | if (NULL != *ppCtx) { | 1959 | if (NULL != *ppCtx) { |
| 1960 | sWelsEncCtx* pCtx = *ppCtx; | 1960 | sWelsEncCtx* pCtx = *ppCtx; |
| 1961 | CMemoryAlign* pMa = pCtx->pMemAlign; | 1961 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 1962 | SWelsSvcCodingParam* pParam = pCtx->pSvcParam; | 1962 | SWelsSvcCodingParam* pParam = pCtx->pSvcParam; |
| 1963 | int32_t ilayer = 0; | 1963 | int32_t ilayer = 0; |
| 1964 | 1964 | ||
| 1965 | // SStrideTables | 1965 | // SStrideTables |
| 1966 | if (NULL != pCtx->pStrideTab) { | 1966 | if (NULL != pCtx->pStrideTab) { |
| @@ -2034,12 +2034,12 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 67 unmodified lines | |||
| 2034 | 2034 | ||
| 2035 | if (NULL != pCtx->pMvUnitBlock4x4) { | 2035 | if (NULL != pCtx->pMvUnitBlock4x4) { |
| 2036 | pMa->WelsFree (pCtx->pMvUnitBlock4x4, "pMvUnitBlock4x4"); | 2036 | pMa->WelsFree (pCtx->pMvUnitBlock4x4, "pMvUnitBlock4x4"); |
| 2037 | pCtx->pMvUnitBlock4x4 = NULL; | 2037 | pCtx->pMvUnitBlock4x4 = NULL; |
| 2038 | } | 2038 | } |
| 2039 | 2039 | ||
| 2040 | if (NULL != pCtx->pRefIndexBlock4x4) { | 2040 | if (NULL != pCtx->pRefIndexBlock4x4) { |
| 2041 | pMa->WelsFree (pCtx->pRefIndexBlock4x4, "pRefIndexBlock4x4"); | 2041 | pMa->WelsFree (pCtx->pRefIndexBlock4x4, "pRefIndexBlock4x4"); |
| 2042 | pCtx->pRefIndexBlock4x4 = NULL; | 2042 | pCtx->pRefIndexBlock4x4 = NULL; |
| 2043 | } | 2043 | } |
| 2044 | 2044 | ||
| 2045 | if (NULL != pCtx->ppMbListD) { | 2045 | if (NULL != pCtx->ppMbListD) { |
| @@ -2066,7 +2066,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 20 unmodified lines | |||
| 2066 | ilayer = 0; | 2066 | ilayer = 0; |
| 2067 | if (NULL != pCtx->ppDqLayerList && pParam != NULL) { | 2067 | if (NULL != pCtx->ppDqLayerList && pParam != NULL) { |
| 2068 | while (ilayer < pParam->iSpatialLayerNum) { | 2068 | while (ilayer < pParam->iSpatialLayerNum) { |
| 2069 | SDqLayer* pDq = pCtx->ppDqLayerList[ilayer]; | 2069 | SDqLayer* pDq = pCtx->ppDqLayerList[ilayer]; |
| 2070 | SSpatialLayerConfig* pDlp = &pCtx->pSvcParam->sSpatialLayers[ilayer]; | 2070 | SSpatialLayerConfig* pDlp = &pCtx->pSvcParam->sSpatialLayers[ilayer]; |
| 2071 | 2071 | ||
| 2072 | const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sSliceCfg.uiSliceMode); | 2072 | const bool kbIsDynamicSlicing = (SM_DYN_SLICE == pDlp->sSliceCfg.uiSliceMode); |
| @@ -2093,9 +2093,9 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 20 unmodified lines | |||
| 2093 | } | 2093 | } |
| 2094 | if (kbIsDynamicSlicing) { | 2094 | if (kbIsDynamicSlicing) { |
| 2095 | pMa->WelsFree (pDq->pNumSliceCodedOfPartition, "pNumSliceCodedOfPartition"); | 2095 | pMa->WelsFree (pDq->pNumSliceCodedOfPartition, "pNumSliceCodedOfPartition"); |
| 2096 | pDq->pNumSliceCodedOfPartition = NULL; | 2096 | pDq->pNumSliceCodedOfPartition = NULL; |
| 2097 | pMa->WelsFree (pDq->pLastCodedMbIdxOfPartition, "pLastCodedMbIdxOfPartition"); | 2097 | pMa->WelsFree (pDq->pLastCodedMbIdxOfPartition, "pLastCodedMbIdxOfPartition"); |
| 2098 | pDq->pLastCodedMbIdxOfPartition = NULL; | 2098 | pDq->pLastCodedMbIdxOfPartition = NULL; |
| 2099 | pMa->WelsFree (pDq->pLastMbIdxOfPartition, "pLastMbIdxOfPartition"); | 2099 | pMa->WelsFree (pDq->pLastMbIdxOfPartition, "pLastMbIdxOfPartition"); |
| 2100 | pDq->pLastMbIdxOfPartition = NULL; | 2100 | pDq->pLastMbIdxOfPartition = NULL; |
| 2101 | } | 2101 | } |
| @@ -2119,7 +2119,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 17 unmodified lines | |||
| 2119 | if (NULL != pCtx->ppRefPicListExt && pParam != NULL) { | 2119 | if (NULL != pCtx->ppRefPicListExt && pParam != NULL) { |
| 2120 | ilayer = 0; | 2120 | ilayer = 0; |
| 2121 | while (ilayer < pParam->iSpatialLayerNum) { | 2121 | while (ilayer < pParam->iSpatialLayerNum) { |
| 2122 | SRefList* pRefList = pCtx->ppRefPicListExt[ilayer]; | 2122 | SRefList* pRefList = pCtx->ppRefPicListExt[ilayer]; |
| 2123 | if (NULL != pRefList) { | 2123 | if (NULL != pRefList) { |
| 2124 | int32_t iRef = 0; | 2124 | int32_t iRef = 0; |
| 2125 | do { | 2125 | do { |
| @@ -2143,7 +2143,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 17 unmodified lines | |||
| 2143 | if (NULL != pCtx->pSliceCtxList && pParam != NULL) { | 2143 | if (NULL != pCtx->pSliceCtxList && pParam != NULL) { |
| 2144 | ilayer = 0; | 2144 | ilayer = 0; |
| 2145 | while (ilayer < pParam->iSpatialLayerNum) { | 2145 | while (ilayer < pParam->iSpatialLayerNum) { |
| 2146 | SSliceCtx* pSliceCtx = &pCtx->pSliceCtxList[ilayer]; | 2146 | SSliceCtx* pSliceCtx = &pCtx->pSliceCtxList[ilayer]; |
| 2147 | if (NULL != pSliceCtx) | 2147 | if (NULL != pSliceCtx) |
| 2148 | UninitSlicePEncCtx (pSliceCtx, pMa); | 2148 | UninitSlicePEncCtx (pSliceCtx, pMa); |
| 2149 | ++ ilayer; | 2149 | ++ ilayer; |
| @@ -2163,21 +2163,21 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 13 unmodified lines | |||
| 2163 | } | 2163 | } |
| 2164 | 2164 | ||
| 2165 | pMa->WelsFree (pCtx->pVaa->pVaaBackgroundMbFlag, "pVaa->pVaaBackgroundMbFlag"); | 2165 | pMa->WelsFree (pCtx->pVaa->pVaaBackgroundMbFlag, "pVaa->pVaaBackgroundMbFlag"); |
| 2166 | pCtx->pVaa->pVaaBackgroundMbFlag = NULL; | 2166 | pCtx->pVaa->pVaaBackgroundMbFlag = NULL; |
| 2167 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSad8x8, "pVaa->sVaaCalcInfo.sad8x8"); | 2167 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSad8x8, "pVaa->sVaaCalcInfo.sad8x8"); |
| 2168 | pCtx->pVaa->sVaaCalcInfo.pSad8x8 = NULL; | 2168 | pCtx->pVaa->sVaaCalcInfo.pSad8x8 = NULL; |
| 2169 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSsd16x16, "pVaa->sVaaCalcInfo.pSsd16x16"); | 2169 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSsd16x16, "pVaa->sVaaCalcInfo.pSsd16x16"); |
| 2170 | pCtx->pVaa->sVaaCalcInfo.pSsd16x16 = NULL; | 2170 | pCtx->pVaa->sVaaCalcInfo.pSsd16x16 = NULL; |
| 2171 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSum16x16, "pVaa->sVaaCalcInfo.pSum16x16"); | 2171 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSum16x16, "pVaa->sVaaCalcInfo.pSum16x16"); |
| 2172 | pCtx->pVaa->sVaaCalcInfo.pSum16x16 = NULL; | 2172 | pCtx->pVaa->sVaaCalcInfo.pSum16x16 = NULL; |
| 2173 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16, "pVaa->sVaaCalcInfo.pSumOfSquare16x16"); | 2173 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16, "pVaa->sVaaCalcInfo.pSumOfSquare16x16"); |
| 2174 | pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16 = NULL; | 2174 | pCtx->pVaa->sVaaCalcInfo.pSumOfSquare16x16 = NULL; |
| 2175 | 2175 | ||
| 2176 | if (pCtx->pSvcParam->bEnableBackgroundDetection) { //BGD control | 2176 | if (pCtx->pSvcParam->bEnableBackgroundDetection) { //BGD control |
| 2177 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8, "pVaa->sVaaCalcInfo.pSumOfDiff8x8"); | 2177 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8, "pVaa->sVaaCalcInfo.pSumOfDiff8x8"); |
| 2178 | pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8 = NULL; | 2178 | pCtx->pVaa->sVaaCalcInfo.pSumOfDiff8x8 = NULL; |
| 2179 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8"); | 2179 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8"); |
| 2180 | pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; | 2180 | pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; |
| 2181 | } | 2181 | } |
| 2182 | if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) | 2182 | if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) |
| 2183 | ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iMaxNumRefFrame); | 2183 | ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iMaxNumRefFrame); |
| @@ -2236,12 +2236,12 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 52 unmodified lines | |||
| 2236 | // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, | 2236 | // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, |
| 2237 | // uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode, | 2237 | // uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode, |
| 2238 | // uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future | 2238 | // uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future |
| 2239 | pSlcArg->uiSliceNum = iSliceNum; // used fixed one | 2239 | pSlcArg->uiSliceNum = iSliceNum; // used fixed one |
| 2240 | 2240 | ||
| 2241 | switch (pMso->uiSliceMode) { | 2241 | switch (pMso->uiSliceMode) { |
| 2242 | case SM_DYN_SLICE: | 2242 | case SM_DYN_SLICE: |
| 2243 | iMaxSliceCount = AVERSLICENUM_CONSTRAINT; | 2243 | iMaxSliceCount = AVERSLICENUM_CONSTRAINT; |
| 2244 | break; // go through for SM_DYN_SLICE? | 2244 | break; // go through for SM_DYN_SLICE? |
| 2245 | case SM_FIXEDSLCNUM_SLICE: | 2245 | case SM_FIXEDSLCNUM_SLICE: |
| 2246 | if (iSliceNum > iMaxSliceCount) | 2246 | if (iSliceNum > iMaxSliceCount) |
| 2247 | iMaxSliceCount = iSliceNum; | 2247 | iMaxSliceCount = iSliceNum; |
| @@ -2274,7 +2274,7 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 26 unmodified lines | |||
| 2274 | WelsLog (pLogCtx, WELS_LOG_DEBUG, | 2274 | WelsLog (pLogCtx, WELS_LOG_DEBUG, |
| 2275 | "InitSliceSettings(), uiSliceNum(%d) you set for SM_AUTO_SLICE, now turn to SM_SINGLE_SLICE type!", | 2275 | "InitSliceSettings(), uiSliceNum(%d) you set for SM_AUTO_SLICE, now turn to SM_SINGLE_SLICE type!", |
| 2276 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum); | 2276 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum); |
| 2277 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 2277 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 2278 | break; | 2278 | break; |
| 2279 | } | 2279 | } |
| 2280 | if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom | 2280 | if (pCodingParam->iRCMode != RC_OFF_MODE) { // multiple slices verify with gom |
| @@ -2297,13 +2297,13 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 16 unmodified lines | |||
| 2297 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 2297 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 2298 | "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type", | 2298 | "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type", |
| 2299 | pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); | 2299 | pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); |
| 2300 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 2300 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 2301 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; | 2301 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; |
| 2302 | } | 2302 | } |
| 2303 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting | 2303 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 2304 | if (kiMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { | 2304 | if (kiMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 2305 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | 2305 | pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 2306 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; | 2306 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; |
| 2307 | break; | 2307 | break; |
| 2308 | } | 2308 | } |
| 2309 | break; | 2309 | break; |
| @@ -2314,13 +2314,13 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 4 unmodified lines | |||
| 2314 | ++ iSpatialIdx; | 2314 | ++ iSpatialIdx; |
| 2315 | } while (iSpatialIdx < iSpatialNum); | 2315 | } while (iSpatialIdx < iSpatialNum); |
| 2316 | 2316 | ||
| 2317 | pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); | 2317 | pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); |
| 2318 | pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; | 2318 | pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; |
| 2319 | if (pCodingParam->iLoopFilterDisableIdc == 0 | 2319 | if (pCodingParam->iLoopFilterDisableIdc == 0 |
| 2320 | && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled | 2320 | && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled |
| 2321 | pCodingParam->iLoopFilterDisableIdc = | 2321 | pCodingParam->iLoopFilterDisableIdc = |
| 2322 | 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading | 2322 | 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading |
| 2323 | *pMaxSliceCount = iMaxSliceCount; | 2323 | *pMaxSliceCount = iMaxSliceCount; |
| 2324 | 2324 | ||
| 2325 | return ENC_RETURN_SUCCESS; | 2325 | return ENC_RETURN_SUCCESS; |
| 2326 | } | 2326 | } |
| @@ -2378,9 +2378,8 @@ void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uin · 51 unmodified lines | |||
| 2378 | int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum, | 2378 | int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum, |
| 2379 | int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) { | 2379 | int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) { |
| 2380 | // for cpu features detection, Only detect once?? | 2380 | // for cpu features detection, Only detect once?? |
| 2381 | int32_t uiCpuCores = | 2381 | int32_t uiCpuCores = 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported |
| 2382 | 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported | 2382 | uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features |
| 2383 | uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features | ||
| 2384 | 2383 | ||
| 2385 | #ifdef X86_ASM | 2384 | #ifdef X86_ASM |
| 2386 | if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128) | 2385 | if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_128) |
| @@ -2388,12 +2387,12 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 1 unmodified line | |||
| 2388 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64) | 2387 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_64) |
| 2389 | iCacheLineSize = 64; | 2388 | iCacheLineSize = 64; |
| 2390 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_32) | 2389 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_32) |
| 2391 | iCacheLineSize = 32; | 2390 | iCacheLineSize = 32; |
| 2392 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_16) | 2391 | else if (uiCpuFeatureFlags & WELS_CPU_CACHELINE_16) |
| 2393 | iCacheLineSize = 16; | 2392 | iCacheLineSize = 16; |
| 2394 | OutputCpuFeaturesLog (pLogCtx, uiCpuFeatureFlags, uiCpuCores, iCacheLineSize); | 2393 | OutputCpuFeaturesLog (pLogCtx, uiCpuFeatureFlags, uiCpuCores, iCacheLineSize); |
| 2395 | #else | 2394 | #else |
| 2396 | iCacheLineSize = 16; // 16 bytes aligned in default | 2395 | iCacheLineSize = 16; // 16 bytes aligned in default |
| 2397 | #endif//X86_ASM | 2396 | #endif//X86_ASM |
| 2398 | 2397 | ||
| 2399 | #if defined(DYNAMIC_DETECT_CPU_CORES) | 2398 | #if defined(DYNAMIC_DETECT_CPU_CORES) |
| @@ -2405,14 +2404,14 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 5 unmodified lines | |||
| 2405 | uiCpuCores = DynamicDetectCpuCores(); | 2404 | uiCpuCores = DynamicDetectCpuCores(); |
| 2406 | // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, | 2405 | // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, |
| 2407 | // for client application here it is constrained by maximal to MAX_THREADS_NUM | 2406 | // for client application here it is constrained by maximal to MAX_THREADS_NUM |
| 2408 | if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM | 2407 | if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM |
| 2409 | uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM | 2408 | uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM |
| 2410 | else if (uiCpuCores < 1) // just for safe | 2409 | else if (uiCpuCores < 1) // just for safe |
| 2411 | uiCpuCores = 1; | 2410 | uiCpuCores = 1; |
| 2412 | } | 2411 | } |
| 2413 | #endif//DYNAMIC_DETECT_CPU_CORES | 2412 | #endif//DYNAMIC_DETECT_CPU_CORES |
| 2414 | 2413 | ||
| 2415 | uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); | 2414 | uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); |
| 2416 | 2415 | ||
| 2417 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { | 2416 | if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { |
| 2418 | WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); | 2417 | WelsLog (pLogCtx, WELS_LOG_ERROR, "GetMultipleThreadIdc(), InitSliceSettings failed."); |
| @@ -2440,12 +2439,12 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 21 unmodified lines | |||
| 2440 | return 1; | 2439 | return 1; |
| 2441 | } | 2440 | } |
| 2442 | 2441 | ||
| 2443 | iRet = ParamValidationExt (pLogCtx, pCodingParam); | 2442 | iRet = ParamValidationExt (pLogCtx, pCodingParam); |
| 2444 | if (iRet != 0) { | 2443 | if (iRet != 0) { |
| 2445 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); | 2444 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); |
| 2446 | return iRet; | 2445 | return iRet; |
| 2447 | } | 2446 | } |
| 2448 | iRet = pCodingParam->DetermineTemporalSettings(); | 2447 | iRet = pCodingParam->DetermineTemporalSettings(); |
| 2449 | if (iRet != ENC_RETURN_SUCCESS) { | 2448 | if (iRet != ENC_RETURN_SUCCESS) { |
| 2450 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 2449 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 2451 | "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting! -- in/out = 2^x, x <= temppral_layer_num)", | 2450 | "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting! -- in/out = 2^x, x <= temppral_layer_num)", |
| @@ -2459,9 +2458,9 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 7 unmodified lines | |||
| 2459 | } | 2458 | } |
| 2460 | 2459 | ||
| 2461 | 2460 | ||
| 2462 | *ppCtx = NULL; | 2461 | *ppCtx = NULL; |
| 2463 | 2462 | ||
| 2464 | pCtx = static_cast<sWelsEncCtx*> (malloc (sizeof (sWelsEncCtx))); | 2463 | pCtx = static_cast<sWelsEncCtx*> (malloc (sizeof (sWelsEncCtx))); |
| 2465 | 2464 | ||
| 2466 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)) | 2465 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)) |
| 2467 | memset (pCtx, 0, sizeof (sWelsEncCtx)); | 2466 | memset (pCtx, 0, sizeof (sWelsEncCtx)); |
| @@ -2485,8 +2484,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 17 unmodified lines | |||
| 2485 | } | 2484 | } |
| 2486 | InitFunctionPointers (pCtx, pCtx->pSvcParam, uiCpuFeatureFlags); | 2485 | InitFunctionPointers (pCtx, pCtx->pSvcParam, uiCpuFeatureFlags); |
| 2487 | 2486 | ||
| 2488 | pCtx->iActiveThreadsNum = pCodingParam->iCountThreadsNum; | 2487 | pCtx->iActiveThreadsNum = pCodingParam->iCountThreadsNum; |
| 2489 | pCtx->iMaxSliceCount = iSliceNum; | 2488 | pCtx->iMaxSliceCount = iSliceNum; |
| 2490 | iRet = RequestMemorySvc (&pCtx, pExistingParasetList); | 2489 | iRet = RequestMemorySvc (&pCtx, pExistingParasetList); |
| 2491 | if (iRet != 0) { | 2490 | if (iRet != 0) { |
| 2492 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), RequestMemorySvc failed return %d.", iRet); | 2491 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), RequestMemorySvc failed return %d.", iRet); |
| @@ -2528,7 +2527,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 35 unmodified lines | |||
| 2528 | 2527 | ||
| 2529 | pCtx->iStatisticsLogInterval = STATISTICS_LOG_INTERVAL_MS; | 2528 | pCtx->iStatisticsLogInterval = STATISTICS_LOG_INTERVAL_MS; |
| 2530 | 2529 | ||
| 2531 | *ppCtx = pCtx; | 2530 | *ppCtx = pCtx; |
| 2532 | 2531 | ||
| 2533 | WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsInitEncoderExt(), pCtx= 0x%p.", (void*)pCtx); | 2532 | WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsInitEncoderExt(), pCtx= 0x%p.", (void*)pCtx); |
| 2534 | 2533 | ||
| @@ -2663,7 +2662,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 128 unmodified lines | |||
| 2663 | * \brief get temporal level due to configuration and coding context | 2662 | * \brief get temporal level due to configuration and coding context |
| 2664 | */ | 2663 | */ |
| 2665 | int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize) { | 2664 | int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum, const int32_t kiGopSize) { |
| 2666 | const int32_t kiCodingIdx = kiFrameNum & (kiGopSize - 1); | 2665 | const int32_t kiCodingIdx = kiFrameNum & (kiGopSize - 1); |
| 2667 | 2666 | ||
| 2668 | return fDlp->uiCodingIdx2TemporalId[kiCodingIdx]; | 2667 | return fDlp->uiCodingIdx2TemporalId[kiCodingIdx]; |
| 2669 | } | 2668 | } |
| @@ -2687,7 +2686,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 17 unmodified lines | |||
| 2687 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; | 2686 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; |
| 2688 | 2687 | ||
| 2689 | uiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); | 2688 | uiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); |
| 2690 | pMb->uiSliceIdc = uiSliceIdc; | 2689 | pMb->uiSliceIdc = uiSliceIdc; |
| 2691 | iLeftXY = kiMbXY - 1; | 2690 | iLeftXY = kiMbXY - 1; |
| 2692 | iTopXY = kiMbXY - kiMbWidth; | 2691 | iTopXY = kiMbXY - kiMbWidth; |
| 2693 | iLeftTopXY = iTopXY - 1; | 2692 | iLeftTopXY = iTopXY - 1; |
| @@ -2710,7 +2709,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 16 unmodified lines | |||
| 2710 | if (bRightTop) { | 2709 | if (bRightTop) { |
| 2711 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; | 2710 | uiNeighborAvailFlag |= TOPRIGHT_MB_POS; |
| 2712 | } | 2711 | } |
| 2713 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; | 2712 | pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; |
| 2714 | 2713 | ||
| 2715 | ++ iIdx; | 2714 | ++ iIdx; |
| 2716 | } while (iIdx <= kiEndMbInSlice); | 2715 | } while (iIdx <= kiEndMbInSlice); |
| @@ -2720,9 +2719,9 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 3 unmodified lines | |||
| 2720 | * TUNE back if number of picture partition decision algorithm based on past if available | 2719 | * TUNE back if number of picture partition decision algorithm based on past if available |
| 2721 | */ | 2720 | */ |
| 2722 | int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { | 2721 | int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { |
| 2723 | int32_t iPartitionNum = 1; | 2722 | int32_t iPartitionNum = 1; |
| 2724 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { | 2723 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { |
| 2725 | iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; | 2724 | iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; |
| 2726 | } | 2725 | } |
| 2727 | return iPartitionNum; | 2726 | return iPartitionNum; |
| 2728 | } | 2727 | } |
| @@ -2744,25 +2743,25 @@ void UpdateSlicepEncCtxWithPartition (SSliceCtx* pSliceCtx, int32_t iPartitionNu · 15 unmodified lines | |||
| 2744 | int32_t i/*, j*/; | 2743 | int32_t i/*, j*/; |
| 2745 | 2744 | ||
| 2746 | if (iPartitionNum <= 0) | 2745 | if (iPartitionNum <= 0) |
| 2747 | iPartitionNum = 1; | 2746 | iPartitionNum = 1; |
| 2748 | else if (iPartitionNum > AVERSLICENUM_CONSTRAINT) | 2747 | else if (iPartitionNum > AVERSLICENUM_CONSTRAINT) |
| 2749 | iPartitionNum = AVERSLICENUM_CONSTRAINT; // AVERSLICENUM_CONSTRAINT might be variable, however not fixed by MACRO | 2748 | iPartitionNum = AVERSLICENUM_CONSTRAINT; // AVERSLICENUM_CONSTRAINT might be variable, however not fixed by MACRO |
| 2750 | iCountMbNumPerPartition /= iPartitionNum; | 2749 | iCountMbNumPerPartition /= iPartitionNum; |
| 2751 | pSliceCtx->iSliceNumInFrame = iPartitionNum; | 2750 | pSliceCtx->iSliceNumInFrame = iPartitionNum; |
| 2752 | i = 0; | 2751 | i = 0; |
| 2753 | while (i < iPartitionNum) { | 2752 | while (i < iPartitionNum) { |
| 2754 | if (i + 1 == iPartitionNum) { | 2753 | if (i + 1 == iPartitionNum) { |
| 2755 | pSliceCtx->pCountMbNumInSlice[i] = iAssignableMbLeft; | 2754 | pSliceCtx->pCountMbNumInSlice[i] = iAssignableMbLeft; |
| 2756 | } else { | 2755 | } else { |
| 2757 | pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; | 2756 | pSliceCtx->pCountMbNumInSlice[i] = iCountMbNumPerPartition; |
| 2758 | } | 2757 | } |
| 2759 | pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; | 2758 | pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; |
| 2760 | 2759 | ||
| 2761 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, | 2760 | WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdx, i, |
| 2762 | pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); | 2761 | pSliceCtx->pCountMbNumInSlice[i], sizeof (uint16_t)); |
| 2763 | 2762 | ||
| 2764 | // for next partition(or pSlice) | 2763 | // for next partition(or pSlice) |
| 2765 | iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i]; | 2764 | iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i]; |
| 2766 | iAssignableMbLeft -= pSliceCtx->pCountMbNumInSlice[i]; | 2765 | iAssignableMbLeft -= pSliceCtx->pCountMbNumInSlice[i]; |
| 2767 | ++ i; | 2766 | ++ i; |
| 2768 | } | 2767 | } |
| @@ -2843,7 +2842,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 74 unmodified lines | |||
| 2843 | if (NULL == pCurDq) | 2842 | if (NULL == pCurDq) |
| 2844 | return; | 2843 | return; |
| 2845 | 2844 | ||
| 2846 | pCurDq->pDecPic = pDecPic; | 2845 | pCurDq->pDecPic = pDecPic; |
| 2847 | 2846 | ||
| 2848 | if (fDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update | 2847 | if (fDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE) // need get extra slices for update |
| 2849 | iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sSliceCfg); | 2848 | iSliceCount = GetInitialSliceNum (pCurDq->iMbWidth, pCurDq->iMbHeight, &fDlp->sSliceCfg); |
| @@ -2900,7 +2899,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 50 unmodified lines | |||
| 2900 | iIdx = 1; | 2899 | iIdx = 1; |
| 2901 | while (iIdx < iSliceCount) { | 2900 | while (iIdx < iSliceCount) { |
| 2902 | ++ pSlice; | 2901 | ++ pSlice; |
| 2903 | pSlice->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; | 2902 | pSlice->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; |
| 2904 | ++ iIdx; | 2903 | ++ iIdx; |
| 2905 | } | 2904 | } |
| 2906 | 2905 | ||
| @@ -2920,9 +2919,9 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 13 unmodified lines | |||
| 2920 | pCurDq->iCsStride[2] = pDecPic->iLineSize[2]; | 2919 | pCurDq->iCsStride[2] = pDecPic->iLineSize[2]; |
| 2921 | 2920 | ||
| 2922 | if (pCurDq->pRefLayer != NULL) { | 2921 | if (pCurDq->pRefLayer != NULL) { |
| 2923 | pCurDq->bBaseLayerAvailableFlag = true; | 2922 | pCurDq->bBaseLayerAvailableFlag = true; |
| 2924 | } else { | 2923 | } else { |
| 2925 | pCurDq->bBaseLayerAvailableFlag = false; | 2924 | pCurDq->bBaseLayerAvailableFlag = false; |
| 2926 | } | 2925 | } |
| 2927 | } | 2926 | } |
| 2928 | 2927 | ||
| @@ -3018,7 +3017,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 89 unmodified lines | |||
| 3018 | pFuncList->pfInterFineMd = WelsMdInterFinePartitionVaaOnScreen; | 3017 | pFuncList->pfInterFineMd = WelsMdInterFinePartitionVaaOnScreen; |
| 3019 | 3018 | ||
| 3020 | //ME related func pointers | 3019 | //ME related func pointers |
| 3021 | SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa); | 3020 | SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa); |
| 3022 | if (pVaaExt->sScrollDetectInfo.bScrollDetectFlag | 3021 | if (pVaaExt->sScrollDetectInfo.bScrollDetectFlag |
| 3023 | && (pVaaExt->sScrollDetectInfo.iScrollMvX | pVaaExt->sScrollDetectInfo.iScrollMvY)) { | 3022 | && (pVaaExt->sScrollDetectInfo.iScrollMvX | pVaaExt->sScrollDetectInfo.iScrollMvY)) { |
| 3024 | pFuncList->pfSetScrollingMv = SetScrollingMvToMd; | 3023 | pFuncList->pfSetScrollingMv = SetScrollingMvToMd; |
| @@ -3039,7 +3038,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 14 unmodified lines | |||
| 3039 | pFeatureSearchPreparation->iHighFreMbCount = 0; | 3038 | pFeatureSearchPreparation->iHighFreMbCount = 0; |
| 3040 | 3039 | ||
| 3041 | //calculate bFMESwitchFlag | 3040 | //calculate bFMESwitchFlag |
| 3042 | SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa); | 3041 | SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa); |
| 3043 | const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth; | 3042 | const int32_t kiMbSize = pCurLayer->iMbHeight * pCurLayer->iMbWidth; |
| 3044 | pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount, | 3043 | pFeatureSearchPreparation->bFMESwitchFlag = CalcFMESwitchFlag (pFeatureSearchPreparation->uiFMEGoodFrameCount, |
| 3045 | pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize, | 3044 | pFeatureSearchPreparation->iHighFreMbCount * 100 / kiMbSize, pCtx->pVaa->sVaaCalcInfo.iFrameSad / kiMbSize, |
| @@ -3120,7 +3119,7 @@ static inline void PrefetchReferencePicture (sWelsEncCtx* pCtx, const EVideoFram · 74 unmodified lines | |||
| 3120 | 3119 | ||
| 3121 | iIdx = 0; | 3120 | iIdx = 0; |
| 3122 | while (iIdx < kiSliceCount) { | 3121 | while (iIdx < kiSliceCount) { |
| 3123 | pSliceBase->sSliceHeaderExt.sSliceHeader.uiRefIndex = uiRefIdx; | 3122 | pSliceBase->sSliceHeaderExt.sSliceHeader.uiRefIndex = uiRefIdx; |
| 3124 | ++ pSliceBase; | 3123 | ++ pSliceBase; |
| 3125 | ++ iIdx; | 3124 | ++ iIdx; |
| 3126 | } | 3125 | } |
| @@ -3144,7 +3143,7 @@ void ParasetIdAdditionIdAdjust (SParaSetOffsetVariable* sParaSetOffsetVariable, · 17 unmodified lines | |||
| 3144 | uint32_t uiNextIdInBs = sParaSetOffsetVariable->uiNextParaSetIdToUseInBs; | 3143 | uint32_t uiNextIdInBs = sParaSetOffsetVariable->uiNextParaSetIdToUseInBs; |
| 3145 | 3144 | ||
| 3146 | //update current layer's pCodingParam | 3145 | //update current layer's pCodingParam |
| 3147 | sParaSetOffsetVariable->iParaSetIdDelta[kiEncId] = uiNextIdInBs - | 3146 | sParaSetOffsetVariable->iParaSetIdDelta[kiEncId] = uiNextIdInBs - |
| 3148 | kiEncId; //for current parameter set, change its id_delta | 3147 | kiEncId; //for current parameter set, change its id_delta |
| 3149 | //write pso pData for next update: | 3148 | //write pso pData for next update: |
| 3150 | sParaSetOffsetVariable->bUsedParaSetIdInBs[uiNextIdInBs] = true; // update current used_id | 3149 | sParaSetOffsetVariable->bUsedParaSetIdInBs[uiNextIdInBs] = true; // update current used_id |
| @@ -3160,7 +3159,7 @@ void ParasetIdAdditionIdAdjust (SParaSetOffsetVariable* sParaSetOffsetVariable, · 9 unmodified lines | |||
| 3160 | } | 3159 | } |
| 3161 | 3160 | ||
| 3162 | int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNalSize) { | 3161 | int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNalSize) { |
| 3163 | int iNal = pCtx->pOut->iNalIndex; | 3162 | int iNal = pCtx->pOut->iNalIndex; |
| 3164 | WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST); | 3163 | WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST); |
| 3165 | 3164 | ||
| 3166 | WelsWriteSpsNal (&pCtx->pSpsArray[kiSpsIdx], &pCtx->pOut->sBsWrite, | 3165 | WelsWriteSpsNal (&pCtx->pSpsArray[kiSpsIdx], &pCtx->pOut->sBsWrite, |
| @@ -3173,13 +3172,13 @@ int32_t WelsWriteOneSPS (sWelsEncCtx* pCtx, const int32_t kiSpsIdx, int32_t& iNa · 6 unmodified lines | |||
| 3173 | &iNalSize); | 3172 | &iNalSize); |
| 3174 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3173 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3175 | 3174 | ||
| 3176 | pCtx->iPosBsBuffer += iNalSize; | 3175 | pCtx->iPosBsBuffer += iNalSize; |
| 3177 | return ENC_RETURN_SUCCESS; | 3176 | return ENC_RETURN_SUCCESS; |
| 3178 | } | 3177 | } |
| 3179 | 3178 | ||
| 3180 | int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNalSize) { | 3179 | int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNalSize) { |
| 3181 | //TODO | 3180 | //TODO |
| 3182 | int32_t iNal = pCtx->pOut->iNalIndex; | 3181 | int32_t iNal = pCtx->pOut->iNalIndex; |
| 3183 | /* generate picture parameter set */ | 3182 | /* generate picture parameter set */ |
| 3184 | WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST); | 3183 | WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST); |
| 3185 | WelsWritePpsSyntax (&pCtx->pPPSArray[kiPpsIdx], &pCtx->pOut->sBsWrite, | 3184 | WelsWritePpsSyntax (&pCtx->pPPSArray[kiPpsIdx], &pCtx->pOut->sBsWrite, |
| @@ -3192,7 +3191,7 @@ int32_t WelsWriteOnePPS (sWelsEncCtx* pCtx, const int32_t kiPpsIdx, int32_t& iNa · 6 unmodified lines | |||
| 3192 | &iNalSize); | 3191 | &iNalSize); |
| 3193 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3192 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3194 | 3193 | ||
| 3195 | pCtx->iPosBsBuffer += iNalSize; | 3194 | pCtx->iPosBsBuffer += iNalSize; |
| 3196 | return ENC_RETURN_SUCCESS; | 3195 | return ENC_RETURN_SUCCESS; |
| 3197 | } | 3196 | } |
| 3198 | 3197 | ||
| @@ -3254,12 +3253,12 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 55 unmodified lines | |||
| 3254 | } | 3253 | } |
| 3255 | 3254 | ||
| 3256 | /* generate sequence parameters set */ | 3255 | /* generate sequence parameters set */ |
| 3257 | iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0; | 3256 | iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0; |
| 3258 | 3257 | ||
| 3259 | WelsWriteOneSPS (pCtx, iId, iNalLength); | 3258 | WelsWriteOneSPS (pCtx, iId, iNalLength); |
| 3260 | 3259 | ||
| 3261 | pNalLen[iCountNal] = iNalLength; | 3260 | pNalLen[iCountNal] = iNalLength; |
| 3262 | iSize += iNalLength; | 3261 | iSize += iNalLength; |
| 3263 | 3262 | ||
| 3264 | ++ iIdx; | 3263 | ++ iIdx; |
| 3265 | ++ iCountNal; | 3264 | ++ iCountNal; |
| @@ -3268,7 +3267,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 2 unmodified lines | |||
| 3268 | /* write all Subset SPS */ | 3267 | /* write all Subset SPS */ |
| 3269 | iIdx = 0; | 3268 | iIdx = 0; |
| 3270 | while (iIdx < pCtx->iSubsetSpsNum) { | 3269 | while (iIdx < pCtx->iSubsetSpsNum) { |
| 3271 | iNal = pCtx->pOut->iNalIndex; | 3270 | iNal = pCtx->pOut->iNalIndex; |
| 3272 | 3271 | ||
| 3273 | if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) { | 3272 | if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) { |
| 3274 | #if _DEBUG | 3273 | #if _DEBUG |
| @@ -3281,7 +3280,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 6 unmodified lines | |||
| 3281 | MAX_SPS_COUNT); | 3280 | MAX_SPS_COUNT); |
| 3282 | } | 3281 | } |
| 3283 | 3282 | ||
| 3284 | iId = iIdx; | 3283 | iId = iIdx; |
| 3285 | 3284 | ||
| 3286 | /* generate Subset SPS */ | 3285 | /* generate Subset SPS */ |
| 3287 | WelsLoadNal (pCtx->pOut, NAL_UNIT_SUBSET_SPS, NRI_PRI_HIGHEST); | 3286 | WelsLoadNal (pCtx->pOut, NAL_UNIT_SUBSET_SPS, NRI_PRI_HIGHEST); |
| @@ -3320,7 +3319,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 32 unmodified lines | |||
| 3320 | WelsWriteOnePPS (pCtx, iIdx, iNalLength); | 3319 | WelsWriteOnePPS (pCtx, iIdx, iNalLength); |
| 3321 | 3320 | ||
| 3322 | pNalLen[iCountNal] = iNalLength; | 3321 | pNalLen[iCountNal] = iNalLength; |
| 3323 | iSize += iNalLength; | 3322 | iSize += iNalLength; |
| 3324 | 3323 | ||
| 3325 | ++ iIdx; | 3324 | ++ iIdx; |
| 3326 | ++ iCountNal; | 3325 | ++ iCountNal; |
| @@ -3357,7 +3356,7 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 30 unmodified lines | |||
| 3357 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3356 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3358 | iPayloadSize = pNalLen[*pNalIdxInLayer]; | 3357 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 3359 | 3358 | ||
| 3360 | pCtx->iPosBsBuffer += iPayloadSize; | 3359 | pCtx->iPosBsBuffer += iPayloadSize; |
| 3361 | 3360 | ||
| 3362 | (*pNalIdxInLayer) ++; | 3361 | (*pNalIdxInLayer) ++; |
| 3363 | } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension | 3362 | } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension |
| @@ -3373,7 +3372,7 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 9 unmodified lines | |||
| 3373 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3372 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3374 | iPayloadSize = pNalLen[*pNalIdxInLayer]; | 3373 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 3375 | 3374 | ||
| 3376 | pCtx->iPosBsBuffer += iPayloadSize; | 3375 | pCtx->iPosBsBuffer += iPayloadSize; |
| 3377 | 3376 | ||
| 3378 | (*pNalIdxInLayer) ++; | 3377 | (*pNalIdxInLayer) ++; |
| 3379 | } | 3378 | } |
| @@ -3429,7 +3428,7 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { · 49 unmodified lines | |||
| 3429 | return 1; | 3428 | return 1; |
| 3430 | 3429 | ||
| 3431 | pCtx->bEncCurFrmAsIdrFlag = true; | 3430 | pCtx->bEncCurFrmAsIdrFlag = true; |
| 3432 | pCtx->iCodingIndex = 0; | 3431 | pCtx->iCodingIndex = 0; |
| 3433 | pCtx->bCheckWindowStatusRefreshFlag = false; | 3432 | pCtx->bCheckWindowStatusRefreshFlag = false; |
| 3434 | return 0; | 3433 | return 0; |
| 3435 | } | 3434 | } |
| @@ -3707,9 +3706,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 271 unmodified lines | |||
| 3707 | int32_t i = 0, j = 0, k = 0; | 3706 | int32_t i = 0, j = 0, k = 0; |
| 3708 | #endif//_DEBUG | 3707 | #endif//_DEBUG |
| 3709 | 3708 | ||
| 3710 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; | 3709 | pCtx->iEncoderError = ENC_RETURN_SUCCESS; |
| 3711 | pCtx->bCurFrameMarkedAsSceneLtr = false; | 3710 | pCtx->bCurFrameMarkedAsSceneLtr = false; |
| 3712 | pFbi->iLayerNum = 0; // for initialization | 3711 | pFbi->iLayerNum = 0; // for initialization |
| 3713 | pFbi->uiTimeStamp = pSrcPic->uiTimeStamp; | 3712 | pFbi->uiTimeStamp = pSrcPic->uiTimeStamp; |
| 3714 | // perform csc/denoise/downsample/padding, generate spatial layers | 3713 | // perform csc/denoise/downsample/padding, generate spatial layers |
| 3715 | iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); | 3714 | iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic); |
| @@ -3753,11 +3752,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 37 unmodified lines | |||
| 3753 | pCtx->iContinualSkipFrames = 0; | 3752 | pCtx->iContinualSkipFrames = 0; |
| 3754 | InitFrameCoding (pCtx, eFrameType); | 3753 | InitFrameCoding (pCtx, eFrameType); |
| 3755 | 3754 | ||
| 3756 | iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, | 3755 | iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex, |
| 3757 | pSvcParam->uiGopSize); | 3756 | pSvcParam->uiGopSize); |
| 3758 | pCtx->uiTemporalId = iCurTid; | 3757 | pCtx->uiTemporalId = iCurTid; |
| 3759 | 3758 | ||
| 3760 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; | 3759 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; |
| 3761 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; | 3760 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 3762 | 3761 | ||
| 3763 | if (eFrameType == videoFrameTypeIDR) { | 3762 | if (eFrameType == videoFrameTypeIDR) { |
| @@ -3807,8 +3806,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 43 unmodified lines | |||
| 3807 | case SM_DYN_SLICE: { | 3806 | case SM_DYN_SLICE: { |
| 3808 | int32_t iPicIPartitionNum = PicPartitionNumDecision (pCtx); | 3807 | int32_t iPicIPartitionNum = PicPartitionNumDecision (pCtx); |
| 3809 | // MT compatibility | 3808 | // MT compatibility |
| 3810 | pCtx->iActiveThreadsNum = | 3809 | pCtx->iActiveThreadsNum = |
| 3811 | iPicIPartitionNum; // we try to active number of threads, equal to number of picture partitions | 3810 | iPicIPartitionNum; // we try to active number of threads, equal to number of picture partitions |
| 3812 | WelsInitCurrentDlayerMltslc (pCtx, iPicIPartitionNum); | 3811 | WelsInitCurrentDlayerMltslc (pCtx, iPicIPartitionNum); |
| 3813 | break; | 3812 | break; |
| 3814 | } | 3813 | } |
| @@ -3818,8 +3817,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 3 unmodified lines | |||
| 3818 | } | 3817 | } |
| 3819 | 3818 | ||
| 3820 | /* coding each spatial layer, only one sQualityStat layer within spatial support */ | 3819 | /* coding each spatial layer, only one sQualityStat layer within spatial support */ |
| 3821 | int32_t iSliceCount = 1; | 3820 | int32_t iSliceCount = 1; |
| 3822 | if (iLayerNum >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info writing as follows | 3821 | if (iLayerNum >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info writing as follows |
| 3823 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d)!", iLayerNum, | 3822 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d)!", iLayerNum, |
| 3824 | MAX_LAYER_NUM_OF_FRAME); | 3823 | MAX_LAYER_NUM_OF_FRAME); |
| 3825 | return ENC_RETURN_UNSUPPORTED_PARA; | 3824 | return ENC_RETURN_UNSUPPORTED_PARA; |
| @@ -3832,20 +3831,20 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 6 unmodified lines | |||
| 3832 | (pSvcParam->iSpatialLayerNum > 1)))); | 3831 | (pSvcParam->iSpatialLayerNum > 1)))); |
| 3833 | 3832 | ||
| 3834 | if (eFrameType == videoFrameTypeP) { | 3833 | if (eFrameType == videoFrameTypeP) { |
| 3835 | eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT; | 3834 | eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT; |
| 3836 | } else if (eFrameType == videoFrameTypeIDR) { | 3835 | } else if (eFrameType == videoFrameTypeIDR) { |
| 3837 | eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE_IDR : NAL_UNIT_CODED_SLICE_EXT; | 3836 | eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE_IDR : NAL_UNIT_CODED_SLICE_EXT; |
| 3838 | } | 3837 | } |
| 3839 | if (iCurTid == 0 || pCtx->eSliceType == I_SLICE) | 3838 | if (iCurTid == 0 || pCtx->eSliceType == I_SLICE) |
| 3840 | eNalRefIdc = NRI_PRI_HIGHEST; | 3839 | eNalRefIdc = NRI_PRI_HIGHEST; |
| 3841 | else if (iCurTid == pSvcParam->iDecompStages) | 3840 | else if (iCurTid == pSvcParam->iDecompStages) |
| 3842 | eNalRefIdc = NRI_PRI_LOWEST; | 3841 | eNalRefIdc = NRI_PRI_LOWEST; |
| 3843 | else if (1 + iCurTid == pSvcParam->iDecompStages) | 3842 | else if (1 + iCurTid == pSvcParam->iDecompStages) |
| 3844 | eNalRefIdc = NRI_PRI_LOW; | 3843 | eNalRefIdc = NRI_PRI_LOW; |
| 3845 | else // more details for other temporal layers? | 3844 | else // more details for other temporal layers? |
| 3846 | eNalRefIdc = NRI_PRI_HIGHEST; | 3845 | eNalRefIdc = NRI_PRI_HIGHEST; |
| 3847 | pCtx->eNalType = eNalType; | 3846 | pCtx->eNalType = eNalType; |
| 3848 | pCtx->eNalPriority = eNalRefIdc; | 3847 | pCtx->eNalPriority = eNalRefIdc; |
| 3849 | 3848 | ||
| 3850 | pCtx->pDecPic = pCtx->ppRefPicListExt[iCurDid]->pNextBuffer; | 3849 | pCtx->pDecPic = pCtx->ppRefPicListExt[iCurDid]->pNextBuffer; |
| 3851 | #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) | 3850 | #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC) |
| @@ -3887,11 +3886,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 35 unmodified lines | |||
| 3887 | PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer() | 3886 | PreprocessSliceCoding (pCtx); // MUST be called after pfWelsRcPictureInit() and WelsInitCurrentLayer() |
| 3888 | 3887 | ||
| 3889 | //TODO Complexity Calculation here for screen content | 3888 | //TODO Complexity Calculation here for screen content |
| 3890 | iLayerSize = 0; | 3889 | iLayerSize = 0; |
| 3891 | 3890 | ||
| 3892 | if (SM_SINGLE_SLICE == pParam->sSliceCfg.uiSliceMode) { // only one slice within a sQualityStat layer | 3891 | if (SM_SINGLE_SLICE == pParam->sSliceCfg.uiSliceMode) { // only one slice within a sQualityStat layer |
| 3893 | int32_t iSliceSize = 0; | 3892 | int32_t iSliceSize = 0; |
| 3894 | int32_t iPayloadSize = 0; | 3893 | int32_t iPayloadSize = 0; |
| 3895 | 3894 | ||
| 3896 | if (pCtx->bNeedPrefixNalFlag) { | 3895 | if (pCtx->bNeedPrefixNalFlag) { |
| 3897 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, | 3896 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, |
| @@ -3935,8 +3934,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 37 unmodified lines | |||
| 3935 | int32_t iRet = 0; | 3934 | int32_t iRet = 0; |
| 3936 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE | 3935 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE |
| 3937 | if ((SM_DYN_SLICE != pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { | 3936 | if ((SM_DYN_SLICE != pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3938 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); | 3937 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); |
| 3939 | if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed | 3938 | if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed |
| 3940 | WelsLog (pLogCtx, WELS_LOG_ERROR, | 3939 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 3941 | "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!", | 3940 | "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!", |
| 3942 | iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, pParam->sSliceCfg.uiSliceMode, iSliceCount); | 3941 | iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, pParam->sSliceCfg.uiSliceMode, iSliceCount); |
| @@ -3954,7 +3953,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 11 unmodified lines | |||
| 3954 | int64_t t_bs_append = 0; | 3953 | int64_t t_bs_append = 0; |
| 3955 | #endif | 3954 | #endif |
| 3956 | 3955 | ||
| 3957 | pCtx->iActiveThreadsNum = iSliceCount; | 3956 | pCtx->iActiveThreadsNum = iSliceCount; |
| 3958 | // to fire slice coding threads | 3957 | // to fire slice coding threads |
| 3959 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 3958 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| 3960 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], | 3959 | &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| @@ -4011,8 +4010,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 50 unmodified lines | |||
| 4011 | while (1) { | 4010 | while (1) { |
| 4012 | if (iIndexOfSliceToBeCoded >= iSliceCount && iNumThreadsRunning <= 0) | 4011 | if (iIndexOfSliceToBeCoded >= iSliceCount && iNumThreadsRunning <= 0) |
| 4013 | break; | 4012 | break; |
| 4014 | WELS_THREAD_ERROR_CODE lwait = 0; | 4013 | WELS_THREAD_ERROR_CODE lwait = 0; |
| 4015 | int32_t iEventId = -1; | 4014 | int32_t iEventId = -1; |
| 4016 | 4015 | ||
| 4017 | lwait = WelsMultipleEventsWaitSingleBlocking (iNumThreadsScheduled, | 4016 | lwait = WelsMultipleEventsWaitSingleBlocking (iNumThreadsScheduled, |
| 4018 | &pCtx->pSliceThreading->pSliceCodedEvent[0], | 4017 | &pCtx->pSliceThreading->pSliceCodedEvent[0], |
| @@ -4022,7 +4021,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 3 unmodified lines | |||
| 4022 | if (iIndexOfSliceToBeCoded < iSliceCount) { | 4021 | if (iIndexOfSliceToBeCoded < iSliceCount) { |
| 4023 | // pick up succeeding slice for threading | 4022 | // pick up succeeding slice for threading |
| 4024 | // thread_id equal to iEventId per implementation here | 4023 | // thread_id equal to iEventId per implementation here |
| 4025 | pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded; | 4024 | pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded; |
| 4026 | WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]); | 4025 | WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]); |
| 4027 | WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]); | 4026 | WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iEventId]); |
| 4028 | 4027 | ||
| @@ -4040,7 +4039,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 11 unmodified lines | |||
| 4040 | } | 4039 | } |
| 4041 | // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE | 4040 | // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE |
| 4042 | else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { | 4041 | else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 4043 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; | 4042 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; |
| 4044 | 4043 | ||
| 4045 | // to fire slice coding threads | 4044 | // to fire slice coding threads |
| 4046 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], | 4045 | iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0], |
| @@ -4059,11 +4058,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 12 unmodified lines | |||
| 4059 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 4058 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 4060 | 4059 | ||
| 4061 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); | 4060 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 4062 | } else { // for non-dynamic-slicing mode single threading branch.. | 4061 | } else { // for non-dynamic-slicing mode single threading branch.. |
| 4063 | const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; | 4062 | const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; |
| 4064 | int32_t iSliceIdx = 0; | 4063 | int32_t iSliceIdx = 0; |
| 4065 | 4064 | ||
| 4066 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); | 4065 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); |
| 4067 | while (iSliceIdx < iSliceCount) { | 4066 | while (iSliceIdx < iSliceCount) { |
| 4068 | int32_t iSliceSize = 0; | 4067 | int32_t iSliceSize = 0; |
| 4069 | int32_t iPayloadSize = 0; | 4068 | int32_t iPayloadSize = 0; |
| @@ -4161,19 +4160,19 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 91 unmodified lines | |||
| 4161 | #endif//ENABLE_FRAME_DUMP | 4160 | #endif//ENABLE_FRAME_DUMP |
| 4162 | 4161 | ||
| 4163 | #if defined(ENABLE_PSNR_CALC) | 4162 | #if defined(ENABLE_PSNR_CALC) |
| 4164 | fSnrY = WelsCalcPsnr (fsnr->pData[0], | 4163 | fSnrY = WelsCalcPsnr (fsnr->pData[0], |
| 4165 | fsnr->iLineSize[0], | 4164 | fsnr->iLineSize[0], |
| 4166 | pEncPic->pData[0], | 4165 | pEncPic->pData[0], |
| 4167 | pEncPic->iLineSize[0], | 4166 | pEncPic->iLineSize[0], |
| 4168 | iCurWidth, | 4167 | iCurWidth, |
| 4169 | iCurHeight); | 4168 | iCurHeight); |
| 4170 | fSnrU = WelsCalcPsnr (fsnr->pData[1], | 4169 | fSnrU = WelsCalcPsnr (fsnr->pData[1], |
| 4171 | fsnr->iLineSize[1], | 4170 | fsnr->iLineSize[1], |
| 4172 | pEncPic->pData[1], | 4171 | pEncPic->pData[1], |
| 4173 | pEncPic->iLineSize[1], | 4172 | pEncPic->iLineSize[1], |
| 4174 | (iCurWidth >> 1), | 4173 | (iCurWidth >> 1), |
| 4175 | (iCurHeight >> 1)); | 4174 | (iCurHeight >> 1)); |
| 4176 | fSnrV = WelsCalcPsnr (fsnr->pData[2], | 4175 | fSnrV = WelsCalcPsnr (fsnr->pData[2], |
| 4177 | fsnr->iLineSize[2], | 4176 | fsnr->iLineSize[2], |
| 4178 | pEncPic->pData[2], | 4177 | pEncPic->pData[2], |
| 4179 | pEncPic->iLineSize[2], | 4178 | pEncPic->iLineSize[2], |
| @@ -4231,8 +4230,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 51 unmodified lines | |||
| 4231 | 4230 | ||
| 4232 | #endif//MB_TYPES_CHECK | 4231 | #endif//MB_TYPES_CHECK |
| 4233 | { | 4232 | { |
| 4234 | ++ pCtx->sStatData[iCurDid][0].sSliceData.iSliceCount[pCtx->eSliceType]; // for multiple slices coding | 4233 | ++ pCtx->sStatData[iCurDid][0].sSliceData.iSliceCount[pCtx->eSliceType]; // for multiple slices coding |
| 4235 | pCtx->sStatData[iCurDid][0].sSliceData.iSliceSize[pCtx->eSliceType] += (iLayerSize << 3); // bits | 4234 | pCtx->sStatData[iCurDid][0].sSliceData.iSliceSize[pCtx->eSliceType] += (iLayerSize << 3); // bits |
| 4236 | } | 4235 | } |
| 4237 | #endif//STAT_OUTPUT | 4236 | #endif//STAT_OUTPUT |
| 4238 | 4237 | ||
| @@ -4240,7 +4239,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1 unmodified line | |||
| 4240 | ++ iLayerNum; | 4239 | ++ iLayerNum; |
| 4241 | ++ pLayerBsInfo; | 4240 | ++ pLayerBsInfo; |
| 4242 | 4241 | ||
| 4243 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 4242 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 4244 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; | 4243 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 4245 | 4244 | ||
| 4246 | if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { | 4245 | if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { |
| @@ -4334,8 +4333,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 87 unmodified lines | |||
| 4334 | } | 4333 | } |
| 4335 | 4334 | ||
| 4336 | ++ pCtx->iCodingIndex; | 4335 | ++ pCtx->iCodingIndex; |
| 4337 | pCtx->eLastNalPriority = eNalRefIdc; | 4336 | pCtx->eLastNalPriority = eNalRefIdc; |
| 4338 | pFbi->iLayerNum = iLayerNum; | 4337 | pFbi->iLayerNum = iLayerNum; |
| 4339 | pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType); | 4338 | pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType); |
| 4340 | 4339 | ||
| 4341 | WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iSubSeqId = %d,iFrameSize = %d", | 4340 | WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iSubSeqId = %d,iFrameSize = %d", |
| @@ -4383,19 +4382,19 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 41 unmodified lines | |||
| 4383 | * SVC adjustment results in new requirement in memory blocks adjustment | 4382 | * SVC adjustment results in new requirement in memory blocks adjustment |
| 4384 | */ | 4383 | */ |
| 4385 | int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewParam) { | 4384 | int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewParam) { |
| 4386 | SWelsSvcCodingParam* pOldParam = NULL; | 4385 | SWelsSvcCodingParam* pOldParam = NULL; |
| 4387 | int32_t iReturn = ENC_RETURN_SUCCESS; | 4386 | int32_t iReturn = ENC_RETURN_SUCCESS; |
| 4388 | int8_t iIndexD = 0; | 4387 | int8_t iIndexD = 0; |
| 4389 | bool bNeedReset = false; | 4388 | bool bNeedReset = false; |
| 4390 | int16_t iSliceNum = 1; // number of slices used | 4389 | int16_t iSliceNum = 1; // number of slices used |
| 4391 | int32_t iCacheLineSize = 16; // on chip cache line size in byte | 4390 | int32_t iCacheLineSize = 16; // on chip cache line size in byte |
| 4392 | uint32_t uiCpuFeatureFlags = 0; | 4391 | uint32_t uiCpuFeatureFlags = 0; |
| 4393 | 4392 | ||
| 4394 | if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; | 4393 | if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; |
| 4395 | 4394 | ||
| 4396 | /* Check validation in new parameters */ | 4395 | /* Check validation in new parameters */ |
| 4397 | iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); | 4396 | iReturn = ParamValidationExt (& (*ppCtx)->sLogCtx, pNewParam); |
| 4398 | if (iReturn != ENC_RETURN_SUCCESS) return iReturn; | 4397 | if (iReturn != ENC_RETURN_SUCCESS) return iReturn; |
| 4399 | 4398 | ||
| 4400 | iReturn = GetMultipleThreadIdc (& (*ppCtx)->sLogCtx, pNewParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); | 4399 | iReturn = GetMultipleThreadIdc (& (*ppCtx)->sLogCtx, pNewParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); |
| 4401 | if (iReturn != ENC_RETURN_SUCCESS) { | 4400 | if (iReturn != ENC_RETURN_SUCCESS) { |
| @@ -4404,7 +4403,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 2 unmodified lines | |||
| 4404 | return iReturn; | 4403 | return iReturn; |
| 4405 | } | 4404 | } |
| 4406 | 4405 | ||
| 4407 | pOldParam = (*ppCtx)->pSvcParam; | 4406 | pOldParam = (*ppCtx)->pSvcParam; |
| 4408 | 4407 | ||
| 4409 | if (pOldParam->iUsageType != pNewParam->iUsageType) { | 4408 | if (pOldParam->iUsageType != pNewParam->iUsageType) { |
| 4410 | WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, | 4409 | WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR, |
| @@ -4446,7 +4445,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 35 unmodified lines | |||
| 4446 | pOldParam->sSpatialLayers[iIndexD].iVideoHeight != pNewParam->sSpatialLayers[iIndexD].iVideoHeight || | 4445 | pOldParam->sSpatialLayers[iIndexD].iVideoHeight != pNewParam->sSpatialLayers[iIndexD].iVideoHeight || |
| 4447 | kpOldDlp->iActualWidth != kpNewDlp->iActualWidth || | 4446 | kpOldDlp->iActualWidth != kpNewDlp->iActualWidth || |
| 4448 | kpOldDlp->iActualHeight != kpNewDlp->iActualHeight) { | 4447 | kpOldDlp->iActualHeight != kpNewDlp->iActualHeight) { |
| 4449 | bNeedReset = true; | 4448 | bNeedReset = true; |
| 4450 | break; | 4449 | break; |
| 4451 | } | 4450 | } |
| 4452 | 4451 | ||
| @@ -4454,7 +4453,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1 unmodified line | |||
| 4454 | || | 4453 | || |
| 4455 | pOldParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum != | 4454 | pOldParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum != |
| 4456 | pNewParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum) { | 4455 | pNewParam->sSpatialLayers[iIndexD].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 4457 | bNeedReset = true; | 4456 | bNeedReset = true; |
| 4458 | break; | 4457 | break; |
| 4459 | } | 4458 | } |
| 4460 | 4459 | ||
| @@ -4576,17 +4575,17 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 115 unmodified lines | |||
| 4576 | } | 4575 | } |
| 4577 | pOldParam->iDecompStages = pNewParam->iDecompStages; | 4576 | pOldParam->iDecompStages = pNewParam->iDecompStages; |
| 4578 | /* denoise control */ | 4577 | /* denoise control */ |
| 4579 | pOldParam->bEnableDenoise = pNewParam->bEnableDenoise; | 4578 | pOldParam->bEnableDenoise = pNewParam->bEnableDenoise; |
| 4580 | 4579 | ||
| 4581 | /* background detection control */ | 4580 | /* background detection control */ |
| 4582 | pOldParam->bEnableBackgroundDetection = pNewParam->bEnableBackgroundDetection; | 4581 | pOldParam->bEnableBackgroundDetection = pNewParam->bEnableBackgroundDetection; |
| 4583 | 4582 | ||
| 4584 | /* adaptive quantization control */ | 4583 | /* adaptive quantization control */ |
| 4585 | pOldParam->bEnableAdaptiveQuant = pNewParam->bEnableAdaptiveQuant; | 4584 | pOldParam->bEnableAdaptiveQuant = pNewParam->bEnableAdaptiveQuant; |
| 4586 | 4585 | ||
| 4587 | /* int32_t term reference control */ | 4586 | /* int32_t term reference control */ |
| 4588 | pOldParam->bEnableLongTermReference = pNewParam->bEnableLongTermReference; | 4587 | pOldParam->bEnableLongTermReference = pNewParam->bEnableLongTermReference; |
| 4589 | pOldParam->iLtrMarkPeriod = pNewParam->iLtrMarkPeriod; | 4588 | pOldParam->iLtrMarkPeriod = pNewParam->iLtrMarkPeriod; |
| 4590 | 4589 | ||
| 4591 | // keep below values unchanged as before | 4590 | // keep below values unchanged as before |
| 4592 | pOldParam->bEnableSSEI = pNewParam->bEnableSSEI; | 4591 | pOldParam->bEnableSSEI = pNewParam->bEnableSSEI; |
| @@ -4606,7 +4605,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 13 unmodified lines | |||
| 4606 | pOldParam->iPaddingFlag = pNewParam->iPaddingFlag; | 4605 | pOldParam->iPaddingFlag = pNewParam->iPaddingFlag; |
| 4607 | 4606 | ||
| 4608 | /* Layer definition */ | 4607 | /* Layer definition */ |
| 4609 | pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl; | 4608 | pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl; |
| 4610 | 4609 | ||
| 4611 | // d | 4610 | // d |
| 4612 | iIndexD = 0; | 4611 | iIndexD = 0; |
| @@ -4641,13 +4640,13 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 28 unmodified lines | |||
| 4641 | } | 4640 | } |
| 4642 | 4641 | ||
| 4643 | int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* pLTRValue) { | 4642 | int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* pLTRValue) { |
| 4644 | SWelsSvcCodingParam sConfig; | 4643 | SWelsSvcCodingParam sConfig; |
| 4645 | int32_t iNumRefFrame = 1; | 4644 | int32_t iNumRefFrame = 1; |
| 4646 | int32_t iRet = 0; | 4645 | int32_t iRet = 0; |
| 4647 | memcpy (&sConfig, (*ppCtx)->pSvcParam, sizeof (SWelsSvcCodingParam)); | 4646 | memcpy (&sConfig, (*ppCtx)->pSvcParam, sizeof (SWelsSvcCodingParam)); |
| 4648 | sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference; | 4647 | sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference; |
| 4649 | sConfig.iLTRRefNum = pLTRValue->iLTRRefNum; | 4648 | sConfig.iLTRRefNum = pLTRValue->iLTRRefNum; |
| 4650 | int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1); | 4649 | int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1); |
| 4651 | if (sConfig.iUsageType == SCREEN_CONTENT_REAL_TIME) { | 4650 | if (sConfig.iUsageType == SCREEN_CONTENT_REAL_TIME) { |
| 4652 | if (sConfig.bEnableLongTermReference) { | 4651 | if (sConfig.bEnableLongTermReference) { |
| 4653 | sConfig.iLTRRefNum = LONG_TERM_REF_NUM_SCREEN;//WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN); | 4652 | sConfig.iLTRRefNum = LONG_TERM_REF_NUM_SCREEN;//WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN); |
| @@ -4662,9 +4661,9 @@ int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConf · 8 unmodified lines | |||
| 4662 | } else { | 4661 | } else { |
| 4663 | sConfig.iLTRRefNum = 0; | 4662 | sConfig.iLTRRefNum = 0; |
| 4664 | } | 4663 | } |
| 4665 | iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + | 4664 | iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + |
| 4666 | sConfig.iLTRRefNum); | 4665 | sConfig.iLTRRefNum); |
| 4667 | iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); | 4666 | iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); |
| 4668 | 4667 | ||
| 4669 | } | 4668 | } |
| 4670 | if (iNumRefFrame > sConfig.iMaxNumRefFrame) { | 4669 | if (iNumRefFrame > sConfig.iMaxNumRefFrame) { |
| @@ -4803,7 +4802,7 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 132 unmodified lines | |||
| 4803 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); | 4802 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); |
| 4804 | uiSliceIdx = iMaxSliceNumOld; | 4803 | uiSliceIdx = iMaxSliceNumOld; |
| 4805 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; | 4804 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; |
| 4806 | const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, | 4805 | const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, |
| 4807 | pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); | 4806 | pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); |
| 4808 | while (uiSliceIdx < iMaxSliceNum) { | 4807 | while (uiSliceIdx < iMaxSliceNum) { |
| 4809 | pSORC->iComplexityIndexSlice = 0; | 4808 | pSORC->iComplexityIndexSlice = 0; |