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 { |
| @@ -165,7 +163,6 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 105 unmodified lines | ||
| 165 | 163 | } |
| 166 | 164 | |
| 167 | 165 | |
| 168 | −#ifdef MT_ENABLED | |
| 169 | 166 | //about iMultipleThreadIdc, bDeblockingParallelFlag, iLoopFilterDisableIdc, & uiSliceMode |
| 170 | 167 | // (1) Single Thread |
| 171 | 168 | // if (THREAD==1)//single thread |
| @@ -177,9 +174,6 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 5 unmodified lines | ||
| 177 | 174 | } else { |
| 178 | 175 | pCodingParam->bDeblockingParallelFlag = true; |
| 179 | 176 | } |
| 180 | −#else | |
| 181 | − pCodingParam->bDeblockingParallelFlag = false; | |
| 182 | −#endif//MT_ENABLED | |
| 183 | 177 | |
| 184 | 178 | for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) { |
| 185 | 179 | SDLayerParam* fDlp = &pCodingParam->sDependencyLayers[i]; |
| @@ -295,11 +289,9 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 109 unmodified lines | ||
| 295 | 289 | fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 296 | 290 | break; |
| 297 | 291 | } |
| 298 | −#ifdef MT_ENABLED | |
| 299 | 292 | if (pCodingParam->bEnableRc && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) { |
| 300 | 293 | WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), WARNING: GOM based RC do not support SM_RASTER_SLICE!\n"); |
| 301 | 294 | } |
| 302 | −#endif | |
| 303 | 295 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 304 | 296 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 305 | 297 | fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| @@ -505,19 +497,11 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 199 unmodified lines | ||
| 505 | 497 | iCountNumLayers; // plus iCountNumLayers for reserved application |
| 506 | 498 | |
| 507 | 499 | // to check number of layers / nals / slices dependencies, 12/8/2010 |
| 508 | −#if !defined(MT_ENABLED) | |
| 509 | 500 | if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) { |
| 510 | 501 | WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", |
| 511 | 502 | iCountNumLayers, MAX_LAYER_NUM_OF_FRAME); |
| 512 | 503 | return 1; |
| 513 | 504 | } |
| 514 | −#else//MT_ENABLED | |
| 515 | − if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) { | |
| 516 | − WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", | |
| 517 | − iCountNumLayers, MAX_LAYER_NUM_OF_FRAME); | |
| 518 | − return 1; | |
| 519 | − } | |
| 520 | −#endif//!MT_ENABLED | |
| 521 | 505 | |
| 522 | 506 | if (NULL != pCountLayers) |
| 523 | 507 | *pCountLayers = iCountNumLayers; |
| @@ -781,31 +765,6 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 257 unmodified lines | ||
| 781 | 765 | |
| 782 | 766 | pDqLayer->iMbWidth = kiMbW; |
| 783 | 767 | pDqLayer->iMbHeight = kiMbH; |
| 784 | −#ifndef MT_ENABLED | |
| 785 | − if (SM_DYN_SLICE == pDlayer->sSliceCfg.uiSliceMode) { //wmalloc pSliceInLayer | |
| 786 | − SSlice* pSlice = NULL; | |
| 787 | − int32_t iSliceIdx = 0; | |
| 788 | − //wmalloc AVERSLICENUM_CONSTANT of pDqLayer->sLayerInfo.pSliceInLayer, | |
| 789 | − //wmalloc AVERSLICENUM_CONSTANT num of pSlice as initialization | |
| 790 | − //only set value for the first pSlice | |
| 791 | − pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); | |
| 792 | − | |
| 793 | − WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pDqLayer->sLayerInfo.pSliceInLayer), FreeMemorySvc (ppCtx)) { | |
| 794 | − pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[0]; | |
| 795 | − pSlice->uiSliceIdx = 0; | |
| 796 | − pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; | |
| 797 | − } | |
| 798 | − | |
| 799 | − while (iSliceIdx < iMaxSliceNum) { | |
| 800 | − pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx]; | |
| 801 | − if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) { | |
| 802 | − FreeMemorySvc (ppCtx); | |
| 803 | − return 1; | |
| 804 | − } | |
| 805 | − ++ iSliceIdx; | |
| 806 | − } | |
| 807 | − } else | |
| 808 | −#endif//!MT_ENABLED | |
| 809 | 768 | { |
| 810 | 769 | int32_t iSliceIdx = 0; |
| 811 | 770 | pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer"); |
| @@ -815,14 +774,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 3 unmodified lines | ||
| 815 | 774 | while (iSliceIdx < iMaxSliceNum) { |
| 816 | 775 | SSlice* pSlice = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| 817 | 776 | pSlice->uiSliceIdx = iSliceIdx; |
| 818 | −#ifdef MT_ENABLED | |
| 819 | 777 | if (pParam->iMultipleThreadIdc > 1) |
| 820 | 778 | pSlice->pSliceBsa = & (*ppCtx)->pSliceBs[iSliceIdx].sBsWrite; |
| 821 | 779 | else |
| 822 | 780 | pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; |
| 823 | −#else | |
| 824 | − pSlice->pSliceBsa = & (*ppCtx)->pOut->sBsWrite; | |
| 825 | −#endif//MT_ENABLED | |
| 826 | 781 | if (AllocMbCacheAligned (&pSlice->sMbCacheInfo, pMa)) { |
| 827 | 782 | FreeMemorySvc (ppCtx); |
| 828 | 783 | return 1; |
| @@ -860,11 +815,9 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 31 unmodified lines | ||
| 860 | 815 | pDqLayer->bDeblockingParallelFlag = false; |
| 861 | 816 | } else { |
| 862 | 817 | //multi-pSlice |
| 863 | −#ifdef MT_ENABLED | |
| 864 | 818 | if (0 == pDqLayer->iLoopFilterDisableIdc) { |
| 865 | 819 | pDqLayer->bDeblockingParallelFlag = false; |
| 866 | 820 | } |
| 867 | −#endif | |
| 868 | 821 | } |
| 869 | 822 | |
| 870 | 823 | (*ppCtx)->ppDqLayerList[iDlayerIndex] = pDqLayer; |
| @@ -1231,9 +1184,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 360 unmodified lines | ||
| 1231 | 1184 | const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableSize * sizeof (uint16_t); |
| 1232 | 1185 | int32_t iVclLayersBsSizeCount = 0; |
| 1233 | 1186 | int32_t iNonVclLayersBsSizeCount = 0; |
| 1234 | −#if defined(MT_ENABLED) | |
| 1235 | 1187 | int32_t iTargetSpatialBsSize = 0; |
| 1236 | −#endif//MT_ENABLED | |
| 1237 | 1188 | |
| 1238 | 1189 | if (kiNumDependencyLayers < 1 || kiNumDependencyLayers > MAX_DEPENDENCY_LAYER) { |
| 1239 | 1190 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc() failed due to invalid iNumDependencyLayers(%d)!\n", |
| @@ -1277,9 +1228,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 37 unmodified lines | ||
| 1277 | 1228 | iVclLayersBsSizeCount += iLayerBsSize; |
| 1278 | 1229 | ++ iIndex; |
| 1279 | 1230 | } |
| 1280 | −#if defined(MT_ENABLED) | |
| 1281 | 1231 | iTargetSpatialBsSize = iLayerBsSize; |
| 1282 | −#endif//MT_ENABLED | |
| 1283 | 1232 | iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; |
| 1284 | 1233 | |
| 1285 | 1234 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); |
| @@ -1295,14 +1244,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 9 unmodified lines | ||
| 1295 | 1244 | (*ppCtx)->pOut->iCountNals = iCountNals; |
| 1296 | 1245 | (*ppCtx)->pOut->iNalIndex = 0; |
| 1297 | 1246 | |
| 1298 | −#ifdef MT_ENABLED | |
| 1299 | 1247 | if (pParam->iMultipleThreadIdc > 1) { |
| 1300 | 1248 | const int32_t iTotalLength = iCountBsLen + (iTargetSpatialBsSize * ((*ppCtx)->iMaxSliceCount - 1)); |
| 1301 | 1249 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); |
| 1302 | 1250 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1303 | 1251 | (*ppCtx)->iFrameBsSize = iTotalLength; |
| 1304 | 1252 | } else |
| 1305 | −#endif//MT_ENABLED | |
| 1306 | 1253 | { |
| 1307 | 1254 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); |
| 1308 | 1255 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| @@ -1310,14 +1257,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 1 unmodified line | ||
| 1310 | 1257 | } |
| 1311 | 1258 | (*ppCtx)->iPosBsBuffer = 0; |
| 1312 | 1259 | |
| 1313 | −#ifdef MT_ENABLED | |
| 1314 | 1260 | // for pSlice bs buffers |
| 1315 | 1261 | if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iTargetSpatialBsSize)) { |
| 1316 | 1262 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMtResource failed!"); |
| 1317 | 1263 | FreeMemorySvc (ppCtx); |
| 1318 | 1264 | return 1; |
| 1319 | 1265 | } |
| 1320 | −#endif | |
| 1321 | 1266 | |
| 1322 | 1267 | (*ppCtx)->pIntra4x4PredModeBlocks = static_cast<int8_t*> |
| 1323 | 1268 | (pMa->WelsMallocz (iCountMaxMbNum * INTRA_4x4_MODE_NUM, "pIntra4x4PredModeBlocks")); |
| @@ -1485,10 +1430,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 161 unmodified lines | ||
| 1485 | 1430 | pCtx->pOut = NULL; |
| 1486 | 1431 | } |
| 1487 | 1432 | |
| 1488 | −#ifdef MT_ENABLED | |
| 1489 | 1433 | if (pParam != NULL && pParam->iMultipleThreadIdc > 1) |
| 1490 | 1434 | ReleaseMtResource (ppCtx); |
| 1491 | −#endif//MT_ENABLED | |
| 1492 | 1435 | |
| 1493 | 1436 | // frame bitstream pBuffer |
| 1494 | 1437 | if (NULL != pCtx->pFrameBs) { |
| @@ -1726,9 +1669,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 231 unmodified lines | ||
| 1726 | 1669 | switch (pMso->uiSliceMode) { |
| 1727 | 1670 | case SM_DYN_SLICE: |
| 1728 | 1671 | iMaxSliceCount = AVERSLICENUM_CONSTRAINT; |
| 1729 | −//#ifndef MT_ENABLED | |
| 1730 | − break; // go through for MT_ENABLED & SM_DYN_SLICE? | |
| 1731 | −//#endif//MT_ENABLED | |
| 1672 | + break; // go through for SM_DYN_SLICE? | |
| 1732 | 1673 | case SM_FIXEDSLCNUM_SLICE: |
| 1733 | 1674 | if (iSliceNum > iMaxSliceCount) |
| 1734 | 1675 | iMaxSliceCount = iSliceNum; |
| @@ -1792,13 +1733,8 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 57 unmodified lines | ||
| 1792 | 1733 | ++ iSpatialIdx; |
| 1793 | 1734 | } while (iSpatialIdx < iSpatialNum); |
| 1794 | 1735 | |
| 1795 | −#ifdef MT_ENABLED | |
| 1796 | 1736 | pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); |
| 1797 | 1737 | pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; |
| 1798 | −#else | |
| 1799 | − pCodingParam->iMultipleThreadIdc = 1; | |
| 1800 | − pCodingParam->iCountThreadsNum = 1; | |
| 1801 | −#endif//MT_ENABLED | |
| 1802 | 1738 | |
| 1803 | 1739 | #ifndef WELS_TESTBED // for product release and non-SGE testing |
| 1804 | 1740 | |
| @@ -1907,7 +1843,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 102 unmodified lines | ||
| 1907 | 1843 | |
| 1908 | 1844 | #ifndef WELS_TESTBED |
| 1909 | 1845 | |
| 1910 | −#if defined(MT_ENABLED) && defined(DYNAMIC_DETECT_CPU_CORES) | |
| 1846 | +#if defined(DYNAMIC_DETECT_CPU_CORES) | |
| 1911 | 1847 | if (pCodingParam->iMultipleThreadIdc > 0) |
| 1912 | 1848 | uiCpuCores = pCodingParam->iMultipleThreadIdc; |
| 1913 | 1849 | else { |
| @@ -1921,7 +1857,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 7 unmodified lines | ||
| 1921 | 1857 | else if (uiCpuCores < 1) // just for safe |
| 1922 | 1858 | uiCpuCores = 1; |
| 1923 | 1859 | } |
| 1924 | −#endif//MT_ENABLED && DYNAMIC_DETECT_CPU_CORES | |
| 1860 | +#endif//DYNAMIC_DETECT_CPU_CORES | |
| 1925 | 1861 | |
| 1926 | 1862 | #else//WELS_TESTBED |
| 1927 | 1863 | |
| @@ -1983,10 +1919,8 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 55 unmodified lines | ||
| 1983 | 1919 | return iRet; |
| 1984 | 1920 | } |
| 1985 | 1921 | |
| 1986 | −#ifdef MT_ENABLED | |
| 1987 | 1922 | if (pCodingParam->iMultipleThreadIdc > 1) |
| 1988 | 1923 | iRet = CreateSliceThreads (pCtx); |
| 1989 | −#endif | |
| 1990 | 1924 | |
| 1991 | 1925 | WelsRcInitModule (pCtx, pCtx->pSvcParam->bEnableRc ? WELS_RC_GOM : WELS_RC_DISABLE); |
| 1992 | 1926 | |
| @@ -2112,7 +2046,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 119 unmodified lines | ||
| 2112 | 2046 | StatOverallEncodingExt (*ppCtx); |
| 2113 | 2047 | #endif |
| 2114 | 2048 | |
| 2115 | −#if defined(MT_ENABLED) | |
| 2116 | 2049 | if ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && (*ppCtx)->pSliceThreading != NULL) { |
| 2117 | 2050 | const int32_t iThreadCount = (*ppCtx)->pSvcParam->iCountThreadsNum; |
| 2118 | 2051 | int32_t iThreadIdx = 0; |
| @@ -2132,7 +2065,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 13 unmodified lines | ||
| 2132 | 2065 | } |
| 2133 | 2066 | } |
| 2134 | 2067 | } |
| 2135 | −#endif//MT_ENABLED | |
| 2136 | 2068 | |
| 2137 | 2069 | if ((*ppCtx)->pVpp) { |
| 2138 | 2070 | (*ppCtx)->pVpp->FreeSpatialPictures(*ppCtx); |
| @@ -2205,19 +2137,14 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 66 unmodified lines | ||
| 2205 | 2137 | */ |
| 2206 | 2138 | int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { |
| 2207 | 2139 | int32_t iPartitionNum = 1; |
| 2208 | −#ifdef MT_ENABLED | |
| 2209 | 2140 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { |
| 2210 | 2141 | iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; |
| 2211 | 2142 | if (P_SLICE == pCtx->eSliceType) |
| 2212 | 2143 | iPartitionNum = 1; |
| 2213 | 2144 | } |
| 2214 | 2145 | return iPartitionNum; |
| 2215 | −#else | |
| 2216 | − return iPartitionNum; | |
| 2217 | −#endif//MT_ENABLED | |
| 2218 | 2146 | } |
| 2219 | 2147 | |
| 2220 | −#if defined(MT_ENABLED) | |
| 2221 | 2148 | void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { |
| 2222 | 2149 | //pData init |
| 2223 | 2150 | SDqLayer* pCurDq = pCtx->pCurDqLayer; |
| @@ -2308,83 +2235,6 @@ void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { · 84 unmodified lines | ||
| 2308 | 2235 | |
| 2309 | 2236 | WelsInitCurrentQBLayerMltslc (pCtx); |
| 2310 | 2237 | } |
| 2311 | −#else | |
| 2312 | −void WelsInitCurrentQBLayerMltslc (sWelsEncCtx* pCtx) { | |
| 2313 | − //pData init | |
| 2314 | − SDqLayer* pCurDq = pCtx->pCurDqLayer; | |
| 2315 | − SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); | |
| 2316 | − SSlice* pSlice = &pCurDq->sLayerInfo.pSliceInLayer[0]; | |
| 2317 | − int32_t iTtlMbNumInFrame = pSliceCtx->iMbNumInFrame; | |
| 2318 | − | |
| 2319 | − //pSliceCtx | |
| 2320 | − memset (pSliceCtx->pOverallMbMap, 0, iTtlMbNumInFrame * sizeof (uint8_t)); | |
| 2321 | − memset (pSliceCtx->pCountMbNumInSlice, 0, pSliceCtx->iSliceNumInFrame * sizeof (int32_t)); | |
| 2322 | − memset (pSliceCtx->pFirstMbInSlice, 0, pSliceCtx->iSliceNumInFrame * sizeof (int16_t)); | |
| 2323 | − pSliceCtx->iSliceNumInFrame = 1;// | |
| 2324 | − pSliceCtx->pCountMbNumInSlice[0] = iTtlMbNumInFrame; | |
| 2325 | − | |
| 2326 | − //mb_neighbor | |
| 2327 | − DynslcUpdateMbNeighbourInfoListForAllSlices (pSliceCtx, pCurDq->sMbDataP); | |
| 2328 | − | |
| 2329 | − //pSlice init | |
| 2330 | − pSlice->uiSliceIdx = 0; | |
| 2331 | − pSlice->pSliceBsa = &pCtx->pOut->sBsWrite; | |
| 2332 | − pSlice->bDynamicSlicingSliceSizeCtrlFlag = false; | |
| 2333 | − pSlice->uiAssumeLog2BytePerMb = (pCtx->eSliceType == P_SLICE) ? 0 : 1; | |
| 2334 | −} | |
| 2335 | − | |
| 2336 | −void WelsInitCurrentDlayerMltslc (sWelsEncCtx* pCtx, int32_t iPartitionNum) { | |
| 2337 | − SDqLayer* pCurDq = pCtx->pCurDqLayer; | |
| 2338 | − SSliceCtx* pSliceCtx = (pCurDq->pSliceEncCtx); | |
| 2339 | − int32_t iTtlMbNumInFrame = pCurDq->iMbHeight * pCurDq->iMbWidth; | |
| 2340 | − | |
| 2341 | − pSliceCtx->iMbNumInFrame | |
| 2342 | − = pSliceCtx->pCountMbNumInSlice[0] = iTtlMbNumInFrame; | |
| 2343 | − | |
| 2344 | − if (I_SLICE == pCtx->eSliceType) { //check if uiSliceSizeConstraint too small | |
| 2345 | −#define byte_complexIMBat26 (60) | |
| 2346 | − uint8_t iCurDid = pCtx->uiDependencyId; | |
| 2347 | − uint32_t uiFrmByte = 0; | |
| 2348 | − | |
| 2349 | − if (pCtx->pSvcParam->bEnableRc) { | |
| 2350 | − //RC case | |
| 2351 | − uiFrmByte = ( | |
| 2352 | − ((uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].iSpatialBitrate) | |
| 2353 | − / (uint32_t) (pCtx->pSvcParam->sDependencyLayers[iCurDid].fInputFrameRate)) >> 3); | |
| 2354 | − } else { | |
| 2355 | − //fixed QP case | |
| 2356 | − int32_t iQDeltaTo26 = (26 - pCtx->pSvcParam->sDependencyLayers[iCurDid].iDLayerQp); | |
| 2357 | − | |
| 2358 | − uiFrmByte = (iTtlMbNumInFrame * byte_complexIMBat26); | |
| 2359 | − if (iQDeltaTo26 > 0) { | |
| 2360 | − //smaller QP than 26 | |
| 2361 | − uiFrmByte = (uint32_t) (uiFrmByte * ((float)iQDeltaTo26 / 4)); | |
| 2362 | − } else if (iQDeltaTo26 < 0) { | |
| 2363 | − //larger QP than 26 | |
| 2364 | − iQDeltaTo26 = ((-iQDeltaTo26) >> 2); //delta mod 4 | |
| 2365 | − uiFrmByte = (uiFrmByte >> (iQDeltaTo26)); //if delta 4, byte /2 | |
| 2366 | − } | |
| 2367 | − } | |
| 2368 | − | |
| 2369 | − //MINPACKETSIZE_CONSTRAINT | |
| 2370 | − if (pSliceCtx->uiSliceSizeConstraint | |
| 2371 | − < | |
| 2372 | − (uint32_t) (uiFrmByte//suppose 16 byte per mb at average | |
| 2373 | − / (pSliceCtx->iMaxSliceNumConstraint)) | |
| 2374 | − ) { | |
| 2375 | − | |
| 2376 | − WelsLog (pCtx, | |
| 2377 | − WELS_LOG_WARNING, | |
| 2378 | − "Set-SliceConstraint(%d) too small for current resolution (MB# %d) under QP/BR!\n", | |
| 2379 | − pSliceCtx->uiSliceSizeConstraint, | |
| 2380 | − pSliceCtx->iMbNumInFrame | |
| 2381 | − ); | |
| 2382 | − } | |
| 2383 | − } | |
| 2384 | − | |
| 2385 | − WelsInitCurrentQBLayerMltslc (pCtx); | |
| 2386 | −} | |
| 2387 | −#endif | |
| 2388 | 2238 | |
| 2389 | 2239 | /*! |
| 2390 | 2240 | * \brief initialize current layer |
| @@ -2884,9 +2734,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 493 unmodified lines | ||
| 2884 | 2734 | SPicture* fsnr = NULL; |
| 2885 | 2735 | #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC |
| 2886 | 2736 | SPicture* pEncPic = NULL; // to be decided later |
| 2887 | −#if defined(MT_ENABLED) | |
| 2888 | 2737 | int32_t did_list[MAX_DEPENDENCY_LAYER] = {0}; |
| 2889 | −#endif//MT_ENABLED | |
| 2890 | 2738 | int32_t iLayerNum = 0; |
| 2891 | 2739 | int32_t iLayerSize = 0; |
| 2892 | 2740 | int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame |
| @@ -2976,22 +2824,18 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 83 unmodified lines | ||
| 2976 | 2824 | iCurWidth = param_d->iFrameWidth; |
| 2977 | 2825 | iCurHeight = param_d->iFrameHeight; |
| 2978 | 2826 | |
| 2979 | −#if defined(MT_ENABLED) | |
| 2980 | 2827 | did_list[iSpatialIdx] = iCurDid; |
| 2981 | −#endif//MT_ENABLED | |
| 2982 | 2828 | |
| 2983 | 2829 | // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed |
| 2984 | 2830 | |
| 2985 | 2831 | switch (param_d->sSliceCfg.uiSliceMode) { |
| 2986 | 2832 | case SM_FIXEDSLCNUM_SLICE: |
| 2987 | 2833 | case SM_AUTO_SLICE:{ |
| 2988 | −#if defined(MT_ENABLED) | |
| 2989 | 2834 | if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) && |
| 2990 | 2835 | (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 2991 | 2836 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum) |
| 2992 | 2837 | ) |
| 2993 | 2838 | AdjustEnhanceLayer (pCtx, iCurDid); |
| 2994 | −#endif//MT_ENABLED | |
| 2995 | 2839 | break; |
| 2996 | 2840 | } |
| 2997 | 2841 | case SM_DYN_SLICE: { |
| @@ -3104,18 +2948,13 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 106 unmodified lines | ||
| 3104 | 2948 | pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; |
| 3105 | 2949 | } |
| 3106 | 2950 | // for dynamic slicing single threading.. |
| 3107 | −#ifndef MT_ENABLED | |
| 3108 | − else if (SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) | |
| 3109 | −#else // MT_ENABLED | |
| 3110 | 2951 | else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) |
| 3111 | −#endif//MT_ENABLED | |
| 3112 | 2952 | { |
| 3113 | 2953 | const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame; |
| 3114 | 2954 | pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0, kiLastMbInFrame, 0); |
| 3115 | 2955 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3116 | 2956 | } else { |
| 3117 | 2957 | //other multi-slice uiSliceMode |
| 3118 | −#if defined(MT_ENABLED) | |
| 3119 | 2958 | int err = 0; |
| 3120 | 2959 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE |
| 3121 | 2960 | if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| @@ -3239,7 +3078,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 117 unmodified lines | ||
| 3239 | 3078 | |
| 3240 | 3079 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 3241 | 3080 | } else // for non-dynamic-slicing mode single threading branch.. |
| 3242 | −#endif//MT_ENABLED | |
| 3243 | 3081 | { |
| 3244 | 3082 | const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; |
| 3245 | 3083 | int32_t iSliceIdx = 0; |
| @@ -3294,9 +3132,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 48 unmodified lines | ||
| 3294 | 3132 | |
| 3295 | 3133 | // deblocking filter |
| 3296 | 3134 | if ( |
| 3297 | −#if defined(MT_ENABLED) | |
| 3298 | 3135 | (!pCtx->pCurDqLayer->bDeblockingParallelFlag) && |
| 3299 | −#endif//MT_ENABLED | |
| 3300 | 3136 | #if !defined(ENABLE_FRAME_DUMP) |
| 3301 | 3137 | ((eNalRefIdc != NRI_PRI_LOWEST) && (param_d->iHighestTemporalId == 0 || iCurTid < param_d->iHighestTemporalId)) && |
| 3302 | 3138 | #endif//!ENABLE_FRAME_DUMP |
| @@ -3436,7 +3272,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 133 unmodified lines | ||
| 3436 | 3272 | ++ iLayerNum; |
| 3437 | 3273 | } |
| 3438 | 3274 | |
| 3439 | −#if defined(MT_ENABLED) | |
| 3440 | 3275 | if ((param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE||param_d->sSliceCfg.uiSliceMode == SM_AUTO_SLICE) && pSvcParam->iMultipleThreadIdc > 1 && |
| 3441 | 3276 | pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3442 | 3277 | CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx, |
| @@ -3445,7 +3280,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3445 | 3280 | TrackSliceComplexities (pCtx, iCurDid); |
| 3446 | 3281 | #endif//#if defined(MT_DEBUG) |
| 3447 | 3282 | } |
| 3448 | −#endif//MT_ENABLED | |
| 3449 | 3283 | |
| 3450 | 3284 | ++ iSpatialIdx; |
| 3451 | 3285 | |
| @@ -3472,11 +3306,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 20 unmodified lines | ||
| 3472 | 3306 | } |
| 3473 | 3307 | } |
| 3474 | 3308 | |
| 3475 | −#if defined(MT_ENABLED) && defined(MT_DEBUG) | |
| 3309 | +#if defined(MT_DEBUG) | |
| 3476 | 3310 | TrackSliceConsumeTime (pCtx, did_list, iSpatialNum); |
| 3477 | −#endif//MT_ENABLED && MT_DEBUG | |
| 3311 | +#endif//MT_DEBUG | |
| 3478 | 3312 | |
| 3479 | −#if defined(MT_ENABLED) | |
| 3480 | 3313 | if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID |
| 3481 | 3314 | && ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) |
| 3482 | 3315 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum |
| @@ -3485,7 +3318,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3485 | 3318 | 1]].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3486 | 3319 | AdjustBaseLayer (pCtx); |
| 3487 | 3320 | } |
| 3488 | −#endif | |
| 3489 | 3321 | |
| 3490 | 3322 | #ifdef ENABLE_FRAME_DUMP |
| 3491 | 3323 | DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - |