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

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

Issue 2378003002: Delete webrtc::VideoFrame::CreateEmptyFrame. (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
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 size_t source_height, 153 size_t source_height,
154 size_t target_width, 154 size_t target_width,
155 size_t target_height, 155 size_t target_height,
156 int64_t scroll_time_ms, 156 int64_t scroll_time_ms,
157 int64_t pause_time_ms) 157 int64_t pause_time_ms)
158 : clock_(clock), 158 : clock_(clock),
159 start_time_(clock->TimeInMilliseconds()), 159 start_time_(clock->TimeInMilliseconds()),
160 scroll_time_(scroll_time_ms), 160 scroll_time_(scroll_time_ms),
161 pause_time_(pause_time_ms), 161 pause_time_(pause_time_ms),
162 num_frames_(files.size()), 162 num_frames_(files.size()),
163 target_width_(target_width),
164 target_height_(target_height),
163 current_frame_num_(num_frames_ - 1), 165 current_frame_num_(num_frames_ - 1),
164 current_source_frame_(nullptr), 166 current_source_frame_(nullptr),
165 file_generator_(files, source_width, source_height, 1) { 167 file_generator_(files, source_width, source_height, 1) {
166 RTC_DCHECK(clock_ != nullptr); 168 RTC_DCHECK(clock_ != nullptr);
167 RTC_DCHECK_GT(num_frames_, 0u); 169 RTC_DCHECK_GT(num_frames_, 0u);
168 RTC_DCHECK_GE(source_height, target_height); 170 RTC_DCHECK_GE(source_height, target_height);
169 RTC_DCHECK_GE(source_width, target_width); 171 RTC_DCHECK_GE(source_width, target_width);
170 RTC_DCHECK_GE(scroll_time_ms, 0); 172 RTC_DCHECK_GE(scroll_time_ms, 0);
171 RTC_DCHECK_GE(pause_time_ms, 0); 173 RTC_DCHECK_GE(pause_time_ms, 0);
172 RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0); 174 RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0);
173 current_frame_.CreateEmptyFrame(static_cast<int>(target_width),
174 static_cast<int>(target_height),
175 static_cast<int>(target_width),
176 static_cast<int>((target_width + 1) / 2),
177 static_cast<int>((target_width + 1) / 2));
178 } 175 }
179 176
180 virtual ~ScrollingImageFrameGenerator() {} 177 virtual ~ScrollingImageFrameGenerator() {}
181 178
182 VideoFrame* NextFrame() override { 179 VideoFrame* NextFrame() override {
183 const int64_t kFrameDisplayTime = scroll_time_ + pause_time_; 180 const int64_t kFrameDisplayTime = scroll_time_ + pause_time_;
184 const int64_t now = clock_->TimeInMilliseconds(); 181 const int64_t now = clock_->TimeInMilliseconds();
185 int64_t ms_since_start = now - start_time_; 182 int64_t ms_since_start = now - start_time_;
186 183
187 size_t frame_num = (ms_since_start / kFrameDisplayTime) % num_frames_; 184 size_t frame_num = (ms_since_start / kFrameDisplayTime) % num_frames_;
(...skipping 13 matching lines...) Expand all
201 198
202 void UpdateSourceFrame(size_t frame_num) { 199 void UpdateSourceFrame(size_t frame_num) {
203 while (current_frame_num_ != frame_num) { 200 while (current_frame_num_ != frame_num) {
204 current_source_frame_ = file_generator_.NextFrame(); 201 current_source_frame_ = file_generator_.NextFrame();
205 current_frame_num_ = (current_frame_num_ + 1) % num_frames_; 202 current_frame_num_ = (current_frame_num_ + 1) % num_frames_;
206 } 203 }
207 RTC_DCHECK(current_source_frame_ != nullptr); 204 RTC_DCHECK(current_source_frame_ != nullptr);
208 } 205 }
209 206
210 void CropSourceToScrolledImage(double scroll_factor) { 207 void CropSourceToScrolledImage(double scroll_factor) {
211 const int kTargetWidth = current_frame_.width(); 208 int scroll_margin_x = current_source_frame_->width() - target_width_;
212 const int kTargetHeight = current_frame_.height();
213 int scroll_margin_x = current_source_frame_->width() - kTargetWidth;
214 int pixels_scrolled_x = 209 int pixels_scrolled_x =
215 static_cast<int>(scroll_margin_x * scroll_factor + 0.5); 210 static_cast<int>(scroll_margin_x * scroll_factor + 0.5);
216 int scroll_margin_y = current_source_frame_->height() - kTargetHeight; 211 int scroll_margin_y = current_source_frame_->height() - target_height_;
217 int pixels_scrolled_y = 212 int pixels_scrolled_y =
218 static_cast<int>(scroll_margin_y * scroll_factor + 0.5); 213 static_cast<int>(scroll_margin_y * scroll_factor + 0.5);
219 214
220 int offset_y = (current_source_frame_->video_frame_buffer()->StrideY() * 215 int offset_y = (current_source_frame_->video_frame_buffer()->StrideY() *
221 pixels_scrolled_y) + 216 pixels_scrolled_y) +
222 pixels_scrolled_x; 217 pixels_scrolled_x;
223 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() * 218 int offset_u = (current_source_frame_->video_frame_buffer()->StrideU() *
224 (pixels_scrolled_y / 2)) + 219 (pixels_scrolled_y / 2)) +
225 (pixels_scrolled_x / 2); 220 (pixels_scrolled_x / 2);
226 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() * 221 int offset_v = (current_source_frame_->video_frame_buffer()->StrideV() *
227 (pixels_scrolled_y / 2)) + 222 (pixels_scrolled_y / 2)) +
228 (pixels_scrolled_x / 2); 223 (pixels_scrolled_x / 2);
229 224
230 current_frame_.CreateFrame( 225 current_frame_.CreateFrame(
231 &current_source_frame_->video_frame_buffer()->DataY()[offset_y], 226 &current_source_frame_->video_frame_buffer()->DataY()[offset_y],
232 &current_source_frame_->video_frame_buffer()->DataU()[offset_u], 227 &current_source_frame_->video_frame_buffer()->DataU()[offset_u],
233 &current_source_frame_->video_frame_buffer()->DataV()[offset_v], 228 &current_source_frame_->video_frame_buffer()->DataV()[offset_v],
234 kTargetWidth, kTargetHeight, 229 target_width_, target_height_,
235 current_source_frame_->video_frame_buffer()->StrideY(), 230 current_source_frame_->video_frame_buffer()->StrideY(),
236 current_source_frame_->video_frame_buffer()->StrideU(), 231 current_source_frame_->video_frame_buffer()->StrideU(),
237 current_source_frame_->video_frame_buffer()->StrideV(), 232 current_source_frame_->video_frame_buffer()->StrideV(),
238 kVideoRotation_0); 233 kVideoRotation_0);
239 } 234 }
240 235
241 Clock* const clock_; 236 Clock* const clock_;
242 const int64_t start_time_; 237 const int64_t start_time_;
243 const int64_t scroll_time_; 238 const int64_t scroll_time_;
244 const int64_t pause_time_; 239 const int64_t pause_time_;
245 const size_t num_frames_; 240 const size_t num_frames_;
241 const int target_width_;
242 const int target_height_;
243
246 size_t current_frame_num_; 244 size_t current_frame_num_;
247 VideoFrame* current_source_frame_; 245 VideoFrame* current_source_frame_;
248 VideoFrame current_frame_; 246 VideoFrame current_frame_;
249 YuvFileGenerator file_generator_; 247 YuvFileGenerator file_generator_;
250 }; 248 };
251 249
252 } // namespace 250 } // namespace
253 251
254 FrameForwarder::FrameForwarder() : sink_(nullptr) {} 252 FrameForwarder::FrameForwarder() : sink_(nullptr) {}
255 253
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 files.push_back(file); 308 files.push_back(file);
311 } 309 }
312 310
313 return new ScrollingImageFrameGenerator( 311 return new ScrollingImageFrameGenerator(
314 clock, files, source_width, source_height, target_width, target_height, 312 clock, files, source_width, source_height, target_width, target_height,
315 scroll_time_ms, pause_time_ms); 313 scroll_time_ms, pause_time_ms);
316 } 314 }
317 315
318 } // namespace test 316 } // namespace test
319 } // namespace webrtc 317 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698