Merge pull request #1169 from sijchen/interfaceUT12
[Encoder UT] Interface: EncoderEncodeParameterSets
This commit is contained in:
commit
010e423b2b
@ -2911,6 +2911,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
|
|||||||
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
|
pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen;
|
||||||
InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
|
InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
|
||||||
|
|
||||||
|
pCtx->iPosBsBuffer = 0;
|
||||||
int32_t iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal);
|
int32_t iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal);
|
||||||
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
|
||||||
|
|
||||||
@ -2922,6 +2923,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
|
|||||||
|
|
||||||
pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
|
pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
|
||||||
pFbi->iLayerNum = 1;
|
pFbi->iLayerNum = 1;
|
||||||
|
pFbi->eFrameType = videoFrameTypeInvalid;
|
||||||
|
|
||||||
WelsEmms();
|
WelsEmms();
|
||||||
|
|
||||||
|
@ -8,6 +8,16 @@ class EncoderInterfaceTest : public ::testing::Test {
|
|||||||
#define MB_SIZE (16)
|
#define MB_SIZE (16)
|
||||||
#define MAX_WIDTH (3840)
|
#define MAX_WIDTH (3840)
|
||||||
#define MAX_HEIGHT (2160)
|
#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:
|
public:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
int rv = WelsCreateSVCEncoder (&pPtrEnc);
|
int rv = WelsCreateSVCEncoder (&pPtrEnc);
|
||||||
@ -172,8 +182,10 @@ TEST_F (EncoderInterfaceTest, TestTemporalLayerSetting) {
|
|||||||
|
|
||||||
void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
|
void GetValidEncParamBase (SEncParamBase* pEncParamBase) {
|
||||||
pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
|
pEncParamBase->iUsageType = CAMERA_VIDEO_REAL_TIME;
|
||||||
pEncParamBase->iPicWidth = abs ((rand() * 2) + MB_SIZE) % (MAX_WIDTH + 1);
|
pEncParamBase->iPicWidth = ((rand() * 2) % (MAX_WIDTH));
|
||||||
pEncParamBase->iPicHeight = abs ((rand() * 2) + MB_SIZE) % (MAX_HEIGHT + 1);
|
pEncParamBase->iPicHeight = ((rand() * 2) % (MAX_HEIGHT));
|
||||||
|
pEncParamBase->iPicWidth = VALID_SIZE(pEncParamBase->iPicWidth);
|
||||||
|
pEncParamBase->iPicHeight = VALID_SIZE(pEncParamBase->iPicHeight);
|
||||||
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
|
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
|
||||||
pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
|
pEncParamBase->iRCMode = RC_BITRATE_MODE; //-1, 0, 1, 2
|
||||||
pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
|
pEncParamBase->fMaxFrameRate = rand() + 0.5f; //!=0
|
||||||
@ -293,7 +305,6 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestAutoAdjustment) {
|
|||||||
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
|
EXPECT_GE (sEncParamBase.fMaxFrameRate, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F (EncoderInterfaceTest, ForceIntraFrame) {
|
TEST_F (EncoderInterfaceTest, ForceIntraFrame) {
|
||||||
SEncParamBase sEncParamBase;
|
SEncParamBase sEncParamBase;
|
||||||
GetValidEncParamBase (&sEncParamBase);
|
GetValidEncParamBase (&sEncParamBase);
|
||||||
@ -359,3 +370,51 @@ TEST_F (EncoderInterfaceTest, ForceIntraFrameWithTemporal) {
|
|||||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user