add interface UT for RC and code refactor
This commit is contained in:
parent
470246c20f
commit
562f38afff
@ -9,6 +9,9 @@ class EncoderInterfaceTest : public ::testing::Test {
|
||||
#define MAX_WIDTH (3840)
|
||||
#define MAX_HEIGHT (2160)
|
||||
#define VALID_SIZE(iSize) (((iSize)>1)?(iSize):1)
|
||||
#define MEM_VARY_SIZE (512)
|
||||
#define IMAGE_VARY_SIZE (512)
|
||||
#define TEST_FRAMES (200)
|
||||
|
||||
#define NAL_HEADER_BYTES (4)
|
||||
#define NAL_TYPE (0x0F)
|
||||
@ -52,6 +55,7 @@ class EncoderInterfaceTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeParamExt();
|
||||
void TemporalLayerSettingTest();
|
||||
void MemoryCheckTest();
|
||||
void EncodeOneFrame (SEncParamBase* pEncParamBase);
|
||||
@ -120,7 +124,18 @@ void EncoderInterfaceTest::EncodeOneIDRandP (ISVCEncoder* pPtrEnc) {
|
||||
EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
||||
}
|
||||
|
||||
void EncoderInterfaceTest::TemporalLayerSettingTest() {
|
||||
void EncoderInterfaceTest::InitializeParamExt() {
|
||||
pParamExt->iPicWidth = 1280;
|
||||
pParamExt->iPicHeight = 720;
|
||||
pParamExt->iTargetBitrate = 50000;
|
||||
pParamExt->iTemporalLayerNum = 3;
|
||||
pParamExt->iSpatialLayerNum = 1;
|
||||
pParamExt->sSpatialLayers[0].iVideoHeight = pParamExt->iPicHeight;
|
||||
pParamExt->sSpatialLayers[0].iVideoWidth = pParamExt->iPicWidth;
|
||||
pParamExt->sSpatialLayers[0].iSpatialBitrate = 50000;
|
||||
}
|
||||
|
||||
TEST_F (EncoderInterfaceTest, TemporalLayerSettingTest) {
|
||||
|
||||
pParamExt->iPicWidth = m_iWidth;
|
||||
pParamExt->iPicHeight = m_iHeight;
|
||||
@ -175,27 +190,60 @@ void EncoderInterfaceTest::TemporalLayerSettingTest() {
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP));
|
||||
|
||||
pPtrEnc->Uninitialize();
|
||||
iResult = pPtrEnc->Uninitialize();
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
}
|
||||
|
||||
InitializeParamExt();
|
||||
pParamExt->iUsageType = (rand() % 2) ? SCREEN_CONTENT_REAL_TIME : CAMERA_VIDEO_REAL_TIME;
|
||||
pParamExt->iRCMode = (rand() % 2) ? RC_BITRATE_MODE : RC_QUALITY_MODE;
|
||||
|
||||
int iResult = pPtrEnc->InitializeExt (pParamExt);
|
||||
const int kiFrameNumber = TEST_FRAMES;
|
||||
|
||||
m_iWidth = pParamExt->iPicWidth;
|
||||
m_iHeight = pParamExt->iPicHeight;
|
||||
m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1;
|
||||
delete []pYUV;
|
||||
pYUV = new unsigned char [m_iPicResSize];
|
||||
ASSERT_TRUE (pYUV != NULL);
|
||||
PrepareOneSrcFrame();
|
||||
|
||||
ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT;
|
||||
memcpy (pOption, pParamExt, sizeof (SEncParamExt));
|
||||
|
||||
for(int i = 0; i < kiFrameNumber; i ++){
|
||||
if ((i%7) == 0){
|
||||
if (pOption->iTemporalLayerNum<4){
|
||||
pOption->iTemporalLayerNum++;
|
||||
} else {
|
||||
pOption->iTemporalLayerNum--;
|
||||
}
|
||||
iResult = pPtrEnc->SetOption (eOptionId, pOption);
|
||||
EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
|
||||
pSrcPic->uiTimeStamp += 30;
|
||||
}
|
||||
|
||||
int iStartX = rand() % (m_iPicResSize >> 1);
|
||||
int iEndX = (iStartX + (rand() % MEM_VARY_SIZE)) % m_iPicResSize;
|
||||
for (int j = iStartX; j < iEndX; j++)
|
||||
pYUV[j] = rand() % 256;
|
||||
|
||||
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
||||
EXPECT_EQ (iResult, static_cast<int32_t> (cmResultSuccess));
|
||||
pSrcPic->uiTimeStamp += 30;
|
||||
}
|
||||
|
||||
iResult = pPtrEnc->Uninitialize();
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
|
||||
}
|
||||
|
||||
TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) {
|
||||
TemporalLayerSettingTest();
|
||||
}
|
||||
|
||||
void EncoderInterfaceTest::MemoryCheckTest() {
|
||||
#define MEM_VARY_SIZE 1024
|
||||
#define IMAGE_VARY_SIZE 512
|
||||
#define TEST_FRAMES 500
|
||||
TEST_F (EncoderInterfaceTest, MemoryCheckTest) {
|
||||
|
||||
InitializeParamExt();
|
||||
pParamExt->iPicWidth = 1280;
|
||||
pParamExt->iPicHeight = 720;
|
||||
pParamExt->iTargetBitrate = 60000;
|
||||
pParamExt->sSpatialLayers[0].iVideoHeight = pParamExt->iPicHeight;
|
||||
pParamExt->sSpatialLayers[0].iVideoWidth = pParamExt->iPicWidth;
|
||||
pParamExt->sSpatialLayers[0].iSpatialBitrate = 50000;
|
||||
pParamExt->iTemporalLayerNum = 3;
|
||||
pParamExt->iSpatialLayerNum = 1;
|
||||
|
||||
int iResult = pPtrEnc->InitializeExt (pParamExt);
|
||||
const int kiFrameNumber = TEST_FRAMES;
|
||||
@ -261,11 +309,9 @@ void EncoderInterfaceTest::MemoryCheckTest() {
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
pSrcPic->uiTimeStamp += 30;
|
||||
}
|
||||
pPtrEnc->Uninitialize();
|
||||
}
|
||||
|
||||
TEST_F (EncoderInterfaceTest, MemoryCheck) {
|
||||
MemoryCheckTest();
|
||||
iResult = pPtrEnc->Uninitialize();
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
}
|
||||
|
||||
void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
|
||||
@ -498,11 +544,10 @@ TEST_F (EncoderInterfaceTest, EncodeParameterSets) {
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
||||
|
||||
pPtrEnc->Uninitialize();
|
||||
iResult = pPtrEnc->Uninitialize();
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
}
|
||||
|
||||
TEST_F (EncoderInterfaceTest, BasicReturnTypeTest) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user