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

Unified Diff: webrtc/test/frame_utils.cc

Issue 2362683002: New helper function test::ReadI420Buffer, refactor FrameReader to use it. (Closed)
Patch Set: Another try to fix the 64-bit windows build. 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
« no previous file with comments | « webrtc/test/frame_utils.h ('k') | webrtc/test/test.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/frame_utils.cc
diff --git a/webrtc/test/frame_utils.cc b/webrtc/test/frame_utils.cc
index 0fad3adec85d017890c45e9560ccff02f9431ca8..b332b8fb918d8ff041e7090fae6b705631994d08 100644
--- a/webrtc/test/frame_utils.cc
+++ b/webrtc/test/frame_utils.cc
@@ -72,5 +72,22 @@ bool FrameBufsEqual(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& f1,
half_width, half_height);
}
+rtc::scoped_refptr<I420Buffer> ReadI420Buffer(int width, int height, FILE *f) {
+ int half_width = (width + 1) / 2;
+ rtc::scoped_refptr<I420Buffer> buffer(
+ // Explicit stride, no padding between rows.
+ I420Buffer::Create(width, height, width, half_width, half_width));
+ size_t size_y = static_cast<size_t>(width) * height;
+ size_t size_uv = static_cast<size_t>(half_width) * ((height + 1) / 2);
+
+ if (fread(buffer->MutableDataY(), 1, size_y, f) < size_y)
+ return nullptr;
+ if (fread(buffer->MutableDataU(), 1, size_uv, f) < size_uv)
+ return nullptr;
+ if (fread(buffer->MutableDataV(), 1, size_uv, f) < size_uv)
+ return nullptr;
+ return buffer;
+}
+
} // namespace test
} // namespace webrtc
« no previous file with comments | « webrtc/test/frame_utils.h ('k') | webrtc/test/test.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698