History

astyle all

huili2 committed 12 years ago

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

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

Unified · Split

test/api/BaseDecoderTest.cpp+54−51
@@ -5,18 +5,18 @@ · 4 unmodified lines
55 #include "utils/BufferedData.h"
66 #include "BaseDecoderTest.h"
77
8−static void ReadFrame(std::ifstream* file, BufferedData* buf) {
8+static void ReadFrame (std::ifstream* file, BufferedData* buf) {
99 // start code of a frame is {0, 0, 0, 1}
1010 int zeroCount = 0;
1111 char b;
1212
1313 buf->Clear();
1414 for (;;) {
15− file->read(&b, 1);
15+ file->read (&b, 1);
1616 if (file->gcount() != 1) { // end of file
1717 return;
1818 }
19− if (!buf->PushBack(b)) {
19+ if (!buf->PushBack (b)) {
2020 FAIL() << "unable to allocate memory";
2121 }
2222
@@ -28,8 +28,8 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) { · 5 unmodified lines
2828 zeroCount = b != 0 ? 0 : zeroCount + 1;
2929 } else {
3030 if (b == 1) {
31− if (file->seekg(-4, file->cur).good()) {
32− buf->SetLength(buf->Length() - 4);
31+ if (file->seekg (-4, file->cur).good()) {
32+ buf->SetLength (buf->Length() - 4);
3333 return;
3434 } else {
3535 FAIL() << "unable to seek file";
@@ -44,94 +44,97 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) { · 8 unmodified lines
4444 }
4545
4646 BaseDecoderTest::BaseDecoderTest()
47− : decoder_(NULL), decodeStatus_(OpenFile) {}
47+ : decoder_ (NULL), decodeStatus_ (OpenFile) {}
4848
4949 void BaseDecoderTest::SetUp() {
50− long rv = WelsCreateDecoder(&decoder_);
51− ASSERT_EQ(0, rv);
52− ASSERT_TRUE(decoder_ != NULL);
50+ long rv = WelsCreateDecoder (&decoder_);
51+ ASSERT_EQ (0, rv);
52+ ASSERT_TRUE (decoder_ != NULL);
5353
5454 SDecodingParam decParam;
55− memset(&decParam, 0, sizeof(SDecodingParam));
55+ memset (&decParam, 0, sizeof (SDecodingParam));
5656 decParam.iOutputColorFormat = videoFormatI420;
5757 decParam.uiTargetDqLayer = UCHAR_MAX;
5858 decParam.uiEcActiveFlag = 1;
5959 decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
6060
61− rv = decoder_->Initialize(&decParam);
62− ASSERT_EQ(0, rv);
61+ rv = decoder_->Initialize (&decParam);
62+ ASSERT_EQ (0, rv);
6363 }
6464
6565 void BaseDecoderTest::TearDown() {
6666 if (decoder_ != NULL) {
6767 decoder_->Uninitialize();
68− WelsDestroyDecoder(decoder_);
68+ WelsDestroyDecoder (decoder_);
6969 }
7070 }
7171
7272
73−void BaseDecoderTest::DecodeFrame(const uint8_t* src, int sliceSize, Callback* cbk) {
73+void BaseDecoderTest::DecodeFrame (const uint8_t* src, int sliceSize, Callback* cbk) {
7474 uint8_t* data[3];
7575 SBufferInfo bufInfo;
76− memset(data, 0, sizeof(data));
77− memset(&bufInfo, 0, sizeof(SBufferInfo));
76+ memset (data, 0, sizeof (data));
77+ memset (&bufInfo, 0, sizeof (SBufferInfo));
7878
79− DECODING_STATE rv = decoder_->DecodeFrame2(src, sliceSize, data, &bufInfo);
80− ASSERT_TRUE(rv == dsErrorFree);
79+ DECODING_STATE rv = decoder_->DecodeFrame2 (src, sliceSize, data, &bufInfo);
80+ ASSERT_TRUE (rv == dsErrorFree);
8181
8282 if (bufInfo.iBufferStatus == 1 && cbk != NULL) {
8383 const Frame frame = {
84− { // y plane
85− data[0],
86− bufInfo.UsrData.sSystemBuffer.iWidth,
87− bufInfo.UsrData.sSystemBuffer.iHeight,
88− bufInfo.UsrData.sSystemBuffer.iStride[0]
89− },
90− { // u plane
91− data[1],
92− bufInfo.UsrData.sSystemBuffer.iWidth / 2,
93− bufInfo.UsrData.sSystemBuffer.iHeight / 2,
94− bufInfo.UsrData.sSystemBuffer.iStride[1]
95− },
96− { // v plane
97− data[2],
98− bufInfo.UsrData.sSystemBuffer.iWidth / 2,
99− bufInfo.UsrData.sSystemBuffer.iHeight / 2,
100− bufInfo.UsrData.sSystemBuffer.iStride[1]
101− },
84+ {
85+ // y plane
86+ data[0],
87+ bufInfo.UsrData.sSystemBuffer.iWidth,
88+ bufInfo.UsrData.sSystemBuffer.iHeight,
89+ bufInfo.UsrData.sSystemBuffer.iStride[0]
90+ },
91+ {
92+ // u plane
93+ data[1],
94+ bufInfo.UsrData.sSystemBuffer.iWidth / 2,
95+ bufInfo.UsrData.sSystemBuffer.iHeight / 2,
96+ bufInfo.UsrData.sSystemBuffer.iStride[1]
97+ },
98+ {
99+ // v plane
100+ data[2],
101+ bufInfo.UsrData.sSystemBuffer.iWidth / 2,
102+ bufInfo.UsrData.sSystemBuffer.iHeight / 2,
103+ bufInfo.UsrData.sSystemBuffer.iStride[1]
104+ },
102105 };
103− cbk->onDecodeFrame(frame);
106+ cbk->onDecodeFrame (frame);
104107 }
105108 }
106−void BaseDecoderTest::DecodeFile(const char* fileName, Callback* cbk) {
107− std::ifstream file(fileName, std::ios::in | std::ios::binary);
108− ASSERT_TRUE(file.is_open());
109+void BaseDecoderTest::DecodeFile (const char* fileName, Callback* cbk) {
110+ std::ifstream file (fileName, std::ios::in | std::ios::binary);
111+ ASSERT_TRUE (file.is_open());
109112
110113 BufferedData buf;
111114 while (true) {
112− ReadFrame(&file, &buf);
115+ ReadFrame (&file, &buf);
113116 if (::testing::Test::HasFatalFailure()) {
114117 return;
115118 }
116119 if (buf.Length() == 0) {
117120 break;
118121 }
119− DecodeFrame(buf.data(), buf.Length(), cbk);
122+ DecodeFrame (buf.data(), buf.Length(), cbk);
120123 if (::testing::Test::HasFatalFailure()) {
121124 return;
122125 }
123126 }
124127
125128 int32_t iEndOfStreamFlag = 1;
126− decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
129+ decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
127130
128131 // Get pending last frame
129− DecodeFrame(NULL, 0, cbk);
132+ DecodeFrame (NULL, 0, cbk);
130133 }
131134
132−bool BaseDecoderTest::Open(const char* fileName) {
135+bool BaseDecoderTest::Open (const char* fileName) {
133136 if (decodeStatus_ == OpenFile) {
134− file_.open(fileName, std::ios_base::out | std::ios_base::binary);
137+ file_.open (fileName, std::ios_base::out | std::ios_base::binary);
135138 if (file_.is_open()) {
136139 decodeStatus_ = Decoding;
137140 return true;
@@ -140,10 +143,10 @@ bool BaseDecoderTest::Open(const char* fileName) { · 2 unmodified lines
140143 return false;
141144 }
142145
143−bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) {
146+bool BaseDecoderTest::DecodeNextFrame (Callback* cbk) {
144147 switch (decodeStatus_) {
145148 case Decoding:
146− ReadFrame(&file_, &buf_);
149+ ReadFrame (&file_, &buf_);
147150 if (::testing::Test::HasFatalFailure()) {
148151 return false;
149152 }
@@ -151,15 +154,15 @@ bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) { · 1 unmodified line
151154 decodeStatus_ = EndOfStream;
152155 return true;
153156 }
154− DecodeFrame(buf_.data(), buf_.Length(), cbk);
157+ DecodeFrame (buf_.data(), buf_.Length(), cbk);
155158 if (::testing::Test::HasFatalFailure()) {
156159 return false;
157160 }
158161 return true;
159162 case EndOfStream: {
160163 int32_t iEndOfStreamFlag = 1;
161− decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
162− DecodeFrame(NULL, 0, cbk);
164+ decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
165+ DecodeFrame (NULL, 0, cbk);
163166 decodeStatus_ = End;
164167 break;
165168 }

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