Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 3 files). Show all
Unified · Split
| @@ -1262,6 +1262,27 @@ void ReleaseMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int3 · 1261 unmodified lines | ||
| 1262 | 1262 | * \pParam pEncCtx sWelsEncCtx* |
| 1263 | 1263 | * \return successful - 0; otherwise none 0 for failed |
| 1264 | 1264 | */ |
| 1265 | +void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMvdRange) { | |
| 1266 | + ELevelIdc iMinLevelIdc = LEVEL_5_2; | |
| 1267 | + int32_t iMinMv = 0; | |
| 1268 | + int32_t iMaxMv = 0; | |
| 1269 | + int32_t iFixMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; | |
| 1270 | + int32_t iFixMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((pParam->iSpatialLayerNum == 1) ? CAMERA_MVD_RANGE : | |
| 1271 | + CAMERA_HIGHLAYER_MVD_RANGE)); | |
| 1272 | + for (int32_t iLayer = 0; iLayer < pParam->iSpatialLayerNum; iLayer++) { | |
| 1273 | + if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc) | |
| 1274 | + iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc; | |
| 1275 | + } | |
| 1276 | + iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv)>>2; | |
| 1277 | + iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv)>>2; | |
| 1278 | + iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv); | |
| 1279 | + | |
| 1280 | + iMvRange = WELS_MIN (iMvRange, iFixMvRange); | |
| 1281 | + | |
| 1282 | + iMvdRange = (iMvRange + 1) << 1; | |
| 1283 | + | |
| 1284 | + iMvdRange = WELS_MIN (iMvdRange, iFixMvdRange); | |
| 1285 | +} | |
| 1265 | 1286 | int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { |
| 1266 | 1287 | SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; |
| 1267 | 1288 | CMemoryAlign* pMa = (*ppCtx)->pMemAlign; |
| @@ -1276,10 +1297,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 8 unmodified lines | ||
| 1276 | 1297 | int32_t iResult = 0; |
| 1277 | 1298 | float fCompressRatioThr = .5f; |
| 1278 | 1299 | const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum; |
| 1279 | − (*ppCtx)->iMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; | |
| 1280 | − const int32_t kiMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((kiNumDependencyLayers == 1) ? CAMERA_MVD_RANGE : | |
| 1281 | − CAMERA_HIGHLAYER_MVD_RANGE)); | |
| 1282 | − const uint32_t kuiMvdInterTableSize = (kiMvdRange << 2); //intepel*4=qpel | |
| 1300 | + int32_t iMvdRange = 0; | |
| 1301 | + GetMvMvdRange (pParam, (*ppCtx)->iMvRange, iMvdRange); | |
| 1302 | + const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel | |
| 1283 | 1303 | const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); |
| 1284 | 1304 | const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t); |
| 1285 | 1305 | int32_t iVclLayersBsSizeCount = 0; |
| @@ -1487,8 +1507,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 201 unmodified lines | ||
| 1487 | 1507 | (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize; |
| 1488 | 1508 | (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride; |
| 1489 | 1509 | (*ppCtx)->pMvdCostTable = (uint16_t*)pMa->WelsMallocz (52 * kuiMvdCacheAlignedSize, "pMvdCostTable"); |
| 1490 | − WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx)) | |
| 1491 | − MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? | |
| 1510 | + WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx)) | |
| 1511 | + MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? | |
| 1492 | 1512 | |
| 1493 | 1513 | if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL) |
| 1494 | 1514 | (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; |
| @@ -1861,8 +1881,9 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 366 unmodified lines | ||
| 1861 | 1881 | pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); |
| 1862 | 1882 | pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; |
| 1863 | 1883 | if (pCodingParam->iLoopFilterDisableIdc == 0 |
| 1864 | − && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled | |
| 1865 | − pCodingParam->iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading | |
| 1884 | + && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled | |
| 1885 | + pCodingParam->iLoopFilterDisableIdc = | |
| 1886 | + 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading | |
| 1866 | 1887 | *pMaxSliceCount = iMaxSliceCount; |
| 1867 | 1888 | |
| 1868 | 1889 | return 0; |
| @@ -1966,7 +1987,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 97 unmodified lines | ||
| 1966 | 1987 | uiCpuCores = pCodingParam->iMultipleThreadIdc; |
| 1967 | 1988 | else { |
| 1968 | 1989 | if (uiCpuCores == |
| 1969 | − 0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor | |
| 1990 | + 0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor | |
| 1970 | 1991 | uiCpuCores = DynamicDetectCpuCores(); |
| 1971 | 1992 | // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, |
| 1972 | 1993 | // for client application here it is constrained by maximal to MAX_THREADS_NUM |
| @@ -2953,7 +2974,7 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum) { · 980 unmodified lines | ||
| 2953 | 2974 | * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) |
| 2954 | 2975 | */ |
| 2955 | 2976 | int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) { |
| 2956 | − if( pCtx == NULL ) { | |
| 2977 | + if (pCtx == NULL) { | |
| 2957 | 2978 | return ENC_RETURN_MEMALLOCERR; |
| 2958 | 2979 | } |
| 2959 | 2980 | SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; |