| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/test/frame_generator.h" | 10 #include "webrtc/test/frame_generator.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 x_(random_generator_.Rand(0, width)), | 76 x_(random_generator_.Rand(0, width)), |
| 77 y_(random_generator_.Rand(0, height)), | 77 y_(random_generator_.Rand(0, height)), |
| 78 length_(random_generator_.Rand(1, width > 4 ? width / 4 : 1)), | 78 length_(random_generator_.Rand(1, width > 4 ? width / 4 : 1)), |
| 79 yuv_y_(random_generator_.Rand(0, 255)), | 79 yuv_y_(random_generator_.Rand(0, 255)), |
| 80 yuv_u_(random_generator_.Rand(0, 255)), | 80 yuv_u_(random_generator_.Rand(0, 255)), |
| 81 yuv_v_(random_generator_.Rand(0, 255)) {} | 81 yuv_v_(random_generator_.Rand(0, 255)) {} |
| 82 | 82 |
| 83 void Draw(const rtc::scoped_refptr<I420Buffer>& buffer) { | 83 void Draw(const rtc::scoped_refptr<I420Buffer>& buffer) { |
| 84 x_ = (x_ + random_generator_.Rand(0, 4)) % (buffer->width() - length_); | 84 x_ = (x_ + random_generator_.Rand(0, 4)) % (buffer->width() - length_); |
| 85 y_ = (y_ + random_generator_.Rand(0, 4)) % (buffer->height() - length_); | 85 y_ = (y_ + random_generator_.Rand(0, 4)) % (buffer->height() - length_); |
| 86 for (int x = x_; x < x_ + length_; ++x) { | |
| 87 for (int y = y_; y < y_ + length_; ++y) { | 86 for (int y = y_; y < y_ + length_; ++y) { |
| 88 uint8_t* pos_y = (buffer->MutableDataY() + x + y * buffer->StrideY()); | 87 uint8_t* pos_y = |
| 89 *pos_y = yuv_y_; | 88 (buffer->MutableDataY() + x_ + y * buffer->StrideY()); |
| 89 memset(pos_y, yuv_y_, length_); |
| 90 } |
| 91 |
| 92 for (int y = y_; y < y_ + length_; y = y + 2) { |
| 90 uint8_t* pos_u = | 93 uint8_t* pos_u = |
| 91 (buffer->MutableDataU() + x / 2 + y / 2 * buffer->StrideU()); | 94 (buffer->MutableDataU() + x_ / 2 + y / 2 * buffer->StrideU()); |
| 92 *pos_u = yuv_u_; | 95 memset(pos_u, yuv_u_, length_ / 2); |
| 93 uint8_t* pos_v = | 96 uint8_t* pos_v = |
| 94 (buffer->MutableDataV() + x / 2 + y / 2 * buffer->StrideV()); | 97 (buffer->MutableDataV() + x_ / 2 + y / 2 * buffer->StrideV()); |
| 95 *pos_v = yuv_v_; | 98 memset(pos_v, yuv_v_, length_ / 2); |
| 96 } | 99 } |
| 97 } | |
| 98 } | 100 } |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 Random random_generator_; | 103 Random random_generator_; |
| 102 int x_; | 104 int x_; |
| 103 int y_; | 105 int y_; |
| 104 const int length_; | 106 const int length_; |
| 105 const uint8_t yuv_y_; | 107 const uint8_t yuv_y_; |
| 106 const uint8_t yuv_u_; | 108 const uint8_t yuv_u_; |
| 107 const uint8_t yuv_v_; | 109 const uint8_t yuv_v_; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 files.push_back(file); | 365 files.push_back(file); |
| 364 } | 366 } |
| 365 | 367 |
| 366 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator( | 368 return std::unique_ptr<FrameGenerator>(new ScrollingImageFrameGenerator( |
| 367 clock, files, source_width, source_height, target_width, target_height, | 369 clock, files, source_width, source_height, target_width, target_height, |
| 368 scroll_time_ms, pause_time_ms)); | 370 scroll_time_ms, pause_time_ms)); |
| 369 } | 371 } |
| 370 | 372 |
| 371 } // namespace test | 373 } // namespace test |
| 372 } // namespace webrtc | 374 } // namespace webrtc |
| OLD | NEW |