get mv and mvd from level limitation

This commit is contained in:
ruil2 2014-08-26 16:30:57 +08:00
parent 0951c8fc0c
commit ac7fac9644
3 changed files with 34 additions and 14 deletions

View File

@ -1262,6 +1262,27 @@ void ReleaseMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int3
* \pParam pEncCtx sWelsEncCtx* * \pParam pEncCtx sWelsEncCtx*
* \return successful - 0; otherwise none 0 for failed * \return successful - 0; otherwise none 0 for failed
*/ */
void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMvdRange) {
ELevelIdc iMinLevelIdc = LEVEL_5_2;
int32_t iMinMv = 0;
int32_t iMaxMv = 0;
int32_t iFixMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE;
int32_t iFixMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((pParam->iSpatialLayerNum == 1) ? CAMERA_MVD_RANGE :
CAMERA_HIGHLAYER_MVD_RANGE));
for (int32_t iLayer = 0; iLayer < pParam->iSpatialLayerNum; iLayer++) {
if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc)
iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc;
}
iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv)>>2;
iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv)>>2;
iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv);
iMvRange = WELS_MIN (iMvRange, iFixMvRange);
iMvdRange = (iMvRange + 1) << 1;
iMvdRange = WELS_MIN (iMvdRange, iFixMvdRange);
}
int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam; SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
CMemoryAlign* pMa = (*ppCtx)->pMemAlign; CMemoryAlign* pMa = (*ppCtx)->pMemAlign;
@ -1276,10 +1297,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
int32_t iResult = 0; int32_t iResult = 0;
float fCompressRatioThr = .5f; float fCompressRatioThr = .5f;
const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum; const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum;
(*ppCtx)->iMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; int32_t iMvdRange = 0;
const int32_t kiMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((kiNumDependencyLayers == 1) ? CAMERA_MVD_RANGE : GetMvMvdRange (pParam, (*ppCtx)->iMvRange, iMvdRange);
CAMERA_HIGHLAYER_MVD_RANGE)); const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel
const uint32_t kuiMvdInterTableSize = (kiMvdRange << 2); //intepel*4=qpel
const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t); const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t);
int32_t iVclLayersBsSizeCount = 0; int32_t iVclLayersBsSizeCount = 0;
@ -1487,8 +1507,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
(*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize; (*ppCtx)->iMvdCostTableSize = kuiMvdInterTableSize;
(*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride; (*ppCtx)->iMvdCostTableStride = kuiMvdInterTableStride;
(*ppCtx)->pMvdCostTable = (uint16_t*)pMa->WelsMallocz (52 * kuiMvdCacheAlignedSize, "pMvdCostTable"); (*ppCtx)->pMvdCostTable = (uint16_t*)pMa->WelsMallocz (52 * kuiMvdCacheAlignedSize, "pMvdCostTable");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx)) WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pMvdCostTable), FreeMemorySvc (ppCtx))
MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place? MvdCostInit ((*ppCtx)->pMvdCostTable, kuiMvdInterTableStride); //should put to a better place?
if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL) if ((*ppCtx)->ppRefPicListExt[0] != NULL && (*ppCtx)->ppRefPicListExt[0]->pRef[0] != NULL)
(*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0]; (*ppCtx)->pDecPic = (*ppCtx)->ppRefPicListExt[0]->pRef[0];
@ -1861,8 +1881,9 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar
pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount); pCodingParam->iCountThreadsNum = WELS_MIN (kiCpuCores, iMaxSliceCount);
pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum; pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;
if (pCodingParam->iLoopFilterDisableIdc == 0 if (pCodingParam->iLoopFilterDisableIdc == 0
&& pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled && pCodingParam->iMultipleThreadIdc != 1) // Loop filter requested to be enabled, with threading enabled
pCodingParam->iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading pCodingParam->iLoopFilterDisableIdc =
2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
*pMaxSliceCount = iMaxSliceCount; *pMaxSliceCount = iMaxSliceCount;
return 0; return 0;
@ -1966,7 +1987,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar
uiCpuCores = pCodingParam->iMultipleThreadIdc; uiCpuCores = pCodingParam->iMultipleThreadIdc;
else { else {
if (uiCpuCores == if (uiCpuCores ==
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 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
uiCpuCores = DynamicDetectCpuCores(); uiCpuCores = DynamicDetectCpuCores();
// So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms,
// for client application here it is constrained by maximal to MAX_THREADS_NUM // for client application here it is constrained by maximal to MAX_THREADS_NUM
@ -2953,7 +2974,7 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum) {
* \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)
*/ */
int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) { int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) {
if( pCtx == NULL ) { if (pCtx == NULL) {
return ENC_RETURN_MEMALLOCERR; return ENC_RETURN_MEMALLOCERR;
} }
SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];

View File

@ -1038,9 +1038,8 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice,
int32_t iNextMbIdx = kiSliceFirstMbXY; int32_t iNextMbIdx = kiSliceFirstMbXY;
int32_t iCurMbIdx = -1; int32_t iCurMbIdx = -1;
int32_t iMbSkipRun = 0; int32_t iMbSkipRun = 0;
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iSpatialLayerNum == 1 ? 648 : 972); const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
const int32_t kiMvdInterTableStride = 1 + (kiMvdInterTableSize << 1); uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[kiMvdInterTableSize];
const int32_t kiSliceIdx = pSlice->uiSliceIdx; const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;

View File

@ -118,7 +118,7 @@ static const EncodeFileParam kFileParamArray[] = {
}, },
{ {
"res/Cisco_Absolute_Power_1280x720_30fps.yuv", "res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"dc5aedee4d8f1fe8d6647a9f7b8c2d3df758ac27", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1 "7a0be680c2c89cda208fb5890e64867f3787491e", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
}, },
}; };