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
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
@@ -1474,6 +1471,12 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { · 1381 unmodified lines
1474}1471}
1475 1472
1476void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {1473void 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));
1477 // uninitialize context of current access unit and rbsp buffer clean1480 // uninitialize context of current access unit and rbsp buffer clean
1478 ResetCurrentAccessUnit (pCtx);1481 ResetCurrentAccessUnit (pCtx);
1479}1482}
@@ -1557,9 +1560,6 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 77 unmodified lines
1557 */1560 */
1558int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {1561int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1559 int32_t iErr;1562 int32_t iErr;
1560 int32_t iWidth;
1561 int32_t iHeight;
1562 int32_t iStride[2] = { 0 };
1563 PAccessUnit pCurAu = pCtx->pAccessUnitList;1563 PAccessUnit pCurAu = pCtx->pAccessUnitList;
1564 1564
1565 pCtx->bAuReadyFlag = false;1565 pCtx->bAuReadyFlag = false;
@@ -1591,11 +1591,14 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 25 unmodified lines
1591 }1591 }
1592 1592
1593 1593
1594 iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);1594 iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
1595 1595
1596 WelsDecodeAccessUnitEnd (pCtx);1596 WelsDecodeAccessUnitEnd (pCtx);
1597 //Do error concealment here1597
1598 ImplementErrorCon (pCtx);1598 if (!pCtx->bInstantDecFlag) {
1599 //Do error concealment here
1600 ImplementErrorCon (pCtx);
1601 }
1599 1602
1600 pCtx->bNewSeqBegin = false;1603 pCtx->bNewSeqBegin = false;
1601 WriteBackActiveParameters (pCtx);1604 WriteBackActiveParameters (pCtx);
@@ -1703,8 +1706,7 @@ void ResetParameterSetsState (PWelsDecoderContext pCtx) { · 101 unmodified lines
1703 * DecodeCurrentAccessUnit1706 * DecodeCurrentAccessUnit
1704 * Decode current access unit when current AU is completed.1707 * Decode current access unit when current AU is completed.
1705 */1708 */
1706int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int32_t* pDstLen, int32_t* pWidth,1709int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
1707 int32_t* pHeight, SBufferInfo* pDstInfo) {
1708 int32_t iRefCount[LIST_A];1710 int32_t iRefCount[LIST_A];
1709 PNalUnit pNalCur = NULL;1711 PNalUnit pNalCur = NULL;
1710 PAccessUnit pCurAu = pCtx->pAccessUnitList;1712 PAccessUnit pCurAu = pCtx->pAccessUnitList;
@@ -1748,13 +1750,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 37 unmodified lines
1748 }1750 }
1749 }1751 }
1750 1752
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
1758 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode1753 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
1759 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)1754 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
1760 memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));1755 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
1902#endif//#if !CODEC_FOR_TESTBED1897#endif//#if !CODEC_FOR_TESTBED
1903 1898
1904 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {1899 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
1905 if (DecodeFrameConstruction (pCtx, ppDst, pDstLen, pWidth, pHeight, pDstInfo)) {1900 if (DecodeFrameConstruction (pCtx, ppDst, 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));
1909 return ERR_NONE;1901 return ERR_NONE;
1910 }1902 }
1911 1903
@@ -1934,4 +1926,23 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 22 unmodified lines
1934 return ERR_NONE;1926 return ERR_NONE;
1935}1927}
1936 1928
1929bool 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
1937} // namespace WelsDec1948} // 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