Merge pull request #371 from ruil2/encode_ret

add verification on return value -- review request #128
This commit is contained in:
volvet 2014-03-03 10:27:26 +08:00
commit e3bf5ced53
2 changed files with 25 additions and 4 deletions

View File

@ -78,6 +78,9 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki
pSrcPic->iPicWidth = kiWidth;
pSrcPic->iPicHeight = kiHeight;
//currently encoder only supports videoFormatI420.
if((kiColorspace & (~videoFormatVFlip))!= videoFormatI420)
return 2;
switch (kiColorspace & (~videoFormatVFlip)) {
case videoFormatI420:
case videoFormatYV12:

View File

@ -406,8 +406,14 @@ int CWelsH264SVCEncoder::Initialize2 (SWelsSvcCodingParam* pCfg) {
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 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
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 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
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;