ref: c72d3ad51a7a74745247122c4db7a1c65b385465
parent: 3244f11cfea73fae818df915e5418f56f9a5cd7c
parent: b719c3b0d5872fbfbcd962c299fd51f9164671a3
author: ruil2 <[email protected]>
date: Mon Jan 5 12:06:56 EST 2015
Merge pull request #1697 from huili2/parseonly_frame_complete_return output error when frame incomplete for parse only usage
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -90,12 +90,14 @@
break;
}
- if (WelsTargetMbConstruction (pCtx)) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
- "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
- pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
+ if (!pCtx->bParseOnly) { //for parse only, actual recon MB unnecessary
+ if (WelsTargetMbConstruction (pCtx)) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
+ "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
+ pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
- return -1;
+ return -1;
+ }
}
++iCountNumMb;
@@ -130,6 +132,9 @@
pCtx->pDec->iHeightInPixel = iCurLayerHeight;
if ((pCurSlice->eSliceType != I_SLICE) && (pCurSlice->eSliceType != P_SLICE))
+ return 0;
+
+ if (pCtx->bParseOnly) //for parse only, deblocking should not go on
return 0;
pDeblockMb = WelsDeblockingMb;
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -45,6 +45,8 @@
namespace WelsDec {
static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
+ if (pDstInfo == NULL) //parse only usage
+ return -1;
PDqLayer pCurDq = pCtx->pCurDqLayer;
PPicture pPic = pCtx->pDec;
@@ -1760,7 +1762,7 @@
iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo);
if (pCtx->bParseOnly) {
- if (dsErrorFree == pCtx->iErrorCode) {
+ if ((dsErrorFree == pCtx->iErrorCode) && (pCtx->iTotalNumMbRec == pCtx->pSps->iMbHeight * pCtx->pSps->iMbWidth)) {
SParserBsInfo* pParser = pCtx->pParserBsInfo;
uint8_t* pDstBuf = pParser->pDstBuff;
SNalUnit* pCurNal = NULL;
@@ -1804,6 +1806,10 @@
pCtx->pParserBsInfo->iNalNum = 0;
pCtx->pParserBsInfo->iSpsWidthInPixel = 0;
pCtx->pParserBsInfo->iSpsHeightInPixel = 0;
+ if (dsErrorFree == pCtx->iErrorCode) { //frame not complete
+ pCtx->iTotalNumMbRec = 0;
+ pCtx->iErrorCode |= dsFramePending;
+ }
}
}
@@ -2082,12 +2088,10 @@
}
}
- if (!pCtx->bParseOnly) {
- if (bReconstructSlice) {
- if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
- pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
- return -1;
- }
+ if (bReconstructSlice) {
+ if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
+ pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
+ return -1;
}
}
if (bAllRefComplete && pCtx->eSliceType != I_SLICE) {
@@ -2158,7 +2162,8 @@
return iRet;
}
}
- ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel,
+ if (!pCtx->bParseOnly)
+ ExpandReferencingPicture (pCtx->pDec->pData, pCtx->pDec->iWidthInPixel, pCtx->pDec->iHeightInPixel,
pCtx->pDec->iLinesize,
pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture);
}