Merge pull request #2418 from ruil2/refine_init
fix preprocessing initialization logic
This commit is contained in:
commit
8103988cde
@ -121,7 +121,7 @@ class CWelsPreProcess {
|
|||||||
virtual ~CWelsPreProcess();
|
virtual ~CWelsPreProcess();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int32_t WelsPreprocessReset (sWelsEncCtx* pEncCtx);
|
int32_t WelsPreprocessReset (sWelsEncCtx* pEncCtx,int32_t iWidth,int32_t iHeight);
|
||||||
int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam);
|
int32_t AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam);
|
||||||
void FreeSpatialPictures (sWelsEncCtx* pCtx);
|
void FreeSpatialPictures (sWelsEncCtx* pCtx);
|
||||||
int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrcPic);
|
int32_t BuildSpatialPicList (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrcPic);
|
||||||
|
@ -4627,9 +4627,6 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
|
|||||||
/* Update new parameters */
|
/* Update new parameters */
|
||||||
if (WelsInitEncoderExt (ppCtx, pNewParam, &sLogCtx, pExistingParasetList))
|
if (WelsInitEncoderExt (ppCtx, pNewParam, &sLogCtx, pExistingParasetList))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// reset the scaled spatial picture size
|
|
||||||
(*ppCtx)->pVpp->WelsPreprocessReset (*ppCtx);
|
|
||||||
//if WelsInitEncoderExt succeed
|
//if WelsInitEncoderExt succeed
|
||||||
//for LTR
|
//for LTR
|
||||||
(*ppCtx)->uiIdrPicId = uiTmpIdrPicId ;//this is for LTR!; //this is for LTR!
|
(*ppCtx)->uiIdrPicId = uiTmpIdrPicId ;//this is for LTR!; //this is for LTR!
|
||||||
|
@ -109,9 +109,18 @@ int32_t CWelsPreProcess::WelsPreprocessDestroy() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx) {
|
int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx,int32_t iWidth,int32_t iHeight) {
|
||||||
int32_t iRet = -1;
|
int32_t iRet = -1;
|
||||||
|
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||||
|
//init source width and height
|
||||||
|
pSvcParam->SUsedPicRect.iLeft = 0;
|
||||||
|
pSvcParam->SUsedPicRect.iTop = 0;
|
||||||
|
pSvcParam->SUsedPicRect.iWidth = iWidth;
|
||||||
|
pSvcParam->SUsedPicRect.iHeight = iHeight;
|
||||||
|
if ((iWidth < 16) || ((iHeight < 16))) {
|
||||||
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "Don't support width(%d) or height(%d) which is less than 16 ",iWidth, iHeight);
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
if (pCtx) {
|
if (pCtx) {
|
||||||
FreeScaledPic (&m_sScaledPicture, pCtx->pMemAlign);
|
FreeScaledPic (&m_sScaledPicture, pCtx->pMemAlign);
|
||||||
iRet = InitLastSpatialPictures (pCtx);
|
iRet = InitLastSpatialPictures (pCtx);
|
||||||
@ -175,27 +184,24 @@ void CWelsPreProcess::FreeSpatialPictures (sWelsEncCtx* pCtx) {
|
|||||||
int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture* kpSrcPic) {
|
int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture* kpSrcPic) {
|
||||||
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
|
||||||
int32_t iSpatialNum = 0;
|
int32_t iSpatialNum = 0;
|
||||||
|
int32_t iWidth = ((kpSrcPic->iPicWidth >> 1) << 1);
|
||||||
|
int32_t iHeight = ((kpSrcPic->iPicHeight >> 1) << 1);
|
||||||
|
|
||||||
if (!m_bInitDone) {
|
if (!m_bInitDone) {
|
||||||
if (WelsPreprocessCreate() != 0)
|
if (WelsPreprocessCreate() != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//init source width and height
|
if (WelsPreprocessReset (pCtx,iWidth,iHeight) != 0)
|
||||||
pSvcParam->SUsedPicRect.iLeft = 0;
|
|
||||||
pSvcParam->SUsedPicRect.iTop = 0;
|
|
||||||
pSvcParam->SUsedPicRect.iWidth = ((kpSrcPic->iPicWidth >> 1) << 1);
|
|
||||||
pSvcParam->SUsedPicRect.iHeight = ((kpSrcPic->iPicHeight >> 1) << 1);
|
|
||||||
if ((pSvcParam->SUsedPicRect.iWidth < 16) || ((pSvcParam->SUsedPicRect.iHeight < 16))) {
|
|
||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "Don't support width(%d) or height(%d) which is less than 16 ",
|
|
||||||
pSvcParam->SUsedPicRect.iWidth, pSvcParam->SUsedPicRect.iHeight);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (WelsPreprocessReset (pCtx) != 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
m_iAvaliableRefInSpatialPicList = pSvcParam->iNumRefFrame;
|
m_iAvaliableRefInSpatialPicList = pSvcParam->iNumRefFrame;
|
||||||
|
|
||||||
m_bInitDone = true;
|
m_bInitDone = true;
|
||||||
|
} else {
|
||||||
|
if ((iWidth != pSvcParam->SUsedPicRect.iWidth) || (iHeight != pSvcParam->SUsedPicRect.iHeight)) {
|
||||||
|
if (WelsPreprocessReset (pCtx,iWidth,iHeight) != 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pInterfaceVp == NULL)
|
if (m_pInterfaceVp == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user