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

Unified Diff: webrtc/test/frame_generator.cc

Issue 2362683002: New helper function test::ReadI420Buffer, refactor FrameReader to use it. (Closed)
Patch Set: Created 4 years, 3 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/frame_generator.cc
diff --git a/webrtc/test/frame_generator.cc b/webrtc/test/frame_generator.cc
index 27935e4b26be0a1575547012e6955e3c1d52fe11..2b4fb008e032b7c4b31417631654b60c6780b573 100644
--- a/webrtc/test/frame_generator.cc
+++ b/webrtc/test/frame_generator.cc
@@ -18,7 +18,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/system_wrappers/include/clock.h"
-#include "libyuv/convert.h"
+#include "webrtc/test/frame_utils.h"
namespace webrtc {
namespace test {
@@ -101,35 +101,17 @@ class YuvFileGenerator : public FrameGenerator {
return temp_frame_.get();
}
- // TODO(nisse): Have a frame reader in one place. And read directly
- // into the planes of an I420Buffer, the extra copying below is silly.
void ReadNextFrame() {
- size_t bytes_read =
- fread(frame_buffer_.get(), 1, frame_size_, files_[file_index_]);
- if (bytes_read < frame_size_) {
+ last_read_buffer_ =
+ test::ReadI420Buffer(width_, height_, files_[file_index_]);
+ if (!last_read_buffer_) {
// No more frames to read in this file, rewind and move to next file.
rewind(files_[file_index_]);
file_index_ = (file_index_ + 1) % files_.size();
- bytes_read = fread(frame_buffer_.get(), 1, frame_size_,
- files_[file_index_]);
- assert(bytes_read >= frame_size_);
+ last_read_buffer_ =
+ test::ReadI420Buffer(width_, height_, files_[file_index_]);
+ RTC_CHECK(last_read_buffer_);
}
-
- size_t half_width = (width_ + 1) / 2;
- size_t size_y = width_ * height_;
- size_t size_uv = half_width * ((height_ + 1) / 2);
- last_read_buffer_ = I420Buffer::Create(
- static_cast<int>(width_), static_cast<int>(height_),
- static_cast<int>(width_), static_cast<int>(half_width),
- static_cast<int>(half_width));
- libyuv::I420Copy(
- frame_buffer_.get(), static_cast<int>(width_),
- frame_buffer_.get() + size_y, static_cast<int>(half_width),
- frame_buffer_.get() + size_y + size_uv, static_cast<int>(half_width),
- last_read_buffer_->MutableDataY(), last_read_buffer_->StrideY(),
- last_read_buffer_->MutableDataU(), last_read_buffer_->StrideU(),
- last_read_buffer_->MutableDataV(), last_read_buffer_->StrideV(),
- static_cast<int>(width_), static_cast<int>(height_));
}
private:

Powered by Google App Engine
This is Rietveld 408576698