| 45 | |
| 46 | namespace WelsDec { |
| 47 | static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { |
| 48 | PDqLayer pCurDq = pCtx->pCurDqLayer; |
| 49 | PPicture pPic = pCtx->pDec; |
| 50 | |
| 51 | const int32_t kiWidth = pCurDq->iMbWidth << 4; |
| 52 | const int32_t kiHeight = pCurDq->iMbHeight << 4; |
| 53 | |
| 54 | const int32_t kiTotalNumMbInCurLayer = pCurDq->iMbWidth * pCurDq->iMbHeight; |
| 55 | bool bFrameCompleteFlag = true; |
| 56 | |
| 57 | if (pPic->bNewSeqBegin) { |
| 58 | memcpy (& (pCtx->sFrameCrop), & (pCurDq->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.pSps->sFrameCrop), |
| 59 | sizeof (SPosOffset)); //confirmed_safe_unsafe_usage |
| 60 | #ifdef LONG_TERM_REF |
| 61 | pCtx->bParamSetsLostFlag = false; |
| 62 | #else |
| 63 | pCtx->bReferenceLostAtT0Flag = false; // need initialize it due new seq, 6/4/2010 |
| 64 | #endif //LONG_TERM_REF |
| 65 | if (pCtx->iTotalNumMbRec == kiTotalNumMbInCurLayer) { |
| 66 | pCtx->bPrintFrameErrorTraceFlag = true; |
| 67 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, |
| 68 | "DecodeFrameConstruction(): will output first frame of new sequence, %d x %d, crop_left:%d, crop_right:%d, crop_top:%d, crop_bottom:%d, ignored error packet:%d.", |
| 69 | kiWidth, kiHeight, pCtx->sFrameCrop.iLeftOffset, pCtx->sFrameCrop.iRightOffset, pCtx->sFrameCrop.iTopOffset, |
| 70 | pCtx->sFrameCrop.iBottomOffset, pCtx->iIgnoredErrorInfoPacketCount); |
| 71 | pCtx->iIgnoredErrorInfoPacketCount = 0; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | const int32_t kiActualWidth = kiWidth - (pCtx->sFrameCrop.iLeftOffset + pCtx->sFrameCrop.iRightOffset) * 2; |
| 76 | const int32_t kiActualHeight = kiHeight - (pCtx->sFrameCrop.iTopOffset + pCtx->sFrameCrop.iBottomOffset) * 2; |
| 77 | |
| 78 | |
| 79 | if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) { |
| 80 | if ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth) |
| 81 | || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight)) { |
| 82 | pCtx->pDecoderStatistics->uiResolutionChangeTimes++; |
| 83 | pCtx->pDecoderStatistics->uiWidth = kiActualWidth; |
| 84 | pCtx->pDecoderStatistics->uiHeight = kiActualHeight; |
| 85 | } |
| 86 | UpdateDecStatNoFreezingInfo (pCtx); |
| 87 | } |
| 88 | |
| 89 | if (pCtx->pParam->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo |
| 90 | PAccessUnit pCurAu = pCtx->pAccessUnitList; |
| 91 | if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer |
| 92 | SParserBsInfo* pParser = pCtx->pParserBsInfo; |
| 93 | SNalUnit* pCurNal = NULL; |
| 94 | int32_t iTotalNalLen = 0; |
| 95 | int32_t iNalLen = 0; |
| 96 | int32_t iNum = 0; |
| 97 | while (iNum < pParser->iNalNum) { |
| 98 | iTotalNalLen += pParser->pNalLenInByte[iNum++]; |
| 99 | } |
| 100 | uint8_t* pDstBuf = pParser->pDstBuff + iTotalNalLen; |
| 101 | int32_t iIdx = pCurAu->uiStartPos; |
| 102 | int32_t iEndIdx = pCurAu->uiEndPos; |
| 103 | uint8_t* pNalBs = NULL; |
| 104 | pParser->uiOutBsTimeStamp = (pCurAu->pNalUnitsList [iIdx]) ? pCurAu->pNalUnitsList [iIdx]->uiTimeStamp : 0; |
no test coverage detected