History

add protection for decoder and data format

huili2 committed 12 years ago

Commit f8d2ae41 parent 06e56ec4 files · +36 −17Browse files

Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 4 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+14−8
@@ -273,9 +273,10 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 272 unmodified lines
273273 /*!
274274 * \brief Open decoder
275275 */
276−void WelsOpenDecoder (PWelsDecoderContext pCtx) {
276+int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
277277 // function pointers
278278 //initial MC function pointer--
279+ int iRet = ERR_NONE;
279280 InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
280281 InitErrorCon (pCtx);
281282
@@ -286,8 +287,9 @@ void WelsOpenDecoder (PWelsDecoderContext pCtx) { · 4 unmodified lines
286287 InitVlcTable (&pCtx->sVlcTable);
287288
288289 // startup memory
289− if (ERR_NONE != WelsInitMemory (pCtx))
290− return;
290+ iRet = WelsInitMemory (pCtx);
291+ if (ERR_NONE != iRet)
292+ return iRet;
291293
292294 #ifdef LONG_TERM_REF
293295 pCtx->bParamSetsLostFlag = true;
@@ -298,6 +300,7 @@ void WelsOpenDecoder (PWelsDecoderContext pCtx) { · 4 unmodified lines
298300 pCtx->bDecErrorConedFlag = false; //default: decoder normal status
299301 pCtx->bPrintFrameErrorTraceFlag = true;
300302 pCtx->iIgnoredErrorInfoPacketCount = 0;
303+ return iRet;
301304 }
302305
303306 /*!
@@ -333,6 +336,9 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 29 unmodified lines
333336
334337 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
335338 pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
339+ int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
340+ if (iRet)
341+ return iRet;
336342 pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
337343
338344 if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||
@@ -368,10 +374,7 @@ int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 29 unmodified lines
368374 WelsDecoderDefaults (pCtx, pLogCtx);
369375
370376 // open decoder
371− WelsOpenDecoder (pCtx);
372−
373−
374− return ERR_NONE;
377+ return WelsOpenDecoder (pCtx);
375378 }
376379
377380 /*!
@@ -596,9 +599,12 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { · 218 unmodified lines
596599 }
597600
598601 //For now, support only videoFormatI420!
599− if (kiColorFormat != (int32_t) videoFormatI420) {
602+ if (kiColorFormat == (int32_t) videoFormatInternal) {
603+ pCtx->pParam->eOutputColorFormat = pCtx->eOutputColorFormat = videoFormatI420;
604+ } else if (kiColorFormat != (int32_t) videoFormatI420) {
600605 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "Support I420 output only for now! Change to I420...");
601606 pCtx->pParam->eOutputColorFormat = pCtx->eOutputColorFormat = videoFormatI420;
607+ return cmUnsupportedData;
602608 }
603609
604610 return 0;

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