ref: 76ef30dc82a84ac8e9ba64fac429706ef0f49852
parent: a5cb0ea22c6e3a386b19463a0973ebc3afa570bf
author: Sijia Chen <sijchen@cisco.com>
date: Fri Jan 9 10:55:03 EST 2015
refactor
--- a/codec/encoder/core/inc/wels_preprocess.h
+++ b/codec/encoder/core/inc/wels_preprocess.h
@@ -145,6 +145,7 @@
int32_t WelsPreprocessCreate();
int32_t WelsPreprocessDestroy();
int32_t InitLastSpatialPictures (sWelsEncCtx* pEncCtx);
+ int32_t GetCurPicPosition(const int32_t kiDidx);
private:
int32_t SingleLayerPreprocess (sWelsEncCtx* pEncCtx, const SSourcePicture* kpSrc, Scaled_Picture* m_sScaledPicture);
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -255,26 +255,28 @@
return 0;
}
+int32_t CWelsPreProcess::GetCurPicPosition(const int32_t kiDidx) {
+ return (m_uiSpatialLayersInTemporal[kiDidx] - 1);
+}
+
int32_t CWelsPreProcess::UpdateSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam,
const int8_t iCurTid, const int32_t kiDidx) {
if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME)
return 0;
- if (iCurTid < m_uiSpatialLayersInTemporal[kiDidx] - 1 || pParam->iDecompStages == 0) {
- if ((iCurTid >= MAX_TEMPORAL_LEVEL) || (m_uiSpatialLayersInTemporal[kiDidx] - 1 > MAX_TEMPORAL_LEVEL)) {
+ const int32_t kiCurPos = GetCurPicPosition(kiDidx);
+ if (iCurTid < kiCurPos || pParam->iDecompStages == 0) {
+ if ((iCurTid >= MAX_TEMPORAL_LEVEL) || (kiCurPos > MAX_TEMPORAL_LEVEL)) {
InitLastSpatialPictures (pCtx);
return 1;
}
if (pParam->bEnableLongTermReference && pCtx->bLongTermRefFlag[kiDidx][iCurTid]) {
- SPicture* tmp = m_pSpatialPic[kiDidx][m_uiSpatialLayersInTemporal[kiDidx] + pCtx->pVaa->uiMarkLongTermPicIdx];
- m_pSpatialPic[kiDidx][m_uiSpatialLayersInTemporal[kiDidx] + pCtx->pVaa->uiMarkLongTermPicIdx] =
- m_pSpatialPic[kiDidx][iCurTid];
- m_pSpatialPic[kiDidx][iCurTid] = m_pSpatialPic[kiDidx][m_uiSpatialLayersInTemporal[kiDidx] - 1];
- m_pSpatialPic[kiDidx][m_uiSpatialLayersInTemporal[kiDidx] - 1] = tmp;
- pCtx->bLongTermRefFlag[kiDidx][iCurTid] = false;
- } else {
- WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][m_uiSpatialLayersInTemporal[kiDidx] - 1],
+ const int32_t kiAvailableLtrPos = m_uiSpatialLayersInTemporal[kiDidx] + pCtx->pVaa->uiMarkLongTermPicIdx;
+ WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][kiAvailableLtrPos],
&m_pSpatialPic[kiDidx][iCurTid]);
+ pCtx->bLongTermRefFlag[kiDidx][iCurTid] = false;
}
+ WelsExchangeSpatialPictures (&m_pSpatialPic[kiDidx][kiCurPos],
+ &m_pSpatialPic[kiDidx][iCurTid]);
}
return 0;
}