History

reorganize tests

Licai Guo committed 12 years ago

Commit f26bb571 parent 667bfe223 files · +68 −43Browse files

Showing the changes to test/api/encoder_test.cpp (1 of 23 files). Show all

Unified · Split

test/api/encoder_test.cpp+101−0
@@ -0,0 +1,101 @@
1+#include <gtest/gtest.h>
2+#include "utils/HashFunctions.h"
3+#include "BaseEncoderTest.h"
4+
5+static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {
6+ for (int i = 0; i < info.iLayerNum; ++i) {
7+ const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
8+ int layerSize = 0;
9+ for (int j = 0; j < layerInfo.iNalCount; ++j) {
10+ layerSize += layerInfo.iNalLengthInByte[j];
11+ }
12+ SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
13+ }
14+}
15+
16+class EncoderInitTest : public ::testing::Test, public BaseEncoderTest {
17+ public:
18+ virtual void SetUp() {
19+ BaseEncoderTest::SetUp();
20+ }
21+ virtual void TearDown() {
22+ BaseEncoderTest::TearDown();
23+ }
24+};
25+
26+TEST_F(EncoderInitTest, JustInit) {}
27+
28+struct EncodeFileParam {
29+ const char* fileName;
30+ const char* hashStr;
31+ int width;
32+ int height;
33+ float frameRate;
34+ SliceModeEnum slices;
35+ bool denoise;
36+ int deblocking;
37+ int layers;
38+};
39+
40+class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
41+ public EncoderInitTest , public BaseEncoderTest::Callback {
42+ public:
43+ virtual void SetUp() {
44+ EncoderInitTest::SetUp();
45+ if (HasFatalFailure()) {
46+ return;
47+ }
48+ SHA1Reset(&ctx_);
49+ }
50+ virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) {
51+ UpdateHashFromFrame(frameInfo, &ctx_);
52+ }
53+ protected:
54+ SHA1Context ctx_;
55+};
56+
57+
58+TEST_P(EncoderOutputTest, CompareOutput) {
59+ EncodeFileParam p = GetParam();
60+ EncodeFile(p.fileName, p.width, p.height, p.frameRate, p.slices, p.denoise, p.deblocking, p.layers, this);
61+
62+ unsigned char digest[SHA_DIGEST_LENGTH];
63+ SHA1Result(&ctx_, digest);
64+ if (!HasFatalFailure()) {
65+ CompareHash(digest, p.hashStr);
66+ }
67+}
68+
69+static const EncodeFileParam kFileParamArray[] = {
70+ {
71+ "res/CiscoVT2people_320x192_12fps.yuv",
72+ "06441376891cbc237a36e59b62131cd94ff9cb19", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, 1
73+ },
74+ {
75+ "res/CiscoVT2people_160x96_6fps.yuv",
76+ "4f3759fc44125b27a179ebff158dbba9e431bd0b", 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, 1
77+ },
78+ {
79+ "res/Static_152_100.yuv",
80+ "af5c6a41b567ce1b2cb6fd427f4379473d3b829f", 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, 1
81+ },
82+ {
83+ "res/CiscoVT2people_320x192_12fps.yuv",
84+ "be0079b022b18fdce04570db24e4327ca26a0ecb", 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, 1 // One slice per MB row
85+ },
86+ {
87+ "res/CiscoVT2people_320x192_12fps.yuv",
88+ "f4649601ca15f9693671d7e161e9daa8efd3a7a1", 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, 1
89+ },
90+ {
91+ "res/CiscoVT2people_320x192_12fps.yuv",
92+ "e4bcd744d2e6f885f6c0dbe5d52818ba64d986d9", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0, 1
93+ },
94+ {
95+ "res/CiscoVT2people_320x192_12fps.yuv",
96+ "ba81a0f1a14214e6d3c7f1608991b3ac97789370", 320, 192, 12.0f, SM_SINGLE_SLICE, false, 0, 2
97+ },
98+};
99+
100+INSTANTIATE_TEST_CASE_P(EncodeFile, EncoderOutputTest,
101+ ::testing::ValuesIn(kFileParamArray));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t