History

parse only add and UT

huili2 committed 11 years ago

Commit b231e3f1 parent 53c14dc13 files · +607 −60Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+100−32
@@ -88,21 +88,23 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 87 unmodified lines
8888
8989 pCtx->iTotalNumMbRec = 0;
9090
91− //////output:::normal path
92− ppDst[0] = pPic->pData[0];
93− ppDst[1] = pPic->pData[1];
94− ppDst[2] = pPic->pData[2];
95−
96− pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420;
97−
98− pDstInfo->UsrData.sSystemBuffer.iWidth = kiWidth - (pCtx->sFrameCrop.iLeftOffset + pCtx->sFrameCrop.iRightOffset) * 2;
99− pDstInfo->UsrData.sSystemBuffer.iHeight = kiHeight - (pCtx->sFrameCrop.iTopOffset + pCtx->sFrameCrop.iBottomOffset) * 2;
100− pDstInfo->UsrData.sSystemBuffer.iStride[0] = pPic->iLinesize[0];
101− pDstInfo->UsrData.sSystemBuffer.iStride[1] = pPic->iLinesize[1];
102− ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2;
103− ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
104− ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
105− pDstInfo->iBufferStatus = 1;
91+ if (!pCtx->bParseOnly) {
92+ //////output:::normal path
93+ ppDst[0] = pPic->pData[0];
94+ ppDst[1] = pPic->pData[1];
95+ ppDst[2] = pPic->pData[2];
96+
97+ pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420;
98+
99+ pDstInfo->UsrData.sSystemBuffer.iWidth = kiWidth - (pCtx->sFrameCrop.iLeftOffset + pCtx->sFrameCrop.iRightOffset) * 2;
100+ pDstInfo->UsrData.sSystemBuffer.iHeight = kiHeight - (pCtx->sFrameCrop.iTopOffset + pCtx->sFrameCrop.iBottomOffset) * 2;
101+ pDstInfo->UsrData.sSystemBuffer.iStride[0] = pPic->iLinesize[0];
102+ pDstInfo->UsrData.sSystemBuffer.iStride[1] = pPic->iLinesize[1];
103+ ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2;
104+ ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
105+ ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset;
106+ pDstInfo->iBufferStatus = 1;
107+ }
106108
107109 bool bOutResChange = (pCtx->iLastImgWidthInPixel != pDstInfo->UsrData.sSystemBuffer.iWidth)
108110 || (pCtx->iLastImgHeightInPixel != pDstInfo->UsrData.sSystemBuffer.iHeight);
@@ -114,7 +116,6 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 5 unmodified lines
114116 else if (pCtx->eErrorConMethod == ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE && pCtx->iErrorCode && bOutResChange)
115117 pCtx->bFreezeOutput = true;
116118
117−
118119 if ((pDstInfo->iBufferStatus == 1) && (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag)) {
119120 if (pPic->bIsComplete)
120121 pCtx->sDecoderStatistics.uiIDRRecvNum++;
@@ -331,6 +332,14 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 210 unmodified lines
331332 }
332333 pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead;
333334 pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte;
335+ if (pCtx->bParseOnly) {
336+ if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte,
337+ "pCtx->sSavedData.pHead"))) == NULL) {
338+ return ERR_INFO_OUT_OF_MEMORY;
339+ }
340+ pCtx->sSavedData.pStartPos = pCtx->sSavedData.pCurPos = pCtx->sSavedData.pHead;
341+ pCtx->sSavedData.pEnd = pCtx->sSavedData.pHead + pCtx->iMaxBsBufferSizeInByte;
342+ }
334343 return ERR_NONE;
335344 }
336345
@@ -434,6 +443,13 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 97 unmodified lines
434443 pCtx->sRawData.pEnd = NULL;
435444 pCtx->sRawData.pStartPos = NULL;
436445 pCtx->sRawData.pCurPos = NULL;
446+ if (pCtx->sSavedData.pHead) {
447+ WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
448+ }
449+ pCtx->sSavedData.pHead = NULL;
450+ pCtx->sSavedData.pEnd = NULL;
451+ pCtx->sSavedData.pStartPos = NULL;
452+ pCtx->sSavedData.pCurPos = NULL;
437453 }
438454
439455 /*
@@ -1692,7 +1708,8 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 1252 unmodified lines
16921708
16931709 if (ERR_NONE != iErr) {
16941710 ForceResetCurrentAccessUnit (pCtx->pAccessUnitList);
1695− pDstInfo->iBufferStatus = 0;
1711+ if (!pCtx->bParseOnly)
1712+ pDstInfo->iBufferStatus = 0;
16961713 return iErr;
16971714 }
16981715
@@ -1713,6 +1730,53 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 14 unmodified lines
17131730
17141731 iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
17151732
1733+ if (pCtx->bParseOnly) {
1734+ if (dsErrorFree == pCtx->iErrorCode) {
1735+ SParserBsInfo* pParser = pCtx->pParserBsInfo;
1736+ uint8_t* pDstBuf = pParser->pDstBuff;
1737+ SNalUnit* pCurNal = NULL;
1738+ int32_t iNalLen = 0;
1739+ int32_t iIdx = pCurAu->uiStartPos;
1740+ int32_t iEndIdx = pCurAu->uiEndPos;
1741+ uint8_t* pNalBs = NULL;
1742+
1743+ pParser->iNalNum = 0;
1744+ pParser->iSpsWidthInPixel = (pCtx->pSps->iMbWidth << 4);
1745+ pParser->iSpsHeightInPixel = (pCtx->pSps->iMbHeight << 4);
1746+
1747+ if (pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.bIdrFlag) { //IDR
1748+ bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType);
1749+ SSpsBsInfo* pSpsBs = NULL;
1750+ SPpsBsInfo* pPpsBs = NULL;
1751+ int32_t iSpsId = pCtx->pSps->iSpsId;
1752+ int32_t iPpsId = pCtx->pPps->iPpsId;
1753+ pCtx->bParamSetsLostFlag = false;
1754+ //find required sps, pps and write into dst buff
1755+ pSpsBs = bSubSps ? &pCtx->sSubsetSpsBsInfo [iSpsId] : &pCtx->sSpsBsInfo [iSpsId];
1756+ memcpy (pDstBuf, pSpsBs->pSpsBsBuf, pSpsBs->uiSpsBsLen);
1757+ pParser->iNalLenInByte [pParser->iNalNum ++] = pSpsBs->uiSpsBsLen;
1758+ pDstBuf += pSpsBs->uiSpsBsLen;
1759+ pPpsBs = &pCtx->sPpsBsInfo [iPpsId];
1760+ memcpy (pDstBuf, pPpsBs->pPpsBsBuf, pPpsBs->uiPpsBsLen);
1761+ pParser->iNalLenInByte [pParser->iNalNum ++] = pPpsBs->uiPpsBsLen;
1762+ pDstBuf += pPpsBs->uiPpsBsLen;
1763+ } //IDR required SPS, PPS
1764+ //then VCL data re-write
1765+ while (iIdx <= iEndIdx) {
1766+ pCurNal = pCurAu->pNalUnitsList [iIdx ++];
1767+ iNalLen = pCurNal->sNalData.sVclNal.iNalLength;
1768+ pNalBs = pCurNal->sNalData.sVclNal.pNalPos;
1769+ pParser->iNalLenInByte [pParser->iNalNum ++] = iNalLen;
1770+ memcpy (pDstBuf, pNalBs, iNalLen);
1771+ pDstBuf += iNalLen;
1772+ }
1773+ } else { //error
1774+ pCtx->pParserBsInfo->iNalNum = 0;
1775+ pCtx->pParserBsInfo->iSpsWidthInPixel = 0;
1776+ pCtx->pParserBsInfo->iSpsHeightInPixel = 0;
1777+ }
1778+ }
1779+
17161780 WelsDecodeAccessUnitEnd (pCtx);
17171781
17181782 pCtx->bNewSeqBegin = false;
@@ -1985,10 +2049,13 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 266 unmodified lines
19852049 return iRet;
19862050 }
19872051 }
1988− if (bReconstructSlice) {
1989− if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
1990− pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
1991− return -1;
2052+
2053+ if (!pCtx->bParseOnly) {
2054+ if (bReconstructSlice) {
2055+ if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
2056+ pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
2057+ return -1;
2058+ }
19922059 }
19932060 }
19942061 if (bAllRefComplete && (pCtx->sRefPic.uiRefCount[LIST_0] > 0 || pCtx->eSliceType != I_SLICE)) {
@@ -2031,20 +2098,21 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 36 unmodified lines
20312098 #endif//#if !CODEC_FOR_TESTBED
20322099
20332100 if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) {
2034− if (!pCtx->bInstantDecFlag) {
2035− //Do error concealment here
2036− if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) {
2037− ImplementErrorCon (pCtx);
2038− pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
2039− pCtx->pDec->iSpsId = pCtx->pSps->iSpsId;
2040− pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
2101+ if (!pCtx->bParseOnly) {
2102+ if (!pCtx->bInstantDecFlag) {
2103+ //Do error concealment here
2104+ if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) {
2105+ ImplementErrorCon (pCtx);
2106+ pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
2107+ pCtx->pDec->iSpsId = pCtx->pSps->iSpsId;
2108+ pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
2109+ }
20412110 }
2042− }
20432111
2044− if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
2045− return ERR_NONE;
2112+ if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
2113+ return ERR_NONE;
2114+ }
20462115 }
2047−
20482116 if (uiNalRefIdc > 0) {
20492117 pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
20502118 iRet = WelsMarkAsRef (pCtx);

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