Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: webrtc/test/frame_generator.cc

Issue 2383493005: Revert of Let ViEEncoder handle resolution changes. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/frame_generator.h ('k') | webrtc/test/frame_generator_capturer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 #include <math.h> 12 #include <math.h>
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <string.h> 14 #include <string.h>
15 15
16 #include <memory> 16 #include <memory>
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
20 #include "webrtc/system_wrappers/include/clock.h" 20 #include "webrtc/system_wrappers/include/clock.h"
21 #include "libyuv/convert.h" 21 #include "libyuv/convert.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 namespace test { 24 namespace test {
25 namespace { 25 namespace {
26 26
27 class ChromaGenerator : public FrameGenerator { 27 class ChromaGenerator : public FrameGenerator {
28 public: 28 public:
29 ChromaGenerator(size_t width, size_t height) : angle_(0.0) { 29 ChromaGenerator(size_t width, size_t height)
30 ChangeResolution(width, height); 30 : angle_(0.0), width_(width), height_(height) {
31 }
32
33 void ChangeResolution(size_t width, size_t height) override {
34 rtc::CritScope lock(&crit_);
35 width_ = width;
36 height_ = height;
37 RTC_CHECK(width_ > 0); 31 RTC_CHECK(width_ > 0);
38 RTC_CHECK(height_ > 0); 32 RTC_CHECK(height_ > 0);
39 half_width_ = (width_ + 1) / 2; 33 half_width_ = (width_ + 1) / 2;
40 y_size_ = width_ * height_; 34 y_size_ = width_ * height_;
41 uv_size_ = half_width_ * ((height_ + 1) / 2); 35 uv_size_ = half_width_ * ((height_ + 1) / 2);
42 } 36 }
43 37
44 VideoFrame* NextFrame() override { 38 VideoFrame* NextFrame() override {
45 rtc::CritScope lock(&crit_);
46 angle_ += 30.0; 39 angle_ += 30.0;
47 uint8_t u = fabs(sin(angle_)) * 0xFF; 40 uint8_t u = fabs(sin(angle_)) * 0xFF;
48 uint8_t v = fabs(cos(angle_)) * 0xFF; 41 uint8_t v = fabs(cos(angle_)) * 0xFF;
49 42
50 // Ensure stride == width. 43 // Ensure stride == width.
51 rtc::scoped_refptr<I420Buffer> buffer(I420Buffer::Create( 44 rtc::scoped_refptr<I420Buffer> buffer(I420Buffer::Create(
52 static_cast<int>(width_), static_cast<int>(height_), 45 static_cast<int>(width_), static_cast<int>(height_),
53 static_cast<int>(width_), static_cast<int>(half_width_), 46 static_cast<int>(width_), static_cast<int>(half_width_),
54 static_cast<int>(half_width_))); 47 static_cast<int>(half_width_)));
55 48
56 memset(buffer->MutableDataY(), 0x80, y_size_); 49 memset(buffer->MutableDataY(), 0x80, y_size_);
57 memset(buffer->MutableDataU(), u, uv_size_); 50 memset(buffer->MutableDataU(), u, uv_size_);
58 memset(buffer->MutableDataV(), v, uv_size_); 51 memset(buffer->MutableDataV(), v, uv_size_);
59 52
60 frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0)); 53 frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0));
61 return frame_.get(); 54 return frame_.get();
62 } 55 }
63 56
64 private: 57 private:
65 rtc::CriticalSection crit_; 58 double angle_;
66 double angle_ GUARDED_BY(&crit_); 59 size_t width_;
67 size_t width_ GUARDED_BY(&crit_); 60 size_t height_;
68 size_t height_ GUARDED_BY(&crit_); 61 size_t half_width_;
69 size_t half_width_ GUARDED_BY(&crit_); 62 size_t y_size_;
70 size_t y_size_ GUARDED_BY(&crit_); 63 size_t uv_size_;
71 size_t uv_size_ GUARDED_BY(&crit_); 64 std::unique_ptr<VideoFrame> frame_;
72 std::unique_ptr<VideoFrame> frame_ GUARDED_BY(&crit_);
73 }; 65 };
74 66
75 class YuvFileGenerator : public FrameGenerator { 67 class YuvFileGenerator : public FrameGenerator {
76 public: 68 public:
77 YuvFileGenerator(std::vector<FILE*> files, 69 YuvFileGenerator(std::vector<FILE*> files,
78 size_t width, 70 size_t width,
79 size_t height, 71 size_t height,
80 int frame_repeat_count) 72 int frame_repeat_count)
81 : file_index_(0), 73 : file_index_(0),
82 files_(files), 74 files_(files),
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 files.push_back(file); 310 files.push_back(file);
319 } 311 }
320 312
321 return new ScrollingImageFrameGenerator( 313 return new ScrollingImageFrameGenerator(
322 clock, files, source_width, source_height, target_width, target_height, 314 clock, files, source_width, source_height, target_width, target_height,
323 scroll_time_ms, pause_time_ms); 315 scroll_time_ms, pause_time_ms);
324 } 316 }
325 317
326 } // namespace test 318 } // namespace test
327 } // namespace webrtc 319 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/frame_generator.h ('k') | webrtc/test/frame_generator_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698