History

add EC frame/slice copy.

huili2 committed 12 years ago

Commit bc2c4b01 parent b2f71919 files · +156 −21Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+40−10
@@ -54,12 +54,21 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 53 unmodified lines
5454 const int32_t kiHeight = pCurDq->iMbHeight << 4;
5555
5656 const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight;
57+ bool bFrameCompleteFlag = true;
5758
5859 if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
60+ if ((pCtx->iTotalNumMbRec != 0) && (I_SLICE == pCurDq->sLayerInfo.sSliceInLayer.eSliceType)) { //TODO should be IDR instead of I_SLICE!
61+ memcpy (& (pCtx->sFrameCrop), & (pCurDq->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.pSps->sFrameCrop), sizeof (SPosOffset));
62+#ifdef LONG_TERM_REF
63+ pCtx->bParamSetsLostFlag = false;
64+#else
65+ pCtx->bReferenceLostAtT0Flag = false;
66+#endif //LONG_TERM_REF
67+ }
5968 WelsLog (pCtx, WELS_LOG_WARNING,
6069 "DecodeFrameConstruction():::iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d \n",
6170 pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
62− return -1;
71+ bFrameCompleteFlag = false; //return later after output buffer is done
6372 }
6473 #ifdef NO_WAITING_AU
6574 pCtx->iTotalNumMbRec = 0;
@@ -99,6 +108,14 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 33 unmodified lines
99108 ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
100109 pDstInfo->iBufferStatus = 1;
101110
111+ if (pCtx->iErrorConMethod == ERROR_CON_DISABLE) //no buffer output if EC is disabled and frame incomplete
112+ pDstInfo->iBufferStatus = (int32_t) bFrameCompleteFlag;
113+
114+ if (!bFrameCompleteFlag) {
115+ pCtx->iErrorCode |= dsBitstreamError;
116+ return -1;
117+ }
118+
102119 return 0;
103120 }
104121
@@ -955,6 +972,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 850 unmodified lines
955972 pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
956973 int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]");
957974
975+ pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
976+
958977 // check memory block valid due above allocated..
959978 WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY,
960979 ((NULL == pCtx->sMb.pMbType[i]) ||
@@ -972,7 +991,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 11 unmodified lines
972991 (NULL == pCtx->sMb.pSubMbType[i]) ||
973992 (NULL == pCtx->sMb.pSliceIdc[i]) ||
974993 (NULL == pCtx->sMb.pResidualPredFlag[i]) ||
975− (NULL == pCtx->sMb.pInterPredictionDoneFlag[i])
994+ (NULL == pCtx->sMb.pInterPredictionDoneFlag[i]) ||
995+ (NULL == pCtx->sMb.pMbCorrectlyDecodedFlag[i])
976996 )
977997 )
978998
@@ -1100,6 +1120,12 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 121 unmodified lines
11001120
11011121 pCtx->sMb.pInterPredictionDoneFlag[i] = NULL;
11021122 }
1123+
1124+ if (pCtx->sMb.pMbCorrectlyDecodedFlag[i]) {
1125+ WelsFree (pCtx->sMb.pMbCorrectlyDecodedFlag[i], "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
1126+ pCtx->sMb.pMbCorrectlyDecodedFlag[i] = NULL;
1127+ }
1128+
11031129 WelsFree (pDq, "pDq");
11041130
11051131 pDq = NULL;
@@ -1560,8 +1586,6 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 454 unmodified lines
15601586 pCtx->bNewSeqBegin = false;
15611587 if (ERR_NONE != iErr) {
15621588 WelsLog (pCtx, WELS_LOG_INFO, "returned error from decoding:[0x%x]\n", iErr);
1563−
1564− pDstInfo->iBufferStatus = 0;
15651589 return iErr;
15661590 }
15671591
@@ -1651,6 +1675,7 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { · 83 unmodified lines
16511675 pCurDq->pSubMbType = pCtx->sMb.pSubMbType[0];
16521676 pCurDq->pInterPredictionDoneFlag = pCtx->sMb.pInterPredictionDoneFlag[0];
16531677 pCurDq->pResidualPredFlag = pCtx->sMb.pResidualPredFlag[0];
1678+ pCurDq->pMbCorrectlyDecodedFlag = pCtx->sMb.pMbCorrectlyDecodedFlag[0];
16541679 }
16551680 }
16561681
@@ -1725,6 +1750,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 68 unmodified lines
17251750 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
17261751 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
17271752 memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t)));
1753+ memset (pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag, 0, pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight);
17281754 }
17291755 GetI4LumaIChromaAddrTable (pCtx->iDecBlockOffsetArray, pCtx->pDec->iLinesize[0], pCtx->pDec->iLinesize[1]);
17301756
@@ -1796,15 +1822,16 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 65 unmodified lines
17961822 "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d\n", pCtx->iPrevFrameNum,
17971823 pSh->iFrameNum);
17981824
1825+ pCtx->iErrorCode |= dsRefLost;
1826+ if (pCtx->iErrorConMethod == ERROR_CON_DISABLE) {
17991827 #ifdef LONG_TERM_REF
1800− pCtx->bParamSetsLostFlag = true;
1828+ pCtx->bParamSetsLostFlag = true;
18011829 #else
1802− pCtx->bReferenceLostAtT0Flag = true;
1830+ pCtx->bReferenceLostAtT0Flag = true;
18031831 #endif
1804− ResetParameterSetsState (pCtx);
1805−
1806− pCtx->iErrorCode |= dsRefLost;
1807− return ERR_INFO_REFERENCE_PIC_LOST;
1832+ ResetParameterSetsState (pCtx);
1833+ return ERR_INFO_REFERENCE_PIC_LOST;
1834+ }
18081835 }
18091836 }
18101837
@@ -1875,6 +1902,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 64 unmodified lines
18751902 #endif
18761903
18771904 }
1905+
1906+ pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
1907+
18781908 if (uiNalRefIdc > 0) {
18791909 iRet = WelsMarkAsRef (pCtx);
18801910 if (iRet != ERR_NONE) {

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