History

parse only add and UT

huili2 committed 11 years ago

Commit b231e3f1 parent 53c14dc13 files · +607 −60Browse files

Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 13 files). Show all

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+30−5
@@ -197,7 +197,7 @@ long CWelsDecoder::Initialize (const SDecodingParam* pParam) { · 196 unmodified lines
197 }197 }
198 198
199 // H.264 decoder initialization,including memory allocation,then open it ready to decode199 // H.264 decoder initialization,including memory allocation,then open it ready to decode
200 iRet = InitDecoder();200 iRet = InitDecoder (pParam->bParseOnly);
201 if (iRet)201 if (iRet)
202 return iRet;202 return iRet;
203 203
@@ -232,16 +232,18 @@ void CWelsDecoder::UninitDecoder (void) { · 28 unmodified lines
232}232}
233 233
234// the return value of this function is not suitable, it need report failure info to upper layer.234// the return value of this function is not suitable, it need report failure info to upper layer.
235int32_t CWelsDecoder::InitDecoder (void) {235int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) {
236 236
237 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder(), openh264 codec version = %s",237 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder(), openh264 codec version = %s",
238 VERSION_NUMBER);238 VERSION_NUMBER);
239 239
240 if (m_pDecContext) //free
241 UninitDecoder();
240 m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");242 m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
241 if (NULL == m_pDecContext)243 if (NULL == m_pDecContext)
242 return cmMallocMemeError;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 m_pDecContext->iFeedbackTidInAu = -1; //initialize424 m_pDecContext->iFeedbackTidInAu = -1; //initialize
423 425
424 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst,426 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst,
425 pDstInfo); //iErrorCode has been modified in this function427 pDstInfo, NULL); //iErrorCode has been modified in this function
426 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag428 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
427 if (m_pDecContext->iErrorCode) {429 if (m_pDecContext->iErrorCode) {
428 EWelsNalUnitType eNalType =430 EWelsNalUnitType eNalType =
@@ -500,7 +502,30 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 71 unmodified lines
500DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,502DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
501 const int kiSrcLen,503 const int kiSrcLen,
502 SParserBsInfo* pDstInfo) {504 SParserBsInfo* pDstInfo) {
503//TODO, add function here505 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 return (DECODING_STATE) m_pDecContext->iErrorCode;529 return (DECODING_STATE) m_pDecContext->iErrorCode;
505}530}
506 531

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t