From 823b3b682081acbcf1b05b60f7223097e97f4fc8 Mon Sep 17 00:00:00 2001 From: ruil2 Date: Fri, 28 Feb 2014 14:31:17 +0800 Subject: [PATCH 1/3] add verification on return value --- codec/encoder/plus/src/welsEncoderExt.cpp | 26 +++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/codec/encoder/plus/src/welsEncoderExt.cpp b/codec/encoder/plus/src/welsEncoderExt.cpp index 4a30ddd7..97d19a15 100644 --- a/codec/encoder/plus/src/welsEncoderExt.cpp +++ b/codec/encoder/plus/src/welsEncoderExt.cpp @@ -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; From 23df8a9ff6ac759f2d8e724679a04c36f18d3c5d Mon Sep 17 00:00:00 2001 From: ruil2 Date: Mon, 3 Mar 2014 09:03:59 +0800 Subject: [PATCH 2/3] add video format support verification --- codec/encoder/core/src/encoder.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codec/encoder/core/src/encoder.cpp b/codec/encoder/core/src/encoder.cpp index 4d44a675..7ce7e07b 100644 --- a/codec/encoder/core/src/encoder.cpp +++ b/codec/encoder/core/src/encoder.cpp @@ -78,6 +78,10 @@ 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: From abdeb1951debec08a7ca8dc2859c3a9d3dc4c7b5 Mon Sep 17 00:00:00 2001 From: ruil2 Date: Mon, 3 Mar 2014 09:07:16 +0800 Subject: [PATCH 3/3] format update --- codec/encoder/core/src/encoder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codec/encoder/core/src/encoder.cpp b/codec/encoder/core/src/encoder.cpp index 7ce7e07b..92070b00 100644 --- a/codec/encoder/core/src/encoder.cpp +++ b/codec/encoder/core/src/encoder.cpp @@ -78,10 +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. + //currently encoder only supports videoFormatI420. if((kiColorspace & (~videoFormatVFlip))!= videoFormatI420) return 2; - switch (kiColorspace & (~videoFormatVFlip)) { case videoFormatI420: case videoFormatYV12: