Showing the changes to test/BaseEncoderTest.cpp (1 of 8 files). Show all
Unified · Split
| @@ -2,6 +2,7 @@ · 1 unmodified line | |||
| 2 | #include <gtest/gtest.h> | 2 | #include <gtest/gtest.h> |
| 3 | #include "codec_def.h" | 3 | #include "codec_def.h" |
| 4 | #include "utils/BufferedData.h" | 4 | #include "utils/BufferedData.h" |
| 5 | #include "utils/FileInputStream.h" | ||
| 5 | #include "BaseEncoderTest.h" | 6 | #include "BaseEncoderTest.h" |
| 6 | 7 | ||
| 7 | static int InitWithParam(ISVCEncoder* encoder, int width, | 8 | static int InitWithParam(ISVCEncoder* encoder, int width, |
| @@ -50,11 +51,8 @@ void BaseEncoderTest::TearDown() { · 42 unmodified lines | |||
| 50 | } | 51 | } |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, | 54 | void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height, |
| 54 | float frameRate, Callback* cbk) { | 55 | float frameRate, Callback* cbk) { |
| 55 | std::ifstream file(fileName, std::ios::in | std::ios::binary); | ||
| 56 | ASSERT_TRUE(file.is_open()); | ||
| 57 | |||
| 58 | int rv = InitWithParam(encoder_, width, height, frameRate); | 56 | int rv = InitWithParam(encoder_, width, height, frameRate); |
| 59 | ASSERT_TRUE(rv == cmResultSuccess); | 57 | ASSERT_TRUE(rv == cmResultSuccess); |
| 60 | 58 | ||
| @@ -64,12 +62,11 @@ void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, · 3 unmodified lines | |||
| 64 | BufferedData buf; | 62 | BufferedData buf; |
| 65 | buf.SetLength(frameSize); | 63 | buf.SetLength(frameSize); |
| 66 | ASSERT_TRUE(buf.Length() == frameSize); | 64 | ASSERT_TRUE(buf.Length() == frameSize); |
| 67 | char* data = reinterpret_cast<char*>(buf.data()); | ||
| 68 | 65 | ||
| 69 | SFrameBSInfo info; | 66 | SFrameBSInfo info; |
| 70 | memset(&info, 0, sizeof(SFrameBSInfo)); | 67 | memset(&info, 0, sizeof(SFrameBSInfo)); |
| 71 | 68 | ||
| 72 | while (file.read(data, frameSize), file.gcount() == frameSize) { | 69 | while (in->read(buf.data(), frameSize) == frameSize) { |
| 73 | rv = encoder_->EncodeFrame(buf.data(), &info); | 70 | rv = encoder_->EncodeFrame(buf.data(), &info); |
| 74 | ASSERT_TRUE(rv != videoFrameTypeInvalid); | 71 | ASSERT_TRUE(rv != videoFrameTypeInvalid); |
| 75 | if (rv != videoFrameTypeSkip && cbk != NULL) { | 72 | if (rv != videoFrameTypeSkip && cbk != NULL) { |
| @@ -77,3 +74,10 @@ void BaseEncoderTest::EncodeFile(const char* fileName, int width, int height, · 1 unmodified line | |||
| 77 | } | 74 | } |
| 78 | } | 75 | } |
| 79 | } | 76 | } |
| 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 | } | ||