From 2c830e64d784d1e70af5ada7ee37aed5f36fbf47 Mon Sep 17 00:00:00 2001 From: karina li Date: Tue, 8 Sep 2015 17:21:56 +0800 Subject: [PATCH] exception case for width or height is less than 16 --- codec/encoder/core/src/wels_preprocess.cpp | 4 ++++ test/encoder/EncUT_EncoderExt.cpp | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/codec/encoder/core/src/wels_preprocess.cpp b/codec/encoder/core/src/wels_preprocess.cpp index a46d9259..6a5a951d 100644 --- a/codec/encoder/core/src/wels_preprocess.cpp +++ b/codec/encoder/core/src/wels_preprocess.cpp @@ -185,6 +185,10 @@ int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePi pSvcParam->SUsedPicRect.iTop = 0; pSvcParam->SUsedPicRect.iWidth = ((kpSrcPic->iPicWidth >> 1) << 1); pSvcParam->SUsedPicRect.iHeight = ((kpSrcPic->iPicHeight >> 1) << 1); + if((pSvcParam->SUsedPicRect.iWidth<16)||((pSvcParam->SUsedPicRect.iHeight<16))){ + WelsLog ( & (pCtx->sLogCtx), WELS_LOG_ERROR, "Don't support width(%d) or height(%d) which is less than 16 ",pSvcParam->SUsedPicRect.iWidth,pSvcParam->SUsedPicRect.iHeight); + return -1; + } if (WelsPreprocessReset (pCtx) != 0) return -1; diff --git a/test/encoder/EncUT_EncoderExt.cpp b/test/encoder/EncUT_EncoderExt.cpp index ee6c5abd..7fee8451 100644 --- a/test/encoder/EncUT_EncoderExt.cpp +++ b/test/encoder/EncUT_EncoderExt.cpp @@ -10,7 +10,7 @@ class EncoderInterfaceTest : public ::testing::Test { #define MB_SIZE (16) #define MAX_WIDTH (3840) #define MAX_HEIGHT (2160) -#define VALID_SIZE(iSize) (((iSize)>1)?(iSize):1) +#define VALID_SIZE(iSize) (((iSize)>16)?(iSize):16) #define MEM_VARY_SIZE (512) #define IMAGE_VARY_SIZE (512) #define TEST_FRAMES (30) @@ -87,9 +87,10 @@ void EncoderInterfaceTest::PrepareOneSrcFrame() { pSrcPic->uiTimeStamp = 0; pSrcPic->iPicWidth = pParamExt->iPicWidth; pSrcPic->iPicHeight = pParamExt->iPicHeight; - - m_iWidth = pParamExt->iPicWidth; - m_iHeight = pParamExt->iPicHeight; + pSrcPic->iPicWidth = VALID_SIZE (pParamExt->iPicWidth); + pSrcPic->iPicHeight = VALID_SIZE (pParamExt->iPicHeight); + m_iWidth = pSrcPic->iPicWidth; + m_iHeight = pSrcPic->iPicHeight; m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1; pYUV[0] = rand() % 256;