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