History

astyle all

huili2 committed 12 years ago

Commit dc3fae41 parent 101265385 files · +4906 −4701Browse files

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

Unified · Split

test/api/decode_encode_test.cpp+25−25
@@ -6,21 +6,21 @@ · 5 unmodified lines
6#include "BaseDecoderTest.h"6#include "BaseDecoderTest.h"
7#include "BaseEncoderTest.h"7#include "BaseEncoderTest.h"
8 8
9static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {9static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
10 for (int i = 0; i < info.iLayerNum; ++i) {10 for (int i = 0; i < info.iLayerNum; ++i) {
11 const SLayerBSInfo& layerInfo = info.sLayerInfo[i];11 const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
12 int layerSize = 0;12 int layerSize = 0;
13 for (int j = 0; j < layerInfo.iNalCount; ++j) {13 for (int j = 0; j < layerInfo.iNalCount; ++j) {
14 layerSize += layerInfo.pNalLengthInByte[j];14 layerSize += layerInfo.pNalLengthInByte[j];
15 }15 }
16 SHA1Input(ctx, layerInfo.pBsBuf, layerSize);16 SHA1Input (ctx, layerInfo.pBsBuf, layerSize);
17 }17 }
18}18}
19 19
20static void WritePlaneBuffer(BufferedData* buf, const uint8_t* plane,20static void WritePlaneBuffer (BufferedData* buf, const uint8_t* plane,
21 int width, int height, int stride) {21 int width, int height, int stride) {
22 for (int i = 0; i < height; i++) {22 for (int i = 0; i < height; i++) {
23 if (!buf->PushBack(plane, width)) {23 if (!buf->PushBack (plane, width)) {
24 FAIL() << "unable to allocate memory";24 FAIL() << "unable to allocate memory";
25 }25 }
26 plane += stride;26 plane += stride;
@@ -36,9 +36,9 @@ struct DecodeEncodeFileParam { · 9 unmodified lines
36};36};
37 37
38class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,38class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
39 public BaseDecoderTest, public BaseDecoderTest::Callback,39 public BaseDecoderTest, public BaseDecoderTest::Callback,
40 public BaseEncoderTest , public BaseEncoderTest::Callback,40 public BaseEncoderTest , public BaseEncoderTest::Callback,
41 public InputStream {41 public InputStream {
42 public:42 public:
43 virtual void SetUp() {43 virtual void SetUp() {
44 BaseDecoderTest::SetUp();44 BaseDecoderTest::SetUp();
@@ -49,7 +49,7 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>, · 4 unmodified lines
49 if (HasFatalFailure()) {49 if (HasFatalFailure()) {
50 return;50 return;
51 }51 }
52 SHA1Reset(&ctx_);52 SHA1Reset (&ctx_);
53 }53 }
54 54
55 virtual void TearDown() {55 virtual void TearDown() {
@@ -57,22 +57,22 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>, · 1 unmodified line
57 BaseEncoderTest::TearDown();57 BaseEncoderTest::TearDown();
58 }58 }
59 59
60 virtual void onDecodeFrame(const Frame& frame) {60 virtual void onDecodeFrame (const Frame& frame) {
61 const Plane& y = frame.y;61 const Plane& y = frame.y;
62 const Plane& u = frame.u;62 const Plane& u = frame.u;
63 const Plane& v = frame.v;63 const Plane& v = frame.v;
64 WritePlaneBuffer(&buf_, y.data, y.width, y.height, y.stride);64 WritePlaneBuffer (&buf_, y.data, y.width, y.height, y.stride);
65 WritePlaneBuffer(&buf_, u.data, u.width, u.height, u.stride);65 WritePlaneBuffer (&buf_, u.data, u.width, u.height, u.stride);
66 WritePlaneBuffer(&buf_, v.data, v.width, v.height, v.stride);66 WritePlaneBuffer (&buf_, v.data, v.width, v.height, v.stride);
67 }67 }
68 68
69 virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) {69 virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
70 UpdateHashFromFrame(frameInfo, &ctx_);70 UpdateHashFromFrame (frameInfo, &ctx_);
71 }71 }
72 72
73 virtual int read(void* ptr, size_t len) {73 virtual int read (void* ptr, size_t len) {
74 while (buf_.Length() < len) {74 while (buf_.Length() < len) {
75 bool hasNext = DecodeNextFrame(this);75 bool hasNext = DecodeNextFrame (this);
76 if (HasFatalFailure()) {76 if (HasFatalFailure()) {
77 return -1;77 return -1;
78 }78 }
@@ -83,7 +83,7 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>, · 4 unmodified lines
83 break;83 break;
84 }84 }
85 }85 }
86 return buf_.PopFront(static_cast<uint8_t*>(ptr), len);86 return buf_.PopFront (static_cast<uint8_t*> (ptr), len);
87 }87 }
88 88
89 protected:89 protected:
@@ -91,15 +91,15 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>, · 1 unmodified line
91 BufferedData buf_;91 BufferedData buf_;
92};92};
93 93
94TEST_P(DecodeEncodeTest, CompareOutput) {94TEST_P (DecodeEncodeTest, CompareOutput) {
95 DecodeEncodeFileParam p = GetParam();95 DecodeEncodeFileParam p = GetParam();
96 96
97 ASSERT_TRUE(Open(p.fileName));97 ASSERT_TRUE (Open (p.fileName));
98 EncodeStream(this, CAMERA_VIDEO_REAL_TIME,p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);98 EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
99 unsigned char digest[SHA_DIGEST_LENGTH];99 unsigned char digest[SHA_DIGEST_LENGTH];
100 SHA1Result(&ctx_, digest);100 SHA1Result (&ctx_, digest);
101 if (!HasFatalFailure()) {101 if (!HasFatalFailure()) {
102 CompareHash(digest, p.hashStr);102 CompareHash (digest, p.hashStr);
103 }103 }
104}104}
105 105
@@ -108,5 +108,5 @@ static const DecodeEncodeFileParam kFileParamArray[] = { · 2 unmodified lines
108 {"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},108 {"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
109};109};
110 110
111INSTANTIATE_TEST_CASE_P(DecodeEncodeFile, DecodeEncodeTest,111INSTANTIATE_TEST_CASE_P (DecodeEncodeFile, DecodeEncodeTest,
112 ::testing::ValuesIn(kFileParamArray));112 ::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