ref: 823b3b682081acbcf1b05b60f7223097e97f4fc8
parent: 3d47b7847d6e8a6f5c186f87d40058c839234995
author: ruil2 <[email protected]>
date: Fri Feb 28 09:31:17 EST 2014
add verification on return value
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -406,8 +406,14 @@
m_iSrcListSize = 0;
return cmMallocMemeError;
}
- InitPic (m_pSrcPicList[i], iColorspace, m_iMaxPicWidth, m_iMaxPicHeight);
- }
+ if(InitPic (m_pSrcPicList[i], iColorspace, m_iMaxPicWidth, m_iMaxPicHeight))
+ {
+ WelsLog (m_pEncContext, WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::Initialize(), InitPic Failed iColorspace= 0x%x\n", iColorspace);
+ Uninitialize();
+ return cmInitParaError;
+ }
+ }
if (WelsInitEncoderExt (&m_pEncContext, pCfg)) {
WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), WelsInitEncoderExt failed.\n");
@@ -711,7 +717,13 @@
continue;
}
- InitPic (m_pSrcPicList[iPicIdx], iColorspace, m_iMaxPicWidth, m_iMaxPicHeight);
+ if(InitPic (m_pSrcPicList[iPicIdx], iColorspace, m_iMaxPicWidth, m_iMaxPicHeight))
+ {
+ WelsLog (m_pEncContext, WELS_LOG_INFO,
+ "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_DATAFORMAT, iColorspace= 0x%x\n",
+ iColorspace);
+ return cmInitParaError;
+ }
}
m_iCspInternal = iColorspace;
#ifdef REC_FRAME_COUNT
@@ -810,7 +822,13 @@
}
if (m_iCspInternal != iInputColorspace || m_iMaxPicWidth != iTargetWidth
|| m_iMaxPicHeight != iTargetHeight) { // for color space due to changed
- InitPic (m_pSrcPicList[0], iInputColorspace, iTargetWidth, iTargetHeight);
+ if(InitPic (m_pSrcPicList[0], iInputColorspace, iTargetWidth, iTargetHeight))
+ {
+ WelsLog (m_pEncContext, WELS_LOG_INFO,
+ "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, iInputColorspace= 0x%x\n",
+ iInputColorspace);
+ return cmInitParaError;
+ }
m_iMaxPicWidth = iTargetWidth;
m_iMaxPicHeight = iTargetHeight;
m_iCspInternal = iInputColorspace;