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