Chromium Code Reviews| Index: webrtc/test/testsupport/frame_reader.cc |
| diff --git a/webrtc/test/testsupport/frame_reader.cc b/webrtc/test/testsupport/frame_reader.cc |
| index 2593afd8c8cb002137fe4216f36d777a5fe19a5d..19120b83b0feaba59529e648fdcc88772213dd5f 100644 |
| --- a/webrtc/test/testsupport/frame_reader.cc |
| +++ b/webrtc/test/testsupport/frame_reader.cc |
| @@ -10,8 +10,6 @@ |
| #include "webrtc/test/testsupport/frame_reader.h" |
| -#include <assert.h> |
| - |
| #include "webrtc/api/video/i420_buffer.h" |
| #include "webrtc/test/frame_utils.h" |
| #include "webrtc/test/testsupport/fileutils.h" |
| @@ -19,18 +17,21 @@ |
| namespace webrtc { |
| namespace test { |
| -FrameReaderImpl::FrameReaderImpl(std::string input_filename, |
| - int width, int height) |
| +YuvFrameReaderImpl::YuvFrameReaderImpl(std::string input_filename, |
| + int width, |
| + int height) |
| : input_filename_(input_filename), |
| - width_(width), height_(height), |
| - input_file_(NULL) { |
| -} |
| + frame_length_in_bytes_(0), |
| + width_(width), |
| + height_(height), |
| + number_of_frames_(-1), |
| + input_file_(nullptr) {} |
| -FrameReaderImpl::~FrameReaderImpl() { |
| +YuvFrameReaderImpl::~YuvFrameReaderImpl() { |
| Close(); |
| } |
| -bool FrameReaderImpl::Init() { |
| +bool YuvFrameReaderImpl::Init() { |
| if (width_ <= 0 || height_ <= 0) { |
| fprintf(stderr, "Frame width and height must be >0, was %d x %d\n", |
| width_, height_); |
| @@ -40,7 +41,7 @@ bool FrameReaderImpl::Init() { |
| width_ * height_ + 2 * ((width_ + 1) / 2) * ((height_ + 1) / 2); |
| input_file_ = fopen(input_filename_.c_str(), "rb"); |
| - if (input_file_ == NULL) { |
| + if (input_file_ == nullptr) { |
| fprintf(stderr, "Couldn't open input file for reading: %s\n", |
| input_filename_.c_str()); |
| return false; |
| @@ -56,15 +57,8 @@ bool FrameReaderImpl::Init() { |
| return true; |
| } |
| -void FrameReaderImpl::Close() { |
| - if (input_file_ != NULL) { |
|
brandtr
2017/02/17 08:21:31
Reordered method definitions to match order of met
|
| - fclose(input_file_); |
| - input_file_ = NULL; |
| - } |
| -} |
| - |
| -rtc::scoped_refptr<I420Buffer> FrameReaderImpl::ReadFrame() { |
| - if (input_file_ == NULL) { |
| +rtc::scoped_refptr<I420Buffer> YuvFrameReaderImpl::ReadFrame() { |
| + if (input_file_ == nullptr) { |
| fprintf(stderr, "FrameReader is not initialized (input file is NULL)\n"); |
| return nullptr; |
| } |
| @@ -77,8 +71,20 @@ rtc::scoped_refptr<I420Buffer> FrameReaderImpl::ReadFrame() { |
| return buffer; |
| } |
| -size_t FrameReaderImpl::FrameLength() { return frame_length_in_bytes_; } |
| -int FrameReaderImpl::NumberOfFrames() { return number_of_frames_; } |
| +void YuvFrameReaderImpl::Close() { |
| + if (input_file_ != nullptr) { |
| + fclose(input_file_); |
| + input_file_ = nullptr; |
| + } |
| +} |
| + |
| +size_t YuvFrameReaderImpl::FrameLength() { |
| + return frame_length_in_bytes_; |
|
brandtr
2017/02/17 08:21:31
git cl format did this
|
| +} |
| + |
| +int YuvFrameReaderImpl::NumberOfFrames() { |
| + return number_of_frames_; |
| +} |
| } // namespace test |
| } // namespace webrtc |