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*
* \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) {
SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
CMemoryAlign* pMa = (*ppCtx)->pMemAlign;
@ -1276,10 +1297,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) {
int32_t iResult = 0;
float fCompressRatioThr = .5f;
const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum;
(*ppCtx)->iMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE;
const int32_t kiMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((kiNumDependencyLayers == 1) ? CAMERA_MVD_RANGE :
CAMERA_HIGHLAYER_MVD_RANGE));
const uint32_t kuiMvdInterTableSize = (kiMvdRange << 2); //intepel*4=qpel
int32_t iMvdRange = 0;
GetMvMvdRange (pParam, (*ppCtx)->iMvRange, iMvdRange);
const uint32_t kuiMvdInterTableSize = (iMvdRange << 2); //intepel*4=qpel
const uint32_t kuiMvdInterTableStride = 1 + (kuiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableStride * sizeof (uint16_t);
int32_t iVclLayersBsSizeCount = 0;
@ -1862,7 +1882,8 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPar
pCodingParam->iMultipleThreadIdc = pCodingParam->iCountThreadsNum;
if (pCodingParam->iLoopFilterDisableIdc == 0
&& 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;
return 0;
@ -2953,7 +2974,7 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum) {
* \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP)
*/
int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) {
if( pCtx == NULL ) {
if (pCtx == NULL) {
return ENC_RETURN_MEMALLOCERR;
}
SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];

View File

@ -1038,9 +1038,8 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice,
int32_t iNextMbIdx = kiSliceFirstMbXY;
int32_t iCurMbIdx = -1;
int32_t iMbSkipRun = 0;
const int32_t kiMvdInterTableSize = (pEncCtx->pSvcParam->iSpatialLayerNum == 1 ? 648 : 972);
const int32_t kiMvdInterTableStride = 1 + (kiMvdInterTableSize << 1);
uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[kiMvdInterTableSize];
const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
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",
"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
},
};