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
197197 }
198198
199199 // H.264 decoder initialization,including memory allocation,then open it ready to decode
200− iRet = InitDecoder();
200+ iRet = InitDecoder (pParam->bParseOnly);
201201 if (iRet)
202202 return iRet;
203203
@@ -232,16 +232,18 @@ void CWelsDecoder::UninitDecoder (void) { · 28 unmodified lines
232232 }
233233
234234 // 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) {
236236
237237 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder(), openh264 codec version = %s",
238238 VERSION_NUMBER);
239239
240+ if (m_pDecContext) //free
241+ UninitDecoder();
240242 m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
241243 if (NULL == m_pDecContext)
242244 return cmMallocMemeError;
243245
244− return WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx);
246+ return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx);
245247 }
246248
247249 /*
@@ -422,7 +424,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 174 unmodified lines
422424 m_pDecContext->iFeedbackTidInAu = -1; //initialize
423425
424426 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
426428 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
427429 if (m_pDecContext->iErrorCode) {
428430 EWelsNalUnitType eNalType =
@@ -500,7 +502,30 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 71 unmodified lines
500502 DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
501503 const int kiSrcLen,
502504 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+
504529 return (DECODING_STATE) m_pDecContext->iErrorCode;
505530 }
506531

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