Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 13 files). Show all
Unified · Split
| @@ -197,7 +197,7 @@ long CWelsDecoder::Initialize (const SDecodingParam* pParam) { · 196 unmodified lines | ||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // H.264 decoder initialization,including memory allocation,then open it ready to decode |
| 200 | − iRet = InitDecoder(); | |
| 200 | + iRet = InitDecoder (pParam->bParseOnly); | |
| 201 | 201 | if (iRet) |
| 202 | 202 | return iRet; |
| 203 | 203 | |
| @@ -232,16 +232,18 @@ void CWelsDecoder::UninitDecoder (void) { · 28 unmodified lines | ||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // the return value of this function is not suitable, it need report failure info to upper layer. |
| 235 | −int32_t CWelsDecoder::InitDecoder (void) { | |
| 235 | +int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) { | |
| 236 | 236 | |
| 237 | 237 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder(), openh264 codec version = %s", |
| 238 | 238 | VERSION_NUMBER); |
| 239 | 239 | |
| 240 | + if (m_pDecContext) //free | |
| 241 | + UninitDecoder(); | |
| 240 | 242 | m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext"); |
| 241 | 243 | if (NULL == m_pDecContext) |
| 242 | 244 | return cmMallocMemeError; |
| 243 | 245 | |
| 244 | − return WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx); | |
| 246 | + return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx); | |
| 245 | 247 | } |
| 246 | 248 | |
| 247 | 249 | /* |
| @@ -422,7 +424,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 174 unmodified lines | ||
| 422 | 424 | m_pDecContext->iFeedbackTidInAu = -1; //initialize |
| 423 | 425 | |
| 424 | 426 | WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst, |
| 425 | − pDstInfo); //iErrorCode has been modified in this function | |
| 427 | + pDstInfo, NULL); //iErrorCode has been modified in this function | |
| 426 | 428 | m_pDecContext->bInstantDecFlag = false; //reset no-delay flag |
| 427 | 429 | if (m_pDecContext->iErrorCode) { |
| 428 | 430 | EWelsNalUnitType eNalType = |
| @@ -500,7 +502,30 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 71 unmodified lines | ||
| 500 | 502 | DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, |
| 501 | 503 | const int kiSrcLen, |
| 502 | 504 | SParserBsInfo* pDstInfo) { |
| 503 | −//TODO, add function here | |
| 505 | + if (CheckBsBuffer (m_pDecContext, kiSrcLen)) { | |
| 506 | + return dsOutOfMemory; | |
| 507 | + } | |
| 508 | + if (kiSrcLen > 0 && kpSrc != NULL) { | |
| 509 | +#ifdef OUTPUT_BITSTREAM | |
| 510 | + if (m_pFBS) { | |
| 511 | + WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS); | |
| 512 | + WelsFflush (m_pFBS); | |
| 513 | + } | |
| 514 | +#endif//OUTPUT_BIT_STREAM | |
| 515 | + m_pDecContext->bEndOfStreamFlag = false; | |
| 516 | + } else { | |
| 517 | + //For application MODE, the error detection should be added for safe. | |
| 518 | + //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL. | |
| 519 | + m_pDecContext->bEndOfStreamFlag = true; | |
| 520 | + m_pDecContext->bInstantDecFlag = true; | |
| 521 | + } | |
| 522 | + | |
| 523 | + m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding. | |
| 524 | + m_pDecContext->pParserBsInfo = pDstInfo; | |
| 525 | + pDstInfo->iNalNum = 0; | |
| 526 | + pDstInfo->iSpsWidthInPixel = pDstInfo->iSpsHeightInPixel = 0; | |
| 527 | + WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo); | |
| 528 | + | |
| 504 | 529 | return (DECODING_STATE) m_pDecContext->iErrorCode; |
| 505 | 530 | } |
| 506 | 531 | |