2014-07-08 08:01:42 +02:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <stdlib.h>
|
2014-07-02 12:42:05 +02:00
|
|
|
#include "codec_api.h"
|
2014-07-11 07:50:58 +02:00
|
|
|
#include "codec_app_def.h"
|
|
|
|
//TODO: consider using BaseEncoderTest class from #include "../BaseEncoderTest.h"
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
class EncoderInterfaceTest : public ::testing::Test {
|
2014-07-11 07:50:58 +02:00
|
|
|
#define MB_SIZE (16)
|
|
|
|
#define MAX_WIDTH (3840)
|
|
|
|
#define MAX_HEIGHT (2160)
|
2014-07-02 12:42:05 +02:00
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
2014-07-11 07:50:58 +02:00
|
|
|
int rv = WelsCreateSVCEncoder (&pPtrEnc);
|
|
|
|
ASSERT_EQ (0, rv);
|
|
|
|
ASSERT_TRUE (pPtrEnc != NULL);
|
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
pParamExt = new SEncParamExt();
|
2014-07-11 07:50:58 +02:00
|
|
|
ASSERT_TRUE (pParamExt != NULL);
|
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
pSrcPic = new SSourcePicture;
|
2014-07-11 07:50:58 +02:00
|
|
|
ASSERT_TRUE (pSrcPic != NULL);
|
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
pOption = new SEncParamExt();
|
2014-07-11 07:50:58 +02:00
|
|
|
ASSERT_TRUE (pOption != NULL);
|
2014-07-02 12:42:05 +02:00
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
pYUV = NULL;
|
|
|
|
m_iWidth = MAX_WIDTH;
|
|
|
|
m_iHeight = MAX_HEIGHT;
|
2014-07-02 12:42:05 +02:00
|
|
|
m_iPicResSize = m_iWidth * m_iHeight * 3 >> 1;
|
2014-07-11 07:50:58 +02:00
|
|
|
pYUV = new unsigned char [m_iPicResSize];
|
|
|
|
ASSERT_TRUE (pYUV != NULL);
|
2014-07-02 12:42:05 +02:00
|
|
|
}
|
2014-07-11 07:50:58 +02:00
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
virtual void TearDown() {
|
|
|
|
delete pParamExt;
|
|
|
|
delete pOption;
|
|
|
|
delete pSrcPic;
|
|
|
|
delete []pYUV;
|
2014-07-11 07:50:58 +02:00
|
|
|
if (pPtrEnc) {
|
|
|
|
WelsDestroySVCEncoder (pPtrEnc);
|
|
|
|
pPtrEnc = NULL;
|
|
|
|
}
|
2014-07-02 12:42:05 +02:00
|
|
|
}
|
2014-07-11 07:50:58 +02:00
|
|
|
|
|
|
|
void TemporalLayerSettingTest();
|
|
|
|
void EncodeOneFrame (SEncParamBase* pEncParamBase);
|
|
|
|
void PrepareOneSrcFrame();
|
2014-07-14 09:30:01 +02:00
|
|
|
void EncodeOneIDRandP (ISVCEncoder* pPtrEnc);
|
2014-07-11 07:50:58 +02:00
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
public:
|
2014-07-11 07:50:58 +02:00
|
|
|
ISVCEncoder* pPtrEnc;
|
|
|
|
|
2014-07-02 12:42:05 +02:00
|
|
|
SEncParamExt* pParamExt;
|
|
|
|
SSourcePicture* pSrcPic;
|
|
|
|
SEncParamExt* pOption;
|
2014-07-11 07:50:58 +02:00
|
|
|
unsigned char* pYUV;
|
2014-07-02 12:42:05 +02:00
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
SFrameBSInfo sFbi;
|
2014-07-02 12:42:05 +02:00
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
int m_iWidth;
|
|
|
|
int m_iHeight;
|
|
|
|
int m_iPicResSize;
|
|
|
|
};
|
2014-07-02 12:42:05 +02:00
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
void EncoderInterfaceTest::PrepareOneSrcFrame() {
|
2014-07-02 12:42:05 +02:00
|
|
|
pSrcPic->iColorFormat = videoFormatI420;
|
|
|
|
pSrcPic->uiTimeStamp = 0;
|
|
|
|
pSrcPic->iPicWidth = pParamExt->iPicWidth;
|
|
|
|
pSrcPic->iPicHeight = pParamExt->iPicHeight;
|
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
for (int i = 0; i < m_iPicResSize; i++)
|
2014-07-02 12:42:05 +02:00
|
|
|
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);
|
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
//clean the output
|
2014-07-02 12:42:05 +02:00
|
|
|
memset (&sFbi, 0, sizeof (SFrameBSInfo));
|
2014-07-11 07:50:58 +02:00
|
|
|
}
|
2014-07-02 12:42:05 +02:00
|
|
|
|
2014-07-11 07:50:58 +02:00
|
|
|
void EncoderInterfaceTest::EncodeOneFrame (SEncParamBase* pEncParamBase) {
|
|
|
|
int iResult;
|
|
|
|
iResult = pPtrEnc->Initialize (pEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
PrepareOneSrcFrame();
|
2014-07-02 12:42:05 +02:00
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
|
|
|
|
|
|
|
iResult = pPtrEnc->GetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, pEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
|
|
|
|
pPtrEnc->Uninitialize();
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
}
|
|
|
|
|
2014-07-14 09:30:01 +02:00
|
|
|
void EncoderInterfaceTest::EncodeOneIDRandP (ISVCEncoder* pPtrEnc) {
|
|
|
|
int iResult;
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
2014-07-11 07:50:58 +02:00
|
|
|
|
2014-07-14 09:30:01 +02:00
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
|
|
|
}
|
2014-07-11 07:50:58 +02:00
|
|
|
|
|
|
|
void EncoderInterfaceTest::TemporalLayerSettingTest() {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
int iResult = pPtrEnc->InitializeExt (pParamExt);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
|
|
|
|
PrepareOneSrcFrame();
|
|
|
|
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
pSrcPic->uiTimeStamp = 30;
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
memcpy (pOption, pParamExt, sizeof (SEncParamExt));
|
|
|
|
pOption ->iTemporalLayerNum = 4;
|
|
|
|
|
|
|
|
ENCODER_OPTION eOptionId = ENCODER_OPTION_SVC_ENCODE_PARAM_EXT;
|
|
|
|
iResult = pPtrEnc->SetOption (eOptionId, pOption);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
pSrcPic->uiTimeStamp = 60;
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
pOption ->iTemporalLayerNum = 2;
|
|
|
|
iResult = pPtrEnc->SetOption (eOptionId, pOption);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
2014-07-02 12:42:05 +02:00
|
|
|
pSrcPic->uiTimeStamp = 90;
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
pOption ->iTemporalLayerNum = 4;
|
|
|
|
iResult = pPtrEnc->SetOption (eOptionId, pOption);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
2014-07-02 12:42:05 +02:00
|
|
|
pSrcPic->uiTimeStamp = 120;
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
2014-07-11 07:50:58 +02:00
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP));
|
2014-07-02 12:42:05 +02:00
|
|
|
|
|
|
|
pPtrEnc->Uninitialize();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) {
|
|
|
|
TemporalLayerSettingTest();
|
2014-07-08 08:01:42 +02:00
|
|
|
}
|
2014-07-11 07:50:58 +02:00
|
|
|
|
|
|
|
void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
|
|
|
|
pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
|
2014-07-14 09:30:01 +02:00
|
|
|
pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1);
|
|
|
|
pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1);
|
2014-07-11 07:50:58 +02:00
|
|
|
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
|
|
|
|
pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
|
|
|
|
pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, BasicInitializeTest) {
|
|
|
|
SEncParamBase sEncParamBase;
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
|
|
|
|
int iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
if (iResult != cmResultSuccess) {
|
|
|
|
fprintf (stderr, "Unexpected ParamBase? \
|
2014-07-14 09:30:01 +02:00
|
|
|
iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n",
|
2014-07-11 07:50:58 +02:00
|
|
|
sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight,
|
|
|
|
sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
PrepareOneSrcFrame();
|
|
|
|
|
|
|
|
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
|
|
|
|
|
|
|
|
pPtrEnc->Uninitialize();
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, BasicInitializeTestFalse) {
|
|
|
|
int iResult;
|
|
|
|
SEncParamBase sEncParamBase;
|
|
|
|
|
|
|
|
//iUsageType
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iUsageType = static_cast<EUsageType> (2);
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//iPicWidth
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iPicWidth = 0;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iPicWidth = -1;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//TODO: add checking max in interface and then enable this checking
|
|
|
|
//GetValidEncParamBase(&sEncParamBase);
|
|
|
|
//sEncParamBase.iPicWidth = rand()+(MAX_WIDTH+1);
|
|
|
|
//iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
//EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//iPicHeight
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iPicHeight = 0;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iPicHeight = -1;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//TODO: add checking max in interface and then enable this checking
|
|
|
|
//GetValidEncParamBase(&sEncParamBase);
|
|
|
|
//sEncParamBase.iPicWidth = rand()+(MAX_HEIGHT+1);
|
|
|
|
//iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
//EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//iTargetBitrate
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iTargetBitrate = 0;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iTargetBitrate = -1;
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
|
|
|
|
//iUsageType
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.iRCMode = static_cast<RC_MODES> (3);
|
|
|
|
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) {
|
|
|
|
SEncParamBase sEncParamBase;
|
|
|
|
|
|
|
|
// large fMaxFrameRate
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.fMaxFrameRate = 50000;
|
|
|
|
EncodeOneFrame (&sEncParamBase);
|
|
|
|
EXPECT_LE (sEncParamBase.fMaxFrameRate, 30.0);
|
|
|
|
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
|
|
|
|
|
|
|
|
// fMaxFrameRate = 0
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.fMaxFrameRate = 0;
|
|
|
|
EncodeOneFrame (&sEncParamBase);
|
|
|
|
EXPECT_LE (sEncParamBase.fMaxFrameRate, 30.0);
|
|
|
|
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
|
|
|
|
|
|
|
|
// fMaxFrameRate = -1
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
sEncParamBase.fMaxFrameRate = -1;
|
|
|
|
EncodeOneFrame (&sEncParamBase);
|
|
|
|
EXPECT_LE (sEncParamBase.fMaxFrameRate, 30.0);
|
|
|
|
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
|
|
|
|
}
|
2014-07-14 09:30:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, ForceIntraFrame) {
|
|
|
|
SEncParamBase sEncParamBase;
|
|
|
|
GetValidEncParamBase (&sEncParamBase);
|
|
|
|
|
|
|
|
int iResult = pPtrEnc->Initialize (&sEncParamBase);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
if (iResult != cmResultSuccess) {
|
|
|
|
fprintf (stderr, "Unexpected ParamBase? \
|
|
|
|
iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n",
|
|
|
|
sEncParamBase.iUsageType, sEncParamBase.iPicWidth, sEncParamBase.iPicHeight,
|
|
|
|
sEncParamBase.iTargetBitrate, sEncParamBase.iRCMode, sEncParamBase.fMaxFrameRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
PrepareOneSrcFrame();
|
|
|
|
|
|
|
|
bool bIDR = true;
|
|
|
|
pPtrEnc->ForceIntraFrame (bIDR);
|
|
|
|
EncodeOneIDRandP (pPtrEnc);
|
|
|
|
|
|
|
|
//call next frame to be IDR
|
|
|
|
pPtrEnc->ForceIntraFrame (bIDR);
|
|
|
|
EncodeOneIDRandP (pPtrEnc);
|
|
|
|
|
|
|
|
pPtrEnc->Uninitialize();
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) {
|
|
|
|
SEncParamExt sEncParamExt;
|
|
|
|
pPtrEnc->GetDefaultParams (&sEncParamExt);
|
|
|
|
sEncParamExt.iUsageType = CAMERA_VIDEO_REAL_TIME;
|
|
|
|
sEncParamExt.iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1);
|
|
|
|
sEncParamExt.iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1);
|
|
|
|
sEncParamExt.iTargetBitrate = rand() + 1; //!=0
|
|
|
|
sEncParamExt.iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
|
|
|
|
sEncParamExt.fMaxFrameRate = rand() + 0.5f; //!=0
|
|
|
|
sEncParamExt.sSpatialLayers[0].iVideoWidth = sEncParamExt.iPicWidth;
|
|
|
|
sEncParamExt.sSpatialLayers[0].iVideoHeight = sEncParamExt.iPicHeight;
|
|
|
|
sEncParamExt.sSpatialLayers[0].iSpatialBitrate = sEncParamExt.iTargetBitrate;
|
|
|
|
|
|
|
|
int iTargetTemporalLayerNum = rand() % MAX_TEMPORAL_LAYER_NUM;
|
|
|
|
sEncParamExt.iTemporalLayerNum = (iTargetTemporalLayerNum > 2) ? iTargetTemporalLayerNum : 2;
|
|
|
|
|
|
|
|
int iResult = pPtrEnc->InitializeExt (&sEncParamExt);
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
if (iResult != cmResultSuccess) {
|
|
|
|
fprintf (stderr, "Unexpected ParamBase? \
|
|
|
|
iUsageType=%d, Pic=%dx%d, TargetBitrate=%d, iRCMode=%d, fMaxFrameRate=%.1f\n",
|
|
|
|
sEncParamExt.iUsageType, sEncParamExt.iPicWidth, sEncParamExt.iPicHeight,
|
|
|
|
sEncParamExt.iTargetBitrate, sEncParamExt.iRCMode, sEncParamExt.fMaxFrameRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
PrepareOneSrcFrame();
|
|
|
|
|
|
|
|
bool bIDR = true;
|
|
|
|
EncodeOneIDRandP (pPtrEnc);
|
|
|
|
|
|
|
|
//call next frame to be IDR
|
|
|
|
pPtrEnc->ForceIntraFrame (bIDR);
|
|
|
|
EncodeOneIDRandP (pPtrEnc);
|
|
|
|
|
|
|
|
pPtrEnc->Uninitialize();
|
|
|
|
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
|
|
|
}
|
|
|
|
|