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