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
273/*!273/*!
274 * \brief Open decoder274 * \brief Open decoder
275 */275 */
276void WelsOpenDecoder (PWelsDecoderContext pCtx) {276int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
277 // function pointers277 // function pointers
278 //initial MC function pointer--278 //initial MC function pointer--
279 int iRet = ERR_NONE;
279 InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);280 InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
280 InitErrorCon (pCtx);281 InitErrorCon (pCtx);
281 282
@@ -286,8 +287,9 @@ void WelsOpenDecoder (PWelsDecoderContext pCtx) { · 4 unmodified lines
286 InitVlcTable (&pCtx->sVlcTable);287 InitVlcTable (&pCtx->sVlcTable);
287 288
288 // startup memory289 // startup memory
289 if (ERR_NONE != WelsInitMemory (pCtx))290 iRet = WelsInitMemory (pCtx);
290 return;291 if (ERR_NONE != iRet)
292 return iRet;
291 293
292#ifdef LONG_TERM_REF294#ifdef LONG_TERM_REF
293 pCtx->bParamSetsLostFlag = true;295 pCtx->bParamSetsLostFlag = true;
@@ -298,6 +300,7 @@ void WelsOpenDecoder (PWelsDecoderContext pCtx) { · 4 unmodified lines
298 pCtx->bDecErrorConedFlag = false; //default: decoder normal status300 pCtx->bDecErrorConedFlag = false; //default: decoder normal status
299 pCtx->bPrintFrameErrorTraceFlag = true;301 pCtx->bPrintFrameErrorTraceFlag = true;
300 pCtx->iIgnoredErrorInfoPacketCount = 0;302 pCtx->iIgnoredErrorInfoPacketCount = 0;
303 return iRet;
301}304}
302 305
303/*!306/*!
@@ -333,6 +336,9 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 29 unmodified lines
333 336
334 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));337 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
335 pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;338 pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
339 int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
340 if (iRet)
341 return iRet;
336 pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;342 pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
337 343
338 if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||344 if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType ||
@@ -368,10 +374,7 @@ int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 29 unmodified lines
368 WelsDecoderDefaults (pCtx, pLogCtx);374 WelsDecoderDefaults (pCtx, pLogCtx);
369 375
370 // open decoder376 // open decoder
371 WelsOpenDecoder (pCtx);377 return WelsOpenDecoder (pCtx);
372
373
374 return ERR_NONE;
375}378}
376 379
377/*!380/*!
@@ -596,9 +599,12 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { · 218 unmodified lines
596 }599 }
597 600
598 //For now, support only videoFormatI420!601 //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) {
600 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "Support I420 output only for now! Change to I420...");605 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "Support I420 output only for now! Change to I420...");
601 pCtx->pParam->eOutputColorFormat = pCtx->eOutputColorFormat = videoFormatI420;606 pCtx->pParam->eOutputColorFormat = pCtx->eOutputColorFormat = videoFormatI420;
607 return cmUnsupportedData;
602 }608 }
603 609
604 return 0;610 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