| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 int64_t scroll_time_ms, | 139 int64_t scroll_time_ms, |
| 140 int64_t pause_time_ms) | 140 int64_t pause_time_ms) |
| 141 : clock_(clock), | 141 : clock_(clock), |
| 142 start_time_(clock->TimeInMilliseconds()), | 142 start_time_(clock->TimeInMilliseconds()), |
| 143 scroll_time_(scroll_time_ms), | 143 scroll_time_(scroll_time_ms), |
| 144 pause_time_(pause_time_ms), | 144 pause_time_(pause_time_ms), |
| 145 num_frames_(files.size()), | 145 num_frames_(files.size()), |
| 146 current_frame_num_(num_frames_ - 1), | 146 current_frame_num_(num_frames_ - 1), |
| 147 current_source_frame_(nullptr), | 147 current_source_frame_(nullptr), |
| 148 file_generator_(files, source_width, source_height, 1) { | 148 file_generator_(files, source_width, source_height, 1) { |
| 149 DCHECK(clock_ != nullptr); | 149 RTC_DCHECK(clock_ != nullptr); |
| 150 DCHECK_GT(num_frames_, 0u); | 150 RTC_DCHECK_GT(num_frames_, 0u); |
| 151 DCHECK_GE(source_height, target_height); | 151 RTC_DCHECK_GE(source_height, target_height); |
| 152 DCHECK_GE(source_width, target_width); | 152 RTC_DCHECK_GE(source_width, target_width); |
| 153 DCHECK_GE(scroll_time_ms, 0); | 153 RTC_DCHECK_GE(scroll_time_ms, 0); |
| 154 DCHECK_GE(pause_time_ms, 0); | 154 RTC_DCHECK_GE(pause_time_ms, 0); |
| 155 DCHECK_GT(scroll_time_ms + pause_time_ms, 0); | 155 RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0); |
| 156 current_frame_.CreateEmptyFrame(static_cast<int>(target_width), | 156 current_frame_.CreateEmptyFrame(static_cast<int>(target_width), |
| 157 static_cast<int>(target_height), | 157 static_cast<int>(target_height), |
| 158 static_cast<int>(target_width), | 158 static_cast<int>(target_width), |
| 159 static_cast<int>((target_width + 1) / 2), | 159 static_cast<int>((target_width + 1) / 2), |
| 160 static_cast<int>((target_width + 1) / 2)); | 160 static_cast<int>((target_width + 1) / 2)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 virtual ~ScrollingImageFrameGenerator() {} | 163 virtual ~ScrollingImageFrameGenerator() {} |
| 164 | 164 |
| 165 VideoFrame* NextFrame() override { | 165 VideoFrame* NextFrame() override { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 180 CropSourceToScrolledImage(scroll_factor); | 180 CropSourceToScrolledImage(scroll_factor); |
| 181 | 181 |
| 182 return ¤t_frame_; | 182 return ¤t_frame_; |
| 183 } | 183 } |
| 184 | 184 |
| 185 void UpdateSourceFrame(size_t frame_num) { | 185 void UpdateSourceFrame(size_t frame_num) { |
| 186 while (current_frame_num_ != frame_num) { | 186 while (current_frame_num_ != frame_num) { |
| 187 current_source_frame_ = file_generator_.NextFrame(); | 187 current_source_frame_ = file_generator_.NextFrame(); |
| 188 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; | 188 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; |
| 189 } | 189 } |
| 190 DCHECK(current_source_frame_ != nullptr); | 190 RTC_DCHECK(current_source_frame_ != nullptr); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void CropSourceToScrolledImage(double scroll_factor) { | 193 void CropSourceToScrolledImage(double scroll_factor) { |
| 194 const int kTargetWidth = current_frame_.width(); | 194 const int kTargetWidth = current_frame_.width(); |
| 195 const int kTargetHeight = current_frame_.height(); | 195 const int kTargetHeight = current_frame_.height(); |
| 196 int scroll_margin_x = current_source_frame_->width() - kTargetWidth; | 196 int scroll_margin_x = current_source_frame_->width() - kTargetWidth; |
| 197 int pixels_scrolled_x = | 197 int pixels_scrolled_x = |
| 198 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); | 198 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); |
| 199 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; | 199 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; |
| 200 int pixels_scrolled_y = | 200 int pixels_scrolled_y = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 FrameGenerator* FrameGenerator::CreateFromYuvFile( | 241 FrameGenerator* FrameGenerator::CreateFromYuvFile( |
| 242 std::vector<std::string> filenames, | 242 std::vector<std::string> filenames, |
| 243 size_t width, | 243 size_t width, |
| 244 size_t height, | 244 size_t height, |
| 245 int frame_repeat_count) { | 245 int frame_repeat_count) { |
| 246 assert(!filenames.empty()); | 246 assert(!filenames.empty()); |
| 247 std::vector<FILE*> files; | 247 std::vector<FILE*> files; |
| 248 for (const std::string& filename : filenames) { | 248 for (const std::string& filename : filenames) { |
| 249 FILE* file = fopen(filename.c_str(), "rb"); | 249 FILE* file = fopen(filename.c_str(), "rb"); |
| 250 DCHECK(file != nullptr); | 250 RTC_DCHECK(file != nullptr); |
| 251 files.push_back(file); | 251 files.push_back(file); |
| 252 } | 252 } |
| 253 | 253 |
| 254 return new YuvFileGenerator(files, width, height, frame_repeat_count); | 254 return new YuvFileGenerator(files, width, height, frame_repeat_count); |
| 255 } | 255 } |
| 256 | 256 |
| 257 FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles( | 257 FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles( |
| 258 Clock* clock, | 258 Clock* clock, |
| 259 std::vector<std::string> filenames, | 259 std::vector<std::string> filenames, |
| 260 size_t source_width, | 260 size_t source_width, |
| 261 size_t source_height, | 261 size_t source_height, |
| 262 size_t target_width, | 262 size_t target_width, |
| 263 size_t target_height, | 263 size_t target_height, |
| 264 int64_t scroll_time_ms, | 264 int64_t scroll_time_ms, |
| 265 int64_t pause_time_ms) { | 265 int64_t pause_time_ms) { |
| 266 assert(!filenames.empty()); | 266 assert(!filenames.empty()); |
| 267 std::vector<FILE*> files; | 267 std::vector<FILE*> files; |
| 268 for (const std::string& filename : filenames) { | 268 for (const std::string& filename : filenames) { |
| 269 FILE* file = fopen(filename.c_str(), "rb"); | 269 FILE* file = fopen(filename.c_str(), "rb"); |
| 270 DCHECK(file != nullptr); | 270 RTC_DCHECK(file != nullptr); |
| 271 files.push_back(file); | 271 files.push_back(file); |
| 272 } | 272 } |
| 273 | 273 |
| 274 return new ScrollingImageFrameGenerator( | 274 return new ScrollingImageFrameGenerator( |
| 275 clock, files, source_width, source_height, target_width, target_height, | 275 clock, files, source_width, source_height, target_width, target_height, |
| 276 scroll_time_ms, pause_time_ms); | 276 scroll_time_ms, pause_time_ms); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace test | 279 } // namespace test |
| 280 } // namespace webrtc | 280 } // namespace webrtc |
| OLD | NEW |