Fix the decoder init failed case in UT
This commit is contained in:
parent
25f53a2e3d
commit
46f42ec5f3
@ -28,7 +28,7 @@ class BaseDecoderTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
BaseDecoderTest();
|
BaseDecoderTest();
|
||||||
void SetUp();
|
int32_t SetUp();
|
||||||
void TearDown();
|
void TearDown();
|
||||||
void DecodeFile (const char* fileName, Callback* cbk);
|
void DecodeFile (const char* fileName, Callback* cbk);
|
||||||
|
|
||||||
|
@ -46,10 +46,13 @@ static void ReadFrame (std::ifstream* file, BufferedData* buf) {
|
|||||||
BaseDecoderTest::BaseDecoderTest()
|
BaseDecoderTest::BaseDecoderTest()
|
||||||
: decoder_ (NULL), decodeStatus_ (OpenFile) {}
|
: decoder_ (NULL), decodeStatus_ (OpenFile) {}
|
||||||
|
|
||||||
void BaseDecoderTest::SetUp() {
|
int32_t BaseDecoderTest::SetUp() {
|
||||||
long rv = WelsCreateDecoder (&decoder_);
|
long rv = WelsCreateDecoder (&decoder_);
|
||||||
ASSERT_EQ (0, rv);
|
EXPECT_EQ (0, rv);
|
||||||
ASSERT_TRUE (decoder_ != NULL);
|
EXPECT_TRUE (decoder_ != NULL);
|
||||||
|
if (decoder_ == NULL) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
SDecodingParam decParam;
|
SDecodingParam decParam;
|
||||||
memset (&decParam, 0, sizeof (SDecodingParam));
|
memset (&decParam, 0, sizeof (SDecodingParam));
|
||||||
@ -58,7 +61,8 @@ void BaseDecoderTest::SetUp() {
|
|||||||
decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
||||||
|
|
||||||
rv = decoder_->Initialize (&decParam);
|
rv = decoder_->Initialize (&decParam);
|
||||||
ASSERT_EQ (0, rv);
|
EXPECT_EQ (0, rv);
|
||||||
|
return (int32_t)rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseDecoderTest::TearDown() {
|
void BaseDecoderTest::TearDown() {
|
||||||
|
@ -766,6 +766,13 @@ const char* pHashStr[] = { //DO NOT CHANGE!
|
|||||||
|
|
||||||
class DecodeParseAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase>, public EncodeDecodeTestBase {
|
class DecodeParseAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase>, public EncodeDecodeTestBase {
|
||||||
public:
|
public:
|
||||||
|
DecodeParseAPI() {
|
||||||
|
memset (&BsInfo_, 0, sizeof (SParserBsInfo));
|
||||||
|
fYuv_ = NULL;
|
||||||
|
iWidth_ = 0;
|
||||||
|
iHeight_ = 0;
|
||||||
|
memset (&ctx_, 0, sizeof (SHA1Context));
|
||||||
|
}
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
SHA1Reset (&ctx_);
|
SHA1Reset (&ctx_);
|
||||||
EncodeDecodeTestBase::SetUp();
|
EncodeDecodeTestBase::SetUp();
|
||||||
@ -789,7 +796,9 @@ class DecodeParseAPI : public ::testing::TestWithParam<EncodeDecodeFileParamBase
|
|||||||
}
|
}
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
EncodeDecodeTestBase::TearDown();
|
EncodeDecodeTestBase::TearDown();
|
||||||
fclose (fYuv_);
|
if (fYuv_ != NULL) {
|
||||||
|
fclose (fYuv_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareEncDecParam (const EncodeDecodeFileParamBase p) {
|
void prepareEncDecParam (const EncodeDecodeFileParamBase p) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "codec_def.h"
|
#include "codec_def.h"
|
||||||
#include "codec_app_def.h"
|
#include "codec_app_def.h"
|
||||||
#include "codec_api.h"
|
#include "codec_api.h"
|
||||||
|
#include "error_code.h"
|
||||||
#include "wels_common_basis.h"
|
#include "wels_common_basis.h"
|
||||||
#include "memory_align.h"
|
#include "memory_align.h"
|
||||||
#include "ls_defines.h"
|
#include "ls_defines.h"
|
||||||
@ -25,9 +26,9 @@ class DecoderInterfaceTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Init members
|
//Init members
|
||||||
void Init();
|
int32_t Init();
|
||||||
//Init valid members
|
//Init valid members
|
||||||
void ValidInit();
|
int32_t ValidInit();
|
||||||
//Uninit members
|
//Uninit members
|
||||||
void Uninit();
|
void Uninit();
|
||||||
//Mock input data for test
|
//Mock input data for test
|
||||||
@ -77,7 +78,7 @@ class DecoderInterfaceTest : public ::testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Init members
|
//Init members
|
||||||
void DecoderInterfaceTest::Init() {
|
int32_t DecoderInterfaceTest::Init() {
|
||||||
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
||||||
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
|
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
|
||||||
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
||||||
@ -93,10 +94,11 @@ void DecoderInterfaceTest::Init() {
|
|||||||
m_szBuffer[3] = 1;
|
m_szBuffer[3] = 1;
|
||||||
m_iBufLength = 4;
|
m_iBufLength = 4;
|
||||||
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
|
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
|
||||||
ASSERT_EQ (eRet, cmResultSuccess);
|
EXPECT_EQ (eRet, cmResultSuccess);
|
||||||
|
return (int32_t)eRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecoderInterfaceTest::ValidInit() {
|
int32_t DecoderInterfaceTest::ValidInit() {
|
||||||
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
||||||
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
||||||
m_sDecParam.pFileNameRestructed = NULL;
|
m_sDecParam.pFileNameRestructed = NULL;
|
||||||
@ -111,7 +113,8 @@ void DecoderInterfaceTest::ValidInit() {
|
|||||||
m_szBuffer[3] = 1;
|
m_szBuffer[3] = 1;
|
||||||
m_iBufLength = 4;
|
m_iBufLength = 4;
|
||||||
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
|
CM_RETURN eRet = (CM_RETURN) m_pDec->Initialize (&m_sDecParam);
|
||||||
ASSERT_EQ (eRet, cmResultSuccess);
|
EXPECT_EQ (eRet, cmResultSuccess);
|
||||||
|
return (int32_t)eRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecoderInterfaceTest::Uninit() {
|
void DecoderInterfaceTest::Uninit() {
|
||||||
@ -220,6 +223,7 @@ void DecoderInterfaceTest::MockPacketType (const EWelsNalUnitType eNalUnitType,
|
|||||||
void DecoderInterfaceTest::TestInitUninit() {
|
void DecoderInterfaceTest::TestInitUninit() {
|
||||||
int iOutput;
|
int iOutput;
|
||||||
CM_RETURN eRet;
|
CM_RETURN eRet;
|
||||||
|
int32_t iRet = ERR_NONE;
|
||||||
//No initialize, no GetOption can be done
|
//No initialize, no GetOption can be done
|
||||||
m_pDec->Uninitialize();
|
m_pDec->Uninitialize();
|
||||||
for (int i = 0; i <= (int) DECODER_OPTION_TRACE_CALLBACK_CONTEXT; ++i) {
|
for (int i = 0; i <= (int) DECODER_OPTION_TRACE_CALLBACK_CONTEXT; ++i) {
|
||||||
@ -227,9 +231,13 @@ void DecoderInterfaceTest::TestInitUninit() {
|
|||||||
EXPECT_EQ (eRet, cmInitExpected);
|
EXPECT_EQ (eRet, cmInitExpected);
|
||||||
}
|
}
|
||||||
//Initialize first, can get input color format
|
//Initialize first, can get input color format
|
||||||
Init();
|
iRet = Init();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
m_sDecParam.bParseOnly = false;
|
m_sDecParam.bParseOnly = false;
|
||||||
m_pDec->Initialize (&m_sDecParam);
|
eRet = (CM_RETURN)m_pDec->Initialize (&m_sDecParam);
|
||||||
|
ASSERT_EQ (eRet, cmResultSuccess);
|
||||||
|
|
||||||
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOutput);
|
eRet = (CM_RETURN) m_pDec->GetOption (DECODER_OPTION_END_OF_STREAM, &iOutput);
|
||||||
EXPECT_EQ (eRet, cmResultSuccess);
|
EXPECT_EQ (eRet, cmResultSuccess);
|
||||||
EXPECT_EQ (iOutput, 0);
|
EXPECT_EQ (iOutput, 0);
|
||||||
@ -329,8 +337,10 @@ void DecoderInterfaceTest::TestParseOnlyAPI() {
|
|||||||
void DecoderInterfaceTest::TestEndOfStream() {
|
void DecoderInterfaceTest::TestEndOfStream() {
|
||||||
int iTmp, iOut;
|
int iTmp, iOut;
|
||||||
CM_RETURN eRet;
|
CM_RETURN eRet;
|
||||||
|
int32_t iRet = ERR_NONE;
|
||||||
|
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
//invalid input
|
//invalid input
|
||||||
eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, NULL);
|
eRet = (CM_RETURN) m_pDec->SetOption (DECODER_OPTION_END_OF_STREAM, NULL);
|
||||||
@ -391,8 +401,10 @@ void DecoderInterfaceTest::TestEndOfStream() {
|
|||||||
void DecoderInterfaceTest::TestVclNal() {
|
void DecoderInterfaceTest::TestVclNal() {
|
||||||
int iTmp, iOut;
|
int iTmp, iOut;
|
||||||
CM_RETURN eRet;
|
CM_RETURN eRet;
|
||||||
|
int32_t iRet = ERR_NONE;
|
||||||
|
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
//Test SetOption
|
//Test SetOption
|
||||||
//VclNal never supports SetOption
|
//VclNal never supports SetOption
|
||||||
@ -453,8 +465,10 @@ void DecoderInterfaceTest::TestLtrMarkedFrameNum() {
|
|||||||
void DecoderInterfaceTest::TestErrorConIdc() {
|
void DecoderInterfaceTest::TestErrorConIdc() {
|
||||||
int iTmp, iOut;
|
int iTmp, iOut;
|
||||||
CM_RETURN eRet;
|
CM_RETURN eRet;
|
||||||
|
int32_t iRet = ERR_NONE;
|
||||||
|
|
||||||
Init();
|
iRet = Init();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
//Test GetOption
|
//Test GetOption
|
||||||
//invalid input
|
//invalid input
|
||||||
@ -498,10 +512,12 @@ void DecoderInterfaceTest::TestTraceCallbackContext() {
|
|||||||
//DECODER_OPTION_GET_STATISTICS
|
//DECODER_OPTION_GET_STATISTICS
|
||||||
void DecoderInterfaceTest::TestGetDecStatistics() {
|
void DecoderInterfaceTest::TestGetDecStatistics() {
|
||||||
CM_RETURN eRet;
|
CM_RETURN eRet;
|
||||||
|
int32_t iRet;
|
||||||
SDecoderStatistics sDecStatic;
|
SDecoderStatistics sDecStatic;
|
||||||
int32_t iError = 0;
|
int32_t iError = 0;
|
||||||
|
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
//GetOption before decoding
|
//GetOption before decoding
|
||||||
m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic);
|
m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic);
|
||||||
EXPECT_EQ (0u, sDecStatic.uiDecodedFrameCount);
|
EXPECT_EQ (0u, sDecStatic.uiDecodedFrameCount);
|
||||||
@ -528,7 +544,8 @@ void DecoderInterfaceTest::TestGetDecStatistics() {
|
|||||||
Uninit();
|
Uninit();
|
||||||
|
|
||||||
//Decoder error bs when the first IDR lost
|
//Decoder error bs when the first IDR lost
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
iError = 2;
|
iError = 2;
|
||||||
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
||||||
DecoderBs ("res/BA_MW_D_IDR_LOST.264");
|
DecoderBs ("res/BA_MW_D_IDR_LOST.264");
|
||||||
@ -546,7 +563,9 @@ void DecoderInterfaceTest::TestGetDecStatistics() {
|
|||||||
Uninit();
|
Uninit();
|
||||||
|
|
||||||
//ecoder error bs when the first P lost
|
//ecoder error bs when the first P lost
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
iError = 2;
|
iError = 2;
|
||||||
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
||||||
|
|
||||||
@ -567,7 +586,9 @@ void DecoderInterfaceTest::TestGetDecStatistics() {
|
|||||||
//EC enable
|
//EC enable
|
||||||
|
|
||||||
//EC Off UT just correc bitstream
|
//EC Off UT just correc bitstream
|
||||||
ValidInit();
|
iRet = ValidInit();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
|
|
||||||
iError = 0;
|
iError = 0;
|
||||||
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
m_pDec->SetOption (DECODER_OPTION_ERROR_CON_IDC, &iError);
|
||||||
DecoderBs ("res/test_vd_1d.264");
|
DecoderBs ("res/test_vd_1d.264");
|
||||||
|
@ -128,7 +128,7 @@ class DecoderParseSyntaxTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Init members
|
//Init members
|
||||||
void Init();
|
int32_t Init();
|
||||||
//Uninit members
|
//Uninit members
|
||||||
void Uninit();
|
void Uninit();
|
||||||
//Decoder real bitstream
|
//Decoder real bitstream
|
||||||
@ -155,7 +155,7 @@ class DecoderParseSyntaxTest : public ::testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Init members
|
//Init members
|
||||||
void DecoderParseSyntaxTest::Init() {
|
int32_t DecoderParseSyntaxTest::Init() {
|
||||||
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
|
||||||
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
|
||||||
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
|
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
|
||||||
@ -180,7 +180,7 @@ void DecoderParseSyntaxTest::Init() {
|
|||||||
m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
|
m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
|
||||||
}
|
}
|
||||||
CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);
|
CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);
|
||||||
(void) eRet;
|
return (int32_t)eRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecoderParseSyntaxTest::Uninit() {
|
void DecoderParseSyntaxTest::Uninit() {
|
||||||
@ -262,7 +262,9 @@ void DecoderParseSyntaxTest::TestScalingList() {
|
|||||||
uint8_t iScalingListPPS[6][16];
|
uint8_t iScalingListPPS[6][16];
|
||||||
memset (iScalingListPPS, 0, 6 * 16 * sizeof (uint8_t));
|
memset (iScalingListPPS, 0, 6 * 16 * sizeof (uint8_t));
|
||||||
//Scalinglist matrix not written into sps or pps
|
//Scalinglist matrix not written into sps or pps
|
||||||
Init();
|
int32_t iRet = ERR_NONE;
|
||||||
|
iRet = Init();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
DecodeBs ("res/BA_MW_D.264");
|
DecodeBs ("res/BA_MW_D.264");
|
||||||
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
|
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
|
||||||
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
||||||
@ -270,7 +272,8 @@ void DecoderParseSyntaxTest::TestScalingList() {
|
|||||||
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
||||||
Uninit();
|
Uninit();
|
||||||
//Scalinglist value just written into sps and pps
|
//Scalinglist value just written into sps and pps
|
||||||
Init();
|
iRet = Init();
|
||||||
|
ASSERT_EQ (iRet, ERR_NONE);
|
||||||
DecodeBs ("res/test_scalinglist_jm.264");
|
DecodeBs ("res/test_scalinglist_jm.264");
|
||||||
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
|
ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
@ -280,8 +283,6 @@ void DecoderParseSyntaxTest::TestScalingList() {
|
|||||||
ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
|
ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
|
||||||
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
EXPECT_EQ (0, memcmp (iScalingListPPS, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
|
||||||
Uninit();
|
Uninit();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TEST here for whole tests
|
//TEST here for whole tests
|
||||||
|
Loading…
x
Reference in New Issue
Block a user