| 19 | } EDecCase; |
| 20 | |
| 21 | DECODING_STATE DecodeFrame (const unsigned char* kpSrc, |
| 22 | const int kiSrcLen, |
| 23 | unsigned char** ppDst, |
| 24 | SBufferInfo* pDstInfo, |
| 25 | PWelsDecoderContext pCtx) { |
| 26 | PWelsDecoderContext m_pDecContext = pCtx; |
| 27 | if (CheckBsBuffer (m_pDecContext, kiSrcLen)) { |
| 28 | return dsOutOfMemory; |
| 29 | } |
| 30 | if (kiSrcLen > 0 && kpSrc != NULL) { |
| 31 | m_pDecContext->bEndOfStreamFlag = false; |
| 32 | } else { |
| 33 | //For application MODE, the error detection should be added for safe. |
| 34 | //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL. |
| 35 | m_pDecContext->bEndOfStreamFlag = true; |
| 36 | m_pDecContext->bInstantDecFlag = true; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | ppDst[0] = ppDst[1] = ppDst[2] = NULL; |
| 41 | m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. |
| 42 | m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize |
| 43 | unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp; |
| 44 | memset (pDstInfo, 0, sizeof (SBufferInfo)); |
| 45 | pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp; |
| 46 | |
| 47 | m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR |
| 48 | m_pDecContext->bCurAuContainLtrMarkSeFlag = false; |
| 49 | m_pDecContext->iFrameNumOfAuMarkedLtr = 0; |
| 50 | m_pDecContext->iFrameNum = -1; //initialize |
| 51 | |
| 52 | |
| 53 | m_pDecContext->iFeedbackTidInAu = -1; //initialize |
| 54 | if (pDstInfo) { |
| 55 | pDstInfo->uiOutYuvTimeStamp = 0; |
| 56 | m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp; |
| 57 | } else { |
| 58 | m_pDecContext->uiTimeStamp = 0; |
| 59 | } |
| 60 | WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst, |
| 61 | pDstInfo, NULL); //iErrorCode has been modified in this function |
| 62 | m_pDecContext->bInstantDecFlag = false; //reset no-delay flag |
| 63 | |
| 64 | return (DECODING_STATE) m_pDecContext->iErrorCode; |
| 65 | } |
| 66 | |
| 67 | void UninitDecoder (PWelsDecoderContext& pCtx) { |
| 68 | if (NULL == pCtx) |