ref: e3bf5ced5381f8a1002c4266da74c57cb07c3114
parent: aa043fa4e5f3d8798199fa710d28e3c36b2b4cfa
parent: abdeb1951debec08a7ca8dc2859c3a9d3dc4c7b5
author: volvet <[email protected]>
date: Mon Mar 3 05:27:26 EST 2014
Merge pull request #371 from ruil2/encode_ret add verification on return value -- review request #128
--- a/codec/encoder/core/src/encoder.cpp
+++ b/codec/encoder/core/src/encoder.cpp
@@ -78,6 +78,9 @@
pSrcPic->iPicWidth = kiWidth;
pSrcPic->iPicHeight = kiHeight;
+ //currently encoder only supports videoFormatI420.
+ if((kiColorspace & (~videoFormatVFlip))!= videoFormatI420)
+ return 2;
switch (kiColorspace & (~videoFormatVFlip)) {
case videoFormatI420:
case videoFormatYV12:
--- 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;