| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 double scroll_factor; | 182 double scroll_factor; |
| 183 int64_t time_into_frame = ms_since_start % kFrameDisplayTime; | 183 int64_t time_into_frame = ms_since_start % kFrameDisplayTime; |
| 184 if (time_into_frame < scroll_time_) { | 184 if (time_into_frame < scroll_time_) { |
| 185 scroll_factor = static_cast<double>(time_into_frame) / scroll_time_; | 185 scroll_factor = static_cast<double>(time_into_frame) / scroll_time_; |
| 186 } else { | 186 } else { |
| 187 scroll_factor = 1.0; | 187 scroll_factor = 1.0; |
| 188 } | 188 } |
| 189 CropSourceToScrolledImage(scroll_factor); | 189 CropSourceToScrolledImage(scroll_factor); |
| 190 | 190 |
| 191 return ¤t_frame_; | 191 return current_frame_ ? &*current_frame_ : nullptr; |
| 192 } | 192 } |
| 193 | 193 |
| 194 void UpdateSourceFrame(size_t frame_num) { | 194 void UpdateSourceFrame(size_t frame_num) { |
| 195 while (current_frame_num_ != frame_num) { | 195 while (current_frame_num_ != frame_num) { |
| 196 current_source_frame_ = file_generator_.NextFrame(); | 196 current_source_frame_ = file_generator_.NextFrame(); |
| 197 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; | 197 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; |
| 198 } | 198 } |
| 199 RTC_DCHECK(current_source_frame_ != nullptr); | 199 RTC_DCHECK(current_source_frame_ != nullptr); |
| 200 } | 200 } |
| 201 | 201 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 pixels_scrolled_x; | 212 pixels_scrolled_x; |
| 213 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() * | 213 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() * |
| 214 (pixels_scrolled_y / 2)) + | 214 (pixels_scrolled_y / 2)) + |
| 215 (pixels_scrolled_x / 2); | 215 (pixels_scrolled_x / 2); |
| 216 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * | 216 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * |
| 217 (pixels_scrolled_y / 2)) + | 217 (pixels_scrolled_y / 2)) + |
| 218 (pixels_scrolled_x / 2); | 218 (pixels_scrolled_x / 2); |
| 219 | 219 |
| 220 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer( | 220 rtc::scoped_refptr<VideoFrameBuffer> frame_buffer( |
| 221 current_source_frame_->video_frame_buffer()); | 221 current_source_frame_->video_frame_buffer()); |
| 222 current_frame_ = webrtc::VideoFrame( | 222 current_frame_ = rtc::Optional<webrtc::VideoFrame>(webrtc::VideoFrame( |
| 223 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( | 223 new rtc::RefCountedObject<webrtc::WrappedI420Buffer>( |
| 224 target_width_, target_height_, | 224 target_width_, target_height_, |
| 225 &frame_buffer->DataY()[offset_y], frame_buffer->StrideY(), | 225 &frame_buffer->DataY()[offset_y], frame_buffer->StrideY(), |
| 226 &frame_buffer->DataU()[offset_u], frame_buffer->StrideU(), | 226 &frame_buffer->DataU()[offset_u], frame_buffer->StrideU(), |
| 227 &frame_buffer->DataV()[offset_v], frame_buffer->StrideV(), | 227 &frame_buffer->DataV()[offset_v], frame_buffer->StrideV(), |
| 228 KeepRefUntilDone(frame_buffer)), | 228 KeepRefUntilDone(frame_buffer)), |
| 229 kVideoRotation_0, 0); | 229 kVideoRotation_0, 0)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 Clock* const clock_; | 232 Clock* const clock_; |
| 233 const int64_t start_time_; | 233 const int64_t start_time_; |
| 234 const int64_t scroll_time_; | 234 const int64_t scroll_time_; |
| 235 const int64_t pause_time_; | 235 const int64_t pause_time_; |
| 236 const size_t num_frames_; | 236 const size_t num_frames_; |
| 237 const int target_width_; | 237 const int target_width_; |
| 238 const int target_height_; | 238 const int target_height_; |
| 239 | 239 |
| 240 size_t current_frame_num_; | 240 size_t current_frame_num_; |
| 241 VideoFrame* current_source_frame_; | 241 VideoFrame* current_source_frame_; |
| 242 VideoFrame current_frame_; | 242 rtc::Optional<VideoFrame> current_frame_; |
| 243 YuvFileGenerator file_generator_; | 243 YuvFileGenerator file_generator_; |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 } // namespace | 246 } // namespace |
| 247 | 247 |
| 248 FrameForwarder::FrameForwarder() : sink_(nullptr) {} | 248 FrameForwarder::FrameForwarder() : sink_(nullptr) {} |
| 249 | 249 |
| 250 void FrameForwarder::IncomingCapturedFrame(const VideoFrame& video_frame) { | 250 void FrameForwarder::IncomingCapturedFrame(const VideoFrame& video_frame) { |
| 251 rtc::CritScope lock(&crit_); | 251 rtc::CritScope lock(&crit_); |
| 252 if (sink_) | 252 if (sink_) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 files.push_back(file); | 315 files.push_back(file); |
| 316 } | 316 } |
| 317 | 317 |
| 318 return new ScrollingImageFrameGenerator( | 318 return new ScrollingImageFrameGenerator( |
| 319 clock, files, source_width, source_height, target_width, target_height, | 319 clock, files, source_width, source_height, target_width, target_height, |
| 320 scroll_time_ms, pause_time_ms); | 320 scroll_time_ms, pause_time_ms); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace test | 323 } // namespace test |
| 324 } // namespace webrtc | 324 } // namespace webrtc |
| OLD | NEW |