Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: webrtc/test/testsupport/yuv_frame_reader.cc

Issue 2700493006: Add optional visualization file writers to VideoProcessor tests. (Closed)
Patch Set: kjellander comments 2. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/test/testsupport/yuv_frame_reader.cc
diff --git a/webrtc/test/testsupport/frame_reader.cc b/webrtc/test/testsupport/yuv_frame_reader.cc
similarity index 60%
rename from webrtc/test/testsupport/frame_reader.cc
rename to webrtc/test/testsupport/yuv_frame_reader.cc
index 2593afd8c8cb002137fe4216f36d777a5fe19a5d..3fe481ee1ebd95b6a1e2dd13909972566515ab16 100644
--- a/webrtc/test/testsupport/frame_reader.cc
+++ b/webrtc/test/testsupport/yuv_frame_reader.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@@ -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,28 +17,31 @@
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_);
+ fprintf(stderr, "Frame width and height must be >0, was %d x %d\n", width_,
+ height_);
return false;
}
frame_length_in_bytes_ =
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;
@@ -51,21 +52,15 @@ bool FrameReaderImpl::Init() {
fprintf(stderr, "Found empty file: %s\n", input_filename_.c_str());
return false;
}
- number_of_frames_ = static_cast<int>(source_file_size /
- frame_length_in_bytes_);
+ number_of_frames_ =
+ static_cast<int>(source_file_size / frame_length_in_bytes_);
return true;
}
-void FrameReaderImpl::Close() {
- if (input_file_ != NULL) {
- fclose(input_file_);
- input_file_ = NULL;
- }
-}
-
-rtc::scoped_refptr<I420Buffer> FrameReaderImpl::ReadFrame() {
- if (input_file_ == NULL) {
- fprintf(stderr, "FrameReader is not initialized (input file is NULL)\n");
+rtc::scoped_refptr<I420Buffer> YuvFrameReaderImpl::ReadFrame() {
+ if (input_file_ == nullptr) {
+ fprintf(stderr,
+ "YuvFrameReaderImpl is not initialized (input file is NULL)\n");
return nullptr;
}
rtc::scoped_refptr<I420Buffer> buffer(
@@ -77,8 +72,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_;
+}
+
+int YuvFrameReaderImpl::NumberOfFrames() {
+ return number_of_frames_;
+}
} // namespace test
} // namespace webrtc
« no previous file with comments | « webrtc/test/testsupport/y4m_frame_writer_unittest.cc ('k') | webrtc/test/testsupport/yuv_frame_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698