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-01-07 03:23:44 +01:00
|
|
|
|
2014-01-17 09:43:26 +01: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-01-17 09:43:26 +01: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-01-14 08:48:20 +01:00
|
|
|
TEST_F(EncoderInitTest, JustInit) {}
|
2014-01-07 03:23:44 +01:00
|
|
|
|
|
|
|
struct EncodeFileParam {
|
|
|
|
const char* fileName;
|
|
|
|
const char* hashStr;
|
2014-04-18 05:17:25 +02:00
|
|
|
EUsageType usageType;
|
2014-01-07 03:23:44 +01:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
float frameRate;
|
2014-03-10 09:57:19 +01:00
|
|
|
SliceModeEnum slices;
|
2014-03-14 17:40:40 +01:00
|
|
|
bool denoise;
|
2014-03-14 18:01:37 +01:00
|
|
|
int layers;
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
|
|
|
|
public EncoderInitTest , public BaseEncoderTest::Callback {
|
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
|
|
|
EncoderInitTest::SetUp();
|
|
|
|
if (HasFatalFailure()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Reset(&ctx_);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
|
|
|
virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) {
|
|
|
|
UpdateHashFromFrame(frameInfo, &ctx_);
|
|
|
|
}
|
|
|
|
protected:
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Context ctx_;
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(EncoderOutputTest, CompareOutput) {
|
|
|
|
EncodeFileParam p = GetParam();
|
2014-04-18 05:17:25 +02:00
|
|
|
EncodeFile(p.fileName, p.usageType ,p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
|
2014-01-14 08:48:20 +01:00
|
|
|
|
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.
|
|
|
|
if(p.usageType == SCREEN_CONTENT_REAL_TIME)
|
|
|
|
return;
|
2014-01-14 08:48:20 +01:00
|
|
|
unsigned char digest[SHA_DIGEST_LENGTH];
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Result(&ctx_, digest);
|
2014-01-14 08:48:20 +01:00
|
|
|
if (!HasFatalFailure()) {
|
2014-03-03 09:45:03 +01:00
|
|
|
CompareHash(digest, p.hashStr);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const EncodeFileParam kFileParamArray[] = {
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2014-06-24 08:49:28 +02:00
|
|
|
"0a36b75e423fc6b49f6adf7eee12c039a096f538", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
|
2014-01-07 03:23:44 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
2014-06-24 08:49:28 +02:00
|
|
|
"73981e6ea5b62f7338212c538a7cc755e7c9c030", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
|
2014-01-07 03:23:44 +01:00
|
|
|
},
|
2014-01-12 14:55:37 +01:00
|
|
|
{
|
|
|
|
"res/Static_152_100.yuv",
|
2014-06-24 08:49:28 +02:00
|
|
|
"83db4c0e3006bbe039bd327b6e78c57fbb05316f", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
|
2014-03-03 09:59:16 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2014-05-27 10:59:00 +02:00
|
|
|
"c8b759bcec7ffa048f1d3ded594b8815bed0aead", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
|
2014-03-14 17:40:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2014-06-24 08:49:28 +02:00
|
|
|
"e64ba75456c821ca35a949eda89f85bff8ee69fa", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
|
2014-03-14 17:40:40 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2014-06-24 08:49:28 +02:00
|
|
|
"684e6d141ada776892bdb01ee93efe475983ed36", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2
|
2014-01-12 14:55:37 +01:00
|
|
|
},
|
2014-05-22 13:39:43 +02:00
|
|
|
{
|
|
|
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
2014-05-27 10:59:00 +02:00
|
|
|
"6df1ece77c0de63cdf8ab52ccef3a7d139022717", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
|
2014-05-22 13:39:43 +02:00
|
|
|
},
|
2014-04-18 05:17:25 +02:00
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
|
|
|
"", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
|
|
|
"", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/Static_152_100.yuv",
|
|
|
|
"", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
|
|
|
|
}
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(EncodeFile, EncoderOutputTest,
|
|
|
|
::testing::ValuesIn(kFileParamArray));
|