Showing the changes to test/decoder/DecUT_DecExt.cpp (1 of 2 files). Show all
Unified · Split
| @@ -34,6 +34,8 @@ class DecoderInterfaceTest : public ::testing::Test { · 33 unmodified lines | |||
| 34 | void DecoderBs (const char* sFileName); | 34 | void DecoderBs (const char* sFileName); |
| 35 | //Test Initialize/Uninitialize | 35 | //Test Initialize/Uninitialize |
| 36 | void TestInitUninit(); | 36 | void TestInitUninit(); |
| 37 | //Test parse only API | ||
| 38 | void TestParseOnlyAPI(); | ||
| 37 | //DECODER_OPTION_END_OF_STREAM | 39 | //DECODER_OPTION_END_OF_STREAM |
| 38 | void TestEndOfStream(); | 40 | void TestEndOfStream(); |
| 39 | //DECODER_OPTION_VCL_NAL | 41 | //DECODER_OPTION_VCL_NAL |
| @@ -66,6 +68,7 @@ class DecoderInterfaceTest : public ::testing::Test { · 26 unmodified lines | |||
| 66 | ISVCDecoder* m_pDec; | 68 | ISVCDecoder* m_pDec; |
| 67 | SDecodingParam m_sDecParam; | 69 | SDecodingParam m_sDecParam; |
| 68 | SBufferInfo m_sBufferInfo; | 70 | SBufferInfo m_sBufferInfo; |
| 71 | SParserBsInfo m_sParserBsInfo; | ||
| 69 | uint8_t* m_pData[3]; | 72 | uint8_t* m_pData[3]; |
| 70 | unsigned char m_szBuffer[BUF_SIZE]; //for mocking packet | 73 | unsigned char m_szBuffer[BUF_SIZE]; //for mocking packet |
| 71 | int m_iBufLength; //record the valid data in m_szBuffer | 74 | int m_iBufLength; //record the valid data in m_szBuffer |
| @@ -74,6 +77,7 @@ class DecoderInterfaceTest : public ::testing::Test { · 2 unmodified lines | |||
| 74 | //Init members | 77 | //Init members |
| 75 | void DecoderInterfaceTest::Init() { | 78 | void DecoderInterfaceTest::Init() { |
| 76 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); | 79 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); |
| 80 | memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); | ||
| 77 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); | 81 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); |
| 78 | m_sDecParam.pFileNameRestructed = NULL; | 82 | m_sDecParam.pFileNameRestructed = NULL; |
| 79 | m_sDecParam.uiCpuLoad = rand() % 100; | 83 | m_sDecParam.uiCpuLoad = rand() % 100; |
| @@ -96,6 +100,7 @@ void DecoderInterfaceTest::Uninit() { · 16 unmodified lines | |||
| 96 | ASSERT_EQ (eRet, cmResultSuccess); | 100 | ASSERT_EQ (eRet, cmResultSuccess); |
| 97 | } | 101 | } |
| 98 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); | 102 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); |
| 103 | memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); | ||
| 99 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); | 104 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); |
| 100 | m_pData[0] = m_pData[1] = m_pData[2] = NULL; | 105 | m_pData[0] = m_pData[1] = m_pData[2] = NULL; |
| 101 | m_iBufLength = 0; | 106 | m_iBufLength = 0; |
| @@ -180,16 +185,15 @@ void DecoderInterfaceTest::MockPacketType (const EWelsNalUnitType eNalUnitType, · 78 unmodified lines | |||
| 180 | default: | 185 | default: |
| 181 | m_szBuffer[m_iBufLength++] = 0; //NAL_UNIT_UNSPEC_0 | 186 | m_szBuffer[m_iBufLength++] = 0; //NAL_UNIT_UNSPEC_0 |
| 182 | break; | 187 | break; |
| 183 | |||
| 184 | int iAddLength = iPacketLength - 5; //excluding 0001 and type | ||
| 185 | if (iAddLength > PAYLOAD_SIZE) | ||
| 186 | iAddLength = PAYLOAD_SIZE; | ||
| 187 | for (int i = 0; i < iAddLength; ++i) { | ||
| 188 | m_szBuffer[m_iBufLength++] = rand() % 256; | ||
| 189 | } | ||
| 190 | m_szBuffer[m_iBufLength++] = '\0'; | ||
| 191 | |||
| 192 | } | 188 | } |
| 189 | int iAddLength = iPacketLength - 5; //excluding 0001 and type | ||
| 190 | if (iAddLength > PAYLOAD_SIZE) | ||
| 191 | iAddLength = PAYLOAD_SIZE; | ||
| 192 | for (int i = 0; i < iAddLength; ++i) { | ||
| 193 | m_szBuffer[m_iBufLength++] = rand() % 256; | ||
| 194 | } | ||
| 195 | m_szBuffer[m_iBufLength++] = '\0'; | ||
| 196 | |||
| 193 | } | 197 | } |
| 194 | 198 | ||
| 195 | //Test Initialize/Uninitialize | 199 | //Test Initialize/Uninitialize |
| @@ -220,6 +224,87 @@ void DecoderInterfaceTest::TestInitUninit() { · 24 unmodified lines | |||
| 220 | } | 224 | } |
| 221 | } | 225 | } |
| 222 | 226 | ||
| 227 | //Test parse only API | ||
| 228 | void DecoderInterfaceTest::TestParseOnlyAPI() { | ||
| 229 | int iOutput; | ||
| 230 | int iRet; | ||
| 231 | |||
| 232 | m_pData[0] = m_pData[1] = m_pData[2] = NULL; | ||
| 233 | m_szBuffer[0] = m_szBuffer[1] = m_szBuffer[2] = 0; | ||
| 234 | m_szBuffer[3] = 1; | ||
| 235 | m_iBufLength = 4; | ||
| 236 | MockPacketType (NAL_UNIT_SPS, 12); | ||
| 237 | |||
| 238 | m_pDec->Uninitialize(); | ||
| 239 | |||
| 240 | //test 1: bParseOnly = true; eEcActiveIdc = 0,1 | ||
| 241 | for (int iNum = 0; iNum < 2; ++iNum) { //loop for EC | ||
| 242 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); | ||
| 243 | memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); | ||
| 244 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); | ||
| 245 | m_sDecParam.pFileNameRestructed = NULL; | ||
| 246 | m_sDecParam.uiCpuLoad = rand() % 100; | ||
| 247 | m_sDecParam.uiTargetDqLayer = -1; | ||
| 248 | m_sDecParam.bParseOnly = true; | ||
| 249 | m_sDecParam.eEcActiveIdc = (ERROR_CON_IDC) iNum; | ||
| 250 | m_sDecParam.sVideoProperty.size = sizeof (SVideoProperty); | ||
| 251 | m_sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE) (rand() % 3); | ||
| 252 | |||
| 253 | iRet = m_pDec->Initialize (&m_sDecParam); | ||
| 254 | ASSERT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 255 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 256 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 257 | EXPECT_EQ (iOutput, (int32_t) ERROR_CON_DISABLE); //should be 0 | ||
| 258 | //call DecodeParser(), correct call | ||
| 259 | iRet = (int32_t) m_pDec->DecodeParser (m_szBuffer, m_iBufLength, &m_sParserBsInfo); | ||
| 260 | EXPECT_EQ (iRet, (int32_t) dsNoParamSets); | ||
| 261 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 262 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 263 | EXPECT_EQ (iOutput, (int32_t) ERROR_CON_DISABLE); //should be 0 | ||
| 264 | //call DecodeFrame2(), incorrect call | ||
| 265 | iRet = (int32_t) m_pDec->DecodeFrame2 (m_szBuffer, m_iBufLength, m_pData, &m_sBufferInfo); | ||
| 266 | EXPECT_EQ (iRet, (int32_t) dsInvalidArgument); | ||
| 267 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 268 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 269 | EXPECT_EQ (iOutput, (int32_t) ERROR_CON_DISABLE); //should be 0 | ||
| 270 | m_pDec->Uninitialize(); | ||
| 271 | } | ||
| 272 | |||
| 273 | //test 2: bParseOnly = false; eEcActiveIdc = 0,1 | ||
| 274 | for (int iNum = 0; iNum < 2; ++iNum) { //loop for EC | ||
| 275 | memset (&m_sBufferInfo, 0, sizeof (SBufferInfo)); | ||
| 276 | memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo)); | ||
| 277 | memset (&m_sDecParam, 0, sizeof (SDecodingParam)); | ||
| 278 | m_sDecParam.pFileNameRestructed = NULL; | ||
| 279 | m_sDecParam.uiCpuLoad = rand() % 100; | ||
| 280 | m_sDecParam.uiTargetDqLayer = -1; | ||
| 281 | m_sDecParam.bParseOnly = false; | ||
| 282 | m_sDecParam.eEcActiveIdc = (ERROR_CON_IDC) iNum; | ||
| 283 | m_sDecParam.sVideoProperty.size = sizeof (SVideoProperty); | ||
| 284 | m_sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE) (rand() % 3); | ||
| 285 | |||
| 286 | iRet = m_pDec->Initialize (&m_sDecParam); | ||
| 287 | ASSERT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 288 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 289 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 290 | EXPECT_EQ (iOutput, iNum); | ||
| 291 | //call DecodeParser(), incorrect call | ||
| 292 | iRet = (int32_t) m_pDec->DecodeParser (m_szBuffer, m_iBufLength, &m_sParserBsInfo); | ||
| 293 | EXPECT_EQ (iRet, (int32_t) dsInvalidArgument); //error call | ||
| 294 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 295 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 296 | EXPECT_EQ (iOutput, iNum); | ||
| 297 | //call DecodeFrame2(), correct call | ||
| 298 | iRet = (int32_t) m_pDec->DecodeFrame2 (m_szBuffer, m_iBufLength, m_pData, &m_sBufferInfo); | ||
| 299 | EXPECT_EQ (iRet, (int32_t) dsNoParamSets); | ||
| 300 | iRet = m_pDec->GetOption (DECODER_OPTION_ERROR_CON_IDC, &iOutput); | ||
| 301 | EXPECT_EQ (iRet, (int32_t) cmResultSuccess); | ||
| 302 | EXPECT_EQ (iOutput, iNum); | ||
| 303 | m_pDec->Uninitialize(); | ||
| 304 | } | ||
| 305 | |||
| 306 | } | ||
| 307 | |||
| 223 | //DECODER_OPTION_END_OF_STREAM | 308 | //DECODER_OPTION_END_OF_STREAM |
| 224 | void DecoderInterfaceTest::TestEndOfStream() { | 309 | void DecoderInterfaceTest::TestEndOfStream() { |
| 225 | int iTmp, iOut; | 310 | int iTmp, iOut; |