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
45 45
46namespace WelsDec {46namespace WelsDec {
47 47
48static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen,48static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
49 int32_t* pWidth, int32_t* pHeight, SBufferInfo* pDstInfo) {
50 PDqLayer pCurDq = pCtx->pCurDqLayer;49 PDqLayer pCurDq = pCtx->pCurDqLayer;
51 PPicture pPic = pCtx->pDec;50 PPicture pPic = pCtx->pDec;
52 51
@@ -56,15 +55,6 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 3 unmodified lines
56 const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight;55 const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight;
57 bool bFrameCompleteFlag = true;56 bool bFrameCompleteFlag = true;
58 57
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
68 if (pCtx->bNewSeqBegin) {58 if (pCtx->bNewSeqBegin) {
69 memcpy (& (pCtx->sFrameCrop), & (pCurDq->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.pSps->sFrameCrop),59 memcpy (& (pCtx->sFrameCrop), & (pCurDq->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.pSps->sFrameCrop),
70 sizeof (SPosOffset)); //confirmed_safe_unsafe_usage60 sizeof (SPosOffset)); //confirmed_safe_unsafe_usage
@@ -79,14 +69,21 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 8 unmodified lines
79 pCtx->sFrameCrop.iBottomOffset);69 pCtx->sFrameCrop.iBottomOffset);
80 }70 }
81 71
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
82 //////output:::normal path83 //////output:::normal path
83 ppDst[0] = pPic->pData[0];84 ppDst[0] = pPic->pData[0];
84 ppDst[1] = pPic->pData[1];85 ppDst[1] = pPic->pData[1];
85 ppDst[2] = pPic->pData[2];86 ppDst[2] = pPic->pData[2];
86 *pDstLen = pPic->iLinesize[0];
87 * (pDstLen + 1) = pPic->iLinesize[1];
88 *pWidth = kiWidth;
89 *pHeight = kiHeight;
90 87
91 pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420;88 pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420;
92 89
@@ -1520,6 +1517,12 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { · 1427 unmodified lines
1520}1517}
1521 1518
1522void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {1519void 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));
1523 // uninitialize context of current access unit and rbsp buffer clean1526 // uninitialize context of current access unit and rbsp buffer clean
1524 ResetCurrentAccessUnit (pCtx);1527 ResetCurrentAccessUnit (pCtx);
1525}1528}
@@ -1603,9 +1606,6 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 77 unmodified lines
1603 */1606 */
1604int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {1607int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1605 int32_t iErr;1608 int32_t iErr;
1606 int32_t iWidth;
1607 int32_t iHeight;
1608 int32_t iStride[2] = { 0 };
1609 PAccessUnit pCurAu = pCtx->pAccessUnitList;1609 PAccessUnit pCurAu = pCtx->pAccessUnitList;
1610 1610
1611 pCtx->bAuReadyFlag = false;1611 pCtx->bAuReadyFlag = false;
@@ -1637,11 +1637,14 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 25 unmodified lines
1637 }1637 }
1638 1638
1639 1639
1640 iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);1640 iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
1641 1641
1642 WelsDecodeAccessUnitEnd (pCtx);1642 WelsDecodeAccessUnitEnd (pCtx);
1643 //Do error concealment here1643
1644 ImplementErrorCon (pCtx);1644 if (!pCtx->bInstantDecFlag) {
1645 //Do error concealment here
1646 ImplementErrorCon (pCtx);
1647 }
1645 1648
1646 pCtx->bNewSeqBegin = false;1649 pCtx->bNewSeqBegin = false;
1647 WriteBackActiveParameters (pCtx);1650 WriteBackActiveParameters (pCtx);
@@ -1749,8 +1752,7 @@ void ResetParameterSetsState (PWelsDecoderContext pCtx) { · 101 unmodified lines
1749 * DecodeCurrentAccessUnit1752 * DecodeCurrentAccessUnit
1750 * Decode current access unit when current AU is completed.1753 * Decode current access unit when current AU is completed.
1751 */1754 */
1752int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen, int32_t* pWidth,1755int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1753 int32_t* pHeight, SBufferInfo* pDstInfo) {
1754 int32_t iRefCount[LIST_A];1756 int32_t iRefCount[LIST_A];
1755 PNalUnit pNalCur = NULL;1757 PNalUnit pNalCur = NULL;
1756 PAccessUnit pCurAu = pCtx->pAccessUnitList;1758 PAccessUnit pCurAu = pCtx->pAccessUnitList;
@@ -1794,13 +1796,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 37 unmodified lines
1794 }1796 }
1795 }1797 }
1796 1798
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
1804 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode1799 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
1805 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)1800 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
1806 memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));1801 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
1948#endif//#if !CODEC_FOR_TESTBED1943#endif//#if !CODEC_FOR_TESTBED
1949 1944
1950 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {1945 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
1951 if (DecodeFrameConstruction (pCtx, ppDst, pDstLen, pWidth, pHeight, pDstInfo)) {1946 if (DecodeFrameConstruction (pCtx, ppDst, 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));
1955 return ERR_NONE;1947 return ERR_NONE;
1956 }1948 }
1957 1949
@@ -1981,4 +1973,23 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 23 unmodified lines
1981 return ERR_NONE;1973 return ERR_NONE;
1982}1974}
1983 1975
1976bool 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
1984} // namespace WelsDec1995} // 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