clean multi-threading macro
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 16 files). Show all
Unified · Split
| @@ -51,9 +51,7 @@ · 50 unmodified lines | ||
| 51 | 51 | #include "ref_list_mgr_svc.h" |
| 52 | 52 | #include "ls_defines.h" |
| 53 | 53 | #include "crt_util_safe_x.h" // Safe CRT routines like utils for cross platforms |
| 54 | −#if defined(MT_ENABLED) | |
| 55 | 54 | #include "slice_multi_threading.h" |
| 56 | −#endif//MT_ENABLED | |
| 57 | 55 | #include "measure_time.h" |
| 58 | 56 | |
| 59 | 57 | namespace WelsSVCEnc { |
| @@ -161,7 +159,6 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 101 unmodified lines | ||
| 161 | 159 | } |
| 162 | 160 | |
| 163 | 161 | |
| 164 | −#ifdef MT_ENABLED | |
| 165 | 162 | //about iMultipleThreadIdc, bDeblockingParallelFlag, iLoopFilterDisableIdc, & uiSliceMode |
| 166 | 163 | // (1) Single Thread |
| 167 | 164 | // if (THREAD==1)//single thread |
| @@ -173,9 +170,6 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 5 unmodified lines | ||
| 173 | 170 | } else { |
| 174 | 171 | pCodingParam->bDeblockingParallelFlag = true; |
| 175 | 172 | } |
| 176 | −#else | |
| 177 | − pCodingParam->bDeblockingParallelFlag = false; | |
| 178 | −#endif//MT_ENABLED | |
| 179 | 173 | |
| 180 | 174 | for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) { |
| 181 | 175 | SDLayerParam* fDlp = &pCodingParam->sDependencyLayers[i]; |
| @@ -291,11 +285,9 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 109 unmodified lines | ||
| 291 | 285 | fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 292 | 286 | break; |
| 293 | 287 | } |
| 294 | −#ifdef MT_ENABLED | |
| 295 | 288 | if (pCodingParam->bEnableRc && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) { |
| 296 | 289 | WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), WARNING: GOM based RC do not support SM_RASTER_SLICE!\n"); |
| 297 | 290 | } |
| 298 | −#endif | |
| 299 | 291 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 300 | 292 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 301 | 293 | fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| @@ -501,19 +493,11 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 199 unmodified lines | ||
| 501 | 493 | iCountNumLayers; // plus iCountNumLayers for reserved application |
| 502 | 494 | |
| 503 | 495 | // to check number of layers / nals / slices dependencies, 12/8/2010 |
| 504 | −#if !defined(MT_ENABLED) | |
| 505 | 496 | if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) { |
| 506 | 497 | WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", |
| 507 | 498 | iCountNumLayers, MAX_LAYER_NUM_OF_FRAME); |
| 508 | 499 | return 1; |
| 509 | 500 | } |
| 510 | −#else//MT_ENABLED | |
| 511 | − if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) { | |
| 512 | − WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", | |
| 513 | − iCountNumLayers, MAX_LAYER_NUM_OF_FRAME); | |
| 514 | − return 1; | |
| 515 | − } | |
| 516 | −#endif//!MT_ENABLED | |
| 517 | 501 | |
| 518 | 502 | if (NULL != pCountLayers) |
| 519 | 503 | *pCountLayers = iCountNumLayers; |
| @@ -777,31 +761,6 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 257 unmodified lines | ||
| 777 | 761 | |
| 778 | 762 | pDqLayer->iMbWidth = kiMbW; |
| 779 | 763 | pDqLayer->iMbHeight = kiMbH; |
| 780 | −#ifndef MT_ENABLED | |
| 781 | − if (SM_DYN_SLICE == pDlayer->sSliceCfg.uiSliceMode) { //wmalloc pSliceInLayer | |
| 782 | − SSlice* pSlice = NULL; | |
| 783 | − int32_t iSliceIdx = 0; | |
| 784 | − //wmalloc AVERSLICENUM_CONSTANT of pDqLayer->sLayerInfo.pSliceInLayer, | |
| 785 | − //wmalloc AVERSLICENUM_CONSTANT num of pSlice as initialization | |
| 786 | − //only set value for the first pSlice | |
| 787 | − pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); | |
| 788 | − | |
| 789 | − WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx)) { | |
| 790 | − pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[0]; | |
| 791 | − pSlice->uiSliceIdx = 0; | |
| 792 | − pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; | |
| 793 | − } | |
| 794 | − | |
| 795 | − while (iSliceIdx < iMaxSliceNum) { | |
| 796 | − pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx]; | |
| 797 | − if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) { | |
| 798 | − FreeMemorySvc (ppCtx); | |
| 799 | − return 1; | |
| 800 | − } | |
| 801 | − ++ iSliceIdx; | |
| 802 | − } | |
| 803 | − } else | |
| 804 | −#endif//!MT_ENABLED | |
| 805 | 764 | { |
| 806 | 765 | int32_t iSliceIdx = 0; |
| 807 | 766 | pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); |
| @@ -811,14 +770,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 3 unmodified lines | ||
| 811 | 770 | while (iSliceIdx < iMaxSliceNum) { |
| 812 | 771 | SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| 813 | 772 | pSlice->uiSliceIdx = iSliceIdx; |
| 814 | −#ifdef MT_ENABLED | |
| 815 | 773 | if (pParam->iMultipleThreadIdc > 1) |
| 816 | 774 | pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite; |
| 817 | 775 | else |
| 818 | 776 | pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; |
| 819 | −#else | |
| 820 | − pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; | |
| 821 | −#endif//MT_ENABLED | |
| 822 | 777 | if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) { |
| 823 | 778 | FreeMemorySvc (ppCtx); |
| 824 | 779 | return 1; |
| @@ -856,11 +811,9 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 31 unmodified lines | ||
| 856 | 811 | pDqLayer->bDeblockingParallelFlag = false; |
| 857 | 812 | } else { |
| 858 | 813 | //multi-pSlice |
| 859 | −#ifdef MT_ENABLED | |
| 860 | 814 | if (0 == pDqLayer->iLoopFilterDisableIdc) { |
| 861 | 815 | pDqLayer->bDeblockingParallelFlag = false; |
| 862 | 816 | } |
| 863 | −#endif | |
| 864 | 817 | } |
| 865 | 818 | |
| 866 | 819 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; |
| @@ -1227,9 +1180,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 360 unmodified lines | ||
| 1227 | 1180 | const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableSize * sizeof (uint16_t); |
| 1228 | 1181 | int32_t iVclLayersBsSizeCount = 0; |
| 1229 | 1182 | int32_t iNonVclLayersBsSizeCount = 0; |
| 1230 | −#if defined(MT_ENABLED) | |
| 1231 | 1183 | int32_t iTargetSpatialBsSize = 0; |
| 1232 | −#endif//MT_ENABLED | |
| 1233 | 1184 | |
| 1234 | 1185 | if (kiNumDependencyLayers < 1 || kiNumDependencyLayers > MAX_DEPENDENCY_LAYER) { |
| 1235 | 1186 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc() failed due to invalid iNumDependencyLayers(%d)!\n", |
| @@ -1273,9 +1224,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 37 unmodified lines | ||
| 1273 | 1224 | iVclLayersBsSizeCount += iLayerBsSize; |
| 1274 | 1225 | ++ iIndex; |
| 1275 | 1226 | } |
| 1276 | −#if defined(MT_ENABLED) | |
| 1277 | 1227 | iTargetSpatialBsSize = iLayerBsSize; |
| 1278 | −#endif//MT_ENABLED | |
| 1279 | 1228 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; |
| 1280 | 1229 | |
| 1281 | 1230 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); |
| @@ -1291,14 +1240,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 9 unmodified lines | ||
| 1291 | 1240 | (*ppCtx)->pOut->iCountNals = iCountNals; |
| 1292 | 1241 | (*ppCtx)->pOut->iNalIndex = 0; |
| 1293 | 1242 | |
| 1294 | −#ifdef MT_ENABLED | |
| 1295 | 1243 | if (pParam->iMultipleThreadIdc > 1) { |
| 1296 | 1244 | const int32_t iTotalLength = iCountBsLen + (iTargetSpatialBsSize * ((*ppCtx)->iMaxSliceCount - 1)); |
| 1297 | 1245 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); |
| 1298 | 1246 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1299 | 1247 | (*ppCtx)->iFrameBsSize = iTotalLength; |
| 1300 | 1248 | } else |
| 1301 | −#endif//MT_ENABLED | |
| 1302 | 1249 | { |
| 1303 | 1250 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); |
| 1304 | 1251 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| @@ -1306,14 +1253,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 1 unmodified line | ||
| 1306 | 1253 | } |
| 1307 | 1254 | (*ppCtx)->iPosBsBuffer = 0; |
| 1308 | 1255 | |
| 1309 | −#ifdef MT_ENABLED | |
| 1310 | 1256 | // for pSlice bs buffers |
| 1311 | 1257 | if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iTargetSpatialBsSize)) { |
| 1312 | 1258 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMtResource failed!"); |
| 1313 | 1259 | FreeMemorySvc (ppCtx); |
| 1314 | 1260 | return 1; |
| 1315 | 1261 | } |
| 1316 | −#endif | |
| 1317 | 1262 | |
| 1318 | 1263 | (*ppCtx)->pIntra4x4PredModeBlocks = static_cast<int8_t*> |
| 1319 | 1264 | (pMa->WelsMallocz (iCountMaxMbNum * INTRA_4x4_MODE_NUM, "pIntra4x4PredModeBlocks")); |
| @@ -1481,10 +1426,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 161 unmodified lines | ||
| 1481 | 1426 | pCtx->pOut = NULL; |
| 1482 | 1427 | } |
| 1483 | 1428 | |
| 1484 | −#ifdef MT_ENABLED | |
| 1485 | 1429 | if (pParam != NULL && pParam->iMultipleThreadIdc > 1) |
| 1486 | 1430 | ReleaseMtResource (ppCtx); |
| 1487 | −#endif//MT_ENABLED | |
| 1488 | 1431 | |
| 1489 | 1432 | // frame bitstream pBuffer |
| 1490 | 1433 | if (NULL != pCtx->pFrameBs) { |
| @@ -1722,9 +1665,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 231 unmodified lines | ||
| 1722 | 1665 | switch (pMso->uiSliceMode) { |
| 1723 | 1666 | case SM_DYN_SLICE: |
| 1724 | 1667 | iMaxSliceCount = AVERSLICENUM_CONSTRAINT; |
| 1725 | −//#ifndef MT_ENABLED | |
| 1726 | − break; // go through for MT_ENABLED & SM_DYN_SLICE? | |
| 1727 | −//#endif//MT_ENABLED | |
| 1668 | + break; // go through for SM_DYN_SLICE? | |
| 1728 | 1669 | case SM_FIXEDSLCNUM_SLICE: |
| 1729 | 1670 | if (iSliceNum > iMaxSliceCount) |
| 1730 | 1671 | iMaxSliceCount = iSliceNum; |
| @@ -1788,13 +1729,8 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 57 unmodified lines | ||
| 1788 | 1729 | ++ iSpatialIdx; |
| 1789 | 1730 | } while (iSpatialIdx < iSpatialNum); |
| 1790 | 1731 | |
| 1791 | −#ifdef MT_ENABLED | |
| 1792 | 1732 | pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); |
| 1793 | 1733 | pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; |
| 1794 | −#else | |
| 1795 | − pCodingParam->iMultipleThreadIdc = 1; | |
| 1796 | − pCodingParam->iCountThreadsNum = 1; | |
| 1797 | −#endif//MT_ENABLED | |
| 1798 | 1734 | |
| 1799 | 1735 | #ifndef WELS_TESTBED // for product release and non-SGE testing |
| 1800 | 1736 | |
| @@ -1903,7 +1839,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 102 unmodified lines | ||
| 1903 | 1839 | |
| 1904 | 1840 | #ifndef WELS_TESTBED |
| 1905 | 1841 | |
| 1906 | −#if defined(MT_ENABLED) && defined(DYNAMIC_DETECT_CPU_CORES) | |
| 1842 | +#if defined(DYNAMIC_DETECT_CPU_CORES) | |
| 1907 | 1843 | if (pCodingParam->iMultipleThreadIdc > 0) |
| 1908 | 1844 | uiCpuCores = pCodingParam->iMultipleThreadIdc; |
| 1909 | 1845 | else { |
| @@ -1917,7 +1853,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 7 unmodified lines | ||
| 1917 | 1853 | else if (uiCpuCores < 1) // just for safe |
| 1918 | 1854 | uiCpuCores = 1; |
| 1919 | 1855 | } |
| 1920 | −#endif//MT_ENABLED && DYNAMIC_DETECT_CPU_CORES | |
| 1856 | +#endif//DYNAMIC_DETECT_CPU_CORES | |
| 1921 | 1857 | |
| 1922 | 1858 | #else//WELS_TESTBED |
| 1923 | 1859 | |
| @@ -1979,10 +1915,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 55 unmodified lines | ||
| 1979 | 1915 | return iRet; |
| 1980 | 1916 | } |
| 1981 | 1917 | |
| 1982 | −#ifdef MT_ENABLED | |
| 1983 | 1918 | if (pCodingParam->iMultipleThreadIdc > 1) |
| 1984 | 1919 | iRet = CreateSliceThreads (pCtx); |
| 1985 | −#endif | |
| 1986 | 1920 | |
| 1987 | 1921 | WelsRcInitModule (pCtx, pCtx->pSvcParam->bEnableRc ? WELS_RC_GOM : WELS_RC_DISABLE); |
| 1988 | 1922 | |
| @@ -2108,7 +2042,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 119 unmodified lines | ||
| 2108 | 2042 | StatOverallEncodingExt (*ppCtx); |
| 2109 | 2043 | #endif |
| 2110 | 2044 | |
| 2111 | −#if defined(MT_ENABLED) | |
| 2112 | 2045 | if ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && (*ppCtx)->pSliceThreading != NULL) { |
| 2113 | 2046 | const int32_t iThreadCount = (*ppCtx)->pSvcParam->iCountThreadsNum; |
| 2114 | 2047 | int32_t iThreadIdx = 0; |
| @@ -2128,7 +2061,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 13 unmodified lines | ||
| 2128 | 2061 | } |
| 2129 | 2062 | } |
| 2130 | 2063 | } |
| 2131 | −#endif//MT_ENABLED | |
| 2132 | 2064 | |
| 2133 | 2065 | if ((*ppCtx)->pVpp) { |
| 2134 | 2066 | (*ppCtx)->pVpp->FreeSpatialPictures(*ppCtx); |
| @@ -2201,19 +2133,14 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 66 unmodified lines | ||
| 2201 | 2133 | */ |
| 2202 | 2134 | int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { |
| 2203 | 2135 | int32_t iPartitionNum = 1; |
| 2204 | −#ifdef MT_ENABLED | |
| 2205 | 2136 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { |
| 2206 | 2137 | iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; |
| 2207 | 2138 | if (P_SLICE == pCtx->eSliceType) |
| 2208 | 2139 | iPartitionNum = 1; |
| 2209 | 2140 | } |
| 2210 | 2141 | return iPartitionNum; |
| 2211 | −#else | |
| 2212 | − return iPartitionNum; | |
| 2213 | −#endif//MT_ENABLED | |
| 2214 | 2142 | } |
| 2215 | 2143 | |
| 2216 | −#if defined(MT_ENABLED) | |
| 2217 | 2144 | void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { |
| 2218 | 2145 | //pData init |
| 2219 | 2146 | SDqLayer* pCurDq = pCtx->pCurDqLayer; |
| @@ -2304,83 +2231,6 @@ void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { · 84 unmodified lines | ||
| 2304 | 2231 | |
| 2305 | 2232 | WelsInitCurrentQBLayerMltslc (pCtx); |
| 2306 | 2233 | } |
| 2307 | −#else | |
| 2308 | −void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { | |
| 2309 | − //pData init | |
| 2310 | − SDqLayer* pCurDq = pCtx->pCurDqLayer; | |
| 2311 | − SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); | |
| 2312 | − SSlice* pSlice = &pCurDq->sLayerInfo.pSliceInLayer[0]; | |
| 2313 | − int32_t iTtlMbNumInFrame = pSliceCtx->iMbNumInFrame; | |
| 2314 | − | |
| 2315 | − //pSliceCtx | |
| 2316 | − memset (pSliceCtx->pOverallMbMap, 0, iTtlMbNumInFrame * sizeof (uint8_t)); | |
| 2317 | − memset (pSliceCtx->pCountMbNumInSlice, 0, pSliceCtx->iSliceNumInFrame * sizeof (int32_t)); | |
| 2318 | − memset (pSliceCtx->pFirstMbInSlice, 0, pSliceCtx->iSliceNumInFrame * sizeof (int16_t)); | |
| 2319 | − pSliceCtx->iSliceNumInFrame = 1;// | |
| 2320 | − pSliceCtx->pCountMbNumInSlice[0] = iTtlMbNumInFrame; | |
| 2321 | − | |
| 2322 | − //mb_neighbor | |
| 2323 | − DynslcUpdateMbNeighbourInfoListForAllSlices (pSliceCtx, pCurDq->sMbDataP); | |
| 2324 | − | |
| 2325 | − //pSlice init | |
| 2326 | − pSlice->uiSliceIdx = 0; | |
| 2327 | − pSlice->pSliceBsa = &pCtx->pOut->sBsWrite; | |
| 2328 | − pSlice->bDynamicSlicingSliceSizeCtrlFlag = false; | |
| 2329 | − pSlice->uiAssumeLog2BytePerMb = (pCtx->eSliceType == P_SLICE) ? 0 : 1; | |
| 2330 | −} | |
| 2331 | − | |
| 2332 | −void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { | |
| 2333 | − SDqLayer* pCurDq = pCtx->pCurDqLayer; | |
| 2334 | − SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); | |
| 2335 | − int32_t iTtlMbNumInFrame = pCurDq->iMbHeight * pCurDq->iMbWidth; | |
| 2336 | − | |
| 2337 | − pSliceCtx->iMbNumInFrame | |
| 2338 | − = pSliceCtx->pCountMbNumInSlice[0] = iTtlMbNumInFrame; | |
| 2339 | − | |
| 2340 | − if (I_SLICE == pCtx->eSliceType) { //check if uiSliceSizeConstraint too small | |
| 2341 | −#define byte_complexIMBat26 (60) | |
| 2342 | − uint8_t iCurDid = pCtx->uiDependencyId; | |
| 2343 | − uint32_t uiFrmByte = 0; | |
| 2344 | − | |
| 2345 | − if (pCtx->pSvcParam->bEnableRc) { | |
| 2346 | − //RC case | |
| 2347 | − uiFrmByte = ( | |
| 2348 | − ((uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].iSpatialBitrate) | |
| 2349 | − / (uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].fInputFrameRate)) >> 3); | |
| 2350 | − } else { | |
| 2351 | − //fixed QP case | |
| 2352 | − int32_t iQDeltaTo26 = (26 - pCtx->pSvcParam->sDependencyLayers[iCurDid].iDLayerQp); | |
| 2353 | − | |
| 2354 | − uiFrmByte = (iTtlMbNumInFrame * byte_complexIMBat26); | |
| 2355 | − if (iQDeltaTo26 > 0) { | |
| 2356 | − //smaller QP than 26 | |
| 2357 | − uiFrmByte = (uint32_t) (uiFrmByte * ((float)iQDeltaTo26 / 4)); | |
| 2358 | − } else if (iQDeltaTo26 < 0) { | |
| 2359 | − //larger QP than 26 | |
| 2360 | − iQDeltaTo26 = ((-iQDeltaTo26) >> 2); //delta mod 4 | |
| 2361 | − uiFrmByte = (uiFrmByte >> (iQDeltaTo26)); //if delta 4, byte /2 | |
| 2362 | − } | |
| 2363 | − } | |
| 2364 | − | |
| 2365 | − //MINPACKETSIZE_CONSTRAINT | |
| 2366 | − if (pSliceCtx->uiSliceSizeConstraint | |
| 2367 | − < | |
| 2368 | − (uint32_t) (uiFrmByte//suppose 16 byte per mb at average | |
| 2369 | − / (pSliceCtx->iMaxSliceNumConstraint)) | |
| 2370 | − ) { | |
| 2371 | − | |
| 2372 | − WelsLog (pCtx, | |
| 2373 | − WELS_LOG_WARNING, | |
| 2374 | − "Set-SliceConstraint(%d) too small for current resolution (MB# %d) under QP/BR!\n", | |
| 2375 | − pSliceCtx->uiSliceSizeConstraint, | |
| 2376 | − pSliceCtx->iMbNumInFrame | |
| 2377 | − ); | |
| 2378 | − } | |
| 2379 | − } | |
| 2380 | − | |
| 2381 | − WelsInitCurrentQBLayerMltslc (pCtx); | |
| 2382 | −} | |
| 2383 | −#endif | |
| 2384 | 2234 | |
| 2385 | 2235 | /*! |
| 2386 | 2236 | * \brief initialize current layer |
| @@ -2880,9 +2730,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 493 unmodified lines | ||
| 2880 | 2730 | SPicture* fsnr = NULL; |
| 2881 | 2731 | #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC |
| 2882 | 2732 | SPicture* pEncPic = NULL; // to be decided later |
| 2883 | −#if defined(MT_ENABLED) | |
| 2884 | 2733 | int32_t did_list[MAX_DEPENDENCY_LAYER] = {0}; |
| 2885 | −#endif//MT_ENABLED | |
| 2886 | 2734 | int32_t iLayerNum = 0; |
| 2887 | 2735 | int32_t iLayerSize = 0; |
| 2888 | 2736 | int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame |
| @@ -2972,22 +2820,18 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 83 unmodified lines | ||
| 2972 | 2820 | iCurWidth = param_d->iFrameWidth; |
| 2973 | 2821 | iCurHeight = param_d->iFrameHeight; |
| 2974 | 2822 | |
| 2975 | −#if defined(MT_ENABLED) | |
| 2976 | 2823 | did_list[iSpatialIdx] = iCurDid; |
| 2977 | −#endif//MT_ENABLED | |
| 2978 | 2824 | |
| 2979 | 2825 | // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed |
| 2980 | 2826 | |
| 2981 | 2827 | switch (param_d->sSliceCfg.uiSliceMode) { |
| 2982 | 2828 | case SM_FIXEDSLCNUM_SLICE: |
| 2983 | 2829 | case SM_AUTO_SLICE:{ |
| 2984 | −#if defined(MT_ENABLED) | |
| 2985 | 2830 | if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) && |
| 2986 | 2831 | (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 2987 | 2832 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum) |
| 2988 | 2833 | ) |
| 2989 | 2834 | AdjustEnhanceLayer (pCtx, iCurDid); |
| 2990 | −#endif//MT_ENABLED | |
| 2991 | 2835 | break; |
| 2992 | 2836 | } |
| 2993 | 2837 | case SM_DYN_SLICE: { |
| @@ -3100,18 +2944,13 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 106 unmodified lines | ||
| 3100 | 2944 | pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; |
| 3101 | 2945 | } |
| 3102 | 2946 | // for dynamic slicing single threading.. |
| 3103 | −#ifndef MT_ENABLED | |
| 3104 | − else if (SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) | |
| 3105 | −#else // MT_ENABLED | |
| 3106 | 2947 | else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) |
| 3107 | −#endif//MT_ENABLED | |
| 3108 | 2948 | { |
| 3109 | 2949 | const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame; |
| 3110 | 2950 | pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0, kiLastMbInFrame, 0); |
| 3111 | 2951 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3112 | 2952 | } else { |
| 3113 | 2953 | //other multi-slice uiSliceMode |
| 3114 | −#if defined(MT_ENABLED) | |
| 3115 | 2954 | int err = 0; |
| 3116 | 2955 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE |
| 3117 | 2956 | if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| @@ -3235,7 +3074,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 117 unmodified lines | ||
| 3235 | 3074 | |
| 3236 | 3075 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 3237 | 3076 | } else // for non-dynamic-slicing mode single threading branch.. |
| 3238 | −#endif//MT_ENABLED | |
| 3239 | 3077 | { |
| 3240 | 3078 | const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; |
| 3241 | 3079 | int32_t iSliceIdx = 0; |
| @@ -3290,9 +3128,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 48 unmodified lines | ||
| 3290 | 3128 | |
| 3291 | 3129 | // deblocking filter |
| 3292 | 3130 | if ( |
| 3293 | −#if defined(MT_ENABLED) | |
| 3294 | 3131 | (!pCtx->pCurDqLayer->bDeblockingParallelFlag) && |
| 3295 | −#endif//MT_ENABLED | |
| 3296 | 3132 | #if !defined(ENABLE_FRAME_DUMP) |
| 3297 | 3133 | ((eNalRefIdc != NRI_PRI_LOWEST) && (param_d->iHighestTemporalId == 0 || iCurTid < param_d->iHighestTemporalId)) && |
| 3298 | 3134 | #endif//!ENABLE_FRAME_DUMP |
| @@ -3432,7 +3268,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 133 unmodified lines | ||
| 3432 | 3268 | ++ iLayerNum; |
| 3433 | 3269 | } |
| 3434 | 3270 | |
| 3435 | −#if defined(MT_ENABLED) | |
| 3436 | 3271 | if ((param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE||param_d->sSliceCfg.uiSliceMode == SM_AUTO_SLICE) && pSvcParam->iMultipleThreadIdc > 1 && |
| 3437 | 3272 | pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3438 | 3273 | CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx, |
| @@ -3441,7 +3276,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3441 | 3276 | TrackSliceComplexities (pCtx, iCurDid); |
| 3442 | 3277 | #endif//#if defined(MT_DEBUG) |
| 3443 | 3278 | } |
| 3444 | −#endif//MT_ENABLED | |
| 3445 | 3279 | |
| 3446 | 3280 | ++ iSpatialIdx; |
| 3447 | 3281 | |
| @@ -3468,11 +3302,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 20 unmodified lines | ||
| 3468 | 3302 | } |
| 3469 | 3303 | } |
| 3470 | 3304 | |
| 3471 | −#if defined(MT_ENABLED) && defined(MT_DEBUG) | |
| 3305 | +#if defined(MT_DEBUG) | |
| 3472 | 3306 | TrackSliceConsumeTime (pCtx, did_list, iSpatialNum); |
| 3473 | −#endif//MT_ENABLED && MT_DEBUG | |
| 3307 | +#endif//MT_DEBUG | |
| 3474 | 3308 | |
| 3475 | −#if defined(MT_ENABLED) | |
| 3476 | 3309 | if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID |
| 3477 | 3310 | && ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) |
| 3478 | 3311 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum |
| @@ -3481,7 +3314,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3481 | 3314 | 1]].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3482 | 3315 | AdjustBaseLayer (pCtx); |
| 3483 | 3316 | } |
| 3484 | −#endif | |
| 3485 | 3317 | |
| 3486 | 3318 | #ifdef ENABLE_FRAME_DUMP |
| 3487 | 3319 | DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - |