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

Unified Diff: webrtc/test/frame_generator.cc

Issue 2764753003: Reduce CPU usage in test::FrameGenerator::SquareGenerator. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/frame_generator.cc
diff --git a/webrtc/test/frame_generator.cc b/webrtc/test/frame_generator.cc
index cd0bcc6d04f8d476575b4b80858a0d1c407f6c4e..e29364223977879867b5fde71a00def8636bac5e 100644
--- a/webrtc/test/frame_generator.cc
+++ b/webrtc/test/frame_generator.cc
@@ -83,18 +83,20 @@ class SquareGenerator : public FrameGenerator {
void Draw(const rtc::scoped_refptr<I420Buffer>& buffer) {
x_ = (x_ + random_generator_.Rand(0, 4)) % (buffer->width() - length_);
y_ = (y_ + random_generator_.Rand(0, 4)) % (buffer->height() - length_);
- for (int x = x_; x < x_ + length_; ++x) {
for (int y = y_; y < y_ + length_; ++y) {
- uint8_t* pos_y = (buffer->MutableDataY() + x + y * buffer->StrideY());
- *pos_y = yuv_y_;
+ uint8_t* pos_y =
+ (buffer->MutableDataY() + x_ + y * buffer->StrideY());
+ memset(pos_y, yuv_y_, length_);
+ }
+
+ for (int y = y_; y < y_ + length_; y = y + 2) {
uint8_t* pos_u =
- (buffer->MutableDataU() + x / 2 + y / 2 * buffer->StrideU());
- *pos_u = yuv_u_;
+ (buffer->MutableDataU() + x_ / 2 + y / 2 * buffer->StrideU());
+ memset(pos_u, yuv_u_, length_ / 2);
uint8_t* pos_v =
- (buffer->MutableDataV() + x / 2 + y / 2 * buffer->StrideV());
- *pos_v = yuv_v_;
+ (buffer->MutableDataV() + x_ / 2 + y / 2 * buffer->StrideV());
+ memset(pos_v, yuv_v_, length_ / 2);
}
- }
}
private:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698