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
12621262 * \pParam pEncCtx sWelsEncCtx*
12631263 * \return successful - 0; otherwise none 0 for failed
12641264 */
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+}
12651286 int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
12661287 SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
12671288 CMemoryAlign* pMa = (*ppCtx)->pMemAlign;
@@ -1276,10 +1297,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 8 unmodified lines
12761297 int32_t iResult = 0;
12771298 float fCompressRatioThr = .5f;
12781299 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
12831303 const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
12841304 const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t);
12851305 int32_t iVclLayersBsSizeCount = 0;
@@ -1487,8 +1507,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 201 unmodified lines
14871507 (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize;
14881508 (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride;
14891509 (*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?
14921512
14931513 if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL)
14941514 (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0];
@@ -1861,8 +1881,9 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar · 366 unmodified lines
18611881 pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount);
18621882 pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;
18631883 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
18661887 *pMaxSliceCount = iMaxSliceCount;
18671888
18681889 return 0;
@@ -1966,7 +1987,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 97 unmodified lines
19661987 uiCpuCores = pCodingParam->iMultipleThreadIdc;
19671988 else {
19681989 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
19701991 uiCpuCores = DynamicDetectCpuCores();
19711992 // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
19721993 // 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
29532974 * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)
29542975 */
29552976 int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) {
2956− if( pCtx == NULL ) {
2977+ if (pCtx == NULL) {
29572978 return ENC_RETURN_MEMALLOCERR;
29582979 }
29592980 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