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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 : file_index_(0), | 82 : file_index_(0), |
83 files_(files), | 83 files_(files), |
84 width_(width), | 84 width_(width), |
85 height_(height), | 85 height_(height), |
86 frame_size_(CalcBufferSize(kI420, | 86 frame_size_(CalcBufferSize(kI420, |
87 static_cast<int>(width_), | 87 static_cast<int>(width_), |
88 static_cast<int>(height_))), | 88 static_cast<int>(height_))), |
89 frame_buffer_(new uint8_t[frame_size_]), | 89 frame_buffer_(new uint8_t[frame_size_]), |
90 frame_display_count_(frame_repeat_count), | 90 frame_display_count_(frame_repeat_count), |
91 current_display_count_(0) { | 91 current_display_count_(0) { |
92 assert(width > 0); | 92 RTC_DCHECK_GT(width, 0); |
93 assert(height > 0); | 93 RTC_DCHECK_GT(height, 0); |
94 assert(frame_repeat_count > 0); | 94 RTC_DCHECK_GT(frame_repeat_count, 0); |
95 } | 95 } |
96 | 96 |
97 virtual ~YuvFileGenerator() { | 97 virtual ~YuvFileGenerator() { |
98 for (FILE* file : files_) | 98 for (FILE* file : files_) |
99 fclose(file); | 99 fclose(file); |
100 } | 100 } |
101 | 101 |
102 VideoFrame* NextFrame() override { | 102 VideoFrame* NextFrame() override { |
103 if (current_display_count_ == 0) | 103 if (current_display_count_ == 0) |
104 ReadNextFrame(); | 104 ReadNextFrame(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 FrameGenerator* FrameGenerator::CreateChromaGenerator(size_t width, | 280 FrameGenerator* FrameGenerator::CreateChromaGenerator(size_t width, |
281 size_t height) { | 281 size_t height) { |
282 return new ChromaGenerator(width, height); | 282 return new ChromaGenerator(width, height); |
283 } | 283 } |
284 | 284 |
285 FrameGenerator* FrameGenerator::CreateFromYuvFile( | 285 FrameGenerator* FrameGenerator::CreateFromYuvFile( |
286 std::vector<std::string> filenames, | 286 std::vector<std::string> filenames, |
287 size_t width, | 287 size_t width, |
288 size_t height, | 288 size_t height, |
289 int frame_repeat_count) { | 289 int frame_repeat_count) { |
290 assert(!filenames.empty()); | 290 RTC_DCHECK(!filenames.empty()); |
291 std::vector<FILE*> files; | 291 std::vector<FILE*> files; |
292 for (const std::string& filename : filenames) { | 292 for (const std::string& filename : filenames) { |
293 FILE* file = fopen(filename.c_str(), "rb"); | 293 FILE* file = fopen(filename.c_str(), "rb"); |
294 RTC_DCHECK(file != nullptr); | 294 RTC_DCHECK(file != nullptr); |
295 files.push_back(file); | 295 files.push_back(file); |
296 } | 296 } |
297 | 297 |
298 return new YuvFileGenerator(files, width, height, frame_repeat_count); | 298 return new YuvFileGenerator(files, width, height, frame_repeat_count); |
299 } | 299 } |
300 | 300 |
301 FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles( | 301 FrameGenerator* FrameGenerator::CreateScrollingInputFromYuvFiles( |
302 Clock* clock, | 302 Clock* clock, |
303 std::vector<std::string> filenames, | 303 std::vector<std::string> filenames, |
304 size_t source_width, | 304 size_t source_width, |
305 size_t source_height, | 305 size_t source_height, |
306 size_t target_width, | 306 size_t target_width, |
307 size_t target_height, | 307 size_t target_height, |
308 int64_t scroll_time_ms, | 308 int64_t scroll_time_ms, |
309 int64_t pause_time_ms) { | 309 int64_t pause_time_ms) { |
310 assert(!filenames.empty()); | 310 RTC_DCHECK(!filenames.empty()); |
311 std::vector<FILE*> files; | 311 std::vector<FILE*> files; |
312 for (const std::string& filename : filenames) { | 312 for (const std::string& filename : filenames) { |
313 FILE* file = fopen(filename.c_str(), "rb"); | 313 FILE* file = fopen(filename.c_str(), "rb"); |
314 RTC_DCHECK(file != nullptr); | 314 RTC_DCHECK(file != nullptr); |
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 |