2014-01-07 03:23:44 +01:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "utils/HashFunctions.h"
|
2014-01-14 08:48:20 +01:00
|
|
|
#include "BaseEncoderTest.h"
|
2014-07-28 07:25:27 +02:00
|
|
|
#include <string>
|
2014-10-29 06:50:18 +01:00
|
|
|
|
2014-06-26 03:50:41 +02:00
|
|
|
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
|
2014-01-07 03:23:44 +01:00
|
|
|
for (int i = 0; i < info.iLayerNum; ++i) {
|
|
|
|
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
|
|
|
|
int layerSize = 0;
|
|
|
|
for (int j = 0; j < layerInfo.iNalCount; ++j) {
|
2014-05-14 10:00:36 +02:00
|
|
|
layerSize += layerInfo.pNalLengthInByte[j];
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
2014-06-26 03:50:41 +02:00
|
|
|
SHA1Input (ctx, layerInfo.pBsBuf, layerSize);
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
class EncoderInitTest : public ::testing::Test, public BaseEncoderTest {
|
2014-01-08 04:42:58 +01:00
|
|
|
public:
|
2014-01-07 03:23:44 +01:00
|
|
|
virtual void SetUp() {
|
2014-01-14 08:48:20 +01:00
|
|
|
BaseEncoderTest::SetUp();
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
virtual void TearDown() {
|
2014-01-14 08:48:20 +01:00
|
|
|
BaseEncoderTest::TearDown();
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-26 03:50:41 +02:00
|
|
|
TEST_F (EncoderInitTest, JustInit) {}
|
2014-01-07 03:23:44 +01:00
|
|
|
|
|
|
|
struct EncodeFileParam {
|
2014-10-29 06:50:18 +01:00
|
|
|
const char* pkcFileName;
|
|
|
|
const char* pkcHashStr;
|
|
|
|
EUsageType eUsageType;
|
|
|
|
int iWidth;
|
|
|
|
int iHeight;
|
|
|
|
float fFrameRate;
|
|
|
|
SliceModeEnum eSliceMode;
|
|
|
|
bool bDenoise;
|
|
|
|
int iLayerNum;
|
|
|
|
bool bLossless;
|
|
|
|
bool bEnableLtr;
|
|
|
|
bool bCabac;
|
|
|
|
// unsigned short iMultipleThreadIdc;
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
2014-10-29 06:50:18 +01:00
|
|
|
void EncFileParamToParamExt (EncodeFileParam* pEncFileParam, SEncParamExt* pEnxParamExt) {
|
|
|
|
ASSERT_TRUE (NULL != pEncFileParam && NULL != pEnxParamExt);
|
|
|
|
pEnxParamExt->iUsageType = pEncFileParam->eUsageType;
|
|
|
|
pEnxParamExt->iPicWidth = pEncFileParam->iWidth;
|
|
|
|
pEnxParamExt->iPicHeight = pEncFileParam->iHeight;
|
|
|
|
pEnxParamExt->fMaxFrameRate = pEncFileParam->fFrameRate;
|
|
|
|
pEnxParamExt->iSpatialLayerNum = pEncFileParam->iLayerNum;
|
|
|
|
|
|
|
|
pEnxParamExt->bEnableDenoise = pEncFileParam->bDenoise;
|
|
|
|
pEnxParamExt->bIsLosslessLink = pEncFileParam->bLossless;
|
|
|
|
pEnxParamExt->bEnableLongTermReference = pEncFileParam->bEnableLtr;
|
|
|
|
pEnxParamExt->iEntropyCodingModeFlag = pEncFileParam->bCabac ? 1 : 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < pEnxParamExt->iSpatialLayerNum; i++) {
|
2015-03-18 06:44:03 +01:00
|
|
|
pEnxParamExt->sSpatialLayers[i].sSliceCfg.uiSliceMode = pEncFileParam->eSliceMode;
|
2014-10-29 06:50:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
2014-06-26 03:50:41 +02:00
|
|
|
public EncoderInitTest , public BaseEncoderTest::Callback {
|
2014-01-14 08:48:20 +01:00
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
|
|
|
EncoderInitTest::SetUp();
|
|
|
|
if (HasFatalFailure()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-26 03:50:41 +02:00
|
|
|
SHA1Reset (&ctx_);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
2014-06-26 03:50:41 +02:00
|
|
|
virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
|
|
|
|
UpdateHashFromFrame (frameInfo, &ctx_);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
2014-10-29 06:50:18 +01:00
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
protected:
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Context ctx_;
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-26 03:50:41 +02:00
|
|
|
TEST_P (EncoderOutputTest, CompareOutput) {
|
2014-01-07 03:23:44 +01:00
|
|
|
EncodeFileParam p = GetParam();
|
2014-10-29 06:50:18 +01:00
|
|
|
SEncParamExt EnxParamExt;
|
|
|
|
|
|
|
|
EncFileParamToParamExt (&p, &EnxParamExt);
|
|
|
|
|
2014-07-28 07:25:27 +02:00
|
|
|
#if defined(ANDROID_NDK)
|
2014-10-29 06:50:18 +01:00
|
|
|
std::string filename = std::string ("/sdcard/") + p.pkcFileName;
|
|
|
|
EncodeFile (p.pkcFileName, &EnxParamExt, this);
|
2014-07-28 07:25:27 +02:00
|
|
|
#else
|
2015-03-18 06:44:03 +01:00
|
|
|
EncodeFile (p.pkcFileName, &EnxParamExt, this);
|
2014-07-28 07:25:27 +02:00
|
|
|
#endif
|
2014-04-18 05:17:25 +02:00
|
|
|
//will remove this after screen content algorithms are ready,
|
|
|
|
//because the bitstream output will vary when the different algorithms are added.
|
2014-01-14 08:48:20 +01:00
|
|
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
2014-06-26 03:50:41 +02:00
|
|
|
SHA1Result (&ctx_, digest);
|
2014-01-14 08:48:20 +01:00
|
|
|
if (!HasFatalFailure()) {
|
2014-10-29 06:50:18 +01:00
|
|
|
CompareHash (digest, p.pkcHashStr);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
static const EncodeFileParam kFileParamArray[] = {
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"bfe882345e17346a76438dad967ecd8a15052e0b", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-01-07 03:23:44 +01:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"9879c0e65e0f2d166c450c371c95a1e36eadfa4e", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-01-07 03:23:44 +01:00
|
|
|
},
|
2014-01-12 14:55:37 +01:00
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/Static_152_100.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"f2a4089dbf7278f9e7204351d6ce93e913d6ea1f", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-03-03 09:59:16 +01:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"3ea419b2ea341fe548dbe65be0e955ffea59483a", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, false, false, false // One slice per MB row
|
2014-03-14 17:40:40 +01:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"7614af78a3cb16df8187c1db5492f82f3440a63b", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, false, false, false
|
2014-03-14 17:40:40 +01:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"833a7ae798720f72d6a0b46e5cd1f046c0fdd758", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2, false, false, false
|
2014-01-12 14:55:37 +01:00
|
|
|
},
|
2014-05-22 13:39:43 +02:00
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2015-03-18 06:44:03 +01:00
|
|
|
"6cc7d08b2a80fc2836396808f919f9b5d4ee1d97", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
2014-05-22 13:39:43 +02:00
|
|
|
},
|
2014-07-15 08:41:29 +02:00
|
|
|
{
|
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"40bc1ffec7febdb725ae99954bfa4cb64f070891", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SINGLE_SLICE, false, 4, false, false, false
|
2014-07-15 08:41:29 +02:00
|
|
|
},
|
2014-09-26 10:40:19 +02:00
|
|
|
// the following values may be adjusted for times since we start tuning the strategy
|
2014-04-18 05:17:25 +02:00
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"6ce04eca6d8a6127ae1a6ee3e0d67977f806f5e2", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-04-18 05:17:25 +02:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"2a9942d8d67509712828a5268483141bb8c9b30f", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-04-18 05:17:25 +02:00
|
|
|
},
|
|
|
|
{
|
2014-06-26 03:50:41 +02:00
|
|
|
"res/Static_152_100.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"2041510ebc2810596495d694672ada66f6ec3a0e", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
2014-07-15 08:41:29 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2015-03-18 06:44:03 +01:00
|
|
|
"116663b5a00f000ab40e95b6202563e3cb4ce488", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
2014-09-19 08:46:02 +02:00
|
|
|
},
|
|
|
|
//for different strategy
|
|
|
|
{
|
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2015-03-13 12:08:08 +01:00
|
|
|
"6b981e68a6e0b03a8b769fdd39ec5838380bc4d2", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, true, true, false
|
2014-10-27 06:06:33 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2015-06-07 18:44:42 +02:00
|
|
|
"aae07cf34b065871921f742cdf25a4bf4d623935", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
|
2014-10-27 06:06:33 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2015-03-18 06:44:03 +01:00
|
|
|
"bb8ee13f829fa593b77760afdeb1215d0a577ee1", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, true
|
2014-07-15 08:41:29 +02:00
|
|
|
},
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
2014-06-26 03:50:41 +02:00
|
|
|
INSTANTIATE_TEST_CASE_P (EncodeFile, EncoderOutputTest,
|
|
|
|
::testing::ValuesIn (kFileParamArray));
|