ref: 601105471f7c0ae515aecdffd3bcb0357ec597b1
parent: 3ef97dc0c93bc0068adf1f8ee0d2ae5c4c46d0bb
parent: 44faa1c9a7bea6b60ccaa78b7bb6678574e26948
author: sijchen <sijchen@cisco.com>
date: Thu Jul 3 05:07:09 EDT 2014
Merge pull request #1067 from lyao2/interface_ut_commit encoder interface UT for temporal layer setting change
--- /dev/null
+++ b/test/encoder/EncUT_EncoderExt.cpp
@@ -1,0 +1,118 @@
+#include<gtest/gtest.h>
+#include<stdlib.h>
+#include "codec_api.h"
+#include "welsEncoderExt.h"
+
+using namespace WelsSVCEnc;
+
+class EncoderInterfaceTest : public ::testing::Test {
+ public:
+ virtual void SetUp() {
+ pPtrEnc = new CWelsH264SVCEncoder();
+ pParamExt = new SEncParamExt();
+ pSrcPic = new SSourcePicture;
+ pOption = new SEncParamExt();
+ pYUV = NULL;
+
+ m_iWidth = 1280;
+ m_iHeight = 720;
+ m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1;
+ pYUV = new uint8_t [m_iPicResSize];
+ }
+ void TemporalLayerSettingTest();
+ virtual void TearDown() {
+ delete pPtrEnc;
+ delete pParamExt;
+ delete pOption;
+ delete pSrcPic;
+ delete []pYUV;
+ }
+ public:
+ CWelsH264SVCEncoder* pPtrEnc;
+ SEncParamExt* pParamExt;
+ SSourcePicture* pSrcPic;
+ SEncParamExt* pOption;
+ uint8_t* pYUV;
+
+ int32_t m_iWidth;
+ int32_t m_iHeight;
+ int32_t m_iPicResSize;
+};
+
+void EncoderInterfaceTest::TemporalLayerSettingTest() {
+
+ pParamExt->iInputCsp = 23;
+ pParamExt->iPicWidth = m_iWidth;
+ pParamExt->iPicHeight = m_iHeight;
+ pParamExt->iTargetBitrate = 60000;
+ pParamExt->sSpatialLayers[0].iVideoHeight = pParamExt->iPicHeight;
+ pParamExt->sSpatialLayers[0].iVideoWidth = pParamExt->iPicWidth;
+ pParamExt->sSpatialLayers[0].iSpatialBitrate = 50000;
+ pParamExt->iTemporalLayerNum = 1;
+ pParamExt->iSpatialLayerNum = 1;
+
+ int32_t iResult = pPtrEnc->InitializeExt (pParamExt);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+
+ pSrcPic->iColorFormat = videoFormatI420;
+ pSrcPic->uiTimeStamp = 0;
+ pSrcPic->iPicWidth = pParamExt->iPicWidth;
+ pSrcPic->iPicHeight = pParamExt->iPicHeight;
+
+ for (int32_t i = 0; i < m_iPicResSize; i++)
+ pYUV[i] = rand() % 256;
+
+ pSrcPic->iStride[0] = m_iWidth;
+ pSrcPic->iStride[1] = pSrcPic->iStride[2] = pSrcPic->iStride[0] >> 1;
+
+ pSrcPic->pData[0] = pYUV;
+ pSrcPic->pData[1] = pSrcPic->pData[0] + (m_iWidth * m_iHeight);
+ pSrcPic->pData[2] = pSrcPic->pData[1] + (m_iWidth * m_iHeight >> 2);
+
+ SFrameBSInfo sFbi;
+ memset (&sFbi, 0, sizeof (SFrameBSInfo));
+
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ EXPECT_EQ (sFbi.eFrameType, static_cast<int32_t> (videoFrameTypeIDR));
+
+ pSrcPic->uiTimeStamp = 30;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ EXPECT_EQ (sFbi.eFrameType, static_cast<int32_t> (videoFrameTypeP));
+
+ memcpy (pOption, pParamExt, sizeof (SEncParamExt));
+ pOption ->iTemporalLayerNum = 4;
+
+ ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT;
+ iResult = pPtrEnc->SetOption (eOptionId, pOption);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+
+ pSrcPic->uiTimeStamp = 60;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ EXPECT_EQ (sFbi.eFrameType, static_cast<int32_t> (videoFrameTypeIDR));
+
+ pOption ->iTemporalLayerNum = 2;
+ iResult = pPtrEnc->SetOption (eOptionId, pOption);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ pSrcPic->uiTimeStamp = 90;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ EXPECT_EQ (sFbi.eFrameType, static_cast<int32_t> (videoFrameTypeP));
+
+ pOption ->iTemporalLayerNum = 4;
+ iResult = pPtrEnc->SetOption (eOptionId, pOption);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ pSrcPic->uiTimeStamp = 120;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
+ EXPECT_EQ (sFbi.eFrameType, static_cast<int32_t> (videoFrameTypeP));
+
+ pPtrEnc->Uninitialize();
+
+}
+
+TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) {
+ TemporalLayerSettingTest();
+}
\ No newline at end of file
--- a/test/encoder/targets.mk
+++ b/test/encoder/targets.mk
@@ -1,6 +1,7 @@
ENCODER_UNITTEST_SRCDIR=test/encoder
ENCODER_UNITTEST_CPP_SRCS=\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_DecodeMbAux.cpp\
+ $(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderExt.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMb.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_EncoderMbAux.cpp\
$(ENCODER_UNITTEST_SRCDIR)/EncUT_ExpGolomb.cpp\