History

get mv and mvd from level limitation

ruil2 committed 12 years ago

Commit ac7fac91 parent 0951c8f3 files · +34 −14Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 3 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+31−10
@@ -1262,6 +1262,27 @@ void ReleaseMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int3 · 1261 unmodified lines
1262 * \pParam pEncCtx sWelsEncCtx*1262 * \pParam pEncCtx sWelsEncCtx*
1263 * \return successful - 0; otherwise none 0 for failed1263 * \return successful - 0; otherwise none 0 for failed
1264 */1264 */
1265void 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}
1265int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {1286int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
1266 SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;1287 SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
1267 CMemoryAlign* pMa = (*ppCtx)->pMemAlign;1288 CMemoryAlign* pMa = (*ppCtx)->pMemAlign;
@@ -1276,10 +1297,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 8 unmodified lines
1276 int32_t iResult = 0;1297 int32_t iResult = 0;
1277 float fCompressRatioThr = .5f;1298 float fCompressRatioThr = .5f;
1278 const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum;1299 const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum;
1279 (*ppCtx)->iMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE;1300 int32_t iMvdRange = 0;
1280 const int32_t kiMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((kiNumDependencyLayers == 1) ? CAMERA_MVD_RANGE :1301 GetMvMvdRange (pParam, (*ppCtx)->iMvRange, iMvdRange);
1281 CAMERA_HIGHLAYER_MVD_RANGE));1302 const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel
1282 const uint32_t kuiMvdInterTableSize = (kiMvdRange << 2); //intepel*4=qpel
1283 const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);1303 const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
1284 const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t);1304 const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t);
1285 int32_t iVclLayersBsSizeCount = 0;1305 int32_t iVclLayersBsSizeCount = 0;
@@ -1487,8 +1507,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 201 unmodified lines
1487 (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize;1507 (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize;
1488 (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride;1508 (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride;
1489 (*ppCtx)->pMvdCostTable = (uint16_t*)pMa->WelsMallocz (52 * kuiMvdCacheAlignedSize, "pMvdCostTable");1509 (*ppCtx)->pMvdCostTable = (uint16_t*)pMa->WelsMallocz (52 * kuiMvdCacheAlignedSize, "pMvdCostTable");
1490 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx))1510 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx))
1491 MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place?1511 MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place?
1492 1512
1493 if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL)1513 if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL)
1494 (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0];1514 (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0];
@@ -1861,8 +1881,9 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 366 unmodified lines
1861 pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount);1881 pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount);
1862 pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;1882 pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;
1863 if (pCodingParam->iLoopFilterDisableIdc == 01883 if (pCodingParam->iLoopFilterDisableIdc == 0
1864 && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled1884 && 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 multithreading1885 pCodingParam->iLoopFilterDisableIdc =
1886 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
1866 *pMaxSliceCount = iMaxSliceCount;1887 *pMaxSliceCount = iMaxSliceCount;
1867 1888
1868 return 0;1889 return 0;
@@ -1966,7 +1987,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 97 unmodified lines
1966 uiCpuCores = pCodingParam->iMultipleThreadIdc;1987 uiCpuCores = pCodingParam->iMultipleThreadIdc;
1967 else {1988 else {
1968 if (uiCpuCores ==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 processor1990 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 uiCpuCores = DynamicDetectCpuCores();1991 uiCpuCores = DynamicDetectCpuCores();
1971 // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,1992 // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
1972 // for client application here it is constrained by maximal to MAX_THREADS_NUM1993 // 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 * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)2974 * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)
2954 */2975 */
2955int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) {2976int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) {
2956 if( pCtx == NULL ) {2977 if (pCtx == NULL) {
2957 return ENC_RETURN_MEMALLOCERR;2978 return ENC_RETURN_MEMALLOCERR;
2958 }2979 }
2959 SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];2980 SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t