History

Merge pull request #954 from huili2/instant_dec

enable no-delay decoding for MSlice

dongzha committed 12 years ago

Commit 53f77ee2 parents 0c09847 6f0cdd15 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
@@ -1520,6 +1517,12 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { · 1427 unmodified lines
15201517 }
15211518
15221519 void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {
1520+ //save previous header info
1521+ PAccessUnit pCurAu = pCtx->pAccessUnitList;
1522+ PNalUnit pCurNal = pCurAu->pNalUnitsList[pCurAu->uiEndPos];
1523+ memcpy (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
1524+ memcpy (&pCtx->sLastSliceHeader,
1525+ &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader, sizeof (SSliceHeader));
15231526 // uninitialize context of current access unit and rbsp buffer clean
15241527 ResetCurrentAccessUnit (pCtx);
15251528 }
@@ -1603,9 +1606,6 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 77 unmodified lines
16031606 */
16041607 int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
16051608 int32_t iErr;
1606− int32_t iWidth;
1607− int32_t iHeight;
1608− int32_t iStride[2] = { 0 };
16091609 PAccessUnit pCurAu = pCtx->pAccessUnitList;
16101610
16111611 pCtx->bAuReadyFlag = false;
@@ -1637,11 +1637,14 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 25 unmodified lines
16371637 }
16381638
16391639
1640− iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);
1640+ iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
16411641
16421642 WelsDecodeAccessUnitEnd (pCtx);
1643− //Do error concealment here
1644− ImplementErrorCon (pCtx);
1643+
1644+ if (!pCtx->bInstantDecFlag) {
1645+ //Do error concealment here
1646+ ImplementErrorCon (pCtx);
1647+ }
16451648
16461649 pCtx->bNewSeqBegin = false;
16471650 WriteBackActiveParameters (pCtx);
@@ -1749,8 +1752,7 @@ void ResetParameterSetsState (PWelsDecoderContext pCtx) { · 101 unmodified lines
17491752 * DecodeCurrentAccessUnit
17501753 * Decode current access unit when current AU is completed.
17511754 */
1752−int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen, int32_t* pWidth,
1753− int32_t* pHeight, SBufferInfo* pDstInfo) {
1755+int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
17541756 int32_t iRefCount[LIST_A];
17551757 PNalUnit pNalCur = NULL;
17561758 PAccessUnit pCurAu = pCtx->pAccessUnitList;
@@ -1794,13 +1796,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 37 unmodified lines
17941796 }
17951797 }
17961798
1797− //For fixing the nal lossing issue
1798− if ((pCtx->iTotalNumMbRec != 0) &&
1799− (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pNalCur->sNalHeaderExt, &pCtx->sLastSliceHeader,
1800− &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
1801− pCtx->iTotalNumMbRec = 0;
1802− }
1803−
18041799 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
18051800 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
18061801 memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
@@ -1948,10 +1943,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 141 unmodified lines
19481943 #endif//#if !CODEC_FOR_TESTBED
19491944
19501945 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
1951− if (DecodeFrameConstruction (pCtx, ppDst, pDstLen, pWidth, pHeight, pDstInfo)) {
1952− memcpy (&pCtx->sLastNalHdrExt, &pCurAu->pNalUnitsList[iIdx - 1]->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
1953− memcpy (&pCtx->sLastSliceHeader, &pCurAu->pNalUnitsList[iIdx - 1]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader,
1954− sizeof (SSliceHeader));
1946+ if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
19551947 return ERR_NONE;
19561948 }
19571949
@@ -1981,4 +1973,23 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 23 unmodified lines
19811973 return ERR_NONE;
19821974 }
19831975
1976+bool CheckAndDoEC (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1977+ PAccessUnit pAu = pCtx->pAccessUnitList;
1978+ PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
1979+ if ((pCtx->iTotalNumMbRec != 0)
1980+ && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
1981+ &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
1982+ pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
1983+ DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
1984+ PPicture pCurPic = pCtx->pDec; //temporally store current picture
1985+ //Do Error Concealment here
1986+ ImplementErrorCon (pCtx);
1987+ pCtx->pPreviousDecodedPictureInDpb = pCurPic; //save ECed pic for future use
1988+ pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
1989+ if (pCtx->bLastHasMmco5)
1990+ pCtx->iPrevFrameNum = 0;
1991+ }
1992+ return ERR_NONE;
1993+}
1994+
19841995 } // 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