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

Unified Diff: webrtc/test/frame_generator.cc

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: rebased 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/frame_generator.cc
diff --git a/webrtc/test/frame_generator.cc b/webrtc/test/frame_generator.cc
index 2f911d80249a0aa24f46625fc269337d81f80ba7..a6afce01d906ee20f78920c208a50f1e7fbe49c3 100644
--- a/webrtc/test/frame_generator.cc
+++ b/webrtc/test/frame_generator.cc
@@ -26,8 +26,14 @@ namespace {
class ChromaGenerator : public FrameGenerator {
public:
- ChromaGenerator(size_t width, size_t height)
- : angle_(0.0), width_(width), height_(height) {
+ ChromaGenerator(size_t width, size_t height) : angle_(0.0) {
+ ChangeResolution(width, height);
+ }
+
+ void ChangeResolution(size_t width, size_t height) override {
+ rtc::CritScope lock(&crit_);
+ width_ = width;
+ height_ = height;
RTC_CHECK(width_ > 0);
RTC_CHECK(height_ > 0);
half_width_ = (width_ + 1) / 2;
@@ -36,6 +42,7 @@ class ChromaGenerator : public FrameGenerator {
}
VideoFrame* NextFrame() override {
+ rtc::CritScope lock(&crit_);
angle_ += 30.0;
uint8_t u = fabs(sin(angle_)) * 0xFF;
uint8_t v = fabs(cos(angle_)) * 0xFF;
@@ -55,13 +62,14 @@ class ChromaGenerator : public FrameGenerator {
}
private:
- double angle_;
- size_t width_;
- size_t height_;
- size_t half_width_;
- size_t y_size_;
- size_t uv_size_;
- std::unique_ptr<VideoFrame> frame_;
+ rtc::CriticalSection crit_;
+ double angle_ GUARDED_BY(&crit_);
+ size_t width_ GUARDED_BY(&crit_);
+ size_t height_ GUARDED_BY(&crit_);
+ size_t half_width_ GUARDED_BY(&crit_);
+ size_t y_size_ GUARDED_BY(&crit_);
+ size_t uv_size_ GUARDED_BY(&crit_);
+ std::unique_ptr<VideoFrame> frame_ GUARDED_BY(&crit_);
};
class YuvFileGenerator : public FrameGenerator {
« 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