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

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

Issue 2378003002: Delete webrtc::VideoFrame::CreateEmptyFrame. (Closed)
Patch Set: Added size_t/int cast, needed for windows 64-bit builds. 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/fake_decoder.cc ('k') | webrtc/video/overuse_frame_detector_unittest.cc » ('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"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 size_t source_height, 139 size_t source_height,
140 size_t target_width, 140 size_t target_width,
141 size_t target_height, 141 size_t target_height,
142 int64_t scroll_time_ms, 142 int64_t scroll_time_ms,
143 int64_t pause_time_ms) 143 int64_t pause_time_ms)
144 : clock_(clock), 144 : clock_(clock),
145 start_time_(clock->TimeInMilliseconds()), 145 start_time_(clock->TimeInMilliseconds()),
146 scroll_time_(scroll_time_ms), 146 scroll_time_(scroll_time_ms),
147 pause_time_(pause_time_ms), 147 pause_time_(pause_time_ms),
148 num_frames_(files.size()), 148 num_frames_(files.size()),
149 target_width_(static_cast<int>(target_width)),
150 target_height_(static_cast<int>(target_height)),
149 current_frame_num_(num_frames_ - 1), 151 current_frame_num_(num_frames_ - 1),
150 current_source_frame_(nullptr), 152 current_source_frame_(nullptr),
151 file_generator_(files, source_width, source_height, 1) { 153 file_generator_(files, source_width, source_height, 1) {
152 RTC_DCHECK(clock_ != nullptr); 154 RTC_DCHECK(clock_ != nullptr);
153 RTC_DCHECK_GT(num_frames_, 0u); 155 RTC_DCHECK_GT(num_frames_, 0u);
154 RTC_DCHECK_GE(source_height, target_height); 156 RTC_DCHECK_GE(source_height, target_height);
155 RTC_DCHECK_GE(source_width, target_width); 157 RTC_DCHECK_GE(source_width, target_width);
156 RTC_DCHECK_GE(scroll_time_ms, 0); 158 RTC_DCHECK_GE(scroll_time_ms, 0);
157 RTC_DCHECK_GE(pause_time_ms, 0); 159 RTC_DCHECK_GE(pause_time_ms, 0);
158 RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0); 160 RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0);
159 current_frame_.CreateEmptyFrame(static_cast<int>(target_width),
160 static_cast<int>(target_height),
161 static_cast<int>(target_width),
162 static_cast<int>((target_width + 1) / 2),
163 static_cast<int>((target_width + 1) / 2));
164 } 161 }
165 162
166 virtual ~ScrollingImageFrameGenerator() {} 163 virtual ~ScrollingImageFrameGenerator() {}
167 164
168 VideoFrame* NextFrame() override { 165 VideoFrame* NextFrame() override {
169 const int64_t kFrameDisplayTime = scroll_time_ + pause_time_; 166 const int64_t kFrameDisplayTime = scroll_time_ + pause_time_;
170 const int64_t now = clock_->TimeInMilliseconds(); 167 const int64_t now = clock_->TimeInMilliseconds();
171 int64_t ms_since_start = now - start_time_; 168 int64_t ms_since_start = now - start_time_;
172 169
173 size_t frame_num = (ms_since_start / kFrameDisplayTime) % num_frames_; 170 size_t frame_num = (ms_since_start / kFrameDisplayTime) % num_frames_;
(...skipping 13 matching lines...) Expand all
187 184
188 void UpdateSourceFrame(size_t frame_num) { 185 void UpdateSourceFrame(size_t frame_num) {
189 while (current_frame_num_ != frame_num) { 186 while (current_frame_num_ != frame_num) {
190 current_source_frame_ = file_generator_.NextFrame(); 187 current_source_frame_ = file_generator_.NextFrame();
191 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; 188 current_frame_num_ = (current_frame_num_ + 1) % num_frames_;
192 } 189 }
193 RTC_DCHECK(current_source_frame_ != nullptr); 190 RTC_DCHECK(current_source_frame_ != nullptr);
194 } 191 }
195 192
196 void CropSourceToScrolledImage(double scroll_factor) { 193 void CropSourceToScrolledImage(double scroll_factor) {
197 const int kTargetWidth = current_frame_.width(); 194 int scroll_margin_x = current_source_frame_->width() - target_width_;
198 const int kTargetHeight = current_frame_.height();
199 int scroll_margin_x = current_source_frame_->width() - kTargetWidth;
200 int pixels_scrolled_x = 195 int pixels_scrolled_x =
201 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); 196 static_cast<int>(scroll_margin_x * scroll_factor + 0.5);
202 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; 197 int scroll_margin_y = current_source_frame_->height() - target_height_;
203 int pixels_scrolled_y = 198 int pixels_scrolled_y =
204 static_cast<int>(scroll_margin_y * scroll_factor + 0.5); 199 static_cast<int>(scroll_margin_y * scroll_factor + 0.5);
205 200
206 int offset_y = (current_source_frame_->video_frame_buffer()->StrideY() * 201 int offset_y = (current_source_frame_->video_frame_buffer()->StrideY() *
207 pixels_scrolled_y) + 202 pixels_scrolled_y) +
208 pixels_scrolled_x; 203 pixels_scrolled_x;
209 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() * 204 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() *
210 (pixels_scrolled_y / 2)) + 205 (pixels_scrolled_y / 2)) +
211 (pixels_scrolled_x / 2); 206 (pixels_scrolled_x / 2);
212 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * 207 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() *
213 (pixels_scrolled_y / 2)) + 208 (pixels_scrolled_y / 2)) +
214 (pixels_scrolled_x / 2); 209 (pixels_scrolled_x / 2);
215 210
216 current_frame_.CreateFrame( 211 current_frame_.CreateFrame(
217 &current_source_frame_->video_frame_buffer()->DataY()[offset_y], 212 &current_source_frame_->video_frame_buffer()->DataY()[offset_y],
218 &current_source_frame_->video_frame_buffer()->DataU()[offset_u], 213 &current_source_frame_->video_frame_buffer()->DataU()[offset_u],
219 &current_source_frame_->video_frame_buffer()->DataV()[offset_v], 214 &current_source_frame_->video_frame_buffer()->DataV()[offset_v],
220 kTargetWidth, kTargetHeight, 215 target_width_, target_height_,
221 current_source_frame_->video_frame_buffer()->StrideY(), 216 current_source_frame_->video_frame_buffer()->StrideY(),
222 current_source_frame_->video_frame_buffer()->StrideU(), 217 current_source_frame_->video_frame_buffer()->StrideU(),
223 current_source_frame_->video_frame_buffer()->StrideV(), 218 current_source_frame_->video_frame_buffer()->StrideV(),
224 kVideoRotation_0); 219 kVideoRotation_0);
225 } 220 }
226 221
227 Clock* const clock_; 222 Clock* const clock_;
228 const int64_t start_time_; 223 const int64_t start_time_;
229 const int64_t scroll_time_; 224 const int64_t scroll_time_;
230 const int64_t pause_time_; 225 const int64_t pause_time_;
231 const size_t num_frames_; 226 const size_t num_frames_;
227 const int target_width_;
228 const int target_height_;
229
232 size_t current_frame_num_; 230 size_t current_frame_num_;
233 VideoFrame* current_source_frame_; 231 VideoFrame* current_source_frame_;
234 VideoFrame current_frame_; 232 VideoFrame current_frame_;
235 YuvFileGenerator file_generator_; 233 YuvFileGenerator file_generator_;
236 }; 234 };
237 235
238 } // namespace 236 } // namespace
239 237
240 FrameForwarder::FrameForwarder() : sink_(nullptr) {} 238 FrameForwarder::FrameForwarder() : sink_(nullptr) {}
241 239
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 files.push_back(file); 294 files.push_back(file);
297 } 295 }
298 296
299 return new ScrollingImageFrameGenerator( 297 return new ScrollingImageFrameGenerator(
300 clock, files, source_width, source_height, target_width, target_height, 298 clock, files, source_width, source_height, target_width, target_height,
301 scroll_time_ms, pause_time_ms); 299 scroll_time_ms, pause_time_ms);
302 } 300 }
303 301
304 } // namespace test 302 } // namespace test
305 } // namespace webrtc 303 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_decoder.cc ('k') | webrtc/video/overuse_frame_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698