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 23 matching lines...) Expand all Loading... |
34 VideoFrame* NextFrame() override { | 34 VideoFrame* NextFrame() override { |
35 frame_.CreateEmptyFrame(static_cast<int>(width_), | 35 frame_.CreateEmptyFrame(static_cast<int>(width_), |
36 static_cast<int>(height_), | 36 static_cast<int>(height_), |
37 static_cast<int>(width_), | 37 static_cast<int>(width_), |
38 static_cast<int>((width_ + 1) / 2), | 38 static_cast<int>((width_ + 1) / 2), |
39 static_cast<int>((width_ + 1) / 2)); | 39 static_cast<int>((width_ + 1) / 2)); |
40 angle_ += 30.0; | 40 angle_ += 30.0; |
41 uint8_t u = fabs(sin(angle_)) * 0xFF; | 41 uint8_t u = fabs(sin(angle_)) * 0xFF; |
42 uint8_t v = fabs(cos(angle_)) * 0xFF; | 42 uint8_t v = fabs(cos(angle_)) * 0xFF; |
43 | 43 |
44 memset(frame_.buffer(kYPlane), 0x80, frame_.allocated_size(kYPlane)); | 44 memset(frame_.video_frame_buffer()->MutableDataY(), 0x80, |
45 memset(frame_.buffer(kUPlane), u, frame_.allocated_size(kUPlane)); | 45 frame_.allocated_size(kYPlane)); |
46 memset(frame_.buffer(kVPlane), v, frame_.allocated_size(kVPlane)); | 46 memset(frame_.video_frame_buffer()->MutableDataU(), u, |
| 47 frame_.allocated_size(kUPlane)); |
| 48 memset(frame_.video_frame_buffer()->MutableDataV(), v, |
| 49 frame_.allocated_size(kVPlane)); |
47 return &frame_; | 50 return &frame_; |
48 } | 51 } |
49 | 52 |
50 private: | 53 private: |
51 double angle_; | 54 double angle_; |
52 size_t width_; | 55 size_t width_; |
53 size_t height_; | 56 size_t height_; |
54 VideoFrame frame_; | 57 VideoFrame frame_; |
55 }; | 58 }; |
56 | 59 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void CropSourceToScrolledImage(double scroll_factor) { | 198 void CropSourceToScrolledImage(double scroll_factor) { |
196 const int kTargetWidth = current_frame_.width(); | 199 const int kTargetWidth = current_frame_.width(); |
197 const int kTargetHeight = current_frame_.height(); | 200 const int kTargetHeight = current_frame_.height(); |
198 int scroll_margin_x = current_source_frame_->width() - kTargetWidth; | 201 int scroll_margin_x = current_source_frame_->width() - kTargetWidth; |
199 int pixels_scrolled_x = | 202 int pixels_scrolled_x = |
200 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); | 203 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); |
201 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; | 204 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; |
202 int pixels_scrolled_y = | 205 int pixels_scrolled_y = |
203 static_cast<int>(scroll_margin_y * scroll_factor + 0.5); | 206 static_cast<int>(scroll_margin_y * scroll_factor + 0.5); |
204 | 207 |
205 int offset_y = (current_source_frame_->stride(PlaneType::kYPlane) * | 208 int offset_y = (current_source_frame_->video_frame_buffer()->StrideY() * |
206 pixels_scrolled_y) + | 209 pixels_scrolled_y) + |
207 pixels_scrolled_x; | 210 pixels_scrolled_x; |
208 int offset_u = (current_source_frame_->stride(PlaneType::kUPlane) * | 211 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() * |
209 (pixels_scrolled_y / 2)) + | 212 (pixels_scrolled_y / 2)) + |
210 (pixels_scrolled_x / 2); | 213 (pixels_scrolled_x / 2); |
211 int offset_v = (current_source_frame_->stride(PlaneType::kVPlane) * | 214 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * |
212 (pixels_scrolled_y / 2)) + | 215 (pixels_scrolled_y / 2)) + |
213 (pixels_scrolled_x / 2); | 216 (pixels_scrolled_x / 2); |
214 | 217 |
215 current_frame_.CreateFrame( | 218 current_frame_.CreateFrame( |
216 ¤t_source_frame_->buffer(PlaneType::kYPlane)[offset_y], | 219 ¤t_source_frame_->video_frame_buffer()->DataY()[offset_y], |
217 ¤t_source_frame_->buffer(PlaneType::kUPlane)[offset_u], | 220 ¤t_source_frame_->video_frame_buffer()->DataU()[offset_u], |
218 ¤t_source_frame_->buffer(PlaneType::kVPlane)[offset_v], | 221 ¤t_source_frame_->video_frame_buffer()->DataV()[offset_v], |
219 kTargetWidth, kTargetHeight, | 222 kTargetWidth, kTargetHeight, |
220 current_source_frame_->stride(PlaneType::kYPlane), | 223 current_source_frame_->video_frame_buffer()->StrideY(), |
221 current_source_frame_->stride(PlaneType::kUPlane), | 224 current_source_frame_->video_frame_buffer()->StrideU(), |
222 current_source_frame_->stride(PlaneType::kVPlane), | 225 current_source_frame_->video_frame_buffer()->StrideV(), |
223 kVideoRotation_0); | 226 kVideoRotation_0); |
224 } | 227 } |
225 | 228 |
226 Clock* const clock_; | 229 Clock* const clock_; |
227 const int64_t start_time_; | 230 const int64_t start_time_; |
228 const int64_t scroll_time_; | 231 const int64_t scroll_time_; |
229 const int64_t pause_time_; | 232 const int64_t pause_time_; |
230 const size_t num_frames_; | 233 const size_t num_frames_; |
231 size_t current_frame_num_; | 234 size_t current_frame_num_; |
232 VideoFrame* current_source_frame_; | 235 VideoFrame* current_source_frame_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 files.push_back(file); | 277 files.push_back(file); |
275 } | 278 } |
276 | 279 |
277 return new ScrollingImageFrameGenerator( | 280 return new ScrollingImageFrameGenerator( |
278 clock, files, source_width, source_height, target_width, target_height, | 281 clock, files, source_width, source_height, target_width, target_height, |
279 scroll_time_ms, pause_time_ms); | 282 scroll_time_ms, pause_time_ms); |
280 } | 283 } |
281 | 284 |
282 } // namespace test | 285 } // namespace test |
283 } // namespace webrtc | 286 } // namespace webrtc |
OLD | NEW |