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) {
|
|
|
|
layerSize += layerInfo.iNalLengthInByte[j];
|
|
|
|
}
|
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;
|
|
|
|
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;
|
|
|
|
int deblocking;
|
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-03-14 17:40:40 +01:00
|
|
|
EncodeFile(p.fileName, p.width, p.height, p.frameRate, p.slices, p.denoise, p.deblocking, this);
|
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-03-14 17:40:40 +01:00
|
|
|
"06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
|
2014-01-07 03:23:44 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
2014-03-14 17:40:40 +01:00
|
|
|
"4f3759fc44125b27a179ebff158dbba9e431bd0b", 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-03-14 17:40:40 +01:00
|
|
|
"af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
|
2014-03-03 09:59:16 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
2014-03-14 17:40:40 +01:00
|
|
|
"be0079b022b18fdce04570db24e4327ca26a0ecb", 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
|
|
|
"f4649601ca15f9693671d7e161e9daa8efd3a7a1", 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
|
|
|
"e4bcd744d2e6f885f6c0dbe5d52818ba64d986d9", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0
|
2014-01-12 14:55:37 +01:00
|
|
|
},
|
2014-01-07 03:23:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(EncodeFile, EncoderOutputTest,
|
|
|
|
::testing::ValuesIn(kFileParamArray));
|