History

Remove temp files using the iterator pattern

jwwang committed 12 years ago

Commit 0c2227e1 parent 596be028 files · +144 −34Browse files

Showing the changes to test/BaseEncoderTest.cpp (1 of 8 files). Show all

Unified · Split

test/BaseEncoderTest.cpp+10−6
@@ -2,6 +2,7 @@ · 1 unmodified line
22 #include <gtest/gtest.h>
33 #include "codec_def.h"
44 #include "utils/BufferedData.h"
5+#include "utils/FileInputStream.h"
56 #include "BaseEncoderTest.h"
67
78 static int InitWithParam(ISVCEncoder* encoder, int width,
@@ -50,11 +51,8 @@ void BaseEncoderTest::TearDown() { · 42 unmodified lines
5051 }
5152 }
5253
53−void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height,
54+void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height,
5455 float frameRate, Callback* cbk) {
55− std::ifstream file(fileName, std::ios::in | std::ios::binary);
56− ASSERT_TRUE(file.is_open());
57−
5856 int rv = InitWithParam(encoder_, width, height, frameRate);
5957 ASSERT_TRUE(rv == cmResultSuccess);
6058
@@ -64,12 +62,11 @@ void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, · 3 unmodified lines
6462 BufferedData buf;
6563 buf.SetLength(frameSize);
6664 ASSERT_TRUE(buf.Length() == frameSize);
67− char* data = reinterpret_cast<char*>(buf.data());
6865
6966 SFrameBSInfo info;
7067 memset(&info, 0, sizeof(SFrameBSInfo));
7168
72− while (file.read(data, frameSize), file.gcount() == frameSize) {
69+ while (in->read(buf.data(), frameSize) == frameSize) {
7370 rv = encoder_->EncodeFrame(buf.data(), &info);
7471 ASSERT_TRUE(rv != videoFrameTypeInvalid);
7572 if (rv != videoFrameTypeSkip && cbk != NULL) {
@@ -77,3 +74,10 @@ void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, · 1 unmodified line
7774 }
7875 }
7976 }
77+
78+void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height,
79+ float frameRate, Callback* cbk) {
80+ FileInputStream fileStream;
81+ ASSERT_TRUE(fileStream.Open(fileName));
82+ EncodeStream(&fileStream, width, height, frameRate, cbk);
83+}

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