History

enable no-delay decoding for MSlice

huili2 committed 12 years ago

Commit 6f0cdd11 parent 7de6eb25 files · +57 −37Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 5 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+45−34
@@ -45,8 +45,7 @@ · 44 unmodified lines
4545
4646 namespace WelsDec {
4747
48−static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen,
49− int32_t* pWidth, int32_t* pHeight, SBufferInfo* pDstInfo) {
48+static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
5049 PDqLayer pCurDq = pCtx->pCurDqLayer;
5150 PPicture pPic = pCtx->pDec;
5251
@@ -56,15 +55,6 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 3 unmodified lines
5655 const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight;
5756 bool bFrameCompleteFlag = true;
5857
59− if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
60− WelsLog (pCtx, WELS_LOG_WARNING,
61− "DecodeFrameConstruction():::iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d \n",
62− pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
63− bFrameCompleteFlag = false; //return later after output buffer is done
64− }
65−
66− pCtx->iTotalNumMbRec = 0;
67−
6858 if (pCtx->bNewSeqBegin) {
6959 memcpy (& (pCtx->sFrameCrop), & (pCurDq->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.pSps->sFrameCrop),
7060 sizeof (SPosOffset)); //confirmed_safe_unsafe_usage
@@ -79,14 +69,21 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 8 unmodified lines
7969 pCtx->sFrameCrop.iBottomOffset);
8070 }
8171
72+ if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
73+ WelsLog (pCtx, WELS_LOG_WARNING,
74+ "DecodeFrameConstruction():::iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d \n",
75+ pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
76+ bFrameCompleteFlag = false; //return later after output buffer is done
77+ if (pCtx->bInstantDecFlag) //no-delay decoding, wait for new slice
78+ return -1;
79+ }
80+
81+ pCtx->iTotalNumMbRec = 0;
82+
8283 //////output:::normal path
8384 ppDst[0] = pPic->pData[0];
8485 ppDst[1] = pPic->pData[1];
8586 ppDst[2] = pPic->pData[2];
86− *pDstLen = pPic->iLinesize[0];
87− * (pDstLen + 1) = pPic->iLinesize[1];
88− *pWidth = kiWidth;
89− *pHeight = kiHeight;
9087
9188 pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420;
9289
@@ -1474,6 +1471,12 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { · 1381 unmodified lines
14741471 }
14751472
14761473 void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {
1474+ //save previous header info
1475+ PAccessUnit pCurAu = pCtx->pAccessUnitList;
1476+ PNalUnit pCurNal = pCurAu->pNalUnitsList[pCurAu->uiEndPos];
1477+ memcpy (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
1478+ memcpy (&pCtx->sLastSliceHeader,
1479+ &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader, sizeof (SSliceHeader));
14771480 // uninitialize context of current access unit and rbsp buffer clean
14781481 ResetCurrentAccessUnit (pCtx);
14791482 }
@@ -1557,9 +1560,6 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 77 unmodified lines
15571560 */
15581561 int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
15591562 int32_t iErr;
1560− int32_t iWidth;
1561− int32_t iHeight;
1562− int32_t iStride[2] = { 0 };
15631563 PAccessUnit pCurAu = pCtx->pAccessUnitList;
15641564
15651565 pCtx->bAuReadyFlag = false;
@@ -1591,11 +1591,14 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 25 unmodified lines
15911591 }
15921592
15931593
1594− iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);
1594+ iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
15951595
15961596 WelsDecodeAccessUnitEnd (pCtx);
1597− //Do error concealment here
1598− ImplementErrorCon (pCtx);
1597+
1598+ if (!pCtx->bInstantDecFlag) {
1599+ //Do error concealment here
1600+ ImplementErrorCon (pCtx);
1601+ }
15991602
16001603 pCtx->bNewSeqBegin = false;
16011604 WriteBackActiveParameters (pCtx);
@@ -1703,8 +1706,7 @@ void ResetParameterSetsState (PWelsDecoderContext pCtx) { · 101 unmodified lines
17031706 * DecodeCurrentAccessUnit
17041707 * Decode current access unit when current AU is completed.
17051708 */
1706−int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen, int32_t* pWidth,
1707− int32_t* pHeight, SBufferInfo* pDstInfo) {
1709+int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
17081710 int32_t iRefCount[LIST_A];
17091711 PNalUnit pNalCur = NULL;
17101712 PAccessUnit pCurAu = pCtx->pAccessUnitList;
@@ -1748,13 +1750,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 37 unmodified lines
17481750 }
17491751 }
17501752
1751− //For fixing the nal lossing issue
1752− if ((pCtx->iTotalNumMbRec != 0) &&
1753− (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pNalCur->sNalHeaderExt, &pCtx->sLastSliceHeader,
1754− &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
1755− pCtx->iTotalNumMbRec = 0;
1756− }
1757−
17581753 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
17591754 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
17601755 memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
@@ -1902,10 +1897,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 141 unmodified lines
19021897 #endif//#if !CODEC_FOR_TESTBED
19031898
19041899 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
1905− if (DecodeFrameConstruction (pCtx, ppDst, pDstLen, pWidth, pHeight, pDstInfo)) {
1906− memcpy (&pCtx->sLastNalHdrExt, &pCurAu->pNalUnitsList[iIdx - 1]->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
1907− memcpy (&pCtx->sLastSliceHeader, &pCurAu->pNalUnitsList[iIdx - 1]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader,
1908− sizeof (SSliceHeader));
1900+ if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
19091901 return ERR_NONE;
19101902 }
19111903
@@ -1934,4 +1926,23 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 22 unmodified lines
19341926 return ERR_NONE;
19351927 }
19361928
1929+bool CheckAndDoEC (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1930+ PAccessUnit pAu = pCtx->pAccessUnitList;
1931+ PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
1932+ if ((pCtx->iTotalNumMbRec != 0)
1933+ && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
1934+ &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
1935+ pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
1936+ DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
1937+ PPicture pCurPic = pCtx->pDec; //temporally store current picture
1938+ //Do Error Concealment here
1939+ ImplementErrorCon (pCtx);
1940+ pCtx->pPreviousDecodedPictureInDpb = pCurPic; //save ECed pic for future use
1941+ pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
1942+ if (pCtx->bLastHasMmco5)
1943+ pCtx->iPrevFrameNum = 0;
1944+ }
1945+ return ERR_NONE;
1946+}
1947+
19371948 } // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t