Showing the changes to test/api/encoder_test.cpp (1 of 5 files). Show all
Unified · Split
| @@ -2,6 +2,7 @@ · 1 unmodified line | |||
| 2 | #include "utils/HashFunctions.h" | 2 | #include "utils/HashFunctions.h" |
| 3 | #include "BaseEncoderTest.h" | 3 | #include "BaseEncoderTest.h" |
| 4 | #include <string> | 4 | #include <string> |
| 5 | |||
| 5 | static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) { | 6 | static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) { |
| 6 | for (int i = 0; i < info.iLayerNum; ++i) { | 7 | for (int i = 0; i < info.iLayerNum; ++i) { |
| 7 | const SLayerBSInfo& layerInfo = info.sLayerInfo[i]; | 8 | const SLayerBSInfo& layerInfo = info.sLayerInfo[i]; |
| @@ -26,20 +27,40 @@ class EncoderInitTest : public ::testing::Test, public BaseEncoderTest { · 18 unmodified lines | |||
| 26 | TEST_F (EncoderInitTest, JustInit) {} | 27 | TEST_F (EncoderInitTest, JustInit) {} |
| 27 | 28 | ||
| 28 | struct EncodeFileParam { | 29 | struct EncodeFileParam { |
| 29 | const char* fileName; | 30 | const char* pkcFileName; |
| 30 | const char* hashStr; | 31 | const char* pkcHashStr; |
| 31 | EUsageType usageType; | 32 | EUsageType eUsageType; |
| 32 | int width; | 33 | int iWidth; |
| 33 | int height; | 34 | int iHeight; |
| 34 | float frameRate; | 35 | float fFrameRate; |
| 35 | SliceModeEnum slices; | 36 | SliceModeEnum eSliceMode; |
| 36 | bool denoise; | 37 | bool bDenoise; |
| 37 | int layers; | 38 | int iLayerNum; |
| 38 | bool isLossless; | 39 | bool bLossless; |
| 39 | bool enableLtr; | 40 | bool bEnableLtr; |
| 40 | bool cabac; | 41 | bool bCabac; |
| 42 | // unsigned short iMultipleThreadIdc; | ||
| 41 | }; | 43 | }; |
| 42 | 44 | ||
| 45 | void EncFileParamToParamExt (EncodeFileParam* pEncFileParam, SEncParamExt* pEnxParamExt) { | ||
| 46 | ASSERT_TRUE (NULL != pEncFileParam && NULL != pEnxParamExt); | ||
| 47 | pEnxParamExt->iUsageType = pEncFileParam->eUsageType; | ||
| 48 | pEnxParamExt->iPicWidth = pEncFileParam->iWidth; | ||
| 49 | pEnxParamExt->iPicHeight = pEncFileParam->iHeight; | ||
| 50 | pEnxParamExt->fMaxFrameRate = pEncFileParam->fFrameRate; | ||
| 51 | pEnxParamExt->iSpatialLayerNum = pEncFileParam->iLayerNum; | ||
| 52 | |||
| 53 | pEnxParamExt->bEnableDenoise = pEncFileParam->bDenoise; | ||
| 54 | pEnxParamExt->bIsLosslessLink = pEncFileParam->bLossless; | ||
| 55 | pEnxParamExt->bEnableLongTermReference = pEncFileParam->bEnableLtr; | ||
| 56 | pEnxParamExt->iEntropyCodingModeFlag = pEncFileParam->bCabac ? 1 : 0; | ||
| 57 | |||
| 58 | for (int i = 0; i < pEnxParamExt->iSpatialLayerNum; i++) { | ||
| 59 | pEnxParamExt->sSpatialLayers[i].sSliceCfg.uiSliceMode = pEncFileParam->eSliceMode; | ||
| 60 | } | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 43 | class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>, | 64 | class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>, |
| 44 | public EncoderInitTest , public BaseEncoderTest::Callback { | 65 | public EncoderInitTest , public BaseEncoderTest::Callback { |
| 45 | public: | 66 | public: |
| @@ -53,6 +74,7 @@ class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>, · 7 unmodified lines | |||
| 53 | virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) { | 74 | virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) { |
| 54 | UpdateHashFromFrame (frameInfo, &ctx_); | 75 | UpdateHashFromFrame (frameInfo, &ctx_); |
| 55 | } | 76 | } |
| 77 | |||
| 56 | protected: | 78 | protected: |
| 57 | SHA1Context ctx_; | 79 | SHA1Context ctx_; |
| 58 | }; | 80 | }; |
| @@ -60,20 +82,22 @@ class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>, · 1 unmodified line | |||
| 60 | 82 | ||
| 61 | TEST_P (EncoderOutputTest, CompareOutput) { | 83 | TEST_P (EncoderOutputTest, CompareOutput) { |
| 62 | EncodeFileParam p = GetParam(); | 84 | EncodeFileParam p = GetParam(); |
| 85 | SEncParamExt EnxParamExt; | ||
| 86 | |||
| 87 | EncFileParamToParamExt (&p, &EnxParamExt); | ||
| 88 | |||
| 63 | #if defined(ANDROID_NDK) | 89 | #if defined(ANDROID_NDK) |
| 64 | std::string filename = std::string ("/sdcard/") + p.fileName; | 90 | std::string filename = std::string ("/sdcard/") + p.pkcFileName; |
| 65 | EncodeFile (filename.c_str(), p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless, | 91 | EncodeFile (p.pkcFileName, &EnxParamExt, this); |
| 66 | p.enableLtr,p.cabac, this); | ||
| 67 | #else | 92 | #else |
| 68 | EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, p.isLossless, | 93 | EncodeFile (p.pkcFileName, &EnxParamExt, this); |
| 69 | p.enableLtr, p.cabac, this); | ||
| 70 | #endif | 94 | #endif |
| 71 | //will remove this after screen content algorithms are ready, | 95 | //will remove this after screen content algorithms are ready, |
| 72 | //because the bitstream output will vary when the different algorithms are added. | 96 | //because the bitstream output will vary when the different algorithms are added. |
| 73 | unsigned char digest[SHA_DIGEST_LENGTH]; | 97 | unsigned char digest[SHA_DIGEST_LENGTH]; |
| 74 | SHA1Result (&ctx_, digest); | 98 | SHA1Result (&ctx_, digest); |
| 75 | if (!HasFatalFailure()) { | 99 | if (!HasFatalFailure()) { |
| 76 | CompareHash (digest, p.hashStr); | 100 | CompareHash (digest, p.pkcHashStr); |
| 77 | } | 101 | } |
| 78 | } | 102 | } |
| 79 | static const EncodeFileParam kFileParamArray[] = { | 103 | static const EncodeFileParam kFileParamArray[] = { |