2013-12-24 09:25:30 +01:00
|
|
|
#include <gtest/gtest.h>
|
2014-01-07 03:23:44 +01:00
|
|
|
#include "utils/HashFunctions.h"
|
2014-01-14 08:48:20 +01:00
|
|
|
#include "BaseDecoderTest.h"
|
2013-12-24 09:25:30 +01:00
|
|
|
|
2014-01-17 09:43:26 +01:00
|
|
|
static void UpdateHashFromPlane(SHA1Context* ctx, const uint8_t* plane,
|
2013-12-24 09:25:30 +01:00
|
|
|
int width, int height, int stride) {
|
|
|
|
for (int i = 0; i < height; i++) {
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Input(ctx, plane, width);
|
2013-12-24 09:25:30 +01:00
|
|
|
plane += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
class DecoderInitTest : public ::testing::Test, public BaseDecoderTest {
|
2014-01-08 04:42:58 +01:00
|
|
|
public:
|
2013-12-24 09:25:30 +01:00
|
|
|
virtual void SetUp() {
|
2014-01-14 08:48:20 +01:00
|
|
|
BaseDecoderTest::SetUp();
|
2013-12-24 09:25:30 +01:00
|
|
|
}
|
|
|
|
virtual void TearDown() {
|
2014-01-14 08:48:20 +01:00
|
|
|
BaseDecoderTest::TearDown();
|
2013-12-24 09:25:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
TEST_F(DecoderInitTest, JustInit) {}
|
2013-12-24 09:25:30 +01:00
|
|
|
|
|
|
|
struct FileParam {
|
|
|
|
const char* fileName;
|
|
|
|
const char* hashStr;
|
|
|
|
};
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>,
|
|
|
|
public DecoderInitTest, public BaseDecoderTest::Callback {
|
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
|
|
|
DecoderInitTest::SetUp();
|
|
|
|
if (HasFatalFailure()) {
|
|
|
|
return;
|
|
|
|
}
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Reset(&ctx_);
|
2014-01-14 08:48:20 +01:00
|
|
|
}
|
|
|
|
virtual void onDecodeFrame(const Frame& frame) {
|
|
|
|
const Plane& y = frame.y;
|
|
|
|
const Plane& u = frame.u;
|
|
|
|
const Plane& v = frame.v;
|
|
|
|
UpdateHashFromPlane(&ctx_, y.data, y.width, y.height, y.stride);
|
|
|
|
UpdateHashFromPlane(&ctx_, u.data, u.width, u.height, u.stride);
|
|
|
|
UpdateHashFromPlane(&ctx_, v.data, v.width, v.height, v.stride);
|
|
|
|
}
|
|
|
|
protected:
|
2014-01-17 09:43:26 +01:00
|
|
|
SHA1Context ctx_;
|
2013-12-24 09:25:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(DecoderOutputTest, CompareOutput) {
|
|
|
|
FileParam p = GetParam();
|
2014-01-14 08:48:20 +01:00
|
|
|
DecodeFile(p.fileName, this);
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
ASSERT_TRUE(CompareHash(digest, p.hashStr));
|
|
|
|
}
|
2013-12-24 09:25:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const FileParam kFileParamArray[] = {
|
|
|
|
{"res/test_vd_1d.264", "5827d2338b79ff82cd091c707823e466197281d3"},
|
2014-01-12 14:55:37 +01:00
|
|
|
{"res/test_vd_rc.264", "eea02e97bfec89d0418593a8abaaf55d02eaa1ca"},
|
|
|
|
{"res/Static.264", "91dd4a7a796805b2cd015cae8fd630d96c663f42"}
|
2013-12-24 09:25:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(DecodeFile, DecoderOutputTest,
|
|
|
|
::testing::ValuesIn(kFileParamArray));
|