shithub: openh264

Download patch

ref: e286144524775a83fc785d4c4b899622f2337a05
parent: b1a76aa936c3d02e6f538bfdf7ee87ca0cb66459
parent: e58de20f3a1eb823fdf872a701915ab92967c2b7
author: huili2 <[email protected]>
date: Fri Jul 25 13:41:38 EDT 2014

Merge pull request #1220 from ruil2/interface_ut

    add encoder interface ut

--- 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
  */
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -246,9 +246,10 @@
     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) {
--- a/codec/encoder/core/src/wels_preprocess.cpp
+++ b/codec/encoder/core/src/wels_preprocess.cpp
@@ -1190,8 +1190,6 @@
   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;
--- 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 */
 
--- a/codec/processing/src/common/util.h
+++ b/codec/processing/src/common/util.h
@@ -56,6 +56,7 @@
 
 #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
--- a/test/BaseEncoderTest.h
+++ b/test/BaseEncoderTest.h
@@ -19,8 +19,9 @@
   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__
--- /dev/null
+++ b/test/encoder/EncUT_InterfaceTest.cpp
@@ -1,0 +1,30 @@
+#include <gtest/gtest.h>
+#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<int> (cmInitParaError));
+}
--- a/test/encoder/targets.mk
+++ b/test/encoder/targets.mk
@@ -6,6 +6,7 @@
 	$(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\