diff --git a/codec/common/inc/utils.h b/codec/common/inc/utils.h index 1d915c61..f342f5ef 100644 --- a/codec/common/inc/utils.h +++ b/codec/common/inc/utils.h @@ -43,6 +43,8 @@ #include "typedefs.h" #define MAX_LOG_SIZE 1024 +#define MAX_WIDTH (4096) +#define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304 /* * Function pointer declaration for various tool sets */ diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index 7acbc9dd..63c2a1dd 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -246,9 +246,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa uint32_t iMbHeight = 0; int32_t iMbNumInFrame = 0; uint32_t iMaxSliceNum = MAX_SLICES_NUM; - if (kiPicWidth <= 0 || kiPicHeight <= 0) { - WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid %d x %d in dependency layer settings!\n", kiPicWidth, - kiPicHeight); + if ((kiPicWidth <= 0) || (kiPicHeight <= 0) || (kiPicWidth > MAX_WIDTH) || (kiPicHeight > MAX_HEIGHT)) { + WelsLog (pLogCtx, WELS_LOG_ERROR, + "ParamValidationExt(),width(1-%d),height(1-%d)invalid %d x %d in dependency layer settings!\n", MAX_WIDTH, MAX_HEIGHT, + kiPicWidth, kiPicHeight); return ENC_RETURN_UNSUPPORTED_PARA; } if ((kiPicWidth & 0x0F) != 0 || (kiPicHeight & 0x0F) != 0) { diff --git a/codec/encoder/core/src/wels_preprocess.cpp b/codec/encoder/core/src/wels_preprocess.cpp index 639b41f0..d05e8c9e 100644 --- a/codec/encoder/core/src/wels_preprocess.cpp +++ b/codec/encoder/core/src/wels_preprocess.cpp @@ -1190,8 +1190,6 @@ void CWelsPreProcess::WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SP const int32_t kiDstStrideY = pDstPic->iLineSize[0]; const int32_t kiDstStrideUV = pDstPic->iLineSize[1]; -#define MAX_WIDTH (4096) -#define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304 if (pSrcY) { if (iSrcWidth <= 0 || iSrcWidth > MAX_WIDTH || iSrcHeight <= 0 || iSrcHeight > MAX_HEIGHT) return; diff --git a/codec/processing/src/common/WelsFrameWork.cpp b/codec/processing/src/common/WelsFrameWork.cpp index 945f7706..fc2dfee8 100644 --- a/codec/processing/src/common/WelsFrameWork.cpp +++ b/codec/processing/src/common/WelsFrameWork.cpp @@ -40,7 +40,7 @@ #include "../adaptivequantization/AdaptiveQuantization.h" #include "../complexityanalysis/ComplexityAnalysis.h" #include "../imagerotate/imagerotate.h" - +#include "util.h" /* interface API implement */ diff --git a/codec/processing/src/common/util.h b/codec/processing/src/common/util.h index fa12e5f6..eb54021b 100644 --- a/codec/processing/src/common/util.h +++ b/codec/processing/src/common/util.h @@ -56,6 +56,7 @@ WELSVP_NAMESPACE_BEGIN #define MAX_WIDTH (4096) #define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304 + #define MB_WIDTH_LUMA (16) #define PESN (1e-6) // desired float precision #define AQ_INT_MULTIPLY 10000000 diff --git a/test/BaseEncoderTest.h b/test/BaseEncoderTest.h index 6c9fb2ac..9fad321a 100644 --- a/test/BaseEncoderTest.h +++ b/test/BaseEncoderTest.h @@ -19,8 +19,9 @@ class BaseEncoderTest { void EncodeStream (InputStream* in, EUsageType usageType, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk); - private: ISVCEncoder* encoder_; + private: + }; #endif //__BASEENCODERTEST_H__ diff --git a/test/encoder/EncUT_InterfaceTest.cpp b/test/encoder/EncUT_InterfaceTest.cpp new file mode 100644 index 00000000..3eb33e88 --- /dev/null +++ b/test/encoder/EncUT_InterfaceTest.cpp @@ -0,0 +1,30 @@ +#include +#include "codec_def.h" +#include "codec_api.h" +#include "BaseEncoderTest.h" + +class EncInterfaceCallTest : public ::testing::Test, public BaseEncoderTest { + public: + virtual void SetUp() { + BaseEncoderTest::SetUp(); + }; + virtual void TearDown() { + BaseEncoderTest::TearDown(); + }; + + //testing case + +}; + + +TEST_F (EncInterfaceCallTest, BaseParameterVerify) { + int ret = cmResultSuccess; + SEncParamBase baseparam; + memset (&baseparam, 0, sizeof (SEncParamBase)); + + baseparam.iPicWidth = 0; + baseparam.iPicHeight = 7896; + + ret = encoder_->Initialize (&baseparam); + EXPECT_EQ (ret, static_cast (cmInitParaError)); +} diff --git a/test/encoder/targets.mk b/test/encoder/targets.mk index e99e0aa4..f346038e 100644 --- a/test/encoder/targets.mk +++ b/test/encoder/targets.mk @@ -6,6 +6,7 @@ ENCODER_UNITTEST_CPP_SRCS=\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMbAux.cpp\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpGolomb.cpp\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_GetIntraPredictor.cpp\ + $(ENCODER_UNITTEST_SRCDIR)/EncUT_InterfaceTest.cpp\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_MBCopy.cpp\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\ $(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryZero.cpp\