add interface UT for WelsEncoderEncodeParameterSets

and fix previous value
This commit is contained in:
Sijia Chen 2014-07-14 18:36:35 +08:00
parent 3a37586970
commit b669801e89
2 changed files with 64 additions and 3 deletions

View File

@ -2911,6 +2911,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
pCtx->iPosBsBuffer = 0;
int32_t iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal);
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
@ -2922,6 +2923,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
pFbi->iLayerNum = 1;
pFbi->eFrameType = videoFrameTypeInvalid;
WelsEmms();

View File

@ -8,6 +8,16 @@ class EncoderInterfaceTest : public ::testing::Test {
#define MB_SIZE (16)
#define MAX_WIDTH (3840)
#define MAX_HEIGHT (2160)
#define VALID_SIZE(iSize) (((iSize)>1)?(iSize):1)
#define NAL_HEADER_BYTES (4)
#define NAL_TYPE (0x0F)
#define SPS_NAL_TYPE (7)
#define PPS_NAL_TYPE (8)
#define SUBSETSPS_NAL_TYPE (15)
#define GET_NAL_TYPE(pNalStart) (*(pNalStart+NAL_HEADER_BYTES) & NAL_TYPE)
#define IS_PARASET(iNalType) ((iNalType==SPS_NAL_TYPE) || (iNalType==PPS_NAL_TYPE) || (iNalType==SUBSETSPS_NAL_TYPE))
public:
virtual void SetUp() {
int rv = WelsCreateSVCEncoder (&pPtrEnc);
@ -172,8 +182,10 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) {
void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1);
pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1);
pEncParamBase->iPicWidth = ((rand() * 2) % (MAX_WIDTH));
pEncParamBase->iPicHeight = ((rand() * 2) % (MAX_HEIGHT));
pEncParamBase->iPicWidth = VALID_SIZE(pEncParamBase->iPicWidth);
pEncParamBase->iPicHeight = VALID_SIZE(pEncParamBase->iPicHeight);
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
@ -288,7 +300,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) {
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
}
TEST_F (EncoderInterfaceTest, ForceIntraFrame) {
SEncParamBase sEncParamBase;
GetValidEncParamBase (&sEncParamBase);
@ -354,3 +365,51 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) {
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
}
TEST_F (EncoderInterfaceTest, EncodeParameterSets) {
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();
EncodeOneIDRandP (pPtrEnc);
//try EncodeParameterSets
pPtrEnc->EncodeParameterSets (&sFbi);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeInvalid));
//check the result
int iNalType = 0;
SLayerBSInfo* pLayerBsInfo;
for (int i = 0; i < sFbi.iLayerNum; i++) {
pLayerBsInfo = & (sFbi.sLayerInfo[i]);
EXPECT_EQ (pLayerBsInfo->uiLayerType , static_cast<int> (NON_VIDEO_CODING_LAYER));
iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf);
EXPECT_EQ (true, IS_PARASET (iNalType));
for (int j = 0; j < (pLayerBsInfo->iNalCount - 1); j++) {
iNalType = GET_NAL_TYPE (pLayerBsInfo->pBsBuf + pLayerBsInfo->pNalLengthInByte[j]);
EXPECT_EQ (true, IS_PARASET (iNalType));
}
}
//try another P to make sure no impact on succeeding frames
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
pPtrEnc->Uninitialize();
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
}
TEST_F (EncoderInterfaceTest, BasicReturnTypeTest) {
//TODO
}