Showing the changes to codec/decoder (7 of 14 files). Show all
Unified · Split
| @@ -512,6 +512,7 @@ typedef struct TagWelsDecoderContext { · 511 unmodified lines | ||
| 512 | 512 | int16_t lastReadyHeightOffset[LIST_A][MAX_REF_PIC_COUNT]; //last ready reference MB offset |
| 513 | 513 | PPictInfo pPictInfoList; |
| 514 | 514 | PPictReoderingStatus pPictReoderingStatus; |
| 515 | + SBufferInfo* pDstInfo; | |
| 515 | 516 | } SWelsDecoderContext, *PWelsDecoderContext; |
| 516 | 517 | |
| 517 | 518 | typedef struct tagSWelsDecThread { |
| @@ -44,6 +44,10 @@ · 43 unmodified lines | ||
| 44 | 44 | #include "dec_frame.h" |
| 45 | 45 | #include "decoder_context.h" |
| 46 | 46 | |
| 47 | +#define RETURN_ERR_IF_NULL(pRefPic0) \ | |
| 48 | +if ( pRefPic0 == NULL) \ | |
| 49 | + return GENERATE_ERROR_NO(ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX) | |
| 50 | + | |
| 47 | 51 | /*! |
| 48 | 52 | * \brief update mv and ref_index cache for current MB, only for P_16x16 (SKIP inclusive) |
| 49 | 53 | * \param |
| @@ -255,6 +255,7 @@ void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* · 254 unmodified lines | ||
| 255 | 255 | PPicBuff pPicBuf; |
| 256 | 256 | |
| 257 | 257 | ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false); |
| 258 | + if (pCtx->pDstInfo) pCtx->pDstInfo->iBufferStatus = 0; | |
| 258 | 259 | |
| 259 | 260 | if (NULL == ppPicBuf || NULL == *ppPicBuf) |
| 260 | 261 | return; |
| @@ -297,6 +298,7 @@ void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, P · 36 unmodified lines | ||
| 297 | 298 | pPictInfo[i].bLastGOP = false; |
| 298 | 299 | pPictInfo[i].iPOC = IMinInt32; |
| 299 | 300 | } |
| 301 | + pPictInfo->sBufferInfo.iBufferStatus = 0; | |
| 300 | 302 | } |
| 301 | 303 | } |
| 302 | 304 | |
| @@ -404,7 +404,7 @@ void CreateImplicitWeightTable (PWelsDecoderContext pCtx) { · 403 unmodified lines | ||
| 404 | 404 | //fix Bugzilla 1485229 check if pointers are NULL |
| 405 | 405 | if (pCtx->sRefPic.pRefList[LIST_0][0] && pCtx->sRefPic.pRefList[LIST_1][0]) { |
| 406 | 406 | if (pSliceHeader->uiRefCount[0] == 1 && pSliceHeader->uiRefCount[1] == 1 |
| 407 | − && pCtx->sRefPic.pRefList[LIST_0][0]->iFramePoc + pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc == 2 * iPoc) { | |
| 407 | + && int64_t(pCtx->sRefPic.pRefList[LIST_0][0]->iFramePoc) + int64_t(pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc) == 2 * int64_t(iPoc)) { | |
| 408 | 408 | pCurDqLayer->bUseWeightedBiPredIdc = false; |
| 409 | 409 | return; |
| 410 | 410 | } |
| @@ -777,6 +777,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN · 776 unmodified lines | ||
| 777 | 777 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 778 | 778 | iRef[listIdx] = 0; |
| 779 | 779 | pCtx->iErrorCode |= dsBitstreamError; |
| 780 | + RETURN_ERR_IF_NULL(pCtx->sRefPic.pRefList[listIdx][iRef[listIdx]]); | |
| 780 | 781 | } else { |
| 781 | 782 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 782 | 783 | } |
| @@ -814,6 +815,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN · 31 unmodified lines | ||
| 814 | 815 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 815 | 816 | ref_idx = 0; |
| 816 | 817 | pCtx->iErrorCode |= dsBitstreamError; |
| 818 | + RETURN_ERR_IF_NULL(pCtx->sRefPic.pRefList[listIdx][ref_idx]); | |
| 817 | 819 | } else { |
| 818 | 820 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 819 | 821 | } |
| @@ -858,6 +860,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN · 38 unmodified lines | ||
| 858 | 860 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 859 | 861 | ref_idx = 0; |
| 860 | 862 | pCtx->iErrorCode |= dsBitstreamError; |
| 863 | + RETURN_ERR_IF_NULL(pCtx->sRefPic.pRefList[listIdx][ref_idx]); | |
| 861 | 864 | } else { |
| 862 | 865 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 863 | 866 | } |
| @@ -992,6 +995,7 @@ int32_t ParseInterBMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pN · 128 unmodified lines | ||
| 992 | 995 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 993 | 996 | iref = 0; |
| 994 | 997 | pCtx->iErrorCode |= dsBitstreamError; |
| 998 | + RETURN_ERR_IF_NULL(pCtx->sRefPic.pRefList[listIdx][iref]); | |
| 995 | 999 | } else { |
| 996 | 1000 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 997 | 1001 | } |
| @@ -1389,6 +1389,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ · 1388 unmodified lines | ||
| 1389 | 1389 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 1390 | 1390 | ref_idx_list[listIdx][0] = 0; |
| 1391 | 1391 | pCtx->iErrorCode |= dsBitstreamError; |
| 1392 | + RETURN_ERR_IF_NULL(ppRefPic[listIdx][ref_idx_list[listIdx][0]]); | |
| 1392 | 1393 | } else { |
| 1393 | 1394 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 1394 | 1395 | } |
| @@ -1438,6 +1439,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ · 43 unmodified lines | ||
| 1438 | 1439 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 1439 | 1440 | iRefIdx = 0; |
| 1440 | 1441 | pCtx->iErrorCode |= dsBitstreamError; |
| 1442 | + RETURN_ERR_IF_NULL(ppRefPic[listIdx][iRefIdx]); | |
| 1441 | 1443 | } else { |
| 1442 | 1444 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 1443 | 1445 | } |
| @@ -1497,6 +1499,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ · 53 unmodified lines | ||
| 1497 | 1499 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 1498 | 1500 | iRefIdx = 0; |
| 1499 | 1501 | pCtx->iErrorCode |= dsBitstreamError; |
| 1502 | + RETURN_ERR_IF_NULL(ppRefPic[listIdx][iRefIdx]); | |
| 1500 | 1503 | } else { |
| 1501 | 1504 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 1502 | 1505 | } |
| @@ -1643,6 +1646,7 @@ int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][ · 140 unmodified lines | ||
| 1643 | 1646 | if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) { |
| 1644 | 1647 | iref = 0; |
| 1645 | 1648 | pCtx->iErrorCode |= dsBitstreamError; |
| 1649 | + RETURN_ERR_IF_NULL(ppRefPic[listIdx][iref]); | |
| 1646 | 1650 | } else { |
| 1647 | 1651 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_REF_INDEX); |
| 1648 | 1652 | } |
| @@ -450,6 +450,7 @@ int32_t CWelsDecoder::ResetDecoder (PWelsDecoderContext& pCtx) { · 449 unmodified lines | ||
| 450 | 450 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); |
| 451 | 451 | } |
| 452 | 452 | ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, false); |
| 453 | + if (pCtx->pDstInfo) pCtx->pDstInfo->iBufferStatus = 0; | |
| 453 | 454 | } |
| 454 | 455 | return ERR_INFO_UNINIT; |
| 455 | 456 | } |
| @@ -461,6 +462,7 @@ int32_t CWelsDecoder::ThreadResetDecoder (PWelsDecoderContext& pCtx) { · 5 unmodified lines | ||
| 461 | 462 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d", pCtx->iErrorCode); |
| 462 | 463 | memcpy (&sPrevParam, pCtx->pParam, sizeof (SDecodingParam)); |
| 463 | 464 | ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, true); |
| 465 | + if (pCtx->pDstInfo) pCtx->pDstInfo->iBufferStatus = 0; | |
| 464 | 466 | CloseDecoderThreads(); |
| 465 | 467 | UninitDecoder(); |
| 466 | 468 | InitDecoder (&sPrevParam); |
| @@ -811,11 +813,6 @@ DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContex · 344 unmodified lines | ||
| 811 | 813 | } |
| 812 | 814 | return dsErrorFree; |
| 813 | 815 | } |
| 814 | − if ((pDecContext->iErrorCode & (dsBitstreamError | dsDataErrorConcealed)) && pDecContext->eSliceType == B_SLICE) { | |
| 815 | − ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, true); | |
| 816 | − WelsResetRefPic (pDecContext); | |
| 817 | − return dsErrorFree; | |
| 818 | − } | |
| 819 | 816 | //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss. |
| 820 | 817 | if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) || |
| 821 | 818 | (VIDEO_BITSTREAM_AVC == pDecContext->eVideoType)) { |
| @@ -910,6 +907,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 88 unmodified lines | ||
| 910 | 907 | unsigned char** ppDst, |
| 911 | 908 | SBufferInfo* pDstInfo) { |
| 912 | 909 | PWelsDecoderContext pDecContext = m_pDecThrCtx[0].pCtx; |
| 910 | + pDecContext->pDstInfo = pDstInfo; | |
| 913 | 911 | return DecodeFrame2WithCtx (pDecContext, kpSrc, kiSrcLen, ppDst, pDstInfo); |
| 914 | 912 | } |
| 915 | 913 | |
| @@ -1224,7 +1222,7 @@ void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsign · 308 unmodified lines | ||
| 1224 | 1222 | DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (PWelsDecoderContext pDecContext, unsigned char** ppDst, |
| 1225 | 1223 | SBufferInfo* pDstInfo) { |
| 1226 | 1224 | DECODING_STATE iRet = dsErrorFree; |
| 1227 | − if (pDstInfo->iBufferStatus == 1) { | |
| 1225 | + if ((pDstInfo->iBufferStatus == 1) && (pDecContext->pPps->bEntropyCodingModeFlag)) { | |
| 1228 | 1226 | m_bIsBaseline = pDecContext->pSps->uiProfileIdc == 66 || pDecContext->pSps->uiProfileIdc == 83; |
| 1229 | 1227 | if (!m_bIsBaseline) { |
| 1230 | 1228 | BufferingReadyPicture (pDecContext, ppDst, pDstInfo); |