Remove tabs where a simple space is just enough
This commit is contained in:
@@ -152,14 +152,14 @@ static inline int32_t WelsMedian (int32_t iX, int32_t iY, int32_t iZ) {
|
||||
int32_t iMin = iX, iMax = iX;
|
||||
|
||||
if (iY < iMin)
|
||||
iMin = iY;
|
||||
iMin = iY;
|
||||
else
|
||||
iMax = iY;
|
||||
|
||||
if (iZ < iMin)
|
||||
iMin = iZ;
|
||||
iMin = iZ;
|
||||
else if (iZ > iMax)
|
||||
iMax = iZ;
|
||||
iMax = iZ;
|
||||
|
||||
return (iX + iY + iZ) - (iMin + iMax);
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ WELS_THREAD_ERROR_CODE WelsMultipleEventsWaitAllBlocking (uint32_t nCount,
|
||||
WELS_EVENT* event_list, WELS_EVENT* master_event) {
|
||||
uint32_t nIdx = 0;
|
||||
uint32_t uiCountSignals = 0;
|
||||
uint32_t uiSignalFlag = 0; // UGLY: suppose maximal event number up to 32
|
||||
uint32_t uiSignalFlag = 0; // UGLY: suppose maximal event number up to 32
|
||||
|
||||
if (nCount == 0 || nCount > (sizeof (uint32_t) << 3))
|
||||
return WELS_THREAD_ERROR_WAIT_FAILED;
|
||||
|
||||
@@ -49,9 +49,9 @@ CMemoryAlign::CMemoryAlign (const uint32_t kuiCacheLineSize)
|
||||
#endif//MEMORY_MONITOR
|
||||
{
|
||||
if ((kuiCacheLineSize == 0) || (kuiCacheLineSize & 0x0f))
|
||||
m_nCacheLineSize = 0x10;
|
||||
m_nCacheLineSize = 0x10;
|
||||
else
|
||||
m_nCacheLineSize = kuiCacheLineSize;
|
||||
m_nCacheLineSize = kuiCacheLineSize;
|
||||
}
|
||||
|
||||
CMemoryAlign::~CMemoryAlign() {
|
||||
|
||||
@@ -115,7 +115,7 @@ float WelsCalcPsnr (const void* kpTarPic,
|
||||
for (y = 0; y < kiHeight; ++ y) { // OPTable !!
|
||||
for (x = 0; x < kiWidth; ++ x) {
|
||||
const int32_t kiT = pTar[y * kiTarStride + x] - pRef[y * kiRefStride + x];
|
||||
iSqe += kiT * kiT;
|
||||
iSqe += kiT * kiT;
|
||||
}
|
||||
}
|
||||
if (0 == iSqe) {
|
||||
|
||||
@@ -90,7 +90,7 @@ void welsCodecTrace::SetCodecInstance (void* pCodecInstance) {
|
||||
|
||||
void welsCodecTrace::SetTraceLevel (const int32_t iLevel) {
|
||||
if (iLevel >= 0)
|
||||
m_iTraceLevel = iLevel;
|
||||
m_iTraceLevel = iLevel;
|
||||
}
|
||||
|
||||
void welsCodecTrace::SetTraceCallback (WelsTraceCallback func) {
|
||||
|
||||
@@ -90,7 +90,7 @@ long CReadConfig::ReadLine (std::string* pVal, const int kiValSize/* = 4*/) {
|
||||
bool bCommentFlag = false;
|
||||
|
||||
while (n < kiValSize) {
|
||||
pVal[n] = "";
|
||||
pVal[n] = "";
|
||||
++ n;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ long CReadConfig::ReadLine (std::string* pVal, const int kiValSize/* = 4*/) {
|
||||
break;
|
||||
if (! (*strTags).empty()) {
|
||||
++ nTagNum;
|
||||
strTags = &pVal[nTagNum];
|
||||
strTags = &pVal[nTagNum];
|
||||
}
|
||||
} else
|
||||
*strTags += kCh;
|
||||
|
||||
@@ -362,26 +362,26 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
long nRd = cReadCfg.ReadLine (&strTag[0]);
|
||||
if (nRd > 0) {
|
||||
if (strTag[0].compare ("InputFile") == 0) {
|
||||
strInputFile = strTag[1];
|
||||
strInputFile = strTag[1];
|
||||
} else if (strTag[0].compare ("OutputFile") == 0) {
|
||||
strOutputFile = strTag[1];
|
||||
strOutputFile = strTag[1];
|
||||
} else if (strTag[0].compare ("RestructionFile") == 0) {
|
||||
strReconFile = strTag[1];
|
||||
strReconFile = strTag[1];
|
||||
int32_t iLen = (int32_t)strReconFile.length();
|
||||
sDecParam.pFileNameRestructed = new char[iLen + 1];
|
||||
sDecParam.pFileNameRestructed = new char[iLen + 1];
|
||||
if (sDecParam.pFileNameRestructed != NULL) {
|
||||
sDecParam.pFileNameRestructed[iLen] = 0;
|
||||
}
|
||||
|
||||
strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage
|
||||
} else if (strTag[0].compare ("TargetDQID") == 0) {
|
||||
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
|
||||
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("OutColorFormat") == 0) {
|
||||
sDecParam.eOutputColorFormat = (EVideoFormatType) atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("ErrorConcealmentIdc") == 0) {
|
||||
sDecParam.eEcActiveIdc = (ERROR_CON_IDC)atol (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("CPULoad") == 0) {
|
||||
sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str());
|
||||
sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("VideoBitstreamType") == 0) {
|
||||
sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str());
|
||||
}
|
||||
@@ -393,17 +393,17 @@ int32_t main (int32_t iArgC, char* pArgV[]) {
|
||||
}
|
||||
} else if (strstr (pArgV[1],
|
||||
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
|
||||
strInputFile = pArgV[1];
|
||||
sDecParam.eOutputColorFormat = videoFormatI420;
|
||||
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
||||
strInputFile = pArgV[1];
|
||||
sDecParam.eOutputColorFormat = videoFormatI420;
|
||||
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
||||
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
|
||||
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
||||
}
|
||||
} else { //iArgC > 2
|
||||
strInputFile = pArgV[1];
|
||||
strOutputFile = pArgV[2];
|
||||
sDecParam.eOutputColorFormat = videoFormatI420;
|
||||
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
||||
strInputFile = pArgV[1];
|
||||
strOutputFile = pArgV[2];
|
||||
sDecParam.eOutputColorFormat = videoFormatI420;
|
||||
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
||||
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
|
||||
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
||||
if (iArgC > 3) {
|
||||
|
||||
@@ -138,9 +138,9 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt&
|
||||
if (strTag[0].empty())
|
||||
continue;
|
||||
if (strTag[0].compare ("FrameWidth") == 0) {
|
||||
pDLayer->iVideoWidth = atoi (strTag[1].c_str());
|
||||
pDLayer->iVideoWidth = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FrameHeight") == 0) {
|
||||
pDLayer->iVideoHeight = atoi (strTag[1].c_str());
|
||||
pDLayer->iVideoHeight = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FrameRateOut") == 0) {
|
||||
pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("ReconFile") == 0) {
|
||||
@@ -150,11 +150,11 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt&
|
||||
sFileSet.sRecFileName[iLayer][kiLen] = '\0';
|
||||
strncpy (sFileSet.sRecFileName[iLayer], strTag[1].c_str(), kiLen); // confirmed_safe_unsafe_usage
|
||||
} else if (strTag[0].compare ("ProfileIdc") == 0) {
|
||||
pDLayer->uiProfileIdc = (EProfileIdc)atoi (strTag[1].c_str());
|
||||
pDLayer->uiProfileIdc = (EProfileIdc)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FRExt") == 0) {
|
||||
// pDLayer->frext_mode = (bool)atoi(strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SpatialBitrate") == 0) {
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iRCMode != RC_OFF_MODE) {
|
||||
if (pDLayer->iSpatialBitrate <= 0) {
|
||||
fprintf (stderr, "Invalid spatial bitrate(%d) in dependency layer #%d.\n", pDLayer->iSpatialBitrate, iLayer);
|
||||
@@ -181,11 +181,11 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt&
|
||||
}
|
||||
}
|
||||
} else if (strTag[0].compare ("InitialQP") == 0) {
|
||||
sLayerCtx.iDLayerQp = atoi (strTag[1].c_str());
|
||||
sLayerCtx.iDLayerQp = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceMode") == 0) {
|
||||
sLayerCtx.sSliceCfg.uiSliceMode = (SliceModeEnum)atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.uiSliceMode = (SliceModeEnum)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SliceSize") == 0) { //SM_DYN_SLICE
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (strTag[1].c_str());
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (strTag[1].c_str());
|
||||
continue;
|
||||
} else if (strTag[0].compare ("SliceNum") == 0) {
|
||||
sLayerCtx.sSliceCfg.sSliceArgument.uiSliceNum = atoi (strTag[1].c_str());
|
||||
@@ -225,21 +225,21 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
|
||||
pSrcPic->iPicHeight = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("InputFile") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.strSeqFile = strTag[1];
|
||||
sFileSet.strSeqFile = strTag[1];
|
||||
} else if (strTag[0].compare ("OutputFile") == 0) {
|
||||
sFileSet.strBsFile = strTag[1];
|
||||
sFileSet.strBsFile = strTag[1];
|
||||
} else if (strTag[0].compare ("MaxFrameRate") == 0) {
|
||||
pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str());
|
||||
pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("FramesToBeEncoded") == 0) {
|
||||
sFileSet.uiFrameToBeCoded = atoi (strTag[1].c_str());
|
||||
sFileSet.uiFrameToBeCoded = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("TemporalLayerNum") == 0) {
|
||||
pSvcParam.iTemporalLayerNum = atoi (strTag[1].c_str());
|
||||
pSvcParam.iTemporalLayerNum = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("IntraPeriod") == 0) {
|
||||
pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str());
|
||||
pSvcParam.uiIntraPeriod = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("MaxNalSize") == 0) {
|
||||
pSvcParam.uiMaxNalSize = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("SpsPpsIDStrategy") == 0) {
|
||||
int32_t iValue = atoi (strTag[1].c_str());
|
||||
int32_t iValue = atoi (strTag[1].c_str());
|
||||
switch (iValue) {
|
||||
case 0:
|
||||
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
|
||||
@@ -261,71 +261,71 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
|
||||
break;
|
||||
}
|
||||
} else if (strTag[0].compare ("EnableScalableSEI") == 0) {
|
||||
pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableFrameCropping") == 0) {
|
||||
pSvcParam.bEnableFrameCroppingFlag = (atoi (strTag[1].c_str()) != 0);
|
||||
} else if (strTag[0].compare ("EntropyCodingModeFlag") == 0) {
|
||||
pSvcParam.iEntropyCodingModeFlag = (atoi (strTag[1].c_str()) != 0);
|
||||
} else if (strTag[0].compare ("LoopFilterDisableIDC") == 0) {
|
||||
pSvcParam.iLoopFilterDisableIdc = (int8_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iLoopFilterDisableIdc = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iLoopFilterDisableIdc > 6 || pSvcParam.iLoopFilterDisableIdc < 0) {
|
||||
fprintf (stderr, "Invalid parameter in iLoopFilterDisableIdc: %d.\n", pSvcParam.iLoopFilterDisableIdc);
|
||||
iRet = 1;
|
||||
break;
|
||||
}
|
||||
} else if (strTag[0].compare ("LoopFilterAlphaC0Offset") == 0) {
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iLoopFilterAlphaC0Offset < -6)
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = -6;
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = -6;
|
||||
else if (pSvcParam.iLoopFilterAlphaC0Offset > 6)
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = 6;
|
||||
pSvcParam.iLoopFilterAlphaC0Offset = 6;
|
||||
} else if (strTag[0].compare ("LoopFilterBetaOffset") == 0) {
|
||||
pSvcParam.iLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iLoopFilterBetaOffset = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iLoopFilterBetaOffset < -6)
|
||||
pSvcParam.iLoopFilterBetaOffset = -6;
|
||||
pSvcParam.iLoopFilterBetaOffset = -6;
|
||||
else if (pSvcParam.iLoopFilterBetaOffset > 6)
|
||||
pSvcParam.iLoopFilterBetaOffset = 6;
|
||||
pSvcParam.iLoopFilterBetaOffset = 6;
|
||||
} else if (strTag[0].compare ("MultipleThreadIdc") == 0) {
|
||||
// # 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
|
||||
pSvcParam.iMultipleThreadIdc = atoi (strTag[1].c_str());
|
||||
pSvcParam.iMultipleThreadIdc = atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iMultipleThreadIdc < 0)
|
||||
pSvcParam.iMultipleThreadIdc = 0;
|
||||
else if (pSvcParam.iMultipleThreadIdc > MAX_THREADS_NUM)
|
||||
pSvcParam.iMultipleThreadIdc = MAX_THREADS_NUM;
|
||||
} else if (strTag[0].compare ("RCMode") == 0) {
|
||||
pSvcParam.iRCMode = (RC_MODES) atoi (strTag[1].c_str());
|
||||
pSvcParam.iRCMode = (RC_MODES) atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("TargetBitrate") == 0) {
|
||||
pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
pSvcParam.iTargetBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
if ((pSvcParam.iRCMode != RC_OFF_MODE) && pSvcParam.iTargetBitrate <= 0) {
|
||||
fprintf (stderr, "Invalid target bitrate setting due to RC enabled. Check TargetBitrate field please!\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (strTag[0].compare ("MaxOverallBitrate") == 0) {
|
||||
pSvcParam.iMaxBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
pSvcParam.iMaxBitrate = 1000 * atoi (strTag[1].c_str());
|
||||
if ((pSvcParam.iRCMode != RC_OFF_MODE) && pSvcParam.iMaxBitrate < 0) {
|
||||
fprintf (stderr, "Invalid max overall bitrate setting due to RC enabled. Check MaxOverallBitrate field please!\n");
|
||||
return 1;
|
||||
}
|
||||
} else if (strTag[0].compare ("EnableDenoise") == 0) {
|
||||
pSvcParam.bEnableDenoise = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableDenoise = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableSceneChangeDetection") == 0) {
|
||||
pSvcParam.bEnableSceneChangeDetect = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableSceneChangeDetect = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableBackgroundDetection") == 0) {
|
||||
pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableAdaptiveQuantization") == 0) {
|
||||
pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableFrameSkip") == 0) {
|
||||
pSvcParam.bEnableFrameSkip = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableFrameSkip = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("EnableLongTermReference") == 0) {
|
||||
pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("LongTermReferenceNumber") == 0) {
|
||||
pSvcParam.iLTRRefNum = atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("LtrMarkPeriod") == 0) {
|
||||
pSvcParam.iLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iLtrMarkPeriod = (uint32_t)atoi (strTag[1].c_str());
|
||||
} else if (strTag[0].compare ("LosslessLink") == 0) {
|
||||
pSvcParam.bIsLosslessLink = atoi (strTag[1].c_str()) ? true : false;
|
||||
pSvcParam.bIsLosslessLink = atoi (strTag[1].c_str()) ? true : false;
|
||||
} else if (strTag[0].compare ("NumLayers") == 0) {
|
||||
pSvcParam.iSpatialLayerNum = (int8_t)atoi (strTag[1].c_str());
|
||||
pSvcParam.iSpatialLayerNum = (int8_t)atoi (strTag[1].c_str());
|
||||
if (pSvcParam.iSpatialLayerNum > MAX_DEPENDENCY_LAYER || pSvcParam.iSpatialLayerNum <= 0) {
|
||||
fprintf (stderr, "Invalid parameter in iSpatialLayerNum: %d.\n", pSvcParam.iSpatialLayerNum);
|
||||
iRet = 1;
|
||||
@@ -333,24 +333,24 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
|
||||
}
|
||||
} else if (strTag[0].compare ("LayerCfg") == 0) {
|
||||
if (strTag[1].length() > 0)
|
||||
sFileSet.strLayerCfgFile[iLayerCount] = strTag[1];
|
||||
// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount;
|
||||
sFileSet.strLayerCfgFile[iLayerCount] = strTag[1];
|
||||
// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount;
|
||||
++ iLayerCount;
|
||||
} else if (strTag[0].compare ("PrefixNALAddingCtrl") == 0) {
|
||||
int ctrl_flag = atoi (strTag[1].c_str());
|
||||
if (ctrl_flag > 1)
|
||||
ctrl_flag = 1;
|
||||
ctrl_flag = 1;
|
||||
else if (ctrl_flag < 0)
|
||||
ctrl_flag = 0;
|
||||
pSvcParam.bPrefixNalAddingCtrl = ctrl_flag ? true : false;
|
||||
ctrl_flag = 0;
|
||||
pSvcParam.bPrefixNalAddingCtrl = ctrl_flag ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int8_t kiActualLayerNum = WELS_MIN (pSvcParam.iSpatialLayerNum, iLayerCount);
|
||||
if (pSvcParam.iSpatialLayerNum >
|
||||
kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings
|
||||
pSvcParam.iSpatialLayerNum = kiActualLayerNum;
|
||||
kiActualLayerNum) { // fixed number of dependency layer due to parameter error in settings
|
||||
pSvcParam.iSpatialLayerNum = kiActualLayerNum;
|
||||
}
|
||||
|
||||
assert (kiActualLayerNum <= MAX_DEPENDENCY_LAYER);
|
||||
@@ -527,58 +527,58 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
|
||||
else if (!strcmp (pCommand, "-numl") && (n < argc)) {
|
||||
pSvcParam.iSpatialLayerNum = atoi (argv[n++]);
|
||||
} else if (!strcmp (pCommand, "-lconfig") && (n < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
sFileSet.strLayerCfgFile[iLayer].assign (argv[n++]);
|
||||
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
|
||||
if (-1 == ParseLayerConfig (cRdLayerCfg, iLayer, pSvcParam, sFileSet)) {
|
||||
return 1;
|
||||
}
|
||||
} else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
const unsigned int iLen = (int) strlen (argv[n]);
|
||||
if (iLen >= sizeof (sFileSet.sRecFileName[iLayer]))
|
||||
return 1;
|
||||
sFileSet.sRecFileName[iLayer][iLen] = '\0';
|
||||
strncpy (sFileSet.sRecFileName[iLayer], argv[n++], iLen); // confirmed_safe_unsafe_usage
|
||||
} else if (!strcmp (pCommand, "-dw") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iVideoWidth = atoi (argv[n++]);
|
||||
pDLayer->iVideoWidth = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-dh") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iVideoHeight = atoi (argv[n++]);
|
||||
pDLayer->iVideoHeight = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-frout") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->fFrameRate = (float)atof (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-lqp") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iDLayerQp = sLayerCtx[iLayer].iDLayerQp = atoi (argv[n++]);
|
||||
}
|
||||
//sLayerCtx[iLayer].num_quality_layers = pDLayer->num_quality_layers = 1;
|
||||
|
||||
else if (!strcmp (pCommand, "-ltarb") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (argv[n++]);
|
||||
pDLayer->iSpatialBitrate = 1000 * atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-lmaxb") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->iMaxSpatialBitrate = 1000 * atoi (argv[n++]);
|
||||
pDLayer->iMaxSpatialBitrate = 1000 * atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcmd") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
|
||||
switch (atoi (argv[n++])) {
|
||||
@@ -607,13 +607,13 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcsize") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = atoi (argv[n++]);
|
||||
}
|
||||
|
||||
else if (!strcmp (pCommand, "-slcnum") && (n + 1 < argc)) {
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
unsigned int iLayer = atoi (argv[n++]);
|
||||
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
|
||||
pDLayer->sSliceCfg.sSliceArgument.uiSliceNum = atoi (argv[n++]);
|
||||
}
|
||||
@@ -693,7 +693,7 @@ int FillSpecificParameters (SEncParamExt& sParam) {
|
||||
}
|
||||
|
||||
int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFile) {
|
||||
int iRet = 0;
|
||||
int iRet = 0;
|
||||
|
||||
if (pPtrEnc == NULL)
|
||||
return 1;
|
||||
@@ -860,7 +860,7 @@ int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFi
|
||||
if (!bCanBeRead)
|
||||
break;
|
||||
// To encoder this frame
|
||||
iStart = WelsTime();
|
||||
iStart = WelsTime();
|
||||
pSrcPic->uiTimeStamp = WELS_ROUND (iFrameIdx * (1000 / sSvcParam.fMaxFrameRate));
|
||||
int iEncFrames = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
||||
iTotal += WelsTime() - iStart;
|
||||
@@ -1008,8 +1008,8 @@ extern "C" int EncMain (int argc, char** argv)
|
||||
int main (int argc, char** argv)
|
||||
#endif
|
||||
{
|
||||
ISVCEncoder* pSVCEncoder = NULL;
|
||||
int iRet = 0;
|
||||
ISVCEncoder* pSVCEncoder = NULL;
|
||||
int iRet = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
_setmode (_fileno (stdin), _O_BINARY); /* thanks to Marcoss Morais <morais at dee.ufcg.edu.br> */
|
||||
|
||||
@@ -110,7 +110,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
int32_t iNalSize = iSrcRbspLen;
|
||||
PBitStringAux pBs = NULL;
|
||||
bool bExtensionFlag = false;
|
||||
int32_t iErr = ERR_NONE;
|
||||
int32_t iErr = ERR_NONE;
|
||||
int32_t iBitSize = 0;
|
||||
SDataBuffer* pSavedData = &pCtx->sSavedData;
|
||||
SLogContext* pLogCtx = & (pCtx->sLogCtx);
|
||||
@@ -132,7 +132,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
}
|
||||
}
|
||||
|
||||
pNalUnitHeader->uiForbiddenZeroBit = (uint8_t) (pNal[0] >> 7); // uiForbiddenZeroBit
|
||||
pNalUnitHeader->uiForbiddenZeroBit = (uint8_t) (pNal[0] >> 7); // uiForbiddenZeroBit
|
||||
if (pNalUnitHeader->uiForbiddenZeroBit) { //2010.4.14
|
||||
pCtx->iErrorCode |= dsBitstreamError;
|
||||
return NULL; //uiForbiddenZeroBit should always equal to 0
|
||||
@@ -155,7 +155,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
pCtx->iSpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iSpsNoExistNalNum++;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
pCtx->iSpsErrorIgnored = 0;
|
||||
@@ -169,7 +169,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
pCtx->iPpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iPpsNoExistNalNum++;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
pCtx->iErrorCode = dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
pCtx->iPpsErrorIgnored = 0;
|
||||
@@ -184,7 +184,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
pCtx->iSubSpsErrorIgnored++;
|
||||
}
|
||||
pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++;
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
pCtx->iErrorCode |= dsNoParamSets;
|
||||
return NULL;
|
||||
}
|
||||
pCtx->iSubSpsErrorIgnored = 0;
|
||||
@@ -203,7 +203,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
pCurNal->uiTimeStamp = pCtx->uiTimeStamp;
|
||||
|
||||
if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum;
|
||||
|
||||
if (uiAvailNalNum > 0) {
|
||||
@@ -222,7 +222,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"ParseNalHeader() in Prefix Nal Unit:uiQualityId (%d) != 0, bUseRefBasePicFlag (%d) != 0, not supported!",
|
||||
pCurNal->sNalHeaderExt.uiQualityId, pCurNal->sNalHeaderExt.bUseRefBasePicFlag);
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
PAccessUnit pCurAu = pCtx->pAccessUnitList;
|
||||
uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum;
|
||||
|
||||
if (uiAvailNalNum > 0) {
|
||||
@@ -250,7 +250,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
iErr = DecInitBits (pBs, pNal, iBitSize);
|
||||
if (iErr) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_PREFIX: DecInitBits() fail due invalid access.");
|
||||
pCtx->iErrorCode |= dsBitstreamError;
|
||||
pCtx->iErrorCode |= dsBitstreamError;
|
||||
return NULL;
|
||||
}
|
||||
ParsePrefixNalUnit (pCtx, pBs);
|
||||
@@ -262,12 +262,12 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
bExtensionFlag = true;
|
||||
case NAL_UNIT_CODED_SLICE:
|
||||
case NAL_UNIT_CODED_SLICE_IDR: {
|
||||
PAccessUnit pCurAu = NULL;
|
||||
PAccessUnit pCurAu = NULL;
|
||||
uint32_t uiAvailNalNum;
|
||||
pCurNal = MemGetNextNal (&pCtx->pAccessUnitList);
|
||||
if (NULL == pCurNal) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory.");
|
||||
pCtx->iErrorCode |= dsOutOfMemory;
|
||||
pCtx->iErrorCode |= dsOutOfMemory;
|
||||
return NULL;
|
||||
}
|
||||
pCurNal->uiTimeStamp = pCtx->uiTimeStamp;
|
||||
@@ -386,7 +386,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
|
||||
}
|
||||
}
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "NAL_UNIT_CODED_SLICE: DecInitBits() fail due invalid access.");
|
||||
pCtx->iErrorCode |= dsBitstreamError;
|
||||
pCtx->iErrorCode |= dsBitstreamError;
|
||||
return NULL;
|
||||
}
|
||||
iErr = ParseSliceHeaderSyntaxs (pCtx, pBs, bExtensionFlag);
|
||||
@@ -585,7 +585,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t
|
||||
if (kiSrcLen <= 0)
|
||||
return iErr;
|
||||
|
||||
pBs = &pCtx->sBs; // SBitStringAux instance for non VCL NALs decoding
|
||||
pBs = &pCtx->sBs; // SBitStringAux instance for non VCL NALs decoding
|
||||
iBitSize = (kiSrcLen << 3) - BsGetTrailingBits (pRbsp + kiSrcLen - 1); // convert into bit
|
||||
eNalType = pCtx->sCurNalHead.eNalUnitType;
|
||||
|
||||
@@ -633,7 +633,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t
|
||||
return iErr;
|
||||
}
|
||||
|
||||
pCtx->bPpsExistAheadFlag = true;
|
||||
pCtx->bPpsExistAheadFlag = true;
|
||||
|
||||
break;
|
||||
|
||||
@@ -667,7 +667,7 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //MMCO_base
|
||||
const uint32_t kuiMmco = uiCode;
|
||||
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco;
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco;
|
||||
|
||||
if (kuiMmco == MMCO_END)
|
||||
break;
|
||||
@@ -678,7 +678,7 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi
|
||||
pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0;
|
||||
} else if (kuiMmco == MMCO_LONG2UNUSED) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_base_pic_num
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode;
|
||||
pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode;
|
||||
}
|
||||
++ iIdx;
|
||||
} while (iIdx < MAX_MMCO_COUNT);
|
||||
@@ -694,7 +694,7 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
|
||||
PNalUnitHeaderExt head_ext = &pCurNal->sNalHeaderExt;
|
||||
PPrefixNalUnit sPrefixNal = &pCurNal->sNalData.sPrefixNal;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag
|
||||
sPrefixNal->bStoreRefBasePicFlag = !!uiCode;
|
||||
sPrefixNal->bStoreRefBasePicFlag = !!uiCode;
|
||||
if ((head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag) {
|
||||
WELS_READ_VERIFY (ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking));
|
||||
}
|
||||
@@ -702,7 +702,7 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
|
||||
sPrefixNal->bPrefixNalUnitAdditionalExtFlag = !!uiCode;
|
||||
if (sPrefixNal->bPrefixNalUnitAdditionalExtFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_data_flag
|
||||
sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode;
|
||||
sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode;
|
||||
}
|
||||
}
|
||||
return ERR_NONE;
|
||||
@@ -721,16 +721,16 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
|
||||
|
||||
|
||||
int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) {
|
||||
PSpsSvcExt pExt = NULL;
|
||||
PSpsSvcExt pExt = NULL;
|
||||
uint32_t uiCode;
|
||||
int32_t iCode;
|
||||
|
||||
pExt = &pSpsExt->sSpsSvcExt;
|
||||
pExt = &pSpsExt->sSpsSvcExt;
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //inter_layer_deblocking_filter_control_present_flag
|
||||
pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!uiCode;
|
||||
pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //extended_spatial_scalability_idc
|
||||
pExt->uiExtendedSpatialScalability = uiCode;
|
||||
pExt->uiExtendedSpatialScalability = uiCode;
|
||||
if (pExt->uiExtendedSpatialScalability > 2) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!",
|
||||
@@ -738,14 +738,14 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_ESS);
|
||||
}
|
||||
|
||||
pExt->uiChromaPhaseXPlus1Flag =
|
||||
0; // FIXME: Incoherent with JVT X201 standard (= 1), but conformance to JSVM (= 0) implementation.
|
||||
pExt->uiChromaPhaseYPlus1 = 1;
|
||||
pExt->uiChromaPhaseXPlus1Flag =
|
||||
0; // FIXME: Incoherent with JVT X201 standard (= 1), but conformance to JSVM (= 0) implementation.
|
||||
pExt->uiChromaPhaseYPlus1 = 1;
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //chroma_phase_x_plus1_flag
|
||||
pExt->uiChromaPhaseXPlus1Flag = uiCode;
|
||||
pExt->uiChromaPhaseXPlus1Flag = uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //chroma_phase_y_plus1
|
||||
pExt->uiChromaPhaseYPlus1 = uiCode;
|
||||
pExt->uiChromaPhaseYPlus1 = uiCode;
|
||||
|
||||
pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag;
|
||||
pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1;
|
||||
@@ -754,20 +754,20 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
||||
if (pExt->uiExtendedSpatialScalability == 1) {
|
||||
SPosOffset* const kpPos = &pExt->sSeqScaledRefLayer;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_ref_layer_chroma_phase_x_plus1_flag
|
||||
pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = uiCode;
|
||||
pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //seq_ref_layer_chroma_phase_y_plus1
|
||||
pExt->uiSeqRefLayerChromaPhaseYPlus1 = uiCode;
|
||||
pExt->uiSeqRefLayerChromaPhaseYPlus1 = uiCode;
|
||||
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_left_offset
|
||||
kpPos->iLeftOffset = iCode;
|
||||
kpPos->iLeftOffset = iCode;
|
||||
WELS_CHECK_SE_BOTH_WARNING (kpPos->iLeftOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN,
|
||||
SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MAX, "seq_scaled_ref_layer_left_offset");
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_top_offset
|
||||
kpPos->iTopOffset = iCode;
|
||||
kpPos->iTopOffset = iCode;
|
||||
WELS_CHECK_SE_BOTH_WARNING (kpPos->iTopOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MIN,
|
||||
SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MAX, "seq_scaled_ref_layer_top_offset");
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_right_offset
|
||||
kpPos->iRightOffset = iCode;
|
||||
kpPos->iRightOffset = iCode;
|
||||
WELS_CHECK_SE_BOTH_WARNING (kpPos->iRightOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MIN,
|
||||
SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MAX, "seq_scaled_ref_layer_right_offset");
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_bottom_offset
|
||||
@@ -777,14 +777,14 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
||||
}
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_tcoeff_level_prediction_flag
|
||||
pExt->bSeqTCoeffLevelPredFlag = !!uiCode;
|
||||
pExt->bAdaptiveTCoeffLevelPredFlag = false;
|
||||
pExt->bSeqTCoeffLevelPredFlag = !!uiCode;
|
||||
pExt->bAdaptiveTCoeffLevelPredFlag = false;
|
||||
if (pExt->bSeqTCoeffLevelPredFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_tcoeff_level_prediction_flag
|
||||
pExt->bAdaptiveTCoeffLevelPredFlag = !!uiCode;
|
||||
pExt->bAdaptiveTCoeffLevelPredFlag = !!uiCode;
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_header_restriction_flag
|
||||
pExt->bSliceHeaderRestrictionFlag = !!uiCode;
|
||||
pExt->bSliceHeaderRestrictionFlag = !!uiCode;
|
||||
|
||||
|
||||
|
||||
@@ -903,10 +903,10 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
|
||||
|
||||
int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicWidth, int32_t* pPicHeight,
|
||||
uint8_t* pSrcNal, const int32_t kSrcNalLen) {
|
||||
PBitStringAux pBs = pBsAux;
|
||||
PBitStringAux pBs = pBsAux;
|
||||
SSubsetSps sTempSubsetSps;
|
||||
PSps pSps = NULL;
|
||||
PSubsetSps pSubsetSps = NULL;
|
||||
PSps pSps = NULL;
|
||||
PSubsetSps pSubsetSps = NULL;
|
||||
SNalUnitHeader* pNalHead = &pCtx->sCurNalHead;
|
||||
ProfileIdc uiProfileIdc;
|
||||
uint8_t uiLevelIdc;
|
||||
@@ -917,28 +917,28 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
const bool kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType);
|
||||
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); //profile_idc
|
||||
uiProfileIdc = uiCode;
|
||||
uiProfileIdc = uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set0_flag
|
||||
bConstraintSetFlags[0] = !!uiCode;
|
||||
bConstraintSetFlags[0] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set1_flag
|
||||
bConstraintSetFlags[1] = !!uiCode;
|
||||
bConstraintSetFlags[1] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set2_flag
|
||||
bConstraintSetFlags[2] = !!uiCode;
|
||||
bConstraintSetFlags[2] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set3_flag
|
||||
bConstraintSetFlags[3] = !!uiCode;
|
||||
bConstraintSetFlags[3] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set4_flag
|
||||
bConstraintSetFlags[4] = !!uiCode;
|
||||
bConstraintSetFlags[4] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set5_flag
|
||||
bConstraintSetFlags[5] = !!uiCode;
|
||||
bConstraintSetFlags[5] = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); // reserved_zero_2bits, equal to 0
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); // level_idc
|
||||
uiLevelIdc = uiCode;
|
||||
uiLevelIdc = uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //seq_parameter_set_id
|
||||
if (uiCode >= MAX_SPS_COUNT) { // Modified to check invalid negative iSpsId, 12/1/2009
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " iSpsId is out of range! \n");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW);
|
||||
}
|
||||
iSpsId = uiCode;
|
||||
iSpsId = uiCode;
|
||||
pSubsetSps = &sTempSubsetSps;
|
||||
pSps = &sTempSubsetSps.sSps;
|
||||
memset (pSubsetSps, 0, sizeof (SSubsetSps));
|
||||
@@ -978,19 +978,19 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): bit_depth_luma (%d) Only 8 bit supported.", 8 + uiCode);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
pSps->uiBitDepthLuma = 8;
|
||||
pSps->uiBitDepthLuma = 8;
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //bit_depth_chroma_minus8
|
||||
if (uiCode != 0) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): bit_depth_chroma (%d). Only 8 bit supported.", 8 + uiCode);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
|
||||
}
|
||||
pSps->uiBitDepthChroma = 8;
|
||||
pSps->uiBitDepthChroma = 8;
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //qpprime_y_zero_transform_bypass_flag
|
||||
pSps->bQpPrimeYZeroTransfBypassFlag = !!uiCode;
|
||||
pSps->bQpPrimeYZeroTransfBypassFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
|
||||
pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
|
||||
pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
|
||||
|
||||
if (pSps->bSeqScalingMatrixPresentFlag) {
|
||||
WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4,
|
||||
@@ -1000,33 +1000,33 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
|
||||
WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4));
|
||||
pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiCode;
|
||||
pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_order_cnt_type
|
||||
pSps->uiPocType = uiCode;
|
||||
pSps->uiPocType = uiCode;
|
||||
|
||||
if (0 == pSps->uiPocType) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_pic_order_cnt_lsb_minus4
|
||||
// log2_max_pic_order_cnt_lsb_minus4 should be in range 0 to 12, inclusive. (sec. 7.4.3)
|
||||
WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX, "log2_max_pic_order_cnt_lsb_minus4",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4));
|
||||
pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiCode; // log2_max_pic_order_cnt_lsb_minus4
|
||||
pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiCode; // log2_max_pic_order_cnt_lsb_minus4
|
||||
|
||||
} else if (1 == pSps->uiPocType) {
|
||||
int32_t i;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //delta_pic_order_always_zero_flag
|
||||
pSps->bDeltaPicOrderAlwaysZeroFlag = !!uiCode;
|
||||
pSps->bDeltaPicOrderAlwaysZeroFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_non_ref_pic
|
||||
pSps->iOffsetForNonRefPic = iCode;
|
||||
pSps->iOffsetForNonRefPic = iCode;
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_top_to_bottom_field
|
||||
pSps->iOffsetForTopToBottomField = iCode;
|
||||
pSps->iOffsetForTopToBottomField = iCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_frames_in_pic_order_cnt_cycle
|
||||
WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE_MAX,
|
||||
"num_ref_frames_in_pic_order_cnt_cycle", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS,
|
||||
ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE));
|
||||
pSps->iNumRefFramesInPocCycle = uiCode;
|
||||
pSps->iNumRefFramesInPocCycle = uiCode;
|
||||
for (i = 0; i < pSps->iNumRefFramesInPocCycle; i++) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_ref_frame[ i ]
|
||||
pSps->iOffsetForRefFrame[ i ] = iCode;
|
||||
pSps->iOffsetForRefFrame[ i ] = iCode;
|
||||
}
|
||||
}
|
||||
if (pSps->uiPocType > 2) {
|
||||
@@ -1035,11 +1035,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
}
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_num_ref_frames
|
||||
pSps->iNumRefFrames = uiCode;
|
||||
pSps->iNumRefFrames = uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //gaps_in_frame_num_value_allowed_flag
|
||||
pSps->bGapsInFrameNumValueAllowedFlag = !!uiCode;
|
||||
pSps->bGapsInFrameNumValueAllowedFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_width_in_mbs_minus1
|
||||
pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiCode;
|
||||
pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiCode;
|
||||
if (pSps->iMbWidth > MAX_MB_SIZE) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!", pSps->iMbWidth);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
||||
@@ -1048,7 +1048,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!");
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1
|
||||
pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiCode;
|
||||
pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiCode;
|
||||
if (pSps->iMbHeight > MAX_MB_SIZE) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_height_in_mbs(%d) exceeds the maximum allowed!", pSps->iMbHeight);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
||||
@@ -1060,7 +1060,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
if (uiTmp32 > (uint32_t)pSLevelLimits->uiMaxFS) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the total count of mb exceeds the level limits!");
|
||||
}
|
||||
pSps->uiTotalMbCount = uiTmp32;
|
||||
pSps->uiTotalMbCount = uiTmp32;
|
||||
WELS_CHECK_SE_UPPER_ERROR (pSps->iNumRefFrames, SPS_MAX_NUM_REF_FRAMES_MAX, "max_num_ref_frames",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_NUM_REF_FRAMES));
|
||||
// here we check max_num_ref_frames
|
||||
@@ -1072,29 +1072,29 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " max_num_ref_frames exceeds level limits!");
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_mbs_only_flag
|
||||
pSps->bFrameMbsOnlyFlag = !!uiCode;
|
||||
pSps->bFrameMbsOnlyFlag = !!uiCode;
|
||||
if (!pSps->bFrameMbsOnlyFlag) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "ParseSps(): frame_mbs_only_flag (%d) not supported.",
|
||||
pSps->bFrameMbsOnlyFlag);
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_MBAFF);
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //direct_8x8_inference_flag
|
||||
pSps->bDirect8x8InferenceFlag = !!uiCode;
|
||||
pSps->bDirect8x8InferenceFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_cropping_flag
|
||||
pSps->bFrameCroppingFlag = !!uiCode;
|
||||
pSps->bFrameCroppingFlag = !!uiCode;
|
||||
if (pSps->bFrameCroppingFlag) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_left_offset
|
||||
pSps->sFrameCrop.iLeftOffset = uiCode;
|
||||
pSps->sFrameCrop.iLeftOffset = uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_right_offset
|
||||
pSps->sFrameCrop.iRightOffset = uiCode;
|
||||
pSps->sFrameCrop.iRightOffset = uiCode;
|
||||
if ((pSps->sFrameCrop.iLeftOffset + pSps->sFrameCrop.iRightOffset) > ((int32_t)pSps->iMbWidth * 16 / 2)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA);
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_top_offset
|
||||
pSps->sFrameCrop.iTopOffset = uiCode;
|
||||
pSps->sFrameCrop.iTopOffset = uiCode;
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_bottom_offset
|
||||
pSps->sFrameCrop.iBottomOffset = uiCode;
|
||||
pSps->sFrameCrop.iBottomOffset = uiCode;
|
||||
if ((pSps->sFrameCrop.iTopOffset + pSps->sFrameCrop.iBottomOffset) > ((int32_t)pSps->iMbHeight * 16 / 2)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA);
|
||||
@@ -1106,7 +1106,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset
|
||||
}
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag
|
||||
pSps->bVuiParamPresentFlag = !!uiCode;
|
||||
pSps->bVuiParamPresentFlag = !!uiCode;
|
||||
|
||||
if (pCtx->bParseOnly) {
|
||||
if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds!
|
||||
@@ -1206,7 +1206,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
|
||||
|
||||
if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)
|
||||
pCtx->bAvcBasedFlag = false;
|
||||
pCtx->bAvcBasedFlag = false;
|
||||
|
||||
*pPicWidth = pSps->iMbWidth << 4;
|
||||
*pPicHeight = pSps->iMbHeight << 4;
|
||||
@@ -1251,12 +1251,12 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
||||
// Not overwrite active sps, just copy to final place
|
||||
else if (kbUseSubsetFlag) {
|
||||
memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
|
||||
pCtx->bSubspsAvailFlags[iSpsId] = true;
|
||||
pCtx->bSubspsExistAheadFlag = true;
|
||||
pCtx->bSubspsAvailFlags[iSpsId] = true;
|
||||
pCtx->bSubspsExistAheadFlag = true;
|
||||
} else {
|
||||
memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
|
||||
pCtx->bSpsAvailFlags[iSpsId] = true;
|
||||
pCtx->bSpsExistAheadFlag = true;
|
||||
pCtx->bSpsExistAheadFlag = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1573,8 +1573,8 @@ int32_t ResetFmoList (PWelsDecoderContext pCtx) {
|
||||
if (NULL != pCtx) {
|
||||
// Fixed memory leak due to PPS_ID might not be continuous sometimes, 1/5/2010
|
||||
UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum);
|
||||
iCountNum = pCtx->iActiveFmoNum;
|
||||
pCtx->iActiveFmoNum = 0;
|
||||
iCountNum = pCtx->iActiveFmoNum;
|
||||
pCtx->iActiveFmoNum = 0;
|
||||
}
|
||||
return iCountNum;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs)
|
||||
iRes[ (7 << 3) + i] = b[0] - b[7];
|
||||
}
|
||||
|
||||
uint8_t* pDst = pPred;
|
||||
uint8_t* pDst = pPred;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
pDst[i * kiStride + j] = WelsClip1 (((32 + iRes[ (i << 3) + j]) >> 6) + pDst[i * kiStride + j]);
|
||||
@@ -167,7 +167,7 @@ void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs)
|
||||
}
|
||||
|
||||
void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) {
|
||||
int32_t* pOffset = pBlockOffset;
|
||||
int32_t* pOffset = pBlockOffset;
|
||||
int32_t i;
|
||||
const uint8_t kuiScan0 = g_kuiScan8[0];
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicBuf) {
|
||||
return 1;
|
||||
@@ -109,7 +109,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicNewBuf) {
|
||||
return 1;
|
||||
@@ -153,9 +153,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
// remove old PicBuf
|
||||
if (pPicOldBuf->ppPic != NULL) {
|
||||
WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
|
||||
pPicOldBuf->ppPic = NULL;
|
||||
pPicOldBuf->ppPic = NULL;
|
||||
}
|
||||
pPicOldBuf->iCapacity = 0;
|
||||
pPicOldBuf->iCapacity = 0;
|
||||
pPicOldBuf->iCurrentIdx = 0;
|
||||
WelsFree (pPicOldBuf, "pPicOldBuf");
|
||||
pPicOldBuf = NULL;
|
||||
@@ -171,7 +171,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
return 1;
|
||||
}
|
||||
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
|
||||
|
||||
if (NULL == pPicNewBuf) {
|
||||
return 1;
|
||||
@@ -180,7 +180,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
|
||||
|
||||
if (NULL == pPicNewBuf->ppPic) {
|
||||
pPicNewBuf->iCapacity = 0;
|
||||
pPicNewBuf->iCapacity = 0;
|
||||
DestroyPicBuff (&pPicNewBuf);
|
||||
return 1;
|
||||
}
|
||||
@@ -227,9 +227,9 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
|
||||
// remove old PicBuf
|
||||
if (pPicOldBuf->ppPic != NULL) {
|
||||
WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
|
||||
pPicOldBuf->ppPic = NULL;
|
||||
pPicOldBuf->ppPic = NULL;
|
||||
}
|
||||
pPicOldBuf->iCapacity = 0;
|
||||
pPicOldBuf->iCapacity = 0;
|
||||
pPicOldBuf->iCurrentIdx = 0;
|
||||
WelsFree (pPicOldBuf, "pPicOldBuf");
|
||||
pPicOldBuf = NULL;
|
||||
@@ -257,9 +257,9 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) {
|
||||
|
||||
WelsFree (pPicBuf->ppPic, "pPicBuf->queue");
|
||||
|
||||
pPicBuf->ppPic = NULL;
|
||||
pPicBuf->ppPic = NULL;
|
||||
}
|
||||
pPicBuf->iCapacity = 0;
|
||||
pPicBuf->iCapacity = 0;
|
||||
pPicBuf->iCurrentIdx = 0;
|
||||
|
||||
WelsFree (pPicBuf, "pPicBuf");
|
||||
@@ -331,7 +331,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
* get size of reference picture list in target layer incoming, = (iNumRefFrames
|
||||
*/
|
||||
static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) {
|
||||
int32_t iNumRefFrames = 0;
|
||||
int32_t iNumRefFrames = 0;
|
||||
// +2 for EC MV Copy buffer exchange
|
||||
if ((pCtx == NULL) || (pCtx->pSps == NULL)) {
|
||||
iNumRefFrames = MAX_REF_PIC_COUNT + 2;
|
||||
@@ -365,7 +365,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
|
||||
|
||||
// Fixed the issue about different gop size over last, 5/17/2010
|
||||
// get picture queue size currently
|
||||
iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
|
||||
iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
|
||||
pCtx->iPicQueueNumber = iPicQueueSize;
|
||||
if (pCtx->pPicBuff[LIST_0] != NULL
|
||||
&& pCtx->pPicBuff[LIST_0]->iCapacity ==
|
||||
@@ -482,7 +482,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->bParamSetsLostFlag = true;
|
||||
#else
|
||||
pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010
|
||||
pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010
|
||||
#endif //LONG_TERM_REF
|
||||
pCtx->bNewSeqBegin = true;
|
||||
pCtx->bPrintFrameErrorTraceFlag = true;
|
||||
@@ -517,13 +517,13 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa
|
||||
if (NULL == pCtx || NULL == kpParam)
|
||||
return 1;
|
||||
|
||||
pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
|
||||
pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
|
||||
|
||||
if (NULL == pCtx->pParam)
|
||||
return 1;
|
||||
|
||||
memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
|
||||
pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
|
||||
pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
|
||||
if (!pCtx->bParseOnly) {
|
||||
int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
|
||||
if (iRet)
|
||||
@@ -668,7 +668,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
iConsumedBytes = 0;
|
||||
pDstNal[iDstIdx] = pDstNal[iDstIdx + 1] = pDstNal[iDstIdx + 2] = pDstNal[iDstIdx + 3] =
|
||||
0; // set 4 reserved bytes to zero
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes);
|
||||
if (pNalPayload) { //parse correct
|
||||
if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {
|
||||
iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);
|
||||
@@ -758,8 +758,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
return pCtx->iErrorCode;
|
||||
}
|
||||
} else { /* no supplementary picture payload input, but stored a picture */
|
||||
PAccessUnit pCurAu =
|
||||
pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization
|
||||
PAccessUnit pCurAu =
|
||||
pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization
|
||||
|
||||
if (pCurAu->uiAvailUnitsNum == 0) {
|
||||
return pCtx->iErrorCode;
|
||||
@@ -789,9 +789,9 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
|
||||
int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) {
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pCtx));
|
||||
|
||||
pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
|
||||
pCtx->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
|
||||
if (pCtx->pParam != NULL) {
|
||||
pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
|
||||
pCtx->pParam->eOutputColorFormat = (EVideoFormatType) kiColorFormat;
|
||||
}
|
||||
|
||||
//For now, support only videoFormatI420!
|
||||
|
||||
@@ -329,7 +329,7 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) {
|
||||
// Common syntaxs for P or B slices: list0, list1 followed if B slices used.
|
||||
do {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //ref_pic_list_modification_flag_l0
|
||||
pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode;
|
||||
pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode;
|
||||
|
||||
if (pRefPicListReordering->bRefPicListReorderingFlag[iList]) {
|
||||
int32_t iIdx = 0;
|
||||
@@ -341,7 +341,7 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) {
|
||||
if ((iIdx >= MAX_REF_PIC_COUNT) || (kuiIdc > 3)) {
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING);
|
||||
}
|
||||
pRefPicListReordering->sReorderingSyn[iList][iIdx].uiReorderingOfPicNumsIdc = kuiIdc;
|
||||
pRefPicListReordering->sReorderingSyn[iList][iIdx].uiReorderingOfPicNumsIdc = kuiIdc;
|
||||
if (kuiIdc == 3)
|
||||
break;
|
||||
|
||||
@@ -377,12 +377,12 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli
|
||||
uint32_t uiCode;
|
||||
if (kbIdrFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //no_output_of_prior_pics_flag
|
||||
kpRefMarking->bNoOutputOfPriorPicsFlag = !!uiCode;
|
||||
kpRefMarking->bNoOutputOfPriorPicsFlag = !!uiCode;
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //long_term_reference_flag
|
||||
kpRefMarking->bLongTermRefFlag = !!uiCode;
|
||||
kpRefMarking->bLongTermRefFlag = !!uiCode;
|
||||
} else {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_ref_pic_marking_mode_flag
|
||||
kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode;
|
||||
kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode;
|
||||
if (kpRefMarking->bAdaptiveRefPicMarkingModeFlag) {
|
||||
int32_t iIdx = 0;
|
||||
do {
|
||||
@@ -423,9 +423,9 @@ bool FillDefaultSliceHeaderExt (PSliceHeaderExt pShExt, PNalUnitHeaderExt pNalEx
|
||||
return false;
|
||||
|
||||
if (pNalExt->iNoInterLayerPredFlag || pNalExt->uiQualityId > 0)
|
||||
pShExt->bBasePredWeightTableFlag = false;
|
||||
pShExt->bBasePredWeightTableFlag = false;
|
||||
else
|
||||
pShExt->bBasePredWeightTableFlag = true;
|
||||
pShExt->bBasePredWeightTableFlag = true;
|
||||
pShExt->uiRefLayerDqId = (uint8_t) - 1;
|
||||
pShExt->uiDisableInterLayerDeblockingFilterIdc = 0;
|
||||
pShExt->iInterLayerSliceAlphaC0Offset = 0;
|
||||
@@ -674,15 +674,15 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
const bool kbStoreRefBaseFlag = pSliceHeadExt->bStoreRefBasePicFlag;
|
||||
memcpy (&sBaseMarking, &pSliceHeadExt->sRefBasePicMarking, sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage
|
||||
memset (pSliceHeadExt, 0, sizeof (SSliceHeaderExt));
|
||||
pSliceHeadExt->bStoreRefBasePicFlag = kbStoreRefBaseFlag;
|
||||
pSliceHeadExt->bStoreRefBasePicFlag = kbStoreRefBaseFlag;
|
||||
memcpy (&pSliceHeadExt->sRefBasePicMarking, &sBaseMarking, sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage
|
||||
}
|
||||
|
||||
kpCurNal->sNalData.sVclNal.bSliceHeaderExtFlag = kbExtensionFlag;
|
||||
kpCurNal->sNalData.sVclNal.bSliceHeaderExtFlag = kbExtensionFlag;
|
||||
|
||||
// first_mb_in_slice
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //first_mb_in_slice
|
||||
pSliceHead->iFirstMbInSlice = uiCode;
|
||||
pSliceHead->iFirstMbInSlice = uiCode;
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type
|
||||
uiSliceType = uiCode;
|
||||
@@ -710,7 +710,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
}
|
||||
|
||||
pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);
|
||||
pSliceHead->eSliceType = static_cast <EWelsSliceType> (uiSliceType);
|
||||
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id
|
||||
iPpsId = uiCode;
|
||||
@@ -776,7 +776,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
|
||||
}
|
||||
pCtx->iSPSLastInvalidId = -1;
|
||||
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
|
||||
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
|
||||
}
|
||||
pSliceHead->iPpsId = iPpsId;
|
||||
pSliceHead->iSpsId = pPps->iSpsId;
|
||||
@@ -819,9 +819,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
// standard 7.4.3 idr_pic_id should be in range 0 to 65535, inclusive.
|
||||
WELS_CHECK_SE_UPPER_ERROR (uiCode, SLICE_HEADER_IDR_PIC_ID_MAX, "idr_pic_id", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
|
||||
ERR_INFO_INVALID_IDR_PIC_ID));
|
||||
pSliceHead->uiIdrPicId = uiCode; /* uiIdrPicId */
|
||||
pSliceHead->uiIdrPicId = uiCode; /* uiIdrPicId */
|
||||
#ifdef LONG_TERM_REF
|
||||
pCtx->uiCurIdrPicId = pSliceHead->uiIdrPicId;
|
||||
pCtx->uiCurIdrPicId = pSliceHead->uiIdrPicId;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -830,21 +830,21 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
pSliceHead->iDeltaPicOrderCnt[1] = 0;
|
||||
if (pSps->uiPocType == 0) {
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, pSps->iLog2MaxPocLsb, &uiCode)); //pic_order_cnt_lsb
|
||||
pSliceHead->iPicOrderCntLsb = uiCode;
|
||||
pSliceHead->iPicOrderCntLsb = uiCode;
|
||||
if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt_bottom
|
||||
pSliceHead->iDeltaPicOrderCntBottom = iCode;
|
||||
pSliceHead->iDeltaPicOrderCntBottom = iCode;
|
||||
}
|
||||
} else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 0 ]
|
||||
pSliceHead->iDeltaPicOrderCnt[0] = iCode;
|
||||
pSliceHead->iDeltaPicOrderCnt[0] = iCode;
|
||||
if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 1 ]
|
||||
pSliceHead->iDeltaPicOrderCnt[1] = iCode;
|
||||
}
|
||||
}
|
||||
|
||||
pSliceHead->iRedundantPicCnt = 0;
|
||||
pSliceHead->iRedundantPicCnt = 0;
|
||||
if (pPps->bRedundantPicCntPresentFlag) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //redundant_pic_cnt
|
||||
// standard section 7.4.3, redundant_pic_cnt should be in range 0 to 127, inclusive.
|
||||
@@ -863,12 +863,12 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
if (bReadNumRefFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //num_ref_idx_active_override_flag
|
||||
pSliceHead->bNumRefIdxActiveOverrideFlag = !!uiCode;
|
||||
pSliceHead->bNumRefIdxActiveOverrideFlag = !!uiCode;
|
||||
if (pSliceHead->bNumRefIdxActiveOverrideFlag) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_idx_l0_active_minus1
|
||||
WELS_CHECK_SE_UPPER_ERROR (uiCode, MAX_NUM_REF_IDX_L0_ACTIVE_MINUS1, "num_ref_idx_l0_active_minus1",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_NUM_REF_IDX_L0_ACTIVE_MINUS1));
|
||||
pSliceHead->uiRefCount[0] = 1 + uiCode;
|
||||
pSliceHead->uiRefCount[0] = 1 + uiCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,9 +894,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
|
||||
if (kbExtensionFlag) {
|
||||
if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0)
|
||||
pSliceHeadExt->bBasePredWeightTableFlag = false;
|
||||
pSliceHeadExt->bBasePredWeightTableFlag = false;
|
||||
else
|
||||
pSliceHeadExt->bBasePredWeightTableFlag = true;
|
||||
pSliceHeadExt->bBasePredWeightTableFlag = true;
|
||||
}
|
||||
|
||||
if (kpCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
|
||||
@@ -907,7 +907,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
|
||||
if (kbExtensionFlag && !pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag
|
||||
pSliceHeadExt->bStoreRefBasePicFlag = !!uiCode;
|
||||
pSliceHeadExt->bStoreRefBasePicFlag = !!uiCode;
|
||||
if ((pNalHeaderExt->bUseRefBasePicFlag || pSliceHeadExt->bStoreRefBasePicFlag) && !bIdrFlag) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"ParseSliceHeaderSyntaxs(): bUseRefBasePicFlag or bStoreRefBasePicFlag = 1 not supported.");
|
||||
@@ -948,7 +948,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
pSliceHead->iSliceBetaOffset = 0;
|
||||
if (pPps->bDeblockingFilterControlPresentFlag) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_deblocking_filter_idc
|
||||
pSliceHead->uiDisableDeblockingFilterIdc = uiCode;
|
||||
pSliceHead->uiDisableDeblockingFilterIdc = uiCode;
|
||||
//refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20
|
||||
if (pSliceHead->uiDisableDeblockingFilterIdc > 6) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "disable_deblock_filter_idc (%d) out of range [0, 6]",
|
||||
@@ -957,19 +957,19 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
if (pSliceHead->uiDisableDeblockingFilterIdc != 1) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_alpha_c0_offset_div2
|
||||
pSliceHead->iSliceAlphaC0Offset = iCode * 2;
|
||||
pSliceHead->iSliceAlphaC0Offset = iCode * 2;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceAlphaC0Offset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN,
|
||||
SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
|
||||
ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2));
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_beta_offset_div2
|
||||
pSliceHead->iSliceBetaOffset = iCode * 2;
|
||||
pSliceHead->iSliceBetaOffset = iCode * 2;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceBetaOffset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN,
|
||||
SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_beta_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
|
||||
ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2));
|
||||
}
|
||||
}
|
||||
|
||||
bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3
|
||||
bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3
|
||||
&& pPps->uiSliceGroupMapType <= 5);
|
||||
if (kbExtensionFlag && bSgChangeCycleInvolved)
|
||||
bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID));
|
||||
@@ -978,24 +978,24 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
const int32_t kiNumBits = (int32_t)WELS_CEIL (log (static_cast<double> (1 + pPps->uiPicSizeInMapUnits /
|
||||
pPps->uiSliceGroupChangeRate)));
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, kiNumBits, &uiCode)); //lice_group_change_cycle
|
||||
pSliceHead->iSliceGroupChangeCycle = uiCode;
|
||||
pSliceHead->iSliceGroupChangeCycle = uiCode;
|
||||
} else
|
||||
pSliceHead->iSliceGroupChangeCycle = 0;
|
||||
pSliceHead->iSliceGroupChangeCycle = 0;
|
||||
}
|
||||
|
||||
if (!kbExtensionFlag) {
|
||||
FillDefaultSliceHeaderExt (pSliceHeadExt, pNalHeaderExt);
|
||||
} else {
|
||||
/* Extra syntax elements newly introduced */
|
||||
pSliceHeadExt->pSubsetSps = pSubsetSps;
|
||||
pSliceHeadExt->pSubsetSps = pSubsetSps;
|
||||
|
||||
if (!pNalHeaderExt->iNoInterLayerPredFlag && BASE_QUALITY_ID == uiQualityId) {
|
||||
//the following should be deleted for CODE_CLEAN
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //ref_layer_dq_id
|
||||
pSliceHeadExt->uiRefLayerDqId = uiCode;
|
||||
pSliceHeadExt->uiRefLayerDqId = uiCode;
|
||||
if (pSubsetSps->sSpsSvcExt.bInterLayerDeblockingFilterCtrlPresentFlag) {
|
||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_inter_layer_deblocking_filter_idc
|
||||
pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = uiCode;
|
||||
pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = uiCode;
|
||||
//refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20
|
||||
if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc > 6) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "disable_inter_layer_deblock_filter_idc (%d) out of range [0, 6]",
|
||||
@@ -1004,13 +1004,13 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc != 1) {
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_alpha_c0_offset_div2
|
||||
pSliceHeadExt->iInterLayerSliceAlphaC0Offset = iCode * 2;
|
||||
pSliceHeadExt->iInterLayerSliceAlphaC0Offset = iCode * 2;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceAlphaC0Offset,
|
||||
SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX,
|
||||
"inter_layer_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER,
|
||||
ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2));
|
||||
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_beta_offset_div2
|
||||
pSliceHeadExt->iInterLayerSliceBetaOffset = iCode * 2;
|
||||
pSliceHeadExt->iInterLayerSliceBetaOffset = iCode * 2;
|
||||
WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceBetaOffset, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN,
|
||||
SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX, "inter_layer_slice_beta_offset_div2 * 2",
|
||||
GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2));
|
||||
@@ -1021,7 +1021,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1;
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constrained_intra_resampling_flag
|
||||
pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode;
|
||||
pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode;
|
||||
|
||||
{
|
||||
SPosOffset pos;
|
||||
@@ -1038,7 +1038,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "MGS not supported.");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MGS);
|
||||
} else {
|
||||
pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1;
|
||||
pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1;
|
||||
}
|
||||
|
||||
pSliceHeadExt->bSliceSkipFlag = false;
|
||||
@@ -1055,28 +1055,28 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
|
||||
if (!pNalHeaderExt->iNoInterLayerPredFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_skip_flag
|
||||
pSliceHeadExt->bSliceSkipFlag = !!uiCode;
|
||||
pSliceHeadExt->bSliceSkipFlag = !!uiCode;
|
||||
if (pSliceHeadExt->bSliceSkipFlag) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "bSliceSkipFlag == 1 not supported.");
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_SLICESKIP);
|
||||
} else {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_base_mode_flag
|
||||
pSliceHeadExt->bAdaptiveBaseModeFlag = !!uiCode;
|
||||
pSliceHeadExt->bAdaptiveBaseModeFlag = !!uiCode;
|
||||
if (!pSliceHeadExt->bAdaptiveBaseModeFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_base_mode_flag
|
||||
pSliceHeadExt->bDefaultBaseModeFlag = !!uiCode;
|
||||
pSliceHeadExt->bDefaultBaseModeFlag = !!uiCode;
|
||||
}
|
||||
if (!pSliceHeadExt->bDefaultBaseModeFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_motion_prediction_flag
|
||||
pSliceHeadExt->bAdaptiveMotionPredFlag = !!uiCode;
|
||||
pSliceHeadExt->bAdaptiveMotionPredFlag = !!uiCode;
|
||||
if (!pSliceHeadExt->bAdaptiveMotionPredFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_motion_prediction_flag
|
||||
pSliceHeadExt->bDefaultMotionPredFlag = !!uiCode;
|
||||
pSliceHeadExt->bDefaultMotionPredFlag = !!uiCode;
|
||||
}
|
||||
}
|
||||
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_residual_prediction_flag
|
||||
pSliceHeadExt->bAdaptiveResidualPredFlag = !!uiCode;
|
||||
pSliceHeadExt->bAdaptiveResidualPredFlag = !!uiCode;
|
||||
if (!pSliceHeadExt->bAdaptiveResidualPredFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_residual_prediction_flag
|
||||
pSliceHeadExt->bDefaultResidualPredFlag = !!uiCode;
|
||||
@@ -1084,15 +1084,15 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
}
|
||||
if (pSubsetSps->sSpsSvcExt.bAdaptiveTCoeffLevelPredFlag) {
|
||||
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //tcoeff_level_prediction_flag
|
||||
pSliceHeadExt->bTCoeffLevelPredFlag = !!uiCode;
|
||||
pSliceHeadExt->bTCoeffLevelPredFlag = !!uiCode;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) {
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_start
|
||||
pSliceHeadExt->uiScanIdxStart = uiCode;
|
||||
pSliceHeadExt->uiScanIdxStart = uiCode;
|
||||
WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_end
|
||||
pSliceHeadExt->uiScanIdxEnd = uiCode;
|
||||
pSliceHeadExt->uiScanIdxEnd = uiCode;
|
||||
if (pSliceHeadExt->uiScanIdxStart != 0 || pSliceHeadExt->uiScanIdxEnd != 15) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "uiScanIdxStart (%d) != 0 and uiScanIdxEnd (%d) !=15 not supported here",
|
||||
pSliceHeadExt->uiScanIdxStart, pSliceHeadExt->uiScanIdxEnd);
|
||||
@@ -1113,7 +1113,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
|
||||
* ppDst: succeeded VCL NAL based AVC (I/P Slice)
|
||||
*/
|
||||
bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst, PNalUnit const kpSrc) {
|
||||
PNalUnitHeaderExt pNalHdrExtD = NULL, pNalHdrExtS = NULL;
|
||||
PNalUnitHeaderExt pNalHdrExtD = NULL, pNalHdrExtS = NULL;
|
||||
PSliceHeaderExt pShExtD = NULL;
|
||||
PPrefixNalUnit pPrefixS = NULL;
|
||||
PSps pSps = NULL;
|
||||
@@ -1502,7 +1502,7 @@ void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) {
|
||||
pCurAu->pNalUnitsList[iIdx] = t;
|
||||
++ iIdx;
|
||||
}
|
||||
pCurAu->uiActualUnitsNum = pCurAu->uiAvailUnitsNum = kuiLeftNum;
|
||||
pCurAu->uiActualUnitsNum = pCurAu->uiAvailUnitsNum = kuiLeftNum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2098,22 +2098,22 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
int16_t iLastIdD = -1, iLastIdQ = -1;
|
||||
int16_t iCurrIdD = 0, iCurrIdQ = 0;
|
||||
uint8_t uiNalRefIdc = 0;
|
||||
bool bFreshSliceAvailable =
|
||||
true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
|
||||
bool bFreshSliceAvailable =
|
||||
true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
|
||||
|
||||
//update pCurDqLayer at the starting of AU decoding
|
||||
if (pCtx->bInitialDqLayersMem) {
|
||||
pCtx->pCurDqLayer = pCtx->pDqLayersList[0];
|
||||
pCtx->pCurDqLayer = pCtx->pDqLayersList[0];
|
||||
}
|
||||
|
||||
InitCurDqLayerData (pCtx, pCtx->pCurDqLayer);
|
||||
|
||||
pNalCur = pCurAu->pNalUnitsList[iIdx];
|
||||
while (iIdx <= iEndIdx) {
|
||||
PDqLayer dq_cur = pCtx->pCurDqLayer;
|
||||
PDqLayer dq_cur = pCtx->pCurDqLayer;
|
||||
SLayerInfo pLayerInfo;
|
||||
PSliceHeaderExt pShExt = NULL;
|
||||
PSliceHeader pSh = NULL;
|
||||
PSliceHeaderExt pShExt = NULL;
|
||||
PSliceHeader pSh = NULL;
|
||||
|
||||
if (pCtx->pDec == NULL) {
|
||||
pCtx->pDec = PrefetchPic (pCtx->pPicBuff[0]);
|
||||
@@ -2191,8 +2191,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_FMO_INIT_FAIL);
|
||||
}
|
||||
|
||||
bFreshSliceAvailable = (iCurrIdD != iLastIdD
|
||||
|| iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder
|
||||
bFreshSliceAvailable = (iCurrIdD != iLastIdD
|
||||
|| iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder
|
||||
|
||||
WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps);
|
||||
|
||||
@@ -2279,15 +2279,15 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
fprintf (stderr, "cur_frame : %d\tiCurrIdD : %d\n ",
|
||||
dq_cur->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFrameNum, iCurrIdD);
|
||||
#endif//#if !CODEC_FOR_TESTBED
|
||||
iLastIdD = iCurrIdD;
|
||||
iLastIdQ = iCurrIdQ;
|
||||
iLastIdD = iCurrIdD;
|
||||
iLastIdQ = iCurrIdQ;
|
||||
|
||||
//pNalUnitsList overflow.
|
||||
++ iIdx;
|
||||
if (iIdx <= iEndIdx) {
|
||||
pNalCur = pCurAu->pNalUnitsList[iIdx];
|
||||
pNalCur = pCurAu->pNalUnitsList[iIdx];
|
||||
} else {
|
||||
pNalCur = NULL;
|
||||
pNalCur = NULL;
|
||||
}
|
||||
|
||||
if (pNalCur == NULL ||
|
||||
@@ -2346,7 +2346,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
|
||||
|
||||
// need update frame_num due current frame is well decoded
|
||||
if (pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0)
|
||||
pCtx->iPrevFrameNum = pSh->iFrameNum;
|
||||
pCtx->iPrevFrameNum = pSh->iFrameNum;
|
||||
if (pCtx->bLastHasMmco5)
|
||||
pCtx->iPrevFrameNum = 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in
|
||||
int32_t i = 0;
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == pPps))
|
||||
uiNumSliceGroups = pPps->uiNumSliceGroups;
|
||||
iMbNum = pFmo->iCountMbNum;
|
||||
iMbNum = pFmo->iCountMbNum;
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap || iMbNum <= 0 || kiMbWidth == 0
|
||||
|| uiNumSliceGroups >= MAX_SLICEGROUP_IDS))
|
||||
|
||||
@@ -124,7 +124,7 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
|
||||
// the cases we would not like
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == kpPps))
|
||||
|
||||
iNumMb = pFmo->iCountMbNum;
|
||||
iNumMb = pFmo->iCountMbNum;
|
||||
|
||||
iNumMb = kiMbWidth * kiMbHeight;
|
||||
|
||||
@@ -133,15 +133,15 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
|
||||
|
||||
|
||||
WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
|
||||
pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory
|
||||
pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
|
||||
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory
|
||||
|
||||
pFmo->iCountMbNum = iNumMb;
|
||||
pFmo->iCountMbNum = iNumMb;
|
||||
|
||||
if (kpPps->uiNumSliceGroups < 2 && iNumMb > 0) { // only one slice group, exactly it is single slice based
|
||||
memset (pFmo->pMbAllocMap, 0, iNumMb * sizeof (int8_t)); // for safe
|
||||
|
||||
pFmo->iSliceGroupCount = 1;
|
||||
pFmo->iSliceGroupCount = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
|
||||
|| ((int32_t)kpPps->uiNumSliceGroups != pFmo->iSliceGroupCount)) {
|
||||
switch (kpPps->uiSliceGroupMapType) {
|
||||
case 0:
|
||||
iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps);
|
||||
iErr = FmoGenerateMbAllocMapType0 (pFmo, kpPps);
|
||||
break;
|
||||
case 1:
|
||||
iErr = FmoGenerateMbAllocMapType1 (pFmo, kpPps, kiMbWidth);
|
||||
@@ -161,7 +161,7 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
|
||||
case 5:
|
||||
case 6:
|
||||
// Reserve for others slice group type
|
||||
iErr = 1;
|
||||
iErr = 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
@@ -213,7 +213,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
|
||||
if (NULL != pIter->pMbAllocMap) {
|
||||
WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap");
|
||||
|
||||
pIter->pMbAllocMap = NULL;
|
||||
pIter->pMbAllocMap = NULL;
|
||||
}
|
||||
pIter->iSliceGroupCount = 0;
|
||||
pIter->iSliceGroupType = -1;
|
||||
@@ -272,7 +272,7 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) {
|
||||
} else {
|
||||
if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) {
|
||||
++ (*pActiveFmoNum);
|
||||
pFmo->bActiveFlag = true;
|
||||
pFmo->bActiveFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -318,7 +318,7 @@ MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) {
|
||||
do {
|
||||
++ iNextMb;
|
||||
if (iNextMb >= kiTotalMb) {
|
||||
iNextMb = -1;
|
||||
iNextMb = -1;
|
||||
break;
|
||||
}
|
||||
if (kpMbMap[iNextMb] == kuiSliceGroupIdc) {
|
||||
|
||||
@@ -112,7 +112,7 @@ void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
}
|
||||
|
||||
void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
|
||||
const uint32_t kuiDC32 = 0x80808080U;
|
||||
const uint32_t kuiDC32 = 0x80808080U;
|
||||
|
||||
ST32A4 (pPred , kuiDC32);
|
||||
ST32A4 (pPred + kiStride , kuiDC32);
|
||||
@@ -534,7 +534,7 @@ void WelsI8x8LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAv
|
||||
|
||||
void WelsI8x8LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
|
||||
// for normal 8 bit depth, 8-94
|
||||
const uint64_t kuiDC64 = 0x8080808080808080ULL;
|
||||
const uint64_t kuiDC64 = 0x8080808080808080ULL;
|
||||
|
||||
int32_t iStride[8];
|
||||
int32_t i;
|
||||
|
||||
@@ -87,7 +87,7 @@ void WelsResetRefPic (PWelsDecoderContext pCtx) {
|
||||
PRefPic pRefPic = &pCtx->sRefPic;
|
||||
pCtx->sRefPic.uiLongRefCount[LIST_0] = pCtx->sRefPic.uiShortRefCount[LIST_0] = 0;
|
||||
|
||||
pRefPic->uiRefCount[LIST_0] = 0;
|
||||
pRefPic->uiRefCount[LIST_0] = 0;
|
||||
|
||||
for (i = 0; i < MAX_SHORT_REF_COUNT; i++) {
|
||||
if (pRefPic->pShortRefList[LIST_0][i] != NULL) {
|
||||
|
||||
@@ -64,7 +64,7 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
|
||||
pPtr = pBase;
|
||||
*ppAu = (PAccessUnit)pPtr;
|
||||
pPtr += kuiSizeAu;
|
||||
(*ppAu)->pNalUnitsList = (PNalUnit*)pPtr;
|
||||
(*ppAu)->pNalUnitsList = (PNalUnit*)pPtr;
|
||||
pPtr += kuiSizeNalUnitPtr;
|
||||
do {
|
||||
(*ppAu)->pNalUnitsList[uiIdx] = (PNalUnit)pPtr;
|
||||
|
||||
@@ -1133,8 +1133,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M
|
||||
uint32_t uiSubMbType;
|
||||
|
||||
if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) {
|
||||
iRefCount[0] =
|
||||
iRefCount[1] = 1;
|
||||
iRefCount[0] =
|
||||
iRefCount[1] = 1;
|
||||
}
|
||||
|
||||
//uiSubMbType, partition
|
||||
|
||||
@@ -69,7 +69,7 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
int32_t iLumaSize = 0;
|
||||
int32_t iChromaSize = 0;
|
||||
|
||||
pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture");
|
||||
pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture");
|
||||
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
|
||||
|
||||
memset (pPic, 0, sizeof (SPicture));
|
||||
@@ -88,7 +88,7 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
|
||||
pPic->iLinesize[0] = iPicWidth;
|
||||
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
|
||||
} else {
|
||||
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */
|
||||
pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */
|
||||
+ (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
|
||||
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLe
|
||||
int8_t* pIntra8x8PredMode = pDqLayer->pIntra4x4FinalMode[iMbXy]; // I_NxN
|
||||
int16_t* pRS = pScoeffLevel;
|
||||
/*itransform info*/
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;
|
||||
|
||||
/*************local variable********************/
|
||||
uint8_t i = 0;
|
||||
@@ -133,7 +133,7 @@ int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLe
|
||||
int8_t* pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY];
|
||||
int16_t* pRS = pScoeffLevel;
|
||||
/*itransform info*/
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
|
||||
PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
|
||||
|
||||
|
||||
/*************local variable********************/
|
||||
|
||||
@@ -102,7 +102,7 @@ CWelsDecoder::CWelsDecoder (void)
|
||||
#endif//OUTPUT_BIT_STREAM
|
||||
|
||||
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
if (m_pWelsTrace != NULL) {
|
||||
m_pWelsTrace->SetCodecInstance (this);
|
||||
m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
|
||||
@@ -227,7 +227,7 @@ void CWelsDecoder::UninitDecoder (void) {
|
||||
if (NULL != m_pDecContext) {
|
||||
WelsFree (m_pDecContext, "m_pDecContext");
|
||||
|
||||
m_pDecContext = NULL;
|
||||
m_pDecContext = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -240,7 +240,7 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) {
|
||||
|
||||
if (m_pDecContext) //free
|
||||
UninitDecoder();
|
||||
m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
|
||||
m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
|
||||
if (NULL == m_pDecContext)
|
||||
return cmMallocMemeError;
|
||||
|
||||
@@ -266,23 +266,23 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
iVal = * ((int*)pOption); // is_rgb
|
||||
iVal = * ((int*)pOption); // is_rgb
|
||||
|
||||
return DecoderSetCsp (m_pDecContext, iVal);
|
||||
} else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
|
||||
iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
|
||||
|
||||
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
|
||||
m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
|
||||
|
||||
return cmResultSuccess;
|
||||
} else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status
|
||||
if (pOption == NULL)
|
||||
return cmInitParaError;
|
||||
|
||||
iVal = * ((int*)pOption); // int value for error concealment idc
|
||||
iVal = * ((int*)pOption); // int value for error concealment idc
|
||||
iVal = WELS_CLIP3 (iVal, (int32_t) ERROR_CON_DISABLE, (int32_t) ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);
|
||||
m_pDecContext->eErrorConMethod = (ERROR_CON_IDC) iVal;
|
||||
if ((m_pDecContext->bParseOnly) && (m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE)) {
|
||||
@@ -340,11 +340,11 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) {
|
||||
|
||||
if (DECODER_OPTION_DATAFORMAT == eOptID) {
|
||||
iVal = (int32_t) m_pDecContext->eOutputColorFormat;
|
||||
* ((int*)pOption) = iVal;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
} else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
|
||||
iVal = m_pDecContext->bEndOfStreamFlag;
|
||||
* ((int*)pOption) = iVal;
|
||||
iVal = m_pDecContext->bEndOfStreamFlag;
|
||||
* ((int*)pOption) = iVal;
|
||||
return cmResultSuccess;
|
||||
}
|
||||
#ifdef LONG_TERM_REF
|
||||
@@ -473,7 +473,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
|
||||
EWelsNalUnitType eNalType =
|
||||
NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
|
||||
|
||||
eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
|
||||
eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
|
||||
|
||||
if (m_pDecContext->iErrorCode & dsOutOfMemory) {
|
||||
ForceResetParaSetStatusAndAUList (m_pDecContext);
|
||||
@@ -638,7 +638,7 @@ DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,
|
||||
int& iWidth,
|
||||
int& iHeight,
|
||||
int& iColorFormat) {
|
||||
DECODING_STATE state = dsErrorFree;
|
||||
DECODING_STATE state = dsErrorFree;
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -678,7 +678,7 @@ long WelsCreateDecoder (ISVCDecoder** ppDecoder) {
|
||||
return ERR_INVALID_PARAMETERS;
|
||||
}
|
||||
|
||||
*ppDecoder = new CWelsDecoder();
|
||||
*ppDecoder = new CWelsDecoder();
|
||||
|
||||
if (NULL == *ppDecoder) {
|
||||
return ERR_MALLOC_FAILED;
|
||||
|
||||
@@ -264,7 +264,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
pCodingParam->fMaxFrameRate = fMaxFrameRate;
|
||||
}
|
||||
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
|
||||
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
|
||||
|
||||
iUsageType = pCodingParam.iUsageType;
|
||||
iPicWidth = pCodingParam.iPicWidth;
|
||||
@@ -326,9 +326,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
bSimulcastAVC = pCodingParam.bSimulcastAVC;
|
||||
|
||||
/* Layer definition */
|
||||
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
|
||||
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
|
||||
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
|
||||
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
|
||||
MAX_TEMPORAL_LEVEL); // number of temporal layer specified
|
||||
|
||||
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
|
||||
@@ -350,7 +350,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
iLTRRefNum = (pCodingParam.bEnableLongTermReference ? pCodingParam.iLTRRefNum : 0);
|
||||
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
|
||||
|
||||
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
|
||||
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
|
||||
|
||||
if ( (CONSTANT_ID == pCodingParam.eSpsPpsIdStrategy)
|
||||
|| (INCREASING_ID == pCodingParam.eSpsPpsIdStrategy)
|
||||
@@ -405,7 +405,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
|
||||
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
|
||||
|
||||
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
|
||||
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
|
||||
++ pDlp;
|
||||
++ pSpatialLayer;
|
||||
++ iIdxSpatial;
|
||||
@@ -419,9 +419,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
// assuming that the width/height ratio of all spatial layers are the same
|
||||
|
||||
void SetActualPicResolution() {
|
||||
int32_t iSpatialIdx = iSpatialLayerNum - 1;
|
||||
int32_t iSpatialIdx = iSpatialLayerNum - 1;
|
||||
for (; iSpatialIdx >= 0; iSpatialIdx --) {
|
||||
SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx];
|
||||
SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx];
|
||||
SSpatialLayerConfig* pDlayer = &sSpatialLayers[iSpatialIdx];
|
||||
|
||||
pDlayerInternal->iActualWidth = pDlayer->iVideoWidth;
|
||||
@@ -456,7 +456,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
|
||||
pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
|
||||
|
||||
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
|
||||
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
|
||||
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
|
||||
if (0 == (uiFrameIdx & iNotCodedMask)) {
|
||||
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
|
||||
@@ -474,7 +474,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
|
||||
return ENC_RETURN_INVALIDINPUT;
|
||||
}
|
||||
|
||||
uiProfileIdc = bSimulcastAVC ? (iEntropyCodingModeFlag ? PRO_HIGH : PRO_BASELINE) :
|
||||
uiProfileIdc = bSimulcastAVC ? (iEntropyCodingModeFlag ? PRO_HIGH : PRO_BASELINE) :
|
||||
(iEntropyCodingModeFlag ? PRO_SCALABLE_HIGH : PRO_SCALABLE_BASELINE);
|
||||
++ pDlp;
|
||||
++ pSpatialLayer;
|
||||
|
||||
@@ -64,7 +64,7 @@ return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
|
||||
|
||||
static inline int32_t WriteTotalcoeffTrailingonesChroma (SBitStringAux* pBs, uint8_t uiTotalCoeff,
|
||||
uint8_t uiTrailingOnes) {
|
||||
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
|
||||
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
|
||||
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ return 0;
|
||||
}
|
||||
|
||||
static inline int32_t WriteTotalZeros (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
|
||||
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
|
||||
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
|
||||
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ static int32_t WelsCheckNumRefSetting (SLogContext* pLogCtx, SWelsSvcCodingParam
|
||||
: (WELS_MAX (1, (pParam->uiGopSize >> 1))));
|
||||
int32_t iNeededRefNum = (pParam->uiIntraPeriod != 1) ? (iCurrentStrNum + pParam->iLTRRefNum) : 0;
|
||||
|
||||
iNeededRefNum = WELS_CLIP3 (iNeededRefNum,
|
||||
iNeededRefNum = WELS_CLIP3 (iNeededRefNum,
|
||||
MIN_REF_PIC_COUNT,
|
||||
(pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA :
|
||||
MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN);
|
||||
@@ -474,18 +474,18 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
|
||||
//max value of both iFrameNum and POC are 2^16-1, in our encoder, iPOC=2*iFrameNum, so max of iFrameNum should be 2^15-1.--
|
||||
pSps->uiLog2MaxFrameNum = 15;//16;
|
||||
pSps->iLog2MaxPocLsb = 1 + pSps->uiLog2MaxFrameNum;
|
||||
pSps->iLog2MaxPocLsb = 1 + pSps->uiLog2MaxFrameNum;
|
||||
|
||||
pSps->iNumRefFrames = kiNumRefFrame; /* min pRef size when fifo pRef operation*/
|
||||
pSps->iNumRefFrames = kiNumRefFrame; /* min pRef size when fifo pRef operation*/
|
||||
|
||||
if (kbEnableFrameCropping) {
|
||||
// TODO: get frame_crop_left_offset, frame_crop_right_offset, frame_crop_top_offset, frame_crop_bottom_offset
|
||||
pSps->bFrameCroppingFlag = WelsGetPaddingOffset (pLayerParamInternal->iActualWidth, pLayerParamInternal->iActualHeight,
|
||||
pLayerParam->iVideoWidth, pLayerParam->iVideoHeight, pSps->sFrameCrop);
|
||||
} else {
|
||||
pSps->bFrameCroppingFlag = false;
|
||||
pSps->bFrameCroppingFlag = false;
|
||||
}
|
||||
pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE;
|
||||
pSps->uiProfileIdc = pLayerParam->uiProfileIdc ? pLayerParam->uiProfileIdc : PRO_BASELINE;
|
||||
if (pLayerParam->uiProfileIdc == PRO_BASELINE) {
|
||||
pSps->bConstraintSet0Flag = true;
|
||||
}
|
||||
@@ -496,7 +496,7 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
|
||||
pSps->bConstraintSet2Flag = true;
|
||||
}
|
||||
|
||||
ELevelIdc uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate);
|
||||
ELevelIdc uiLevel = WelsGetLevelIdc (pSps, pLayerParamInternal->fOutputFrameRate, pLayerParam->iSpatialBitrate);
|
||||
//update level
|
||||
//for Scalable Baseline, Scalable High, and Scalable High Intra profiles.If level_idc is equal to 9, the indicated level is level 1b.
|
||||
//for the Baseline, Constrained Baseline, Main, and Extended profiles,If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
|
||||
@@ -533,7 +533,7 @@ int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerPa
|
||||
WelsInitSps (pSps, pLayerParam, pLayerParamInternal, kuiIntraPeriod, kiNumRefFrame, kuiSpsId, kbEnableFrameCropping,
|
||||
bEnableRc, kiDlayerCount, false);
|
||||
|
||||
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
|
||||
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
|
||||
PRO_SCALABLE_BASELINE;
|
||||
|
||||
pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */
|
||||
@@ -558,26 +558,26 @@ int32_t WelsInitPps (SWelsPPS* pPps,
|
||||
assert (pSps != NULL);
|
||||
if (NULL == pSps)
|
||||
return 1;
|
||||
pUsedSps = pSps;
|
||||
pUsedSps = pSps;
|
||||
} else {
|
||||
assert (pSubsetSps != NULL);
|
||||
if (NULL == pSubsetSps)
|
||||
return 1;
|
||||
pUsedSps = &pSubsetSps->pSps;
|
||||
pUsedSps = &pSubsetSps->pSps;
|
||||
}
|
||||
|
||||
/* fill picture parameter set syntax */
|
||||
pPps->iPpsId = kuiPpsId;
|
||||
pPps->iSpsId = pUsedSps->uiSpsId;
|
||||
pPps->iPpsId = kuiPpsId;
|
||||
pPps->iSpsId = pUsedSps->uiSpsId;
|
||||
pPps->bEntropyCodingModeFlag = kbEntropyCodingModeFlag;
|
||||
#if !defined(DISABLE_FMO_FEATURE)
|
||||
pPps->uiNumSliceGroups = 1; //param->qos_param.sliceGroupCount;
|
||||
pPps->uiNumSliceGroups = 1; //param->qos_param.sliceGroupCount;
|
||||
if (pPps->uiNumSliceGroups > 1) {
|
||||
pPps->uiSliceGroupMapType = 0; //param->qos_param.sliceGroupType;
|
||||
pPps->uiSliceGroupMapType = 0; //param->qos_param.sliceGroupType;
|
||||
if (pPps->uiSliceGroupMapType == 0) {
|
||||
uint32_t uiGroup = 0;
|
||||
while (uiGroup < pPps->uiNumSliceGroups) {
|
||||
pPps->uiRunLength[uiGroup] = 25;
|
||||
pPps->uiRunLength[uiGroup] = 25;
|
||||
++ uiGroup;
|
||||
}
|
||||
} else if (pPps->uiSliceGroupMapType == 2) {
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace WelsEnc {
|
||||
****************************************************************************/
|
||||
void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4
|
||||
int16_t iTemp[4];
|
||||
int32_t i = 4;
|
||||
int32_t i = 4;
|
||||
|
||||
while (--i >= 0) {
|
||||
const int32_t kiIdx = i << 2;
|
||||
|
||||
@@ -240,7 +240,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
|
||||
++pEncCtx->iFrameIndex;
|
||||
|
||||
if (pEncCtx->iPOC < (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2) // if iPOC type is no 0, this need be modification
|
||||
pEncCtx->iPOC += 2; // for POC type 0
|
||||
pEncCtx->iPOC += 2; // for POC type 0
|
||||
else
|
||||
pEncCtx->iPOC = 0;
|
||||
|
||||
@@ -248,7 +248,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
|
||||
if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1)
|
||||
++ pEncCtx->iFrameNum;
|
||||
else
|
||||
pEncCtx->iFrameNum = 0; // if iFrameNum overflow
|
||||
pEncCtx->iFrameNum = 0; // if iFrameNum overflow
|
||||
}
|
||||
pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
|
||||
pEncCtx->eSliceType = P_SLICE;
|
||||
@@ -270,7 +270,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
|
||||
// rc_init_gop
|
||||
} else if (keFrameType == videoFrameTypeI) {
|
||||
if (pEncCtx->iPOC < (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2) // if iPOC type is no 0, this need be modification
|
||||
pEncCtx->iPOC += 2; // for POC type 0
|
||||
pEncCtx->iPOC += 2; // for POC type 0
|
||||
else
|
||||
pEncCtx->iPOC = 0;
|
||||
|
||||
@@ -278,7 +278,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
|
||||
if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1)
|
||||
++ pEncCtx->iFrameNum;
|
||||
else
|
||||
pEncCtx->iFrameNum = 0; // if iFrameNum overflow
|
||||
pEncCtx->iFrameNum = 0; // if iFrameNum overflow
|
||||
}
|
||||
|
||||
pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
|
||||
@@ -296,7 +296,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
|
||||
}
|
||||
|
||||
EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum) {
|
||||
SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam;
|
||||
SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam;
|
||||
EVideoFrameType iFrameType = videoFrameTypeInvalid;
|
||||
bool bSceneChangeFlag = false;
|
||||
|
||||
@@ -370,7 +370,7 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum
|
||||
extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
|
||||
SDqLayer* pDqLayer) {
|
||||
WelsFileHandle* pDumpRecFile = NULL;
|
||||
int32_t iWrittenSize = 0;
|
||||
int32_t iWrittenSize = 0;
|
||||
const char* openMode = bAppend ? "ab" : "wb";
|
||||
SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) :
|
||||
pDqLayer->sLayerInfo.pSpsP;
|
||||
@@ -384,8 +384,8 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName
|
||||
pDumpRecFile = WelsFopen (kpFileName, openMode);
|
||||
else {
|
||||
char sDependencyRecFileName[16] = {0};
|
||||
WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage
|
||||
pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode);
|
||||
WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage
|
||||
pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode);
|
||||
}
|
||||
if (NULL != pDumpRecFile && bAppend)
|
||||
WelsFseek (pDumpRecFile, 0, SEEK_END);
|
||||
@@ -437,22 +437,22 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName
|
||||
|
||||
void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
|
||||
SDqLayer* pDqLayer) {
|
||||
WelsFileHandle* pDumpRecFile = NULL;
|
||||
WelsFileHandle* pDumpRecFile = NULL;
|
||||
SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) :
|
||||
pDqLayer->sLayerInfo.pSpsP;
|
||||
bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
|
||||
SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
|
||||
|
||||
int32_t iWrittenSize = 0;
|
||||
int32_t iWrittenSize = 0;
|
||||
const char* openMode = bAppend ? "ab" : "wb";
|
||||
|
||||
if (NULL == pCurPicture || NULL == kpFileName)
|
||||
return;
|
||||
|
||||
if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage
|
||||
pDumpRecFile = WelsFopen (kpFileName, openMode);
|
||||
if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage
|
||||
pDumpRecFile = WelsFopen (kpFileName, openMode);
|
||||
} else {
|
||||
pDumpRecFile = WelsFopen ("rec.yuv", openMode);
|
||||
pDumpRecFile = WelsFopen ("rec.yuv", openMode);
|
||||
}
|
||||
if (NULL != pDumpRecFile && bAppend)
|
||||
WelsFseek (pDumpRecFile, 0, SEEK_END);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -104,22 +104,21 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride)
|
||||
WelsFillingPred8x2to16 (pPred, uiSrc);
|
||||
}
|
||||
void WelsI4x4LumaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
|
||||
const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) +
|
||||
kiStride - 1] +
|
||||
const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) + kiStride - 1] +
|
||||
pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 4) >> 3;
|
||||
|
||||
WelsFillingPred1to16 (pPred, kuiDcValue);
|
||||
}
|
||||
|
||||
void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
|
||||
const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) +
|
||||
const uint8_t kuiDcValue = (pRef[-1] + pRef[kiStride - 1] + pRef[ (kiStride << 1) - 1] + pRef[ (kiStride << 1) +
|
||||
kiStride - 1] + 2) >> 2;
|
||||
|
||||
WelsFillingPred1to16 (pPred, kuiDcValue);
|
||||
}
|
||||
|
||||
void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
|
||||
const uint8_t kuiDcValue = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 2) >> 2;
|
||||
const uint8_t kuiDcValue = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] + 2) >> 2;
|
||||
|
||||
WelsFillingPred1to16 (pPred, kuiDcValue);
|
||||
}
|
||||
@@ -463,8 +462,8 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride)
|
||||
const int32_t kuiL6 = kuiL5 + kiStride;
|
||||
const int32_t kuiL7 = kuiL6 + kiStride;
|
||||
/*caculate the iMean value*/
|
||||
const uint8_t kuiMean1 = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] +
|
||||
pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 4) >> 3;
|
||||
const uint8_t kuiMean1 = (pRef[-kiStride] + pRef[1 - kiStride] + pRef[2 - kiStride] + pRef[3 - kiStride] +
|
||||
pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 4) >> 3;
|
||||
const uint32_t kuiSum2 = pRef[4 - kiStride] + pRef[5 - kiStride] + pRef[6 - kiStride] + pRef[7 - kiStride];
|
||||
const uint32_t kuiSum3 = pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7];
|
||||
const uint8_t kuiMean2 = (kuiSum2 + 2) >> 2;
|
||||
|
||||
@@ -538,7 +538,7 @@ inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefineP
|
||||
|
||||
iCurCost = CALC_COST (pMeRefine->pQuarPixTmp, pParams->iLms[0]);
|
||||
if (iCurCost < pParams->iBestCost) {
|
||||
pParams->iBestQuarPix = ME_QUAR_PIXEL_TOP;
|
||||
pParams->iBestQuarPix = ME_QUAR_PIXEL_TOP;
|
||||
SWITCH_BEST_TMP_BUF (pMeRefine->pQuarPixBest, pMeRefine->pQuarPixTmp);
|
||||
}
|
||||
//=========================(0, 1)=======================//
|
||||
|
||||
@@ -124,7 +124,7 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t
|
||||
int32_t* pDstLen) {
|
||||
const bool kbNALExt = pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_PREFIX
|
||||
|| pRawNal->sNalExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_EXT;
|
||||
int32_t iAssumedNeededLength = NAL_HEADER_SIZE + (kbNALExt ? 3 : 0) + pRawNal->iPayloadSize + 1;
|
||||
int32_t iAssumedNeededLength = NAL_HEADER_SIZE + (kbNALExt ? 3 : 0) + pRawNal->iPayloadSize + 1;
|
||||
WELS_VERIFY_RETURN_IF (ENC_RETURN_UNEXPECTED, (iAssumedNeededLength <= 0))
|
||||
|
||||
//since for each 0x000 need a 0x03, so the needed length will not exceed (iAssumeNeedLenth + iAssumeNeedLength/3), here adjust to >>1 to omit division
|
||||
@@ -145,20 +145,20 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t
|
||||
pDstPointer += 4;
|
||||
|
||||
/* NAL Unit Header */
|
||||
*pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType &
|
||||
*pDstPointer++ = (pRawNal->sNalExt.sNalUnitHeader.uiNalRefIdc << 5) | (pRawNal->sNalExt.sNalUnitHeader.eNalUnitType &
|
||||
0x1f);
|
||||
|
||||
if (kbNALExt) {
|
||||
SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt;
|
||||
SNalUnitHeaderExt* sNalExt = (SNalUnitHeaderExt*)pNalHeaderExt;
|
||||
|
||||
/* NAL UNIT Extension Header */
|
||||
*pDstPointer++ = (0x80) |
|
||||
*pDstPointer++ = (0x80) |
|
||||
(sNalExt->bIdrFlag << 6);
|
||||
|
||||
*pDstPointer++ = (0x80) |
|
||||
*pDstPointer++ = (0x80) |
|
||||
(sNalExt->uiDependencyId << 4);
|
||||
|
||||
*pDstPointer++ = (sNalExt->uiTemporalId << 5) |
|
||||
*pDstPointer++ = (sNalExt->uiTemporalId << 5) |
|
||||
(sNalExt->bDiscardableFlag << 3) |
|
||||
(0x07);
|
||||
}
|
||||
@@ -166,21 +166,21 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t
|
||||
while (pSrcPointer < pSrcEnd) {
|
||||
if (iZeroCount == 2 && *pSrcPointer <= 3) {
|
||||
//add the code 03
|
||||
*pDstPointer++ = 3;
|
||||
iZeroCount = 0;
|
||||
*pDstPointer++ = 3;
|
||||
iZeroCount = 0;
|
||||
}
|
||||
if (*pSrcPointer == 0) {
|
||||
++ iZeroCount;
|
||||
} else {
|
||||
iZeroCount = 0;
|
||||
iZeroCount = 0;
|
||||
}
|
||||
*pDstPointer++ = *pSrcPointer++;
|
||||
}
|
||||
|
||||
/* count length of NAL Unit */
|
||||
iNalLength = (int32_t) (pDstPointer - pDstStart);
|
||||
iNalLength = (int32_t) (pDstPointer - pDstStart);
|
||||
if (NULL != pDstLen)
|
||||
*pDstLen = iNalLength;
|
||||
*pDstLen = iNalLength;
|
||||
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t
|
||||
int32_t iLumaSize = 0;
|
||||
int32_t iChromaSize = 0;
|
||||
|
||||
pPic = static_cast<SPicture*> (pMa->WelsMallocz (sizeof (SPicture), "pPic"));
|
||||
pPic = static_cast<SPicture*> (pMa->WelsMallocz (sizeof (SPicture), "pPic"));
|
||||
|
||||
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
|
||||
|
||||
@@ -95,10 +95,10 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t
|
||||
if (bNeedMbInfo) {
|
||||
const uint32_t kuiCountMbNum = ((15 + kiWidth) >> 4) * ((15 + kiHeight) >> 4);
|
||||
|
||||
pPic->uiRefMbType = (uint32_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint32_t), "pPic->uiRefMbType");
|
||||
pPic->uiRefMbType = (uint32_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint32_t), "pPic->uiRefMbType");
|
||||
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->uiRefMbType, FreePicture (pMa, &pPic));
|
||||
|
||||
pPic->pRefMbQp = (uint8_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint8_t), "pPic->pRefMbQp");
|
||||
pPic->pRefMbQp = (uint8_t*)pMa->WelsMallocz (kuiCountMbNum * sizeof (uint8_t), "pPic->pRefMbQp");
|
||||
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pRefMbQp, FreePicture (pMa, &pPic));
|
||||
|
||||
pPic->sMvList = static_cast<SMVUnitXY*> (pMa->WelsMallocz (kuiCountMbNum * sizeof (SMVUnitXY),
|
||||
|
||||
@@ -85,7 +85,7 @@ int32_t GetLibName (char* pBuf, int32_t iSize) {
|
||||
if (NULL == pBuf)
|
||||
return 0;
|
||||
|
||||
iLen = (int32_t)strlen (WELS_LIB_NAME); // confirmed_safe_unsafe_usage
|
||||
iLen = (int32_t)strlen (WELS_LIB_NAME); // confirmed_safe_unsafe_usage
|
||||
if (iSize <= iLen)
|
||||
return 0;
|
||||
|
||||
@@ -106,7 +106,7 @@ int32_t GetVerNum (char* pBuf, int32_t iSize) {
|
||||
if (NULL == pBuf)
|
||||
return 0;
|
||||
|
||||
iLen = (int32_t)strlen (WELS_VERSION_STR); // confirmed_safe_unsafe_usage
|
||||
iLen = (int32_t)strlen (WELS_VERSION_STR); // confirmed_safe_unsafe_usage
|
||||
if (iSize <= iLen)
|
||||
return 0;
|
||||
|
||||
@@ -127,7 +127,7 @@ int32_t GetIdentInfo (char* pBuf, int32_t iSize) {
|
||||
if (NULL == pBuf)
|
||||
return 0;
|
||||
|
||||
iLen = (int32_t)strlen (WELS_IDENT); // confirmed_safe_unsafe_usage
|
||||
iLen = (int32_t)strlen (WELS_IDENT); // confirmed_safe_unsafe_usage
|
||||
if (iSize <= iLen)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiDecompositionStages = pDLayerParam->iDecompositionStages;
|
||||
const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId;
|
||||
@@ -193,7 +193,7 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
n = 0;
|
||||
while (n <= kiHighestTid) {
|
||||
pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n];
|
||||
pTOverRc[n].iTlayerWeight = iWeightArray[kiDecompositionStages][n];
|
||||
++ n;
|
||||
}
|
||||
//Calculate the frame index for the current frame and its reference frame
|
||||
@@ -296,7 +296,7 @@ void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
pWelsSvcRc->iGopIndexInVGop = 0;
|
||||
pWelsSvcRc->iRemainingBits = 0;
|
||||
pWelsSvcRc->iBitsPerFrame = 0;
|
||||
pWelsSvcRc->iBitsPerFrame = 0;
|
||||
|
||||
//Backup the initial bitrate and fps
|
||||
pWelsSvcRc->iPreviousBitrate = pDLayerParam->iSpatialBitrate;
|
||||
@@ -422,7 +422,7 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) {
|
||||
}
|
||||
|
||||
void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
//obtain the idr qp using previous idr complexity
|
||||
if (pWelsSvcRc->iNumberMbFrame != pWelsSvcRc->iIntraMbCount) {
|
||||
pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame /
|
||||
@@ -687,7 +687,7 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
|
||||
|
||||
void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
|
||||
const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame;
|
||||
//condition 1: whole pBuffer fullness
|
||||
@@ -803,7 +803,7 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iSpatialNum) {
|
||||
SSpatialPicIndex* pSpatialIndexMap = &pEncCtx->sSpatialIndexMap[0];
|
||||
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[iCurDid];
|
||||
const int32_t kiOutputBits = pWelsSvcRc->iBitsPerFrame;
|
||||
const int32_t kiOutputMaxBits = pWelsSvcRc->iMaxBitsPerFrame;
|
||||
@@ -831,7 +831,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co
|
||||
pEncCtx->iCheckWindowCurrentTs = pEncCtx->iCheckWindowStartTs = uiTimeStamp;
|
||||
pEncCtx->bCheckWindowStatusRefreshFlag = true;
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
pEncCtx->pWelsSvcRc[iCurDid].iBufferFullnessSkip = 0;
|
||||
pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] = 0;
|
||||
pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[EVEN_TIME_WINDOW] = 0;
|
||||
@@ -844,7 +844,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co
|
||||
if (pEncCtx->iCheckWindowInterval >= (TIME_CHECK_WINDOW >> 1) && !pEncCtx->bCheckWindowShiftResetFlag) {
|
||||
pEncCtx->bCheckWindowShiftResetFlag = true;
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
if (pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] > 0
|
||||
&& pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] !=
|
||||
pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[0]) {
|
||||
@@ -863,7 +863,7 @@ void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, co
|
||||
pEncCtx->iCheckWindowInterval = 0;
|
||||
pEncCtx->bCheckWindowShiftResetFlag = false;
|
||||
for (int32_t i = 0; i < iSpatialNum; i++) {
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
|
||||
if (pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[EVEN_TIME_WINDOW] > 0) {
|
||||
pEncCtx->pWelsSvcRc[iCurDid].bNeedShiftWindowCheck[ODD_TIME_WINDOW] = true;
|
||||
} else {
|
||||
@@ -912,7 +912,7 @@ void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
|
||||
void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
|
||||
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
|
||||
SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
|
||||
int32_t iTotalQp = 0, iTotalMb = 0;
|
||||
int32_t i;
|
||||
@@ -1095,10 +1095,10 @@ void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma
|
||||
|
||||
void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiQp = pDLayerParam->iDLayerQp;
|
||||
|
||||
pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);
|
||||
pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);
|
||||
|
||||
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
|
||||
@@ -1114,9 +1114,9 @@ void WelsRcPictureInfoUpdateDisable (sWelsEncCtx* pEncCtx, int32_t iLayerSize)
|
||||
}
|
||||
|
||||
void WelsRcMbInitDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
int32_t iLumaQp = pEncCtx->iGlobalQp;
|
||||
int32_t iLumaQp = pEncCtx->iGlobalQp;
|
||||
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
|
||||
|
||||
|
||||
@@ -1134,7 +1134,7 @@ void WelsRcMbInfoUpdateDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCos
|
||||
}
|
||||
|
||||
void WelRcPictureInitBufferBasedQp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
|
||||
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
|
||||
|
||||
int32_t iMinQp = MIN_SCREEN_QP;
|
||||
if (pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE)
|
||||
@@ -1292,7 +1292,7 @@ void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFram
|
||||
}
|
||||
void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
int32_t iLumaQp = pWelsSvcRc->iLastCalculatedQScale;
|
||||
//decide one frame bits allocated
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace WelsEnc {
|
||||
* reset LTR marking , recovery ,feedback state to default
|
||||
*/
|
||||
void ResetLtrState (SLTRState* pLtr) {
|
||||
pLtr->bReceivedT0LostFlag = false;
|
||||
pLtr->bReceivedT0LostFlag = false;
|
||||
pLtr->iLastRecoverFrameNum = 0;
|
||||
pLtr->iLastCorFrameNumDec = -1;
|
||||
pLtr->iCurFrameNumInDec = -1;
|
||||
@@ -149,7 +149,7 @@ static inline int32_t CompareFrameNum (int32_t iFrameNumA, int32_t iFrameNumB, i
|
||||
* delete failed mark according LTR recovery pRequest
|
||||
*/
|
||||
static inline void DeleteInvalidLTR (sWelsEncCtx* pCtx) {
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SPicture** pLongRefList = pRefList->pLongRefList;
|
||||
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
|
||||
int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum);
|
||||
@@ -246,7 +246,7 @@ static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) {
|
||||
* LTR mark process
|
||||
*/
|
||||
static inline void LTRMarkProcess (sWelsEncCtx* pCtx) {
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SPicture** pLongRefList = pRefList->pLongRefList;
|
||||
SPicture** pShortRefList = pRefList->pShortRefList;
|
||||
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
|
||||
@@ -297,7 +297,7 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) {
|
||||
memmove (&pRefList->pLongRefList[1], &pRefList->pLongRefList[0],
|
||||
pRefList->uiLongRefCount * sizeof (SPicture*)); // confirmed_safe_unsafe_usage
|
||||
}
|
||||
pLongRefList[0] = pShortRefList[i];
|
||||
pLongRefList[0] = pShortRefList[i];
|
||||
pRefList->uiLongRefCount++;
|
||||
if (pRefList->uiLongRefCount > pCtx->pSvcParam->iLTRRefNum) {
|
||||
pRefList->pLongRefList[pRefList->uiLongRefCount - 1]->SetUnref();
|
||||
@@ -308,7 +308,7 @@ static inline void LTRMarkProcess (sWelsEncCtx* pCtx) {
|
||||
}
|
||||
|
||||
static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) {
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SPicture** pLongRefList = pRefList->pLongRefList;
|
||||
int32_t iLtrIdx = pCtx->pDecPic->iLongTermPicNum;
|
||||
pCtx->pVaa->uiMarkLongTermPicIdx = pCtx->pDecPic->iLongTermPicNum;
|
||||
@@ -428,7 +428,7 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) {
|
||||
|
||||
bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) {
|
||||
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SPicture** pLongRefList = pRefList->pLongRefList;
|
||||
int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1);
|
||||
int32_t iMaxFrameNumPlus1 = (1 << pCtx->pSps->uiLog2MaxFrameNum);
|
||||
@@ -446,7 +446,7 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx) {
|
||||
}
|
||||
void WelsMarkPic (sWelsEncCtx* pCtx) {
|
||||
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
|
||||
const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
|
||||
const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
|
||||
int32_t iGoPFrameNumInterval = ((pCtx->pSvcParam->uiGopSize >> 1) > 1) ? (pCtx->pSvcParam->uiGopSize >> 1) : (1);
|
||||
int32_t iSliceIdx = 0;
|
||||
|
||||
@@ -568,7 +568,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe
|
||||
|
||||
// build reference list 0/1 if applicable
|
||||
|
||||
pCtx->iNumRef0 = 0;
|
||||
pCtx->iNumRef0 = 0;
|
||||
|
||||
if (pCtx->eSliceType != I_SLICE) {
|
||||
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bReceivedT0LostFlag && pCtx->uiTemporalId == 0) {
|
||||
@@ -586,7 +586,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe
|
||||
for (i = 0; i < pRefList->uiShortRefCount; ++ i) {
|
||||
SPicture* pRef = pRefList->pShortRefList[i];
|
||||
if (pRef != NULL && pRef->bUsedAsRef && pRef->iFramePoc >= 0 && pRef->uiTemporalId <= kuiTid) {
|
||||
pCtx->pRefList0[pCtx->iNumRef0++] = pRef;
|
||||
pCtx->pRefList0[pCtx->iNumRef0++] = pRef;
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DETAIL,
|
||||
"WelsBuildRefList pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d",
|
||||
pCtx->uiTemporalId, pRef->iFrameNum, pRef->uiTemporalId);
|
||||
@@ -600,7 +600,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe
|
||||
for (int32_t k = 0; k < MAX_TEMPORAL_LEVEL; k++) {
|
||||
pCtx->bRefOfCurTidIsLtr[pCtx->uiDependencyId][k] = false;
|
||||
}
|
||||
pCtx->pRefList0[0] = NULL;
|
||||
pCtx->pRefList0[0] = NULL;
|
||||
}
|
||||
|
||||
if (pCtx->iNumRef0 > kiNumRef)
|
||||
@@ -609,7 +609,7 @@ bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRe
|
||||
}
|
||||
|
||||
static void UpdateBlockStatic (sWelsEncCtx* pCtx) {
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
assert (pCtx->iNumRef0 == 1); //multi-ref is not support yet?
|
||||
for (int32_t idx = 0; idx < pCtx->iNumRef0; idx++) {
|
||||
//TODO: we need to re-factor the source picture storage first,
|
||||
@@ -761,10 +761,10 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) {
|
||||
return true;
|
||||
}
|
||||
bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) {
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SWelsSvcCodingParam* pParam = pCtx->pSvcParam;
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
const int32_t iNumRef = pParam->iNumRefFrame;
|
||||
const int32_t iNumRef = pParam->iNumRefFrame;
|
||||
pCtx->iNumRef0 = 0;
|
||||
|
||||
if (pCtx->eSliceType != I_SLICE) {
|
||||
@@ -805,7 +805,7 @@ bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBes
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"WelsBuildRefListScreen(), CurrentFramePoc=%d, isLTR=%d", iPOC, pCtx->bCurFrameMarkedAsSceneLtr);
|
||||
for (int j = 0; j < iNumRef; j++) {
|
||||
SPicture* pARefPicture = pRefList->pLongRefList[j];
|
||||
SPicture* pARefPicture = pRefList->pLongRefList[j];
|
||||
if (pARefPicture != NULL) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"WelsBuildRefListScreen()\tRefLot[%d]: iPoc=%d, iPictureType=%d, bUsedAsRef=%d, bIsLongRef=%d, bIsSceneLTR=%d, uiTemporalId=%d, iFrameNum=%d, iMarkFrameNum=%d, iLongTermPicNum=%d, uiRecieveConfirmed=%d",
|
||||
@@ -828,7 +828,7 @@ bool WelsBuildRefListScreen (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBes
|
||||
// dealing with IDR
|
||||
WelsResetRefList (pCtx); //for IDR, SHOULD reset pRef list.
|
||||
ResetLtrState (&pCtx->pLtr[pCtx->uiDependencyId]); //SHOULD update it when IDR.
|
||||
pCtx->pRefList0[0] = NULL;
|
||||
pCtx->pRefList0[0] = NULL;
|
||||
}
|
||||
if (pCtx->iNumRef0 > iNumRef) {
|
||||
pCtx->iNumRef0 = iNumRef;
|
||||
@@ -850,8 +850,8 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) {
|
||||
iMaxActualLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1 - WELS_MAX (iMaxTid , 1);
|
||||
|
||||
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
|
||||
SPicture** ppLongRefList = pRefList->pLongRefList;
|
||||
const int32_t iNumRef = pCtx->pSvcParam->iNumRefFrame;
|
||||
SPicture** ppLongRefList = pRefList->pLongRefList;
|
||||
const int32_t iNumRef = pCtx->pSvcParam->iNumRefFrame;
|
||||
int32_t i;
|
||||
const int32_t iLongRefNum = iNumRef - STR_ROOM;
|
||||
const bool bIsRefListNotFull = pRefList->uiLongRefCount < iLongRefNum;
|
||||
@@ -876,7 +876,7 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int32_t iRefNum_t[MAX_TEMPORAL_LAYER_NUM] = {0};
|
||||
int32_t iRefNum_t[MAX_TEMPORAL_LAYER_NUM] = {0};
|
||||
for (i = 0 ; i < pRefList->uiLongRefCount ; ++i) {
|
||||
if (ppLongRefList[i]->bUsedAsRef && ppLongRefList[i]->bIsLongRef && (!ppLongRefList[i]->bIsSceneLTR)) {
|
||||
++iRefNum_t[ ppLongRefList[i]->uiTemporalId ];
|
||||
|
||||
@@ -220,7 +220,7 @@ int32_t WelsSampleSatdIntra8x8Combined3_c (uint8_t* pDecCb, int32_t iDecStride,
|
||||
iBestCost = iCurCost;
|
||||
}
|
||||
|
||||
*pBestMode = iBestMode;
|
||||
*pBestMode = iBestMode;
|
||||
|
||||
return iBestCost;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice
|
||||
WelsEmms();
|
||||
|
||||
while (iSliceIdx < kiSliceCount) {
|
||||
iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pCountMbInSlice[iSliceIdx], pSliceTime[iSliceIdx]);
|
||||
iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pCountMbInSlice[iSliceIdx], pSliceTime[iSliceIdx]);
|
||||
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), pSliceConsumeTime[%d]= %d us, slice_run= %d",
|
||||
iSliceIdx,
|
||||
pSliceTime[iSliceIdx], pCountMbInSlice[iSliceIdx]);
|
||||
@@ -183,7 +183,7 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
|
||||
} else
|
||||
fThr = 1.0f;
|
||||
if (fRmse > fThr)
|
||||
iNeedAdj = true;
|
||||
iNeedAdj = true;
|
||||
MT_TRACE_LOG (NULL, WELS_LOG_DEBUG,
|
||||
"[MT] NeedDynamicAdjust(), herein adjustment decision is made (iNeedAdj= %d) by: fRmse of pSlice complexity ratios %.6f, the corresponding threshold %.6f, iCountSliceNum %d",
|
||||
iNeedAdj, fRmse, fThr, iSliceNum);
|
||||
@@ -222,19 +222,19 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
|
||||
if (iNumMbInEachGom * kiCountSliceNum >= kiCountNumMb) {
|
||||
return;
|
||||
}
|
||||
iMinimalMbNum = iNumMbInEachGom;
|
||||
iMinimalMbNum = iNumMbInEachGom;
|
||||
}
|
||||
|
||||
if (kiCountSliceNum < 2 || (kiCountSliceNum & 0x01)) // we need suppose uiSliceNum is even for multiple threading
|
||||
return;
|
||||
|
||||
iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum;
|
||||
iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum;
|
||||
|
||||
WelsEmms();
|
||||
|
||||
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, "[MT] DynamicAdjustSlicing(), iDid= %d, iCountNumMb= %d", iCurDid, kiCountNumMb);
|
||||
|
||||
iSliceIdx = 0;
|
||||
iSliceIdx = 0;
|
||||
while (iSliceIdx + 1 < kiCountSliceNum) {
|
||||
int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * pSliceComplexRatio[iSliceIdx], INT_MULTIPLY);
|
||||
|
||||
@@ -245,9 +245,9 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
|
||||
|
||||
// make sure one GOM at least in each pSlice for safe
|
||||
if (iNumMbAssigning < iMinimalMbNum)
|
||||
iNumMbAssigning = iMinimalMbNum;
|
||||
iNumMbAssigning = iMinimalMbNum;
|
||||
else if (iNumMbAssigning > iMaximalMbNum)
|
||||
iNumMbAssigning = iMaximalMbNum;
|
||||
iNumMbAssigning = iMaximalMbNum;
|
||||
|
||||
assert (iNumMbAssigning > 0);
|
||||
|
||||
@@ -256,13 +256,13 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
|
||||
assert (0);
|
||||
return;
|
||||
}
|
||||
iRunLen[iSliceIdx] = iNumMbAssigning;
|
||||
iRunLen[iSliceIdx] = iNumMbAssigning;
|
||||
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
|
||||
"[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
|
||||
iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx],
|
||||
iNumMbAssigning);
|
||||
++ iSliceIdx;
|
||||
iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
|
||||
iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
|
||||
}
|
||||
iRunLen[iSliceIdx] = iMbNumLeft;
|
||||
MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
|
||||
@@ -301,16 +301,16 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
|
||||
return 1;
|
||||
|
||||
pMa = (*ppCtx)->pMemAlign;
|
||||
pMa = (*ppCtx)->pMemAlign;
|
||||
pPara = pCodingParam;
|
||||
iNumSpatialLayers = pPara->iSpatialLayerNum;
|
||||
iThreadNum = pPara->iCountThreadsNum;
|
||||
iNumSpatialLayers = pPara->iSpatialLayerNum;
|
||||
iThreadNum = pPara->iCountThreadsNum;
|
||||
iMaxSliceNum = (*ppCtx)->iMaxSliceCount;
|
||||
|
||||
pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading");
|
||||
pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt), FreeMemorySvc (ppCtx))
|
||||
(*ppCtx)->pSliceThreading = pSmt;
|
||||
pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum,
|
||||
(*ppCtx)->pSliceThreading = pSmt;
|
||||
pSmt->pThreadPEncCtx = (SSliceThreadPrivateData*)pMa->WelsMalloc (sizeof (SSliceThreadPrivateData) * iThreadNum,
|
||||
"pThreadPEncCtx");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadPEncCtx), FreeMemorySvc (ppCtx))
|
||||
|
||||
@@ -323,14 +323,14 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
|
||||
iIdx = 0;
|
||||
while (iIdx < iNumSpatialLayers) {
|
||||
SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg;
|
||||
SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg;
|
||||
const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum;
|
||||
if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE))
|
||||
&& pPara->iMultipleThreadIdc > 1
|
||||
&& pPara->iMultipleThreadIdc >= kiSliceNum) {
|
||||
pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
|
||||
pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx))
|
||||
pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
|
||||
pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx))
|
||||
} else {
|
||||
pSmt->pSliceConsumeTime[iIdx] = NULL;
|
||||
@@ -348,7 +348,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
fclose (pSmt->pFSliceDiff);
|
||||
pSmt->pFSliceDiff = NULL;
|
||||
}
|
||||
pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+");
|
||||
pSmt->pFSliceDiff = fopen ("slice_time.txt", "wt+");
|
||||
#endif//MT_DEBUG
|
||||
|
||||
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "encpEncCtx= 0x%p", (void*) *ppCtx);
|
||||
@@ -392,7 +392,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);
|
||||
MT_TRACE_LOG (*ppCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);
|
||||
|
||||
(*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs");
|
||||
(*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs");
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx))
|
||||
|
||||
pBsBase = (*ppCtx)->pFrameBs + iCountBsLen;
|
||||
@@ -403,7 +403,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
|
||||
pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer");
|
||||
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSliceB->pBsBuffer), FreeMemorySvc (ppCtx))
|
||||
pSliceB->uiSize = iSliceBsBufferSize;
|
||||
pSliceB->uiSize = iSliceBsBufferSize;
|
||||
|
||||
if (iIdx > 0) {
|
||||
pSliceB->pBs = pBsBase;
|
||||
@@ -537,7 +537,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
||||
++ pSliceBs;
|
||||
if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
|
||||
int32_t iNalIdx = 0;
|
||||
const int32_t iCountNal = pSliceBs->iNalIndex;
|
||||
const int32_t iCountNal = pSliceBs->iNalIndex;
|
||||
|
||||
#if MT_DEBUG_BS_WR
|
||||
assert (pSliceBs->bSliceCodedFlag);
|
||||
@@ -549,7 +549,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
||||
iLayerSize += pSliceBs->uiBsPos;
|
||||
|
||||
while (iNalIdx < iCountNal) {
|
||||
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||
++ iNalIdx;
|
||||
}
|
||||
pLbi->iNalCount += iCountNal;
|
||||
@@ -567,13 +567,13 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
||||
const int32_t kiCountSlicesCoded = pCtx->pCurDqLayer->pNumSliceCodedOfPartition[iPartitionIdx];
|
||||
int32_t iIdx = 0;
|
||||
|
||||
iSliceIdx = iPartitionIdx;
|
||||
iSliceIdx = iPartitionIdx;
|
||||
while (iIdx < kiCountSlicesCoded) {
|
||||
pSliceBs = &pCtx->pSliceBs[iSliceIdx];
|
||||
pSliceBs = &pCtx->pSliceBs[iSliceIdx];
|
||||
if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
|
||||
if (iPartitionIdx > 0) {
|
||||
int32_t iNalIdx = 0;
|
||||
const int32_t iCountNal = pSliceBs->iNalIndex;
|
||||
const int32_t iCountNal = pSliceBs->iNalIndex;
|
||||
|
||||
memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage
|
||||
pCtx->iPosBsBuffer += pSliceBs->uiBsPos;
|
||||
@@ -581,13 +581,13 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
|
||||
iLayerSize += pSliceBs->uiBsPos;
|
||||
|
||||
while (iNalIdx < iCountNal) {
|
||||
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
|
||||
++ iNalIdx;
|
||||
}
|
||||
pLbi->iNalCount += iCountNal;
|
||||
iNalIdxBase += iCountNal;
|
||||
} else {
|
||||
iLayerSize += pSliceBs->uiBsPos;
|
||||
iLayerSize += pSliceBs->uiBsPos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,12 +622,12 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr
|
||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||
iSliceSize += iNalSize;
|
||||
pDst += iNalSize;
|
||||
pLbi->pNalLengthInByte[iNalBase + iNalIdx] = iNalSize;
|
||||
pLbi->pNalLengthInByte[iNalBase + iNalIdx] = iNalSize;
|
||||
|
||||
++ iNalIdx;
|
||||
}
|
||||
|
||||
pSliceBs->uiBsPos = iSliceSize;
|
||||
pSliceBs->uiBsPos = iSliceSize;
|
||||
if (iFirstSlice) {
|
||||
// pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread()
|
||||
pLbi->uiLayerType = VIDEO_CODING_LAYER;
|
||||
@@ -653,7 +653,7 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl
|
||||
int32_t iReturn = ENC_RETURN_SUCCESS;
|
||||
const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf);
|
||||
|
||||
iSliceSize = 0;
|
||||
iSliceSize = 0;
|
||||
assert (kiNalCnt <= 2);
|
||||
if (kiNalCnt > 2)
|
||||
return 0;
|
||||
@@ -668,7 +668,7 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl
|
||||
pDst += iNalSize;
|
||||
++ iNalIdx;
|
||||
}
|
||||
pSliceBs->uiBsPos = iSliceSize;
|
||||
pSliceBs->uiBsPos = iSliceSize;
|
||||
|
||||
return iReturn;
|
||||
}
|
||||
@@ -727,7 +727,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
|
||||
|
||||
if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) {
|
||||
int64_t iSliceStart = 0;
|
||||
int64_t iSliceStart = 0;
|
||||
bool bDsaFlag = false;
|
||||
iSliceIdx = pPrivateData->iSliceIndex;
|
||||
pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
|
||||
@@ -746,7 +746,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
|
||||
|
||||
#if MT_DEBUG_BS_WR
|
||||
pSliceBs->bSliceCodedFlag = false;
|
||||
pSliceBs->bSliceCodedFlag = false;
|
||||
#endif//MT_DEBUG_BS_WR
|
||||
|
||||
if (bNeedPrefix) {
|
||||
@@ -772,7 +772,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
WelsUnloadNalForSlice (pSliceBs);
|
||||
|
||||
if (0 == iSliceIdx) {
|
||||
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
|
||||
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
|
||||
iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);
|
||||
if (ENC_RETURN_SUCCESS != iReturn) {
|
||||
uiThrdRet = iReturn;
|
||||
@@ -818,7 +818,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
#endif//SLICE_INFO_OUTPUT
|
||||
|
||||
#if MT_DEBUG_BS_WR
|
||||
pSliceBs->bSliceCodedFlag = true;
|
||||
pSliceBs->bSliceCodedFlag = true;
|
||||
#endif//MT_DEBUG_BS_WR
|
||||
|
||||
WelsEventSignal (
|
||||
@@ -833,7 +833,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
|
||||
int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
|
||||
|
||||
iSliceIdx = pPrivateData->iSliceIndex;
|
||||
iSliceIdx = pPrivateData->iSliceIndex;
|
||||
|
||||
pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
|
||||
pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside
|
||||
@@ -845,7 +845,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) {
|
||||
// TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage
|
||||
// No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure
|
||||
uiThrdRet = 1;
|
||||
uiThrdRet = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -880,7 +880,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
|
||||
if (0 == kiPartitionId) {
|
||||
if (0 == iSliceIdx)
|
||||
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
|
||||
pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
|
||||
iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer, iSliceIdx,
|
||||
iSliceSize);
|
||||
if (ENC_RETURN_SUCCESS != iReturn) {
|
||||
@@ -931,13 +931,13 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
|
||||
WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
|
||||
}
|
||||
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal
|
||||
uiThrdRet = 0;
|
||||
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal
|
||||
uiThrdRet = 0;
|
||||
break;
|
||||
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
|
||||
iSliceIdx =
|
||||
iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable
|
||||
pCurDq = pEncPEncCtx->pCurDqLayer;
|
||||
} else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
|
||||
iSliceIdx =
|
||||
iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable
|
||||
pCurDq = pEncPEncCtx->pCurDqLayer;
|
||||
UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx);
|
||||
WelsEventSignal (
|
||||
&pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
|
||||
@@ -945,7 +945,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
|
||||
WelsLog (& (pEncPEncCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!", iEventIdx,
|
||||
iWaitRet, iThreadIdx);
|
||||
uiThrdRet = 1;
|
||||
uiThrdRet = 1;
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
@@ -991,7 +991,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData,
|
||||
|
||||
////////////////////////////////////////
|
||||
if (bIsDynamicSlicingMode) {
|
||||
iEndMbIdx = pSliceCtx->iMbNumInFrame;
|
||||
iEndMbIdx = pSliceCtx->iMbNumInFrame;
|
||||
for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {
|
||||
const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx];
|
||||
pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
|
||||
@@ -1003,7 +1003,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData,
|
||||
iIdx = 0;
|
||||
while (iIdx < kiEventCnt) {
|
||||
pPriData[iIdx].pLayerBs = pLbi;
|
||||
pPriData[iIdx].iSliceIndex = iIdx;
|
||||
pPriData[iIdx].iSliceIndex = iIdx;
|
||||
if (pEventsList[iIdx])
|
||||
WelsEventSignal (&pEventsList[iIdx]);
|
||||
if (pMasterEventsList[iIdx])
|
||||
@@ -1027,10 +1027,10 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) {
|
||||
int64_t iT0 = WelsTime();
|
||||
#endif//MT_DEBUG
|
||||
|
||||
pCtx->pCurDqLayer = pCurDq;
|
||||
pCtx->pCurDqLayer = pCurDq;
|
||||
|
||||
// do not need adjust due to not different at both slices of consumed time
|
||||
iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame);
|
||||
iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame);
|
||||
if (iNeedAdj)
|
||||
DynamicAdjustSlicing (pCtx,
|
||||
pCurDq,
|
||||
@@ -1056,7 +1056,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) {
|
||||
// uiSliceMode of referencing spatial should be SM_FIXEDSLCNUM_SLICE
|
||||
// if using spatial base layer for complexity estimation
|
||||
|
||||
const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
|
||||
const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0)
|
||||
&& (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
|
||||
&& pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid -
|
||||
1].sSliceCfg.sSliceArgument.uiSliceNum);
|
||||
@@ -1119,7 +1119,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
|
||||
if (iSpatialNum > MAX_DEPENDENCY_LAYER)
|
||||
return;
|
||||
|
||||
pPara = pCtx->pSvcParam;
|
||||
pPara = pCtx->pSvcParam;
|
||||
while (iSpatialIdx < iSpatialNum) {
|
||||
const int32_t kiDid = pDidList[iSpatialIdx];
|
||||
SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
|
||||
|
||||
@@ -307,7 +307,7 @@ void WelsMdIntraInit (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, con
|
||||
}
|
||||
|
||||
//step 2. initial pWelsMd
|
||||
pCurMb->uiCbp = 0;
|
||||
pCurMb->uiCbp = 0;
|
||||
|
||||
//step 4: locating scaled_tcoeff
|
||||
|
||||
@@ -327,7 +327,7 @@ void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const i
|
||||
const int32_t kiMbWidth = pCurLayer->iMbWidth;
|
||||
const int32_t kiMbHeight = pCurLayer->iMbHeight;
|
||||
|
||||
pMbCache->pEncSad = &pCurLayer->pDecPic->pMbSkipSad[kiMbXY];
|
||||
pMbCache->pEncSad = &pCurLayer->pDecPic->pMbSkipSad[kiMbXY];
|
||||
|
||||
//step 1. load neighbor cache
|
||||
pEncCtx->pFuncList->pfFillInterNeighborCache (pMbCache, pCurMb, kiMbWidth,
|
||||
@@ -351,7 +351,7 @@ void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const i
|
||||
pMbCache->SPicData.pRefMb[2] += MB_WIDTH_CHROMA;
|
||||
}
|
||||
|
||||
pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY];
|
||||
pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY];
|
||||
pMbCache->bCollocatedPredFlag = false;
|
||||
|
||||
//comment: sometimes, mode decision process may skip the md_p16x16 and md_pskip function,
|
||||
@@ -449,7 +449,7 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
|
||||
#endif//X86_ASM
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
const int32_t kiOffset = kpNeighborIntraToI4x4[i];
|
||||
const int32_t kiOffset = kpNeighborIntraToI4x4[i];
|
||||
|
||||
//step 1: locating current 4x4 block position in pEnc and pDecMb
|
||||
iCoordinateX = kpCoordinateIdxX[i];
|
||||
@@ -866,7 +866,7 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb
|
||||
|
||||
int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache* pMbCache, int32_t iLambda) {
|
||||
const int8_t* kpAvailMode;
|
||||
int32_t iAvailCount = 0;
|
||||
int32_t iAvailCount = 0;
|
||||
int32_t iChmaIdx = 0;
|
||||
uint8_t* pPredIntraChma[2] = {pMbCache->pMemPredChroma, pMbCache->pMemPredChroma + 128};
|
||||
uint8_t* pDstChma = pPredIntraChma[0];
|
||||
@@ -920,12 +920,12 @@ int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCa
|
||||
iBestMode = iCurMode;
|
||||
iBestCost = iCurCost;
|
||||
iChmaIdx = iChmaIdx ^ 0x01;
|
||||
pDstChma = pPredIntraChma[iChmaIdx];
|
||||
pDstChma = pPredIntraChma[iChmaIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pMbCache->pBestPredIntraChroma = pPredIntraChma[iChmaIdx ^ 0x01];
|
||||
pMbCache->pBestPredIntraChroma = pPredIntraChma[iChmaIdx ^ 0x01];
|
||||
pMbCache->uiChmaI8x8Mode = iBestMode;
|
||||
return iBestCost;
|
||||
}
|
||||
@@ -1039,7 +1039,7 @@ int32_t WelsMdP16x8 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SWelsMD* pW
|
||||
sMe16x8->iCurMeBlockPixY = pWelsMd->iMbPixY + iPixelY;
|
||||
sMe16x8->uSadPredISatd.uiSadPred = pWelsMd->iSadPredMb >> 1;
|
||||
|
||||
pSlice->sMvc[0] = sMe16x8->sMvBase;
|
||||
pSlice->sMvc[0] = sMe16x8->sMvBase;
|
||||
pSlice->uiMvcNum = 1;
|
||||
|
||||
PredInter16x8Mv (pMbCache, i << 3, 0, & (sMe16x8->sMvp));
|
||||
@@ -1583,7 +1583,7 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
||||
|
||||
}
|
||||
bool WelsMdFirstIntraMode (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
|
||||
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
|
||||
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
|
||||
|
||||
int32_t iCostI16x16 = WelsMdI16x16 (pFunc, pEncCtx->pCurDqLayer, pMbCache, pWelsMd->iLambda);
|
||||
|
||||
@@ -1719,7 +1719,7 @@ void WelsMdInterDecidedPskip (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb,
|
||||
//////
|
||||
void WelsMdInterEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache) {
|
||||
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
//add pEnc&rec to MD--2010.3.15
|
||||
const int32_t kiCsStrideY = pCurDqLayer->iCsStride[0];
|
||||
|
||||
@@ -71,7 +71,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
|
||||
return 1;
|
||||
|
||||
if (SM_ROWMB_SLICE == pSliceSeg->uiSliceMode) {
|
||||
const int32_t kiMbWidth = pSliceSeg->iMbWidth;
|
||||
const int32_t kiMbWidth = pSliceSeg->iMbWidth;
|
||||
int32_t iSliceNum = pSliceSeg->iSliceNumInFrame, uiSliceIdx = 0;
|
||||
|
||||
while (uiSliceIdx < iSliceNum) {
|
||||
@@ -102,7 +102,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
|
||||
|
||||
// due here need check validate mb_assign_map for input pData, can not use memset
|
||||
do {
|
||||
pSliceSeg->pOverallMbMap[iMbIdx + iRunIdx] = iSliceIdx;
|
||||
pSliceSeg->pOverallMbMap[iMbIdx + iRunIdx] = iSliceIdx;
|
||||
++ iRunIdx;
|
||||
} while (iRunIdx < kiCurRunLength && iMbIdx + iRunIdx < kiCountNumMbInFrame);
|
||||
|
||||
@@ -143,7 +143,7 @@ bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceAr
|
||||
|
||||
for (; uiSliceIdx + 1 < kuiSliceNum; ++ uiSliceIdx) {
|
||||
pSlicesAssignList[uiSliceIdx] = kiMbNumPerSlice;
|
||||
iNumMbLeft -= kiMbNumPerSlice;
|
||||
iNumMbLeft -= kiMbNumPerSlice;
|
||||
}
|
||||
pSlicesAssignList[uiSliceIdx] = iNumMbLeft;
|
||||
|
||||
@@ -160,7 +160,7 @@ bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSlic
|
||||
return false;
|
||||
|
||||
while (uiSliceIdx < kuiSliceNum) {
|
||||
pSlicesAssignList[uiSliceIdx] = kiMbWidth;
|
||||
pSlicesAssignList[uiSliceIdx] = kiMbWidth;
|
||||
++ uiSliceIdx;
|
||||
}
|
||||
return true;
|
||||
@@ -267,7 +267,7 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight,
|
||||
int32_t iMaximalMbNum = 0; // dynamically assign later
|
||||
int32_t iGomSize;
|
||||
|
||||
uint32_t uiSliceIdx = 0; // for test
|
||||
uint32_t uiSliceIdx = 0; // for test
|
||||
|
||||
// The default RC is Bit-rate mode [Yi], but need consider as below:
|
||||
// Tuned to use max of mode0 and mode1 due can not refresh on this from rc mode changed outside, 8/16/2011
|
||||
@@ -284,15 +284,15 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight,
|
||||
int32_t iNumMbAssigning = WELS_DIV_ROUND (INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize;
|
||||
int32_t iCurNumMbAssigning = 0;
|
||||
|
||||
iMinimalMbNum = iGomSize;
|
||||
iMinimalMbNum = iGomSize;
|
||||
while (uiSliceIdx + 1 < kuiSliceNum) {
|
||||
iMaximalMbNum = iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
|
||||
iMaximalMbNum = iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
|
||||
|
||||
// make sure one GOM at least in each slice for safe
|
||||
if (iNumMbAssigning < iMinimalMbNum)
|
||||
iCurNumMbAssigning = iMinimalMbNum;
|
||||
iCurNumMbAssigning = iMinimalMbNum;
|
||||
else if (iNumMbAssigning > iMaximalMbNum)
|
||||
iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize;
|
||||
iCurNumMbAssigning = ( iMaximalMbNum / iGomSize ) * iGomSize;
|
||||
else
|
||||
iCurNumMbAssigning = iNumMbAssigning;
|
||||
|
||||
@@ -305,7 +305,7 @@ bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight,
|
||||
return false;
|
||||
}
|
||||
|
||||
pSlicesAssignList[uiSliceIdx] = iCurNumMbAssigning;
|
||||
pSlicesAssignList[uiSliceIdx] = iCurNumMbAssigning;
|
||||
++ uiSliceIdx;
|
||||
}
|
||||
pSlicesAssignList[uiSliceIdx] = iNumMbLeft;
|
||||
@@ -382,7 +382,7 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
if (NULL != pSliceSeg->pCountMbNumInSlice) {
|
||||
pMa->WelsFree (pSliceSeg->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice");
|
||||
|
||||
pSliceSeg->pCountMbNumInSlice = NULL;
|
||||
pSliceSeg->pCountMbNumInSlice = NULL;
|
||||
}
|
||||
// just for safe
|
||||
pSliceSeg->iSliceNumInFrame = 0;
|
||||
@@ -393,12 +393,12 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
}
|
||||
|
||||
if (SM_SINGLE_SLICE == uiSliceMode) {
|
||||
pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
|
||||
pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
|
||||
|
||||
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
|
||||
pSliceSeg->iSliceNumInFrame = 1;
|
||||
pSliceSeg->iSliceNumInFrame = 1;
|
||||
|
||||
pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
"pSliceSeg->pFirstMbInSlice");
|
||||
|
||||
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice)
|
||||
@@ -420,7 +420,7 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
&& uiSliceMode != SM_DYN_SLICE && uiSliceMode != SM_AUTO_SLICE)
|
||||
return 1;
|
||||
|
||||
pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
|
||||
pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
|
||||
|
||||
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
|
||||
|
||||
@@ -432,12 +432,12 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
if (-1 == pSliceSeg->iSliceNumInFrame)
|
||||
return 1;
|
||||
|
||||
pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
pSliceSeg->pCountMbNumInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
"pSliceSeg->pCountMbNumInSlice");
|
||||
|
||||
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice)
|
||||
|
||||
pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
|
||||
"pSliceSeg->pFirstMbInSlice");
|
||||
|
||||
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice)
|
||||
@@ -587,7 +587,7 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) {
|
||||
int32_t iNextMbIdx = kiMbXY;
|
||||
++ iNextMbIdx;
|
||||
if (iNextMbIdx >= pSliceSeg->iMbNumInFrame)
|
||||
iNextMbIdx = -1;
|
||||
iNextMbIdx = -1;
|
||||
return iNextMbIdx;
|
||||
} else { /*if ( SM_MULTIPLE_SLICE == pSliceSeg->uiSliceMode )*/
|
||||
if (SM_RESERVED != pSliceSeg->uiSliceMode) {
|
||||
@@ -685,7 +685,7 @@ int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx,
|
||||
|
||||
iSliceIdx = 0;
|
||||
do {
|
||||
const int32_t kiSliceRun = pRunLength[iSliceIdx];
|
||||
const int32_t kiSliceRun = pRunLength[iSliceIdx];
|
||||
|
||||
pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx;
|
||||
pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun;
|
||||
|
||||
@@ -192,7 +192,7 @@ void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache
|
||||
const int16_t* pMF = g_kiQuantMF[uiQp];
|
||||
const int16_t* pFF = g_kiQuantInterFF[uiQp];
|
||||
int16_t aMax[16];
|
||||
int32_t i, j, iNoneZeroCountMbDcAc = 0, iNoneZeroCount = 0;
|
||||
int32_t i, j, iNoneZeroCountMbDcAc = 0, iNoneZeroCount = 0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
pfQuantizationFour4x4Max (pRes, pFF, pMF, aMax + (i << 2));
|
||||
@@ -259,7 +259,7 @@ void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCac
|
||||
uint8_t uiSubMbIdx = 16 + ((iUV - 1) << 2); //uiSubMbIdx == 16 or 20
|
||||
int16_t* iChromaDc = pMbCache->pDct->iChromaDc[iUV - 1], *pBlock = pMbCache->pDct->iChromaBlock[ (iUV - 1) << 2];
|
||||
int16_t aDct2x2[4], j, aMax[4];
|
||||
int32_t iSingleCtr8x8 = 0;
|
||||
int32_t iSingleCtr8x8 = 0;
|
||||
const int16_t* pMF = g_kiQuantMF[kiQp];
|
||||
const int16_t* pFF = g_kiQuantInterFF[ (!kiInterFlag) * 6 + kiQp];
|
||||
|
||||
@@ -326,7 +326,7 @@ void WelsRecPskip (SDqLayer* pCurLayer, SWelsFuncPtrList* pFuncList, SMB* pCu
|
||||
}
|
||||
|
||||
bool WelsTryPYskip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) {
|
||||
int32_t iSingleCtrMb = 0;
|
||||
int32_t iSingleCtrMb = 0;
|
||||
int16_t* pRes = pMbCache->pCoeffLevel;
|
||||
const uint8_t kuiQp = pCurMb->uiLumaQp;
|
||||
|
||||
|
||||
@@ -67,10 +67,10 @@ void UpdateNonZeroCountCache (SMB* pMb, SMbCache* pMbCache) {
|
||||
}
|
||||
|
||||
void WelsSliceHeaderScalExtInit (SDqLayer* pCurLayer, SSlice* pSlice) {
|
||||
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
|
||||
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
|
||||
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
|
||||
|
||||
uint8_t uiDependencyId = pNalHeadExt->uiDependencyId;
|
||||
uint8_t uiDependencyId = pNalHeadExt->uiDependencyId;
|
||||
|
||||
pSliceHeadExt->bSliceSkipFlag = false;
|
||||
|
||||
@@ -90,7 +90,7 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice*
|
||||
SSliceHeaderExt* pCurSliceExt = &pSlice->sSliceHeaderExt;
|
||||
SSliceHeader* pCurSliceHeader = &pCurSliceExt->sSliceHeader;
|
||||
|
||||
pCurSliceHeader->eSliceType = pEncCtx->eSliceType;
|
||||
pCurSliceHeader->eSliceType = pEncCtx->eSliceType;
|
||||
|
||||
pCurSliceExt->bStoreRefBasePicFlag = false;
|
||||
|
||||
@@ -99,14 +99,14 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice*
|
||||
pCurSliceHeader->iFrameNum = pEncCtx->iFrameNum;
|
||||
pCurSliceHeader->uiIdrPicId = pEncCtx->uiIdrPicId;
|
||||
|
||||
pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0
|
||||
pCurSliceHeader->iPicOrderCntLsb = pEncCtx->pEncPic->iFramePoc; // 0
|
||||
|
||||
if (P_SLICE == pEncCtx->eSliceType) {
|
||||
pCurSliceHeader->uiNumRefIdxL0Active = 1;
|
||||
pCurSliceHeader->uiNumRefIdxL0Active = 1;
|
||||
if (pCurSliceHeader->uiRefCount > 0 &&
|
||||
pCurSliceHeader->uiRefCount < pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) {
|
||||
pCurSliceHeader->bNumRefIdxActiveOverrideFlag = true;
|
||||
pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount;
|
||||
pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount;
|
||||
}
|
||||
//to solve mismatch between debug&release
|
||||
else {
|
||||
@@ -117,23 +117,23 @@ void WelsSliceHeaderExtInit (sWelsEncCtx* pEncCtx, SDqLayer* pCurLayer, SSlice*
|
||||
pCurSliceHeader->iSliceQpDelta = pEncCtx->iGlobalQp - pCurLayer->sLayerInfo.pPpsP->iPicInitQp;
|
||||
|
||||
//for deblocking initial
|
||||
pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc;
|
||||
pCurSliceHeader->iSliceAlphaC0Offset =
|
||||
pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1
|
||||
pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset;
|
||||
pCurSliceHeader->uiDisableDeblockingFilterIdc = pCurLayer->iLoopFilterDisableIdc;
|
||||
pCurSliceHeader->iSliceAlphaC0Offset =
|
||||
pCurLayer->iLoopFilterAlphaC0Offset; // need update iSliceAlphaC0Offset & iSliceBetaOffset for pSlice-header if loop_filter_idc != 1
|
||||
pCurSliceHeader->iSliceBetaOffset = pCurLayer->iLoopFilterBetaOffset;
|
||||
pCurSliceExt->uiDisableInterLayerDeblockingFilterIdc = pCurLayer->uiDisableInterLayerDeblockingFilterIdc;
|
||||
|
||||
if (pSlice->bSliceHeaderExtFlag) {
|
||||
WelsSliceHeaderScalExtInit (pCurLayer, pSlice);
|
||||
} else {
|
||||
//both adaptive and default flags should equal to 0.
|
||||
pCurSliceExt->bAdaptiveBaseModeFlag =
|
||||
pCurSliceExt->bAdaptiveMotionPredFlag =
|
||||
pCurSliceExt->bAdaptiveResidualPredFlag = false;
|
||||
pCurSliceExt->bAdaptiveBaseModeFlag =
|
||||
pCurSliceExt->bAdaptiveMotionPredFlag =
|
||||
pCurSliceExt->bAdaptiveResidualPredFlag = false;
|
||||
|
||||
pCurSliceExt->bDefaultBaseModeFlag =
|
||||
pCurSliceExt->bDefaultMotionPredFlag =
|
||||
pCurSliceExt->bDefaultResidualPredFlag = false;
|
||||
pCurSliceExt->bDefaultBaseModeFlag =
|
||||
pCurSliceExt->bDefaultMotionPredFlag =
|
||||
pCurSliceExt->bDefaultResidualPredFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) {
|
||||
* \brief write reference picture marking syntax in pSlice header
|
||||
*/
|
||||
void WriteRefPicMarking (SBitStringAux* pBs, SSliceHeader* pSliceHeader, SNalUnitHeaderExt* pNalHdrExt) {
|
||||
SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking;
|
||||
SRefPicMarking* sRefMarking = &pSliceHeader->sRefMarking;
|
||||
int16_t n = 0;
|
||||
|
||||
if (pNalHdrExt->bIdrFlag) {
|
||||
@@ -503,7 +503,7 @@ int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encodin
|
||||
}
|
||||
for (; ;) {
|
||||
pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0);
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
pCurMb = &pMbList[ iCurMbIdx ];
|
||||
|
||||
pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice);
|
||||
@@ -567,7 +567,7 @@ int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd +
|
||||
WelsInitSliceCabac (pEncCtx, pSlice);
|
||||
}
|
||||
for (; ;) {
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
pCurMb = &pMbList[ iCurMbIdx ];
|
||||
|
||||
pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, 0);
|
||||
@@ -618,7 +618,7 @@ TRY_REENCODING:
|
||||
iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx);
|
||||
//whether all of MB in current pSlice encoded or not
|
||||
if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbCoded >= kiTotalNumMb) {
|
||||
pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId];
|
||||
pSliceCtx->pCountMbNumInSlice[kiSliceIdx] = iCurMbIdx - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId];
|
||||
pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] =
|
||||
iCurMbIdx; // update pLastCodedMbIdxOfPartition, finish coding, use iCurMbIdx directly
|
||||
break;
|
||||
@@ -662,38 +662,38 @@ int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool
|
||||
|
||||
int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
//pSlice-level init should be outside and before this function
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
|
||||
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
|
||||
|
||||
//MD switch
|
||||
if (kbBaseAvail && kbHighestSpatial) {
|
||||
//initial pMd pointer
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer;
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer;
|
||||
} else {
|
||||
//initial pMd pointer
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
|
||||
}
|
||||
return WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial);
|
||||
}
|
||||
|
||||
int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
//pSlice-level init should be outside and before this function
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbBaseAvail = pCurLayer->bBaseLayerAvailableFlag;
|
||||
const bool kbHighestSpatial = pEncCtx->pSvcParam->iSpatialLayerNum ==
|
||||
(pCurLayer->sLayerInfo.sNalHeaderExt.uiDependencyId + 1);
|
||||
|
||||
//MD switch
|
||||
if (kbBaseAvail && kbHighestSpatial) {
|
||||
//initial pMd pointer
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer;
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMbEnhancelayer;
|
||||
} else {
|
||||
//initial pMd pointer
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
|
||||
pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
|
||||
}
|
||||
return WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial);
|
||||
}
|
||||
@@ -781,9 +781,9 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx,
|
||||
bool bLeftTop;
|
||||
bool bRightTop;
|
||||
int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY;
|
||||
const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY);
|
||||
const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY);
|
||||
|
||||
pMb->uiSliceIdc = kuiSliceIdc;
|
||||
pMb->uiSliceIdc = kuiSliceIdc;
|
||||
iLeftXY = kiMbXY - 1;
|
||||
iTopXY = kiMbXY - kiMbWidth;
|
||||
iLeftTopXY = iTopXY - 1;
|
||||
@@ -806,7 +806,7 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx,
|
||||
if (bRightTop) {
|
||||
uiNeighborAvailFlag |= TOPRIGHT_MB_POS;
|
||||
}
|
||||
pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag;
|
||||
pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag;
|
||||
|
||||
++ pMb;
|
||||
++ iIdx;
|
||||
@@ -824,10 +824,10 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic
|
||||
uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep;
|
||||
SSlice* pNextSlice = NULL;
|
||||
|
||||
SMB* pMbList = pCurLayer->sMbDataP;
|
||||
SMB* pMbList = pCurLayer->sMbDataP;
|
||||
|
||||
//update cur pSlice info
|
||||
pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
|
||||
pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
|
||||
|
||||
//pNextSlice pointer/initialization
|
||||
pNextSlice = & (pCurLayer->sLayerInfo.pSliceInLayer[ iNextSliceIdc ]);
|
||||
@@ -860,7 +860,7 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli
|
||||
int32_t iPosBitOffset = 0;
|
||||
const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum;
|
||||
const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum;
|
||||
const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId];
|
||||
const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId];
|
||||
|
||||
const bool kbCurMbNotFirstMbOfCurSlice = (pSliceCtx->pOverallMbMap[iCurMbIdx] ==
|
||||
pSliceCtx->pOverallMbMap[iCurMbIdx - 1]);
|
||||
@@ -963,7 +963,7 @@ int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
|
||||
for (;;) {
|
||||
pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun);
|
||||
//point to current pMb
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
pCurMb = &pMbList[ iCurMbIdx ];
|
||||
|
||||
|
||||
@@ -1060,7 +1060,7 @@ int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice,
|
||||
pEncCtx->pFuncList->pfStashMBStatus (&sDss, pSlice, pSlice->iMbSkipRun);
|
||||
|
||||
//point to current pMb
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
iCurMbIdx = iNextMbIdx;
|
||||
pCurMb = &pMbList[ iCurMbIdx ];
|
||||
|
||||
//step(1): set QP for the current MB
|
||||
|
||||
@@ -120,7 +120,7 @@ void WelsMdInterMbEnhancelayer (sWelsEncCtx* pEncCtx, SWelsMD* pMd, SSlice* pSli
|
||||
|
||||
// do initiation for noILP (needed by ILFMD)
|
||||
SMB* GetRefMb (SDqLayer* pCurLayer, SMB* pCurMb) {
|
||||
const SDqLayer* kpRefLayer = pCurLayer->pRefLayer;
|
||||
const SDqLayer* kpRefLayer = pCurLayer->pRefLayer;
|
||||
const int32_t kiRefMbIdx = (pCurMb->iMbY >> 1) * kpRefLayer->iMbWidth + (pCurMb->iMbX >>
|
||||
1); //because current lower layer is half size on both vertical and horizontal
|
||||
return (&kpRefLayer->sMbDataP[kiRefMbIdx]);
|
||||
@@ -244,7 +244,7 @@ bool WelsMdInterJudgeBGDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p
|
||||
//TODO: consider reusing this result of ChromaCheck when SCDSkip needs this as well
|
||||
|
||||
if (CheckChromaCost (pEncCtx, pWelsMd, pMbCache, pCurMb->iMbXY)) {
|
||||
SMVUnitXY sVaaPredSkipMv = { 0 };
|
||||
SMVUnitXY sVaaPredSkipMv = { 0 };
|
||||
PredSkipMv (pMbCache, &sVaaPredSkipMv);
|
||||
WelsMdBackgroundMbEnc (pEncCtx, pWelsMd, pCurMb, pMbCache, pSlice, (LD32 (&sVaaPredSkipMv) == 0));
|
||||
return true;
|
||||
@@ -320,7 +320,7 @@ inline bool CheckBorder (int32_t iMbX, int32_t iMbY, int32_t iScrollMvX, int32_t
|
||||
|
||||
|
||||
bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWelsMD* pWelsMd) {
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
const int32_t kiMbX = pCurMb->iMbX;
|
||||
const int32_t kiMbY = pCurMb->iMbY;
|
||||
|
||||
@@ -347,7 +347,7 @@ bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe
|
||||
}
|
||||
|
||||
bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWelsMD* pWelsMd) {
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
const int32_t kiMbX = pCurMb->iMbX;
|
||||
const int32_t kiMbY = pCurMb->iMbY;
|
||||
const int32_t kiMbWidth = pCurDqLayer->iMbWidth;
|
||||
@@ -516,7 +516,7 @@ void SetBlockStaticIdcToMd (void* pVaa, SWelsMD* pWelsMd, SMB* pCurMb, SDqLayer*
|
||||
// Scene Change Detection (SCD) PSkip Decision for screen content
|
||||
////////////////////////
|
||||
bool WelsMdInterJudgeSCDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* slice, SMB* pCurMb, SMbCache* pMbCache) {
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
SetBlockStaticIdcToMd (pEncCtx->pVaa, pWelsMd, pCurMb, pCurDqLayer);
|
||||
|
||||
@@ -634,7 +634,7 @@ void WelsMdInterFinePartitionVaaOnScreen (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd
|
||||
// SetScrollingMvToMd
|
||||
//
|
||||
void SetScrollingMvToMd (SVAAFrameInfo* pVaa, SWelsMD* pWelsMd) {
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pVaa);
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pVaa);
|
||||
|
||||
SMVUnitXY sTempMv;
|
||||
sTempMv.iMvX = pVaaExt->sScrollDetectInfo.iScrollMvX;
|
||||
|
||||
@@ -372,7 +372,7 @@ SMVUnitXY WelsCabacMbMvd (SCabacCtx* pCabacCtx, SMB* pCurMb, uint32_t iMbWidth,
|
||||
int16_t WelsGetMbCtxCabac (SMbCache* pMbCache, SMB* pCurMb, uint32_t iMbWidth, ECtxBlockCat eCtxBlockCat,
|
||||
int16_t iIdx) {
|
||||
int16_t iNzA = -1, iNzB = -1;
|
||||
int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount;
|
||||
int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount;
|
||||
int32_t bIntra = IS_INTRA (pCurMb->uiMbType);
|
||||
int32_t iCtxInc = 0;
|
||||
switch (eCtxBlockCat) {
|
||||
@@ -479,11 +479,11 @@ int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, S
|
||||
int16_t iMbWidth, uint32_t uiChromaQpIndexOffset) {
|
||||
|
||||
const uint16_t uiMbType = pCurMb->uiMbType;
|
||||
SMbCache* pMbCache = &pSlice->sMbCacheInfo;
|
||||
SMbCache* pMbCache = &pSlice->sMbCacheInfo;
|
||||
int16_t i = 0;
|
||||
int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount;
|
||||
int8_t* pNonZeroCoeffCount = pMbCache->iNonZeroCoeffCount;
|
||||
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
|
||||
const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice;
|
||||
const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice;
|
||||
|
||||
|
||||
pCurMb->iCbpDc = 0;
|
||||
@@ -560,7 +560,7 @@ int32_t WelsWriteMbResidualCabac (SWelsFuncPtrList* pFuncList, SSlice* pSlice, S
|
||||
}
|
||||
} else {
|
||||
pCurMb->iLumaDQp = 0;
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + uiChromaQpIndexOffset)];
|
||||
}
|
||||
return 0;
|
||||
@@ -578,11 +578,11 @@ void WelsInitSliceCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
|
||||
|
||||
int32_t WelsSpatialWriteMbSynCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
|
||||
SCabacCtx* pCabacCtx = &pSlice->sCabacCtx;
|
||||
SMbCache* pMbCache = &pSlice->sMbCacheInfo;
|
||||
SMbCache* pMbCache = &pSlice->sMbCacheInfo;
|
||||
const uint16_t uiMbType = pCurMb->uiMbType;
|
||||
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
|
||||
uint32_t uiNumRefIdxL0Active = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1;
|
||||
const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice;
|
||||
const int32_t iSliceFirstMbXY = pSliceHeadExt->sSliceHeader.iFirstMbInSlice;
|
||||
int16_t i = 0;
|
||||
int16_t iMbWidth = pEncCtx->pCurDqLayer->iMbWidth;
|
||||
uint32_t uiChromaQpIndexOffset = pEncCtx->pCurDqLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
|
||||
@@ -592,7 +592,7 @@ int32_t WelsSpatialWriteMbSynCabac (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* p
|
||||
WelsCabacEncodeTerminate (&pSlice->sCabacCtx, 0);
|
||||
|
||||
if (IS_SKIP (pCurMb->uiMbType)) {
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + uiChromaQpIndexOffset)];
|
||||
WelsMbSkipCabac (&pSlice->sCabacCtx, pCurMb, iMbWidth, pEncCtx->eSliceType, 1);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb
|
||||
const uint8_t kuiChromaQpIndexOffset = pEncCtx->pCurDqLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
|
||||
|
||||
if (IS_SKIP (pCurMb->uiMbType)) {
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiLumaQp = pSlice->uiLastMbQp;
|
||||
pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
|
||||
|
||||
pSlice->iMbSkipRun++;
|
||||
|
||||
@@ -155,7 +155,7 @@ int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCoding
|
||||
}
|
||||
|
||||
void CWelsPreProcess::FreeSpatialPictures (sWelsEncCtx* pCtx) {
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
int32_t j = 0;
|
||||
while (j < pCtx->pSvcParam->iSpatialLayerNum) {
|
||||
uint8_t i = 0;
|
||||
@@ -221,7 +221,7 @@ int32_t CWelsPreProcess::AnalyzeSpatialPic (sWelsEncCtx* pCtx, const int32_t kiD
|
||||
bool bCalculateVar = (pSvcParam->iRCMode >= RC_BITRATE_MODE && pCtx->eSliceType == I_SLICE);
|
||||
|
||||
if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
|
||||
SRefInfoParam* BestRefCandidateParam = (pCtx->bCurFrameMarkedAsSceneLtr) ? (& (pVaaExt->sVaaLtrBestRefCandidate[0])) :
|
||||
(& (pVaaExt->sVaaStrBestRefCandidate[0]));
|
||||
SPicture* pRefPic = m_pSpatialPic[0][BestRefCandidateParam->iSrcListIdx];
|
||||
@@ -328,7 +328,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
pDstPic = pSrcPic;
|
||||
if (pScaledPicture->pScaledInputPicture) {
|
||||
// for highest downsampling
|
||||
pDstPic = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
pDstPic = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId];
|
||||
iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId];
|
||||
}
|
||||
@@ -363,7 +363,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
-- iActualSpatialLayerNum;
|
||||
}
|
||||
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
-- iDependencyId;
|
||||
|
||||
// generate other spacial layer
|
||||
@@ -384,7 +384,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
if ((iTemporalId != INVALID_TEMPORAL_ID)) {
|
||||
// down sampling performed
|
||||
|
||||
pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; // small
|
||||
pDstPic = m_pSpatialPic[iDependencyId][iPicturePos]; // small
|
||||
iShrinkWidth = pScaledPicture->iScaledWidth[iDependencyId];
|
||||
iShrinkHeight = pScaledPicture->iScaledHeight[iDependencyId];
|
||||
DownsamplePadding (pSrcPic, pDstPic, iSrcWidth, iSrcHeight, iShrinkWidth, iShrinkHeight, iTargetWidth, iTargetHeight, true);
|
||||
@@ -394,7 +394,7 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
|
||||
-- iActualSpatialLayerNum;
|
||||
++ iSpatialNum;
|
||||
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
m_pLastSpatialPicture[iDependencyId][1] = m_pSpatialPic[iDependencyId][iPicturePos];
|
||||
}
|
||||
-- iDependencyId;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) {
|
||||
int32_t iDlayerIndex = 0;
|
||||
if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) {
|
||||
m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL;
|
||||
m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL;
|
||||
}
|
||||
} else {
|
||||
for (; iDlayerIndex < kiDlayerCount; iDlayerIndex++) {
|
||||
@@ -745,8 +745,8 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu
|
||||
int32_t iComplexityAnalysisMode = 0;
|
||||
|
||||
if (pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
SComplexityAnalysisScreenParam* sComplexityAnalysisParam = &pVaaExt->sComplexityScreenParam;
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
SComplexityAnalysisScreenParam* sComplexityAnalysisParam = &pVaaExt->sComplexityScreenParam;
|
||||
SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId];
|
||||
|
||||
if (pCtx->eSliceType == P_SLICE)
|
||||
@@ -797,7 +797,7 @@ void CWelsPreProcess::AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCu
|
||||
m_pInterfaceVp->Get (iMethodIdx, (void*)sComplexityAnalysisParam);
|
||||
|
||||
} else {
|
||||
SVAAFrameInfo* pVaaInfo = pCtx->pVaa;
|
||||
SVAAFrameInfo* pVaaInfo = pCtx->pVaa;
|
||||
SComplexityAnalysisParam* sComplexityAnalysisParam = & (pVaaInfo->sComplexityAnalysisParam);
|
||||
SWelsSvcRc* SWelsSvcRc = &pCtx->pWelsSvcRc[kiDependencyId];
|
||||
|
||||
@@ -990,7 +990,7 @@ void CWelsPreProcess::SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam*
|
||||
ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPicture* pCurPicture) {
|
||||
#define STATIC_SCENE_MOTION_RATIO 0.01f
|
||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pCtx->pVaa);
|
||||
if (NULL == pCtx || NULL == pVaaExt || NULL == pCurPicture) {
|
||||
return LARGE_CHANGED_SCENE;
|
||||
}
|
||||
@@ -1140,7 +1140,7 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
|
||||
|
||||
int32_t CWelsPreProcess::GetRefFrameInfo (int32_t iRefIdx, bool bCurrentFrameIsSceneLtr, SPicture*& pRefOri) {
|
||||
const int32_t iTargetDid = m_pEncCtx->pSvcParam->iSpatialLayerNum - 1;
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
|
||||
SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (m_pEncCtx->pVaa);
|
||||
SRefInfoParam* pBestRefCandidateParam = (bCurrentFrameIsSceneLtr) ? (& (pVaaExt->sVaaLtrBestRefCandidate[iRefIdx])) :
|
||||
(& (pVaaExt->sVaaStrBestRefCandidate[iRefIdx]));
|
||||
pRefOri = m_pSpatialPic[iTargetDid][pBestRefCandidateParam->iSrcListIdx];
|
||||
@@ -1201,7 +1201,7 @@ int32_t CWelsPreProcess::UpdateBlockIdcForScreen (uint8_t* pCurBlockStaticPoint
|
||||
* \return none
|
||||
*/
|
||||
void CWelsPreProcess::WelsExchangeSpatialPictures (SPicture** ppPic1, SPicture** ppPic2) {
|
||||
SPicture* tmp = *ppPic1;
|
||||
SPicture* tmp = *ppPic1;
|
||||
|
||||
assert (*ppPic1 != *ppPic2);
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ CWelsH264SVCEncoder::~CWelsH264SVCEncoder() {
|
||||
|
||||
void CWelsH264SVCEncoder::InitEncoder (void) {
|
||||
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
if (m_pWelsTrace == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
if (pCfg->iTemporalLayerNum < 1)
|
||||
pCfg->iTemporalLayerNum = 1;
|
||||
pCfg->iTemporalLayerNum = 1;
|
||||
if (pCfg->iTemporalLayerNum > MAX_TEMPORAL_LEVEL) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR,
|
||||
"CWelsH264SVCEncoder::Initialize(), invalid iTemporalLayerNum= %d, valid at range of [1, %d].",
|
||||
@@ -312,9 +312,9 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
|
||||
} else {
|
||||
pCfg->iLTRRefNum = pCfg->bEnableLongTermReference ? LONG_TERM_REF_NUM : 0;
|
||||
if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT) {
|
||||
pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) :
|
||||
pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) :
|
||||
(MIN_REF_PIC_COUNT + pCfg->iLTRRefNum);
|
||||
pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA);
|
||||
pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ int32_t CWelsH264SVCEncoder::Uninitialize() {
|
||||
|
||||
if (NULL != m_pEncContext) {
|
||||
WelsUninitEncoderExt (&m_pEncContext);
|
||||
m_pEncContext = NULL;
|
||||
m_pEncContext = NULL;
|
||||
}
|
||||
|
||||
m_bInitialFlag = false;
|
||||
@@ -671,8 +671,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_DATAFORMAT, m_iCspInternal= 0x%x", m_iCspInternal);
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval
|
||||
int32_t iValue = * ((int32_t*)pOption);
|
||||
case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval
|
||||
int32_t iValue = * ((int32_t*)pOption);
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IDR_INTERVAL iValue= %d", iValue);
|
||||
if (iValue < -1 || iValue == 0)
|
||||
@@ -680,7 +680,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
if (iValue == (int32_t)m_pEncContext->pSvcParam->uiIntraPeriod) {
|
||||
return cmResultSuccess;
|
||||
}
|
||||
m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue;
|
||||
m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter
|
||||
@@ -769,8 +769,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate
|
||||
float iValue = * ((float*)pOption);
|
||||
case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate
|
||||
float iValue = * ((float*)pOption);
|
||||
if (iValue <= 0) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
@@ -791,7 +791,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
iBitrate);
|
||||
return cmInitParaError;
|
||||
}
|
||||
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
|
||||
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
|
||||
switch (pInfo->iLayer) {
|
||||
case SPATIAL_LAYER_ALL:
|
||||
m_pEncContext->pSvcParam->iTargetBitrate = iBitrate;
|
||||
@@ -837,7 +837,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
iBitrate);
|
||||
return cmInitParaError;
|
||||
}
|
||||
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
|
||||
iBitrate = WELS_CLIP3 (iBitrate, MIN_BIT_RATE, MAX_BIT_RATE);
|
||||
switch (pInfo->iLayer) {
|
||||
case SPATIAL_LAYER_ALL:
|
||||
m_pEncContext->pSvcParam->iMaxBitrate = iBitrate;
|
||||
@@ -875,7 +875,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
break;
|
||||
case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode;2:bitrate limited mode
|
||||
int32_t iValue = * ((int32_t*)pOption);
|
||||
m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue;
|
||||
m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_MODE iRCMode= %d ",
|
||||
iValue);
|
||||
@@ -883,7 +883,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
break;
|
||||
case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding
|
||||
int32_t iValue = * ((int32_t*)pOption);
|
||||
m_pEncContext->pSvcParam->iPaddingFlag = iValue;
|
||||
m_pEncContext->pSvcParam->iPaddingFlag = iValue;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_PADDING_PADDING iPaddingFlag= %d ",
|
||||
iValue);
|
||||
@@ -1114,7 +1114,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
case ENCODER_OPTION_DATAFORMAT: { // Input color space
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_DATAFORMAT, m_iCspInternal= 0x%x", m_iCspInternal);
|
||||
* ((int32_t*)pOption) = m_iCspInternal;
|
||||
* ((int32_t*)pOption) = m_iCspInternal;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_IDR_INTERVAL: { // IDR Interval
|
||||
@@ -1141,7 +1141,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::GetOption():ENCODER_OPTION_FRAME_RATE, fMaxFrameRate = %.6ff",
|
||||
m_pEncContext->pSvcParam->fMaxFrameRate);
|
||||
* ((float*)pOption) = m_pEncContext->pSvcParam->fMaxFrameRate;
|
||||
* ((float*)pOption) = m_pEncContext->pSvcParam->fMaxFrameRate;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_BITRATE: { // Target bit-rate
|
||||
@@ -1196,7 +1196,7 @@ int CWelsH264SVCEncoder::GetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_STATISTICS_LOG_INTERVAL: {
|
||||
* ((int32_t*)pOption) = m_pEncContext->iStatisticsLogInterval;
|
||||
* ((int32_t*)pOption) = m_pEncContext->iStatisticsLogInterval;
|
||||
}
|
||||
break;
|
||||
case ENCODER_OPTION_COMPLEXITY: {
|
||||
|
||||
@@ -278,7 +278,7 @@ inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackground
|
||||
|
||||
// chroma component check
|
||||
if (pBackgroundOU->iBackgroundFlag == 1) {
|
||||
int8_t iNeighbourForegroundFlags = !pOUNeighbours[0]->iBackgroundFlag | ((!pOUNeighbours[1]->iBackgroundFlag) << 1)
|
||||
int8_t iNeighbourForegroundFlags = !pOUNeighbours[0]->iBackgroundFlag | ((!pOUNeighbours[1]->iBackgroundFlag) << 1)
|
||||
| ((!pOUNeighbours[2]->iBackgroundFlag) << 2) | ((!pOUNeighbours[3]->iBackgroundFlag) << 3);
|
||||
pBackgroundOU->iBackgroundFlag = !ForegroundDilation23Chroma (iNeighbourForegroundFlags, iChromaSampleStartPos,
|
||||
iPicStrideUV, pBgdParam);
|
||||
@@ -291,9 +291,9 @@ inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackground
|
||||
}
|
||||
inline void CBackgroundDetection::BackgroundErosion (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[]) {
|
||||
if (pBackgroundOU->iMaxDiffSubSd <= (BGD_OU_SIZE * Q_FACTOR)) { //BGD_OU_SIZE*BGD_OU_SIZE>>2
|
||||
int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag +
|
||||
int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag +
|
||||
pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag;
|
||||
int32_t sumNbrBGsad = (pOUNeighbours[0]->iSAD & (-pOUNeighbours[0]->iBackgroundFlag)) + (pOUNeighbours[2]->iSAD &
|
||||
int32_t sumNbrBGsad = (pOUNeighbours[0]->iSAD & (-pOUNeighbours[0]->iBackgroundFlag)) + (pOUNeighbours[2]->iSAD &
|
||||
(-pOUNeighbours[2]->iBackgroundFlag))
|
||||
+ (pOUNeighbours[1]->iSAD & (-pOUNeighbours[1]->iBackgroundFlag)) + (pOUNeighbours[3]->iSAD &
|
||||
(-pOUNeighbours[3]->iBackgroundFlag));
|
||||
|
||||
@@ -105,7 +105,7 @@ void* WelsRealloc (void* pPointer, uint32_t* pRealSize, const uint32_t kuiSize,
|
||||
|
||||
pLocalPointer = InternalReallocate (pPointer, kuiNewSize, pTag);
|
||||
if (NULL != pLocalPointer) {
|
||||
*pRealSize = kuiNewSize;
|
||||
*pRealSize = kuiNewSize;
|
||||
return (pLocalPointer);
|
||||
} else {
|
||||
return NULL;
|
||||
|
||||
@@ -139,14 +139,14 @@ EResult CDownsampling::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pDs
|
||||
|
||||
int32_t CDownsampling::GetAlignedIndex (const int32_t kiSrcWidth) {
|
||||
int32_t iAlignIndex;
|
||||
if ((kiSrcWidth & 0x1f) == 0) // x32
|
||||
iAlignIndex = 0;
|
||||
else if ((kiSrcWidth & 0x0f) == 0) // x16
|
||||
iAlignIndex = 1;
|
||||
else if ((kiSrcWidth & 0x07) == 0) // x8
|
||||
iAlignIndex = 2;
|
||||
if ((kiSrcWidth & 0x1f) == 0) // x32
|
||||
iAlignIndex = 0;
|
||||
else if ((kiSrcWidth & 0x0f) == 0) // x16
|
||||
iAlignIndex = 1;
|
||||
else if ((kiSrcWidth & 0x07) == 0) // x8
|
||||
iAlignIndex = 2;
|
||||
else
|
||||
iAlignIndex = 3;
|
||||
iAlignIndex = 3;
|
||||
return iAlignIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class CSceneChangeDetectorVideo {
|
||||
iCurRowStride = sLocalParam.iCurStride << 3;
|
||||
|
||||
for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) {
|
||||
pRefTmp = pRefY;
|
||||
pRefTmp = pRefY;
|
||||
pCurTmp = pCurY;
|
||||
for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) {
|
||||
int32_t iSad = m_pfSad (pCurTmp, sLocalParam.iCurStride, pRefTmp, sLocalParam.iRefStride);
|
||||
@@ -154,7 +154,7 @@ class CSceneChangeDetectorScreen : public CSceneChangeDetectorVideo {
|
||||
iCurRowStride = sLocalParam.iCurStride << 3;
|
||||
|
||||
for (int32_t j = 0; j < sLocalParam.iBlock8x8Height; j++) {
|
||||
pRefTmp = pRefY;
|
||||
pRefTmp = pRefY;
|
||||
pCurTmp = pCurY;
|
||||
for (int32_t i = 0; i < sLocalParam.iBlock8x8Width; i++) {
|
||||
int32_t iBlockPointX = i << 3;
|
||||
@@ -216,7 +216,7 @@ class CSceneChangeDetection : public IStrategy {
|
||||
int32_t iBlock8x8Num = m_sLocalParam.iBlock8x8Width * m_sLocalParam.iBlock8x8Height;
|
||||
int32_t iSceneChangeThresholdLarge = WelsStaticCast (int32_t,
|
||||
m_cDetector.GetSceneChangeMotionRatioLarge() * iBlock8x8Num + 0.5f + PESN);
|
||||
int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t,
|
||||
int32_t iSceneChangeThresholdMedium = WelsStaticCast (int32_t,
|
||||
m_cDetector.GetSceneChangeMotionRatioMedium() * iBlock8x8Num + 0.5f + PESN);
|
||||
|
||||
m_sSceneChangeParam.iMotionBlockNum = 0;
|
||||
|
||||
@@ -575,7 +575,7 @@ void EncodeDecodeTestAPIBase::SliceParamValidationForMode3 (int iSpatialIdx) {
|
||||
|
||||
unsigned int uiMbHeight = 0;
|
||||
|
||||
uiMbHeight = (param_.iPicHeight + 15) >> 4;
|
||||
uiMbHeight = (param_.iPicHeight + 15) >> 4;
|
||||
|
||||
//change slice mode to SM_SINGLE_SLICE
|
||||
if (uiMbHeight > MAX_SLICES_NUM) {
|
||||
|
||||
@@ -488,12 +488,11 @@ void WelsIChromaPredDcLeft_ref (uint8_t* pPred, const int32_t kiStride) {
|
||||
}
|
||||
|
||||
void WelsIChromaPredDcTop_ref (uint8_t* pPred, const int32_t kiStride) {
|
||||
int32_t iTmp = (kiStride << 3) - kiStride;
|
||||
int32_t iTmp = (kiStride << 3) - kiStride;
|
||||
/*caculate the kMean value*/
|
||||
const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2;
|
||||
const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >>
|
||||
2;
|
||||
const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
|
||||
const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2;
|
||||
const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> 2;
|
||||
const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
|
||||
|
||||
uint8_t i = 7;
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ void UninitDecoder (PWelsDecoderContext pCtx) {
|
||||
WelsEndDecoder (pCtx);
|
||||
if (NULL != pCtx) {
|
||||
free (pCtx);
|
||||
pCtx = NULL;
|
||||
pCtx = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void DecoderParseSyntaxTest::Init() {
|
||||
//
|
||||
m_pCtx = (PWelsDecoderContext)malloc (sizeof (SWelsDecoderContext));
|
||||
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
m_pWelsTrace = new welsCodecTrace();
|
||||
if (m_pWelsTrace != NULL) {
|
||||
m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class MotionEstimateTest : public ::testing::Test {
|
||||
m_iWidth = 64;//size of search window
|
||||
m_iHeight = 64;//size of search window
|
||||
m_iMaxSearchBlock = 16;
|
||||
m_uiMvdTableSize = (1 + (648 << 1));
|
||||
m_uiMvdTableSize = (1 + (648 << 1));
|
||||
|
||||
pMa = new CMemoryAlign (0);
|
||||
m_pRefData = static_cast<uint8_t*>
|
||||
@@ -405,7 +405,7 @@ class FeatureMotionEstimateTest : public ::testing::Test {
|
||||
m_iWidth = 64;//size of search window
|
||||
m_iHeight = 64;//size of search window
|
||||
m_iMaxSearchBlock = 8;
|
||||
m_uiMvdTableSize = (1 + (648 << 1));
|
||||
m_uiMvdTableSize = (1 + (648 << 1));
|
||||
|
||||
m_pMa = new CMemoryAlign (16);
|
||||
ASSERT_TRUE (NULL != m_pMa);
|
||||
|
||||
@@ -16,9 +16,9 @@ class ParameterSetStrategyTest : public ::testing::Test {
|
||||
m_pSubsetArray = NULL;
|
||||
|
||||
pMa = new CMemoryAlign (0);
|
||||
m_pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "m_pSpsArray");
|
||||
m_pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "m_pSpsArray");
|
||||
ASSERT_TRUE (NULL != m_pSpsArray);
|
||||
m_pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SSubsetSps), "m_pSubsetArray");
|
||||
m_pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SSubsetSps), "m_pSubsetArray");
|
||||
ASSERT_TRUE (NULL != m_pSubsetArray);
|
||||
|
||||
m_pSpsArrayPointer = &m_pSpsArray[0];
|
||||
@@ -70,7 +70,7 @@ TEST_F (ParameterSetStrategyTest, FindExistingSps) {
|
||||
int iCurSpsInUse = 1;
|
||||
m_pSpsArrayPointer = &m_pSpsArray[iCurSpsId];
|
||||
|
||||
pDlayerParam = & (sParam1.sSpatialLayers[iDlayerIndex]);
|
||||
pDlayerParam = & (sParam1.sSpatialLayers[iDlayerIndex]);
|
||||
iRet = WelsInitSps (m_pSpsArrayPointer, pDlayerParam, &sParam1.sDependencyLayers[iDlayerIndex], sParam1.uiIntraPeriod,
|
||||
sParam1.iMaxNumRefFrame,
|
||||
iCurSpsId, sParam1.bEnableFrameCroppingFlag, sParam1.iRCMode != RC_OFF_MODE, iDlayerCount, false);
|
||||
@@ -90,7 +90,7 @@ TEST_F (ParameterSetStrategyTest, FindExistingSps) {
|
||||
// add new sps
|
||||
iCurSpsId = 1;
|
||||
m_pSpsArrayPointer = &m_pSpsArray[iCurSpsId];
|
||||
pDlayerParam = & (sParam2.sSpatialLayers[iDlayerIndex]);
|
||||
pDlayerParam = & (sParam2.sSpatialLayers[iDlayerIndex]);
|
||||
iRet = WelsInitSps (m_pSpsArrayPointer, pDlayerParam, &sParam2.sDependencyLayers[iDlayerIndex], sParam2.uiIntraPeriod,
|
||||
sParam2.iMaxNumRefFrame,
|
||||
iCurSpsId, sParam2.bEnableFrameCroppingFlag, sParam2.iRCMode != RC_OFF_MODE, iDlayerCount, false);
|
||||
|
||||
@@ -42,7 +42,7 @@ TEST (IntraSadSatdFuncTest, func) { \
|
||||
const int32_t iLineSizeEnc = 32; \
|
||||
int32_t tmpa, tmpb; \
|
||||
int32_t iBestMode_c, iBestMode_a, iLambda = 50; \
|
||||
int32_t lambda[2] = {iLambda << 2, iLambda}; \
|
||||
int32_t lambda[2] = {iLambda << 2, iLambda}; \
|
||||
int32_t iPredMode = rand() % 3; \
|
||||
if (ASM) {\
|
||||
int32_t iCpuCores = 0; \
|
||||
|
||||
Reference in New Issue
Block a user