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

Side by Side Diff: content/common/gpu/media/video_decode_accelerator_unittest.cc

Issue 294663006: vda_unittest - Move the fps control from ThrottleVDAClient to RenderingHelper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const base::FilePath::CharType* g_test_video_data = 92 const base::FilePath::CharType* g_test_video_data =
93 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11"); 93 // FILE_PATH_LITERAL("test-25fps.vp8:320:240:250:250:50:175:11");
94 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1"); 94 FILE_PATH_LITERAL("test-25fps.h264:320:240:250:258:50:175:1");
95 95
96 // The file path of the test output log. This is used to communicate the test 96 // The file path of the test output log. This is used to communicate the test
97 // results to CrOS autotests. We can enable the log and specify the filename by 97 // results to CrOS autotests. We can enable the log and specify the filename by
98 // the "--output_log" switch. 98 // the "--output_log" switch.
99 const base::FilePath::CharType* g_output_log = NULL; 99 const base::FilePath::CharType* g_output_log = NULL;
100 100
101 // The value is set by the switch "--rendering_fps". 101 // The value is set by the switch "--rendering_fps".
102 double g_rendering_fps = 0; 102 double g_rendering_fps = 60;
103
104 // Disable rendering, the value is set by the switch "--disable_rendering".
105 bool g_disable_rendering = false;
106 103
107 // Magic constants for differentiating the reasons for NotifyResetDone being 104 // Magic constants for differentiating the reasons for NotifyResetDone being
108 // called. 105 // called.
109 enum ResetPoint { 106 enum ResetPoint {
110 // Reset() just after calling Decode() with a fragment containing config info. 107 // Reset() just after calling Decode() with a fragment containing config info.
111 RESET_AFTER_FIRST_CONFIG_INFO = -4, 108 RESET_AFTER_FIRST_CONFIG_INFO = -4,
112 START_OF_STREAM_RESET = -3, 109 START_OF_STREAM_RESET = -3,
113 MID_STREAM_RESET = -2, 110 MID_STREAM_RESET = -2,
114 END_OF_STREAM_RESET = -1 111 END_OF_STREAM_RESET = -1
115 }; 112 };
(...skipping 22 matching lines...) Expand all
138 int height; 135 int height;
139 int num_frames; 136 int num_frames;
140 int num_fragments; 137 int num_fragments;
141 int min_fps_render; 138 int min_fps_render;
142 int min_fps_no_render; 139 int min_fps_no_render;
143 media::VideoCodecProfile profile; 140 media::VideoCodecProfile profile;
144 int reset_after_frame_num; 141 int reset_after_frame_num;
145 std::string data_str; 142 std::string data_str;
146 }; 143 };
147 144
148 // Presumed minimal display size. 145 const gfx::Size kThumbnailsDisplaySize(1366, 768);
149 // We subtract one pixel from the width because some ARM chromebooks do not
150 // support two fullscreen app running at the same time. See crbug.com/270064.
151 const gfx::Size kThumbnailsDisplaySize(1366 - 1, 768);
152 const gfx::Size kThumbnailsPageSize(1600, 1200); 146 const gfx::Size kThumbnailsPageSize(1600, 1200);
153 const gfx::Size kThumbnailSize(160, 120); 147 const gfx::Size kThumbnailSize(160, 120);
154 const int kMD5StringLength = 32; 148 const int kMD5StringLength = 32;
155 149
156 // Read in golden MD5s for the thumbnailed rendering of this video 150 // Read in golden MD5s for the thumbnailed rendering of this video
157 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 151 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
158 std::vector<std::string>* md5_strings) { 152 std::vector<std::string>* md5_strings) {
159 base::FilePath filepath(video_file->file_name); 153 base::FilePath filepath(video_file->file_name);
160 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 154 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
161 std::string all_md5s; 155 std::string all_md5s;
(...skipping 27 matching lines...) Expand all
189 CS_INITIALIZED = 2, 183 CS_INITIALIZED = 2,
190 CS_FLUSHING = 3, 184 CS_FLUSHING = 3,
191 CS_FLUSHED = 4, 185 CS_FLUSHED = 4,
192 CS_RESETTING = 5, 186 CS_RESETTING = 5,
193 CS_RESET = 6, 187 CS_RESET = 6,
194 CS_ERROR = 7, 188 CS_ERROR = 7,
195 CS_DESTROYED = 8, 189 CS_DESTROYED = 8,
196 CS_MAX, // Must be last entry. 190 CS_MAX, // Must be last entry.
197 }; 191 };
198 192
199 // A wrapper client that throttles the PictureReady callbacks to a given rate.
200 // It may drops or queues frame to deliver them on time.
201 class ThrottlingVDAClient : public VideoDecodeAccelerator::Client,
202 public base::SupportsWeakPtr<ThrottlingVDAClient> {
203 public:
204 // Callback invoked whan the picture is dropped and should be reused for
205 // the decoder again.
206 typedef base::Callback<void(int32 picture_buffer_id)> ReusePictureCB;
207
208 ThrottlingVDAClient(VideoDecodeAccelerator::Client* client,
209 double fps,
210 ReusePictureCB reuse_picture_cb);
211 virtual ~ThrottlingVDAClient();
212
213 // VideoDecodeAccelerator::Client implementation
214 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
215 const gfx::Size& dimensions,
216 uint32 texture_target) OVERRIDE;
217 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE;
218 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
219 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE;
220 virtual void NotifyFlushDone() OVERRIDE;
221 virtual void NotifyResetDone() OVERRIDE;
222 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE;
223
224 int num_decoded_frames() { return num_decoded_frames_; }
225
226 private:
227
228 void CallClientPictureReady(int version);
229
230 VideoDecodeAccelerator::Client* client_;
231 ReusePictureCB reuse_picture_cb_;
232 base::TimeTicks next_frame_delivered_time_;
233 base::TimeDelta frame_duration_;
234
235 int num_decoded_frames_;
236 int stream_version_;
237 std::deque<media::Picture> pending_pictures_;
238
239 DISALLOW_IMPLICIT_CONSTRUCTORS(ThrottlingVDAClient);
240 };
241
242 ThrottlingVDAClient::ThrottlingVDAClient(VideoDecodeAccelerator::Client* client,
243 double fps,
244 ReusePictureCB reuse_picture_cb)
245 : client_(client),
246 reuse_picture_cb_(reuse_picture_cb),
247 num_decoded_frames_(0),
248 stream_version_(0) {
249 CHECK(client_);
250 CHECK_GT(fps, 0);
251 frame_duration_ = base::TimeDelta::FromSeconds(1) / fps;
252 }
253
254 ThrottlingVDAClient::~ThrottlingVDAClient() {}
255
256 void ThrottlingVDAClient::ProvidePictureBuffers(uint32 requested_num_of_buffers,
257 const gfx::Size& dimensions,
258 uint32 texture_target) {
259 client_->ProvidePictureBuffers(
260 requested_num_of_buffers, dimensions, texture_target);
261 }
262
263 void ThrottlingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) {
264 client_->DismissPictureBuffer(picture_buffer_id);
265 }
266
267 void ThrottlingVDAClient::PictureReady(const media::Picture& picture) {
268 ++num_decoded_frames_;
269
270 if (pending_pictures_.empty()) {
271 base::TimeDelta delay =
272 next_frame_delivered_time_.is_null()
273 ? base::TimeDelta()
274 : next_frame_delivered_time_ - base::TimeTicks::Now();
275 base::MessageLoop::current()->PostDelayedTask(
276 FROM_HERE,
277 base::Bind(&ThrottlingVDAClient::CallClientPictureReady,
278 AsWeakPtr(),
279 stream_version_),
280 delay);
281 }
282 pending_pictures_.push_back(picture);
283 }
284
285 void ThrottlingVDAClient::CallClientPictureReady(int version) {
286 // Just return if we have reset the decoder
287 if (version != stream_version_)
288 return;
289
290 base::TimeTicks now = base::TimeTicks::Now();
291
292 if (next_frame_delivered_time_.is_null())
293 next_frame_delivered_time_ = now;
294
295 if (next_frame_delivered_time_ + frame_duration_ < now) {
296 // Too late, drop the frame
297 reuse_picture_cb_.Run(pending_pictures_.front().picture_buffer_id());
298 } else {
299 client_->PictureReady(pending_pictures_.front());
300 }
301
302 pending_pictures_.pop_front();
303 next_frame_delivered_time_ += frame_duration_;
304 if (!pending_pictures_.empty()) {
305 base::MessageLoop::current()->PostDelayedTask(
306 FROM_HERE,
307 base::Bind(&ThrottlingVDAClient::CallClientPictureReady,
308 AsWeakPtr(),
309 stream_version_),
310 next_frame_delivered_time_ - base::TimeTicks::Now());
311 }
312 }
313
314 void ThrottlingVDAClient::NotifyEndOfBitstreamBuffer(
315 int32 bitstream_buffer_id) {
316 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id);
317 }
318
319 void ThrottlingVDAClient::NotifyFlushDone() {
320 if (!pending_pictures_.empty()) {
321 base::MessageLoop::current()->PostDelayedTask(
322 FROM_HERE,
323 base::Bind(&ThrottlingVDAClient::NotifyFlushDone,
324 base::Unretained(this)),
325 next_frame_delivered_time_ - base::TimeTicks::Now());
326 return;
327 }
328 client_->NotifyFlushDone();
329 }
330
331 void ThrottlingVDAClient::NotifyResetDone() {
332 ++stream_version_;
333 while (!pending_pictures_.empty()) {
334 reuse_picture_cb_.Run(pending_pictures_.front().picture_buffer_id());
335 pending_pictures_.pop_front();
336 }
337 next_frame_delivered_time_ = base::TimeTicks();
338 client_->NotifyResetDone();
339 }
340
341 void ThrottlingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) {
342 client_->NotifyError(error);
343 }
344
345 // Client that can accept callbacks from a VideoDecodeAccelerator and is used by 193 // Client that can accept callbacks from a VideoDecodeAccelerator and is used by
346 // the TESTs below. 194 // the TESTs below.
347 class GLRenderingVDAClient 195 class GLRenderingVDAClient
348 : public VideoDecodeAccelerator::Client, 196 : public VideoDecodeAccelerator::Client,
197 public RenderingClient,
349 public base::SupportsWeakPtr<GLRenderingVDAClient> { 198 public base::SupportsWeakPtr<GLRenderingVDAClient> {
350 public: 199 public:
351 // Doesn't take ownership of |rendering_helper| or |note|, which must outlive 200 // Doesn't take ownership of |rendering_helper| or |note|, which must outlive
352 // |*this|. 201 // |*this|.
353 // |num_play_throughs| indicates how many times to play through the video. 202 // |num_play_throughs| indicates how many times to play through the video.
354 // |reset_after_frame_num| can be a frame number >=0 indicating a mid-stream 203 // |reset_after_frame_num| can be a frame number >=0 indicating a mid-stream
355 // Reset() should be done after that frame number is delivered, or 204 // Reset() should be done after that frame number is delivered, or
356 // END_OF_STREAM_RESET to indicate no mid-stream Reset(). 205 // END_OF_STREAM_RESET to indicate no mid-stream Reset().
357 // |delete_decoder_state| indicates when the underlying decoder should be 206 // |delete_decoder_state| indicates when the underlying decoder should be
358 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() 207 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode()
359 // calls have been made, N>=0 means interpret as ClientState. 208 // calls have been made, N>=0 means interpret as ClientState.
360 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the 209 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the
361 // last play-through (governed by |num_play_throughs|). 210 // last play-through (governed by |num_play_throughs|).
362 // |rendering_fps| indicates the target rendering fps. 0 means no target fps
363 // and it would render as fast as possible.
364 // |suppress_rendering| indicates GL rendering is suppressed or not. 211 // |suppress_rendering| indicates GL rendering is suppressed or not.
365 // After |delay_reuse_after_frame_num| frame has been delivered, the client 212 // After |delay_reuse_after_frame_num| frame has been delivered, the client
366 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. 213 // will start delaying the call to ReusePictureBuffer() for kReuseDelay.
367 // |decode_calls_per_second| is the number of VDA::Decode calls per second. 214 // |decode_calls_per_second| is the number of VDA::Decode calls per second.
368 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. 215 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1.
369 GLRenderingVDAClient(RenderingHelper* rendering_helper, 216 GLRenderingVDAClient(RenderingHelper* rendering_helper,
370 int rendering_window_id, 217 int rendering_window_id,
371 ClientStateNotification<ClientState>* note, 218 ClientStateNotification<ClientState>* note,
372 const std::string& encoded_data, 219 const std::string& encoded_data,
373 int num_in_flight_decodes, 220 int num_in_flight_decodes,
374 int num_play_throughs, 221 int num_play_throughs,
375 int reset_after_frame_num, 222 int reset_after_frame_num,
376 int delete_decoder_state, 223 int delete_decoder_state,
377 int frame_width, 224 int frame_width,
378 int frame_height, 225 int frame_height,
379 media::VideoCodecProfile profile, 226 media::VideoCodecProfile profile,
380 double rendering_fps,
381 bool suppress_rendering, 227 bool suppress_rendering,
382 int delay_reuse_after_frame_num, 228 int delay_reuse_after_frame_num,
383 int decode_calls_per_second); 229 int decode_calls_per_second,
230 bool render_as_thumbnails);
384 virtual ~GLRenderingVDAClient(); 231 virtual ~GLRenderingVDAClient();
385 void CreateAndStartDecoder(); 232 void CreateAndStartDecoder();
386 233
387 // VideoDecodeAccelerator::Client implementation. 234 // VideoDecodeAccelerator::Client implementation.
388 // The heart of the Client. 235 // The heart of the Client.
389 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, 236 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
390 const gfx::Size& dimensions, 237 const gfx::Size& dimensions,
391 uint32 texture_target) OVERRIDE; 238 uint32 texture_target) OVERRIDE;
392 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; 239 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE;
393 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 240 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
394 // Simple state changes. 241 // Simple state changes.
395 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; 242 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE;
396 virtual void NotifyFlushDone() OVERRIDE; 243 virtual void NotifyFlushDone() OVERRIDE;
397 virtual void NotifyResetDone() OVERRIDE; 244 virtual void NotifyResetDone() OVERRIDE;
398 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; 245 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE;
246 virtual void RenderContent(RenderingHelper*) OVERRIDE;
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 Doesn't belong to the comment at l.234.
Owen Lin 2014/05/26 06:21:07 Done.
399 247
400 void OutputFrameDeliveryTimes(base::File* output); 248 void OutputFrameDeliveryTimes(base::File* output);
401 249
402 void NotifyFrameDropped(int32 picture_buffer_id); 250 void NotifyFrameDropped(int32 picture_buffer_id);
403 251
404 // Simple getters for inspecting the state of the Client. 252 // Simple getters for inspecting the state of the Client.
405 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } 253 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; }
406 int num_skipped_fragments() { return num_skipped_fragments_; } 254 int num_skipped_fragments() { return num_skipped_fragments_; }
407 int num_queued_fragments() { return num_queued_fragments_; } 255 int num_queued_fragments() { return num_queued_fragments_; }
408 int num_decoded_frames(); 256 int num_decoded_frames() { return num_decoded_frames_; }
409 double frames_per_second(); 257 double frames_per_second();
410 // Return the median of the decode time of all decoded frames. 258 // Return the median of the decode time of all decoded frames.
411 base::TimeDelta decode_time_median(); 259 base::TimeDelta decode_time_median();
412 bool decoder_deleted() { return !decoder_.get(); } 260 bool decoder_deleted() { return !decoder_.get(); }
413 261
414 private: 262 private:
415 typedef std::map<int, media::PictureBuffer*> PictureBufferById; 263 typedef std::map<int, media::PictureBuffer*> PictureBufferById;
416 264
417 void SetState(ClientState new_state); 265 void SetState(ClientState new_state);
418 void FinishInitialization(); 266 void FinishInitialization();
267 void ReturnPicture(int32 picture_buffer_id);
419 268
420 // Delete the associated decoder helper. 269 // Delete the associated decoder helper.
421 void DeleteDecoder(); 270 void DeleteDecoder();
422 271
423 // Compute & return the first encoded bytes (including a start frame) to send 272 // Compute & return the first encoded bytes (including a start frame) to send
424 // to the decoder, starting at |start_pos| and returning one fragment. Skips 273 // to the decoder, starting at |start_pos| and returning one fragment. Skips
425 // to the first decodable position. 274 // to the first decodable position.
426 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos); 275 std::string GetBytesForFirstFragment(size_t start_pos, size_t* end_pos);
427 // Compute & return the encoded bytes of next fragment to send to the decoder 276 // Compute & return the encoded bytes of next fragment to send to the decoder
428 // (based on |start_pos|). 277 // (based on |start_pos|).
(...skipping 26 matching lines...) Expand all
455 int num_queued_fragments_; 304 int num_queued_fragments_;
456 int num_decoded_frames_; 305 int num_decoded_frames_;
457 int num_done_bitstream_buffers_; 306 int num_done_bitstream_buffers_;
458 PictureBufferById picture_buffers_by_id_; 307 PictureBufferById picture_buffers_by_id_;
459 base::TimeTicks initialize_done_ticks_; 308 base::TimeTicks initialize_done_ticks_;
460 media::VideoCodecProfile profile_; 309 media::VideoCodecProfile profile_;
461 GLenum texture_target_; 310 GLenum texture_target_;
462 bool suppress_rendering_; 311 bool suppress_rendering_;
463 std::vector<base::TimeTicks> frame_delivery_times_; 312 std::vector<base::TimeTicks> frame_delivery_times_;
464 int delay_reuse_after_frame_num_; 313 int delay_reuse_after_frame_num_;
465 scoped_ptr<ThrottlingVDAClient> throttling_client_;
466 // A map from bitstream buffer id to the decode start time of the buffer. 314 // A map from bitstream buffer id to the decode start time of the buffer.
467 std::map<int, base::TimeTicks> decode_start_time_; 315 std::map<int, base::TimeTicks> decode_start_time_;
468 // The decode time of all decoded frames. 316 // The decode time of all decoded frames.
469 std::vector<base::TimeDelta> decode_time_; 317 std::vector<base::TimeDelta> decode_time_;
470 // The number of VDA::Decode calls per second. This is to simulate webrtc. 318 // The number of VDA::Decode calls per second. This is to simulate webrtc.
471 int decode_calls_per_second_; 319 int decode_calls_per_second_;
320 bool render_as_thumbnails_;
321 bool pending_picture_updated_;
322 std::deque<int32> pending_picture_buffer_ids_;
472 323
473 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); 324 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient);
474 }; 325 };
475 326
476 GLRenderingVDAClient::GLRenderingVDAClient( 327 GLRenderingVDAClient::GLRenderingVDAClient(
477 RenderingHelper* rendering_helper, 328 RenderingHelper* rendering_helper,
478 int rendering_window_id, 329 int rendering_window_id,
479 ClientStateNotification<ClientState>* note, 330 ClientStateNotification<ClientState>* note,
480 const std::string& encoded_data, 331 const std::string& encoded_data,
481 int num_in_flight_decodes, 332 int num_in_flight_decodes,
482 int num_play_throughs, 333 int num_play_throughs,
483 int reset_after_frame_num, 334 int reset_after_frame_num,
484 int delete_decoder_state, 335 int delete_decoder_state,
485 int frame_width, 336 int frame_width,
486 int frame_height, 337 int frame_height,
487 media::VideoCodecProfile profile, 338 media::VideoCodecProfile profile,
488 double rendering_fps,
489 bool suppress_rendering, 339 bool suppress_rendering,
490 int delay_reuse_after_frame_num, 340 int delay_reuse_after_frame_num,
491 int decode_calls_per_second) 341 int decode_calls_per_second,
342 bool render_as_thumbnails)
492 : rendering_helper_(rendering_helper), 343 : rendering_helper_(rendering_helper),
493 rendering_window_id_(rendering_window_id), 344 rendering_window_id_(rendering_window_id),
494 encoded_data_(encoded_data), 345 encoded_data_(encoded_data),
495 num_in_flight_decodes_(num_in_flight_decodes), 346 num_in_flight_decodes_(num_in_flight_decodes),
496 outstanding_decodes_(0), 347 outstanding_decodes_(0),
497 encoded_data_next_pos_to_decode_(0), 348 encoded_data_next_pos_to_decode_(0),
498 next_bitstream_buffer_id_(0), 349 next_bitstream_buffer_id_(0),
499 note_(note), 350 note_(note),
500 remaining_play_throughs_(num_play_throughs), 351 remaining_play_throughs_(num_play_throughs),
501 reset_after_frame_num_(reset_after_frame_num), 352 reset_after_frame_num_(reset_after_frame_num),
502 delete_decoder_state_(delete_decoder_state), 353 delete_decoder_state_(delete_decoder_state),
503 state_(CS_CREATED), 354 state_(CS_CREATED),
504 num_skipped_fragments_(0), 355 num_skipped_fragments_(0),
505 num_queued_fragments_(0), 356 num_queued_fragments_(0),
506 num_decoded_frames_(0), 357 num_decoded_frames_(0),
507 num_done_bitstream_buffers_(0), 358 num_done_bitstream_buffers_(0),
508 texture_target_(0), 359 texture_target_(0),
509 suppress_rendering_(suppress_rendering), 360 suppress_rendering_(suppress_rendering),
510 delay_reuse_after_frame_num_(delay_reuse_after_frame_num), 361 delay_reuse_after_frame_num_(delay_reuse_after_frame_num),
511 decode_calls_per_second_(decode_calls_per_second) { 362 decode_calls_per_second_(decode_calls_per_second),
363 render_as_thumbnails_(render_as_thumbnails) {
512 CHECK_GT(num_in_flight_decodes, 0); 364 CHECK_GT(num_in_flight_decodes, 0);
513 CHECK_GT(num_play_throughs, 0); 365 CHECK_GT(num_play_throughs, 0);
514 CHECK_GE(rendering_fps, 0);
515 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0. 366 // |num_in_flight_decodes_| is unsupported if |decode_calls_per_second_| > 0.
516 if (decode_calls_per_second_ > 0) 367 if (decode_calls_per_second_ > 0)
517 CHECK_EQ(1, num_in_flight_decodes_); 368 CHECK_EQ(1, num_in_flight_decodes_);
518 369
519 // Default to H264 baseline if no profile provided. 370 // Default to H264 baseline if no profile provided.
520 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN 371 profile_ = (profile != media::VIDEO_CODEC_PROFILE_UNKNOWN
521 ? profile 372 ? profile
522 : media::H264PROFILE_BASELINE); 373 : media::H264PROFILE_BASELINE);
523
524 if (rendering_fps > 0)
525 throttling_client_.reset(new ThrottlingVDAClient(
526 this,
527 rendering_fps,
528 base::Bind(&GLRenderingVDAClient::NotifyFrameDropped,
529 base::Unretained(this))));
530 } 374 }
531 375
532 GLRenderingVDAClient::~GLRenderingVDAClient() { 376 GLRenderingVDAClient::~GLRenderingVDAClient() {
533 DeleteDecoder(); // Clean up in case of expected error. 377 DeleteDecoder(); // Clean up in case of expected error.
534 CHECK(decoder_deleted()); 378 CHECK(decoder_deleted());
535 STLDeleteValues(&picture_buffers_by_id_); 379 STLDeleteValues(&picture_buffers_by_id_);
536 SetState(CS_DESTROYED); 380 SetState(CS_DESTROYED);
537 } 381 }
538 382
539 static bool DoNothingReturnTrue() { return true; } 383 static bool DoNothingReturnTrue() { return true; }
540 384
541 void GLRenderingVDAClient::CreateAndStartDecoder() { 385 void GLRenderingVDAClient::CreateAndStartDecoder() {
542 CHECK(decoder_deleted()); 386 CHECK(decoder_deleted());
543 CHECK(!decoder_.get()); 387 CHECK(!decoder_.get());
544 388
545 VideoDecodeAccelerator::Client* client = this; 389 VideoDecodeAccelerator::Client* client = this;
546 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); 390 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
547 if (throttling_client_) {
548 client = throttling_client_.get();
549 weak_client = throttling_client_->AsWeakPtr();
550 }
551 #if defined(OS_WIN) 391 #if defined(OS_WIN)
552 decoder_.reset( 392 decoder_.reset(
553 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue))); 393 new DXVAVideoDecodeAccelerator(base::Bind(&DoNothingReturnTrue)));
554 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) 394 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
555 395
556 scoped_ptr<V4L2Device> device = V4L2Device::Create( 396 scoped_ptr<V4L2Device> device = V4L2Device::Create(
557 static_cast<EGLContext>(rendering_helper_->GetGLContext())); 397 static_cast<EGLContext>(rendering_helper_->GetGLContext()));
558 if (!device.get()) { 398 if (!device.get()) {
559 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 399 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
560 return; 400 return;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 void GLRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) { 451 void GLRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) {
612 PictureBufferById::iterator it = 452 PictureBufferById::iterator it =
613 picture_buffers_by_id_.find(picture_buffer_id); 453 picture_buffers_by_id_.find(picture_buffer_id);
614 CHECK(it != picture_buffers_by_id_.end()); 454 CHECK(it != picture_buffers_by_id_.end());
615 CHECK_EQ(outstanding_texture_ids_.erase(it->second->texture_id()), 1U); 455 CHECK_EQ(outstanding_texture_ids_.erase(it->second->texture_id()), 1U);
616 rendering_helper_->DeleteTexture(it->second->texture_id()); 456 rendering_helper_->DeleteTexture(it->second->texture_id());
617 delete it->second; 457 delete it->second;
618 picture_buffers_by_id_.erase(it); 458 picture_buffers_by_id_.erase(it);
619 } 459 }
620 460
461 void GLRenderingVDAClient::RenderContent(RenderingHelper*) {
462 CHECK(!render_as_thumbnails_);
463
464 // No decoded texture for rendering yet, just skip.
465 if (pending_picture_buffer_ids_.size() == 0)
466 return;
467
468 int32 buffer_id = pending_picture_buffer_ids_.front();
469 media::PictureBuffer* picture_buffer = picture_buffers_by_id_[buffer_id];
470
471 CHECK(picture_buffer);
472 if (!pending_picture_updated_) {
473 // Frame dropped, just redraw the last texture.
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 why is this a good idea? (vs. just doing nothing)
Owen Lin 2014/05/26 06:21:07 When doing nothing, the video flickers. It swaps b
474 rendering_helper_->RenderTexture(texture_target_,
475 picture_buffer->texture_id());
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 indent is off (here and elsewhere; please clang-fo
Owen Lin 2014/05/26 06:21:07 Done.
476 return;
477 }
478
479 base::TimeTicks now = base::TimeTicks::Now();
480 frame_delivery_times_.push_back(now);
481
482 rendering_helper_->RenderTexture(texture_target_,
483 picture_buffer->texture_id());
484
485 if (pending_picture_buffer_ids_.size() <= 1) {
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 can't be <1 so replace with ==1
Owen Lin 2014/05/26 06:21:07 Done.
486 pending_picture_updated_ = false;
487 } else {
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 don't need to pending_picture_updated_=true; ?
Owen Lin 2014/05/26 06:21:07 We get here only when pending_picture_updated == t
488 pending_picture_buffer_ids_.pop_front();
489 ReturnPicture(buffer_id);
490 }
491 }
492
621 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { 493 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) {
622 // We shouldn't be getting pictures delivered after Reset has completed. 494 // We shouldn't be getting pictures delivered after Reset has completed.
623 CHECK_LT(state_, CS_RESET); 495 CHECK_LT(state_, CS_RESET);
624 496
625 if (decoder_deleted()) 497 if (decoder_deleted())
626 return; 498 return;
627 499
628 base::TimeTicks now = base::TimeTicks::Now(); 500 base::TimeTicks now = base::TimeTicks::Now();
629 frame_delivery_times_.push_back(now);
630 // Save the decode time of this picture. 501 // Save the decode time of this picture.
631 std::map<int, base::TimeTicks>::iterator it = 502 std::map<int, base::TimeTicks>::iterator it =
632 decode_start_time_.find(picture.bitstream_buffer_id()); 503 decode_start_time_.find(picture.bitstream_buffer_id());
633 ASSERT_NE(decode_start_time_.end(), it); 504 ASSERT_NE(decode_start_time_.end(), it);
634 decode_time_.push_back(now - it->second); 505 decode_time_.push_back(now - it->second);
635 decode_start_time_.erase(it); 506 decode_start_time_.erase(it);
636 507
637 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_); 508 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_);
638 ++num_decoded_frames_; 509 ++num_decoded_frames_;
639 510
640 // Mid-stream reset applies only to the last play-through per constructor 511 // Mid-stream reset applies only to the last play-through per constructor
641 // comment. 512 // comment.
642 if (remaining_play_throughs_ == 1 && 513 if (remaining_play_throughs_ == 1 &&
643 reset_after_frame_num_ == num_decoded_frames()) { 514 reset_after_frame_num_ == num_decoded_frames_) {
644 reset_after_frame_num_ = MID_STREAM_RESET; 515 reset_after_frame_num_ = MID_STREAM_RESET;
645 decoder_->Reset(); 516 decoder_->Reset();
646 // Re-start decoding from the beginning of the stream to avoid needing to 517 // Re-start decoding from the beginning of the stream to avoid needing to
647 // know how to find I-frames and so on in this test. 518 // know how to find I-frames and so on in this test.
648 encoded_data_next_pos_to_decode_ = 0; 519 encoded_data_next_pos_to_decode_ = 0;
649 } 520 }
650 521
651 media::PictureBuffer* picture_buffer = 522 if (render_as_thumbnails_) {
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 It's unfortunate that the first and last cases are
652 picture_buffers_by_id_[picture.picture_buffer_id()]; 523 frame_delivery_times_.push_back(now);
653 CHECK(picture_buffer); 524 media::PictureBuffer* picture_buffer =
654 if (!suppress_rendering_) { 525 picture_buffers_by_id_[picture.picture_buffer_id()];
655 rendering_helper_->RenderTexture(texture_target_, 526 CHECK(picture_buffer);
656 picture_buffer->texture_id()); 527 rendering_helper_->RenderThumbnail(texture_target_,
528 picture_buffer->texture_id());
529 ReturnPicture(picture.picture_buffer_id());
530 } else if (!suppress_rendering_) {
531 // Keep the picture for rendering.
532 pending_picture_buffer_ids_.push_back(picture.picture_buffer_id());
533 if (pending_picture_buffer_ids_.size() > 1 &&
534 !pending_picture_updated_) {
535 ReturnPicture(pending_picture_buffer_ids_.front());
536 pending_picture_buffer_ids_.pop_front();
537 pending_picture_updated_ = true;
538 }
539 } else {
540 frame_delivery_times_.push_back(now);
541 ReturnPicture(picture.picture_buffer_id());
657 } 542 }
543 }
658 544
659 if (num_decoded_frames() > delay_reuse_after_frame_num_) { 545 void GLRenderingVDAClient::ReturnPicture(int32 picture_buffer_id) {
546 if (decoder_deleted())
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 I think this sort of check could be dropped if you
Owen Lin 2014/05/26 06:21:07 For the TearDownTiming tests, we could delete the
547 return;
548 if (num_decoded_frames_ > delay_reuse_after_frame_num_) {
660 base::MessageLoop::current()->PostDelayedTask( 549 base::MessageLoop::current()->PostDelayedTask(
661 FROM_HERE, 550 FROM_HERE,
662 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, 551 base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer,
663 weak_decoder_factory_->GetWeakPtr(), 552 weak_decoder_factory_->GetWeakPtr(),
664 picture.picture_buffer_id()), 553 picture_buffer_id),
665 kReuseDelay); 554 kReuseDelay);
666 } else { 555 } else {
667 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); 556 decoder_->ReusePictureBuffer(picture_buffer_id);
668 } 557 }
669 } 558 }
670 559
671 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( 560 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer(
672 int32 bitstream_buffer_id) { 561 int32 bitstream_buffer_id) {
673 // TODO(fischman): this test currently relies on this notification to make 562 // TODO(fischman): this test currently relies on this notification to make
674 // forward progress during a Reset(). But the VDA::Reset() API doesn't 563 // forward progress during a Reset(). But the VDA::Reset() API doesn't
675 // guarantee this, so stop relying on it (and remove the notifications from 564 // guarantee this, so stop relying on it (and remove the notifications from
676 // VaapiVideoDecodeAccelerator::FinishReset()). 565 // VaapiVideoDecodeAccelerator::FinishReset()).
677 ++num_done_bitstream_buffers_; 566 ++num_done_bitstream_buffers_;
(...skipping 11 matching lines...) Expand all
689 if (decoder_deleted()) 578 if (decoder_deleted())
690 return; 579 return;
691 decoder_->Reset(); 580 decoder_->Reset();
692 SetState(CS_RESETTING); 581 SetState(CS_RESETTING);
693 } 582 }
694 583
695 void GLRenderingVDAClient::NotifyResetDone() { 584 void GLRenderingVDAClient::NotifyResetDone() {
696 if (decoder_deleted()) 585 if (decoder_deleted())
697 return; 586 return;
698 587
588 // Clear pending_pictures and reuse them.
589 while (!pending_picture_buffer_ids_.empty()) {
590 decoder_->ReusePictureBuffer(pending_picture_buffer_ids_.front());
591 pending_picture_buffer_ids_.pop_front();
Ami GONE FROM CHROMIUM 2014/05/21 18:25:54 pending_picture_updated_ = false; ?
Owen Lin 2014/05/26 06:21:07 Thanks. Done. However, the initial value should be
592 }
593
699 if (reset_after_frame_num_ == MID_STREAM_RESET) { 594 if (reset_after_frame_num_ == MID_STREAM_RESET) {
700 reset_after_frame_num_ = END_OF_STREAM_RESET; 595 reset_after_frame_num_ = END_OF_STREAM_RESET;
701 DecodeNextFragment(); 596 DecodeNextFragment();
702 return; 597 return;
703 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) { 598 } else if (reset_after_frame_num_ == START_OF_STREAM_RESET) {
704 reset_after_frame_num_ = END_OF_STREAM_RESET; 599 reset_after_frame_num_ = END_OF_STREAM_RESET;
705 for (int i = 0; i < num_in_flight_decodes_; ++i) 600 for (int i = 0; i < num_in_flight_decodes_; ++i)
706 DecodeNextFragment(); 601 DecodeNextFragment();
707 return; 602 return;
708 } 603 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 } 826 }
932 827
933 if (decode_calls_per_second_ > 0) { 828 if (decode_calls_per_second_ > 0) {
934 base::MessageLoop::current()->PostDelayedTask( 829 base::MessageLoop::current()->PostDelayedTask(
935 FROM_HERE, 830 FROM_HERE,
936 base::Bind(&GLRenderingVDAClient::DecodeNextFragment, AsWeakPtr()), 831 base::Bind(&GLRenderingVDAClient::DecodeNextFragment, AsWeakPtr()),
937 base::TimeDelta::FromSeconds(1) / decode_calls_per_second_); 832 base::TimeDelta::FromSeconds(1) / decode_calls_per_second_);
938 } 833 }
939 } 834 }
940 835
941 int GLRenderingVDAClient::num_decoded_frames() {
942 return throttling_client_ ? throttling_client_->num_decoded_frames()
943 : num_decoded_frames_;
944 }
945
946 double GLRenderingVDAClient::frames_per_second() { 836 double GLRenderingVDAClient::frames_per_second() {
947 base::TimeDelta delta = frame_delivery_times_.back() - initialize_done_ticks_; 837 base::TimeDelta delta = frame_delivery_times_.back() - initialize_done_ticks_;
948 return num_decoded_frames() / delta.InSecondsF(); 838 return num_decoded_frames_ / delta.InSecondsF();
949 } 839 }
950 840
951 base::TimeDelta GLRenderingVDAClient::decode_time_median() { 841 base::TimeDelta GLRenderingVDAClient::decode_time_median() {
952 if (decode_time_.size() == 0) 842 if (decode_time_.size() == 0)
953 return base::TimeDelta(); 843 return base::TimeDelta();
954 std::sort(decode_time_.begin(), decode_time_.end()); 844 std::sort(decode_time_.begin(), decode_time_.end());
955 int index = decode_time_.size() / 2; 845 int index = decode_time_.size() / 2;
956 if (decode_time_.size() % 2 != 0) 846 if (decode_time_.size() % 2 != 0)
957 return decode_time_[index]; 847 return decode_time_[index];
958 848
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 const size_t num_in_flight_decodes = GetParam().b; 1082 const size_t num_in_flight_decodes = GetParam().b;
1193 const int num_play_throughs = GetParam().c; 1083 const int num_play_throughs = GetParam().c;
1194 const int reset_point = GetParam().d; 1084 const int reset_point = GetParam().d;
1195 const int delete_decoder_state = GetParam().e; 1085 const int delete_decoder_state = GetParam().e;
1196 bool test_reuse_delay = GetParam().f; 1086 bool test_reuse_delay = GetParam().f;
1197 const bool render_as_thumbnails = GetParam().g; 1087 const bool render_as_thumbnails = GetParam().g;
1198 1088
1199 UpdateTestVideoFileParams( 1089 UpdateTestVideoFileParams(
1200 num_concurrent_decoders, reset_point, &test_video_files_); 1090 num_concurrent_decoders, reset_point, &test_video_files_);
1201 1091
1202 // Suppress GL rendering for all tests when the "--disable_rendering" is set. 1092 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1203 const bool suppress_rendering = g_disable_rendering; 1093 const bool suppress_rendering = g_rendering_fps == 0;
1204 1094
1205 std::vector<ClientStateNotification<ClientState>*> 1095 std::vector<ClientStateNotification<ClientState>*>
1206 notes(num_concurrent_decoders, NULL); 1096 notes(num_concurrent_decoders, NULL);
1207 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 1097 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
1208 1098
1209 RenderingHelperParams helper_params; 1099 RenderingHelperParams helper_params;
1100 helper_params.rendering_fps = g_rendering_fps;
1210 helper_params.num_windows = num_concurrent_decoders; 1101 helper_params.num_windows = num_concurrent_decoders;
1211 helper_params.render_as_thumbnails = render_as_thumbnails; 1102 helper_params.render_as_thumbnails = render_as_thumbnails;
1212 if (render_as_thumbnails) { 1103 if (render_as_thumbnails) {
1213 // Only one decoder is supported with thumbnail rendering 1104 // Only one decoder is supported with thumbnail rendering
1214 CHECK_EQ(num_concurrent_decoders, 1U); 1105 CHECK_EQ(num_concurrent_decoders, 1U);
1215 gfx::Size frame_size(test_video_files_[0]->width, 1106 gfx::Size frame_size(test_video_files_[0]->width,
1216 test_video_files_[0]->height); 1107 test_video_files_[0]->height);
1217 helper_params.frame_dimensions.push_back(frame_size); 1108 helper_params.frame_dimensions.push_back(frame_size);
1218 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize); 1109 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize);
1219 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1110 helper_params.thumbnails_page_size = kThumbnailsPageSize;
(...skipping 27 matching lines...) Expand all
1247 index, 1138 index,
1248 note, 1139 note,
1249 video_file->data_str, 1140 video_file->data_str,
1250 num_in_flight_decodes, 1141 num_in_flight_decodes,
1251 num_play_throughs, 1142 num_play_throughs,
1252 video_file->reset_after_frame_num, 1143 video_file->reset_after_frame_num,
1253 delete_decoder_state, 1144 delete_decoder_state,
1254 video_file->width, 1145 video_file->width,
1255 video_file->height, 1146 video_file->height,
1256 video_file->profile, 1147 video_file->profile,
1257 g_rendering_fps,
1258 suppress_rendering, 1148 suppress_rendering,
1259 delay_after_frame_num, 1149 delay_after_frame_num,
1260 0); 1150 0,
1151 render_as_thumbnails);
1152
1261 clients[index] = client; 1153 clients[index] = client;
1154 rendering_helper_.SetClient(index, client);
1262 1155
1263 CreateAndStartDecoder(client, note); 1156 CreateAndStartDecoder(client, note);
1264 } 1157 }
1265 // Then wait for all the decodes to finish. 1158 // Then wait for all the decodes to finish.
1266 // Only check performance & correctness later if we play through only once. 1159 // Only check performance & correctness later if we play through only once.
1267 bool skip_performance_and_correctness_checks = num_play_throughs > 1; 1160 bool skip_performance_and_correctness_checks = num_play_throughs > 1;
1268 for (size_t i = 0; i < num_concurrent_decoders; ++i) { 1161 for (size_t i = 0; i < num_concurrent_decoders; ++i) {
1269 ClientStateNotification<ClientState>* note = notes[i]; 1162 ClientStateNotification<ClientState>* note = notes[i];
1270 ClientState state = note->Wait(); 1163 ClientState state = note->Wait();
1271 if (state != CS_INITIALIZED) { 1164 if (state != CS_INITIALIZED) {
(...skipping 25 matching lines...) Expand all
1297 } 1190 }
1298 ASSERT_NO_FATAL_FAILURE( 1191 ASSERT_NO_FATAL_FAILURE(
1299 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET)); 1192 AssertWaitForStateOrDeleted(note, clients[i], CS_RESET));
1300 // ResetDone requests Destroy(). 1193 // ResetDone requests Destroy().
1301 ASSERT_NO_FATAL_FAILURE( 1194 ASSERT_NO_FATAL_FAILURE(
1302 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED)); 1195 AssertWaitForStateOrDeleted(note, clients[i], CS_DESTROYED));
1303 } 1196 }
1304 // Finally assert that decoding went as expected. 1197 // Finally assert that decoding went as expected.
1305 for (size_t i = 0; i < num_concurrent_decoders && 1198 for (size_t i = 0; i < num_concurrent_decoders &&
1306 !skip_performance_and_correctness_checks; ++i) { 1199 !skip_performance_and_correctness_checks; ++i) {
1200 rendering_helper_.SetClient(i, NULL);
1307 // We can only make performance/correctness assertions if the decoder was 1201 // We can only make performance/correctness assertions if the decoder was
1308 // allowed to finish. 1202 // allowed to finish.
1309 if (delete_decoder_state < CS_FLUSHED) 1203 if (delete_decoder_state < CS_FLUSHED)
1310 continue; 1204 continue;
1311 GLRenderingVDAClient* client = clients[i]; 1205 GLRenderingVDAClient* client = clients[i];
1312 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()]; 1206 TestVideoFile* video_file = test_video_files_[i % test_video_files_.size()];
1313 if (video_file->num_frames > 0) { 1207 if (video_file->num_frames > 0) {
1314 // Expect the decoded frames may be more than the video frames as frames 1208 // Expect the decoded frames may be more than the video frames as frames
1315 // could still be returned until resetting done. 1209 // could still be returned until resetting done.
1316 if (video_file->reset_after_frame_num > 0) 1210 if (video_file->reset_after_frame_num > 0)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 // Thumbnailing test 1365 // Thumbnailing test
1472 INSTANTIATE_TEST_CASE_P( 1366 INSTANTIATE_TEST_CASE_P(
1473 Thumbnail, VideoDecodeAcceleratorParamTest, 1367 Thumbnail, VideoDecodeAcceleratorParamTest,
1474 ::testing::Values( 1368 ::testing::Values(
1475 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1369 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1476 1370
1477 // Measure the median of the decode time when VDA::Decode is called 30 times per 1371 // Measure the median of the decode time when VDA::Decode is called 30 times per
1478 // second. 1372 // second.
1479 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1373 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1480 RenderingHelperParams helper_params; 1374 RenderingHelperParams helper_params;
1375
1376 // Disable rendering by setting the rendering_fps = 0.
1377 helper_params.rendering_fps = 0;
1481 helper_params.num_windows = 1; 1378 helper_params.num_windows = 1;
1482 helper_params.render_as_thumbnails = false; 1379 helper_params.render_as_thumbnails = false;
1483 gfx::Size frame_size(test_video_files_[0]->width, 1380 gfx::Size frame_size(test_video_files_[0]->width,
1484 test_video_files_[0]->height); 1381 test_video_files_[0]->height);
1485 helper_params.frame_dimensions.push_back(frame_size); 1382 helper_params.frame_dimensions.push_back(frame_size);
1486 helper_params.window_dimensions.push_back(frame_size); 1383 helper_params.window_dimensions.push_back(frame_size);
1487 InitializeRenderingHelper(helper_params); 1384 InitializeRenderingHelper(helper_params);
1488 1385
1489 ClientStateNotification<ClientState>* note = 1386 ClientStateNotification<ClientState>* note =
1490 new ClientStateNotification<ClientState>(); 1387 new ClientStateNotification<ClientState>();
1491 GLRenderingVDAClient* client = 1388 GLRenderingVDAClient* client =
1492 new GLRenderingVDAClient(&rendering_helper_, 1389 new GLRenderingVDAClient(&rendering_helper_,
1493 0, 1390 0,
1494 note, 1391 note,
1495 test_video_files_[0]->data_str, 1392 test_video_files_[0]->data_str,
1496 1, 1393 1,
1497 1, 1394 1,
1498 test_video_files_[0]->reset_after_frame_num, 1395 test_video_files_[0]->reset_after_frame_num,
1499 CS_RESET, 1396 CS_RESET,
1500 test_video_files_[0]->width, 1397 test_video_files_[0]->width,
1501 test_video_files_[0]->height, 1398 test_video_files_[0]->height,
1502 test_video_files_[0]->profile, 1399 test_video_files_[0]->profile,
1503 g_rendering_fps,
1504 true, 1400 true,
1505 std::numeric_limits<int>::max(), 1401 std::numeric_limits<int>::max(),
1506 kWebRtcDecodeCallsPerSecond); 1402 kWebRtcDecodeCallsPerSecond,
1403 false /* render_as_thumbnail */);
1404 rendering_helper_.SetClient(0, client);
1507 CreateAndStartDecoder(client, note); 1405 CreateAndStartDecoder(client, note);
1508 WaitUntilDecodeFinish(note); 1406 WaitUntilDecodeFinish(note);
1407 rendering_helper_.SetClient(0, NULL);
1509 1408
1510 base::TimeDelta decode_time_median = client->decode_time_median(); 1409 base::TimeDelta decode_time_median = client->decode_time_median();
1511 std::string output_string = 1410 std::string output_string =
1512 base::StringPrintf("Decode time median: %" PRId64 " us", 1411 base::StringPrintf("Decode time median: %" PRId64 " us",
1513 decode_time_median.InMicroseconds()); 1412 decode_time_median.InMicroseconds());
1514 LOG(INFO) << output_string; 1413 LOG(INFO) << output_string;
1515 1414
1516 if (g_output_log != NULL) 1415 if (g_output_log != NULL)
1517 OutputLogFile(g_output_log, output_string); 1416 OutputLogFile(g_output_log, output_string);
1518 1417
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 content::g_output_log = it->second.c_str(); 1453 content::g_output_log = it->second.c_str();
1555 continue; 1454 continue;
1556 } 1455 }
1557 if (it->first == "rendering_fps") { 1456 if (it->first == "rendering_fps") {
1558 // On Windows, CommandLine::StringType is wstring. We need to convert 1457 // On Windows, CommandLine::StringType is wstring. We need to convert
1559 // it to std::string first 1458 // it to std::string first
1560 std::string input(it->second.begin(), it->second.end()); 1459 std::string input(it->second.begin(), it->second.end());
1561 CHECK(base::StringToDouble(input, &content::g_rendering_fps)); 1460 CHECK(base::StringToDouble(input, &content::g_rendering_fps));
1562 continue; 1461 continue;
1563 } 1462 }
1463 // TODO(owenlin): Remove this flag once it is not used in autotest.
1564 if (it->first == "disable_rendering") { 1464 if (it->first == "disable_rendering") {
1565 content::g_disable_rendering = true; 1465 content::g_rendering_fps = 0;
1566 continue; 1466 continue;
1567 } 1467 }
1568 if (it->first == "v" || it->first == "vmodule") 1468 if (it->first == "v" || it->first == "vmodule")
1569 continue; 1469 continue;
1570 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1470 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1571 } 1471 }
1572 1472
1573 base::ShadowingAtExitManager at_exit_manager; 1473 base::ShadowingAtExitManager at_exit_manager;
1574 1474
1575 return RUN_ALL_TESTS(); 1475 return RUN_ALL_TESTS();
1576 } 1476 }
OLDNEW
« content/common/gpu/media/rendering_helper.h ('K') | « content/common/gpu/media/rendering_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698