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

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

Issue 298123003: rendering_helper - Change the layout of the rendering areas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compiling error Created 6 years, 6 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 | « content/common/gpu/media/rendering_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 int height; 135 int height;
136 int num_frames; 136 int num_frames;
137 int num_fragments; 137 int num_fragments;
138 int min_fps_render; 138 int min_fps_render;
139 int min_fps_no_render; 139 int min_fps_no_render;
140 media::VideoCodecProfile profile; 140 media::VideoCodecProfile profile;
141 int reset_after_frame_num; 141 int reset_after_frame_num;
142 std::string data_str; 142 std::string data_str;
143 }; 143 };
144 144
145 const gfx::Size kThumbnailsDisplaySize(1366, 768);
146 const gfx::Size kThumbnailsPageSize(1600, 1200); 145 const gfx::Size kThumbnailsPageSize(1600, 1200);
147 const gfx::Size kThumbnailSize(160, 120); 146 const gfx::Size kThumbnailSize(160, 120);
148 const int kMD5StringLength = 32; 147 const int kMD5StringLength = 32;
149 148
150 // Read in golden MD5s for the thumbnailed rendering of this video 149 // Read in golden MD5s for the thumbnailed rendering of this video
151 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file, 150 void ReadGoldenThumbnailMD5s(const TestVideoFile* video_file,
152 std::vector<std::string>* md5_strings) { 151 std::vector<std::string>* md5_strings) {
153 base::FilePath filepath(video_file->file_name); 152 base::FilePath filepath(video_file->file_name);
154 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5")); 153 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".md5"));
155 std::string all_md5s; 154 std::string all_md5s;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode() 206 // Destroy()'d and deleted and can take values: N<0: delete after -N Decode()
208 // calls have been made, N>=0 means interpret as ClientState. 207 // calls have been made, N>=0 means interpret as ClientState.
209 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the 208 // Both |reset_after_frame_num| & |delete_decoder_state| apply only to the
210 // last play-through (governed by |num_play_throughs|). 209 // last play-through (governed by |num_play_throughs|).
211 // |suppress_rendering| indicates GL rendering is supressed or not. 210 // |suppress_rendering| indicates GL rendering is supressed or not.
212 // After |delay_reuse_after_frame_num| frame has been delivered, the client 211 // After |delay_reuse_after_frame_num| frame has been delivered, the client
213 // will start delaying the call to ReusePictureBuffer() for kReuseDelay. 212 // will start delaying the call to ReusePictureBuffer() for kReuseDelay.
214 // |decode_calls_per_second| is the number of VDA::Decode calls per second. 213 // |decode_calls_per_second| is the number of VDA::Decode calls per second.
215 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1. 214 // If |decode_calls_per_second| > 0, |num_in_flight_decodes| must be 1.
216 GLRenderingVDAClient(RenderingHelper* rendering_helper, 215 GLRenderingVDAClient(RenderingHelper* rendering_helper,
217 int rendering_window_id,
218 ClientStateNotification<ClientState>* note, 216 ClientStateNotification<ClientState>* note,
219 const std::string& encoded_data, 217 const std::string& encoded_data,
220 int num_in_flight_decodes, 218 int num_in_flight_decodes,
221 int num_play_throughs, 219 int num_play_throughs,
222 int reset_after_frame_num, 220 int reset_after_frame_num,
223 int delete_decoder_state, 221 int delete_decoder_state,
224 int frame_width, 222 int frame_width,
225 int frame_height, 223 int frame_height,
226 media::VideoCodecProfile profile, 224 media::VideoCodecProfile profile,
227 bool suppress_rendering, 225 bool suppress_rendering,
(...skipping 11 matching lines...) Expand all
239 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; 237 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE;
240 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 238 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
241 // Simple state changes. 239 // Simple state changes.
242 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; 240 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE;
243 virtual void NotifyFlushDone() OVERRIDE; 241 virtual void NotifyFlushDone() OVERRIDE;
244 virtual void NotifyResetDone() OVERRIDE; 242 virtual void NotifyResetDone() OVERRIDE;
245 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE; 243 virtual void NotifyError(VideoDecodeAccelerator::Error error) OVERRIDE;
246 244
247 // RenderingHelper::Client implementation. 245 // RenderingHelper::Client implementation.
248 virtual void RenderContent(RenderingHelper*) OVERRIDE; 246 virtual void RenderContent(RenderingHelper*) OVERRIDE;
247 virtual const gfx::Size& GetWindowSize() OVERRIDE;
249 248
250 void OutputFrameDeliveryTimes(base::File* output); 249 void OutputFrameDeliveryTimes(base::File* output);
251 250
252 void NotifyFrameDropped(int32 picture_buffer_id); 251 void NotifyFrameDropped(int32 picture_buffer_id);
253 252
254 // Simple getters for inspecting the state of the Client. 253 // Simple getters for inspecting the state of the Client.
255 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } 254 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; }
256 int num_skipped_fragments() { return num_skipped_fragments_; } 255 int num_skipped_fragments() { return num_skipped_fragments_; }
257 int num_queued_fragments() { return num_queued_fragments_; } 256 int num_queued_fragments() { return num_queued_fragments_; }
258 int num_decoded_frames() { return num_decoded_frames_; } 257 int num_decoded_frames() { return num_decoded_frames_; }
(...skipping 21 matching lines...) Expand all
280 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos); 279 std::string GetBytesForNextFragment(size_t start_pos, size_t* end_pos);
281 // Helpers for GetBytesForNextFragment above. 280 // Helpers for GetBytesForNextFragment above.
282 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264. 281 void GetBytesForNextNALU(size_t start_pos, size_t* end_pos); // For h.264.
283 std::string GetBytesForNextFrame( 282 std::string GetBytesForNextFrame(
284 size_t start_pos, size_t* end_pos); // For VP8. 283 size_t start_pos, size_t* end_pos); // For VP8.
285 284
286 // Request decode of the next fragment in the encoded data. 285 // Request decode of the next fragment in the encoded data.
287 void DecodeNextFragment(); 286 void DecodeNextFragment();
288 287
289 RenderingHelper* rendering_helper_; 288 RenderingHelper* rendering_helper_;
290 int rendering_window_id_; 289 gfx::Size frame_size_;
291 std::string encoded_data_; 290 std::string encoded_data_;
292 const int num_in_flight_decodes_; 291 const int num_in_flight_decodes_;
293 int outstanding_decodes_; 292 int outstanding_decodes_;
294 size_t encoded_data_next_pos_to_decode_; 293 size_t encoded_data_next_pos_to_decode_;
295 int next_bitstream_buffer_id_; 294 int next_bitstream_buffer_id_;
296 ClientStateNotification<ClientState>* note_; 295 ClientStateNotification<ClientState>* note_;
297 scoped_ptr<VideoDecodeAccelerator> decoder_; 296 scoped_ptr<VideoDecodeAccelerator> decoder_;
298 scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator> > 297 scoped_ptr<base::WeakPtrFactory<VideoDecodeAccelerator> >
299 weak_decoder_factory_; 298 weak_decoder_factory_;
300 std::set<int> outstanding_texture_ids_; 299 std::set<int> outstanding_texture_ids_;
(...skipping 20 matching lines...) Expand all
321 int decode_calls_per_second_; 320 int decode_calls_per_second_;
322 bool render_as_thumbnails_; 321 bool render_as_thumbnails_;
323 bool pending_picture_updated_; 322 bool pending_picture_updated_;
324 std::deque<int32> pending_picture_buffer_ids_; 323 std::deque<int32> pending_picture_buffer_ids_;
325 324
326 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient); 325 DISALLOW_IMPLICIT_CONSTRUCTORS(GLRenderingVDAClient);
327 }; 326 };
328 327
329 GLRenderingVDAClient::GLRenderingVDAClient( 328 GLRenderingVDAClient::GLRenderingVDAClient(
330 RenderingHelper* rendering_helper, 329 RenderingHelper* rendering_helper,
331 int rendering_window_id,
332 ClientStateNotification<ClientState>* note, 330 ClientStateNotification<ClientState>* note,
333 const std::string& encoded_data, 331 const std::string& encoded_data,
334 int num_in_flight_decodes, 332 int num_in_flight_decodes,
335 int num_play_throughs, 333 int num_play_throughs,
336 int reset_after_frame_num, 334 int reset_after_frame_num,
337 int delete_decoder_state, 335 int delete_decoder_state,
338 int frame_width, 336 int frame_width,
339 int frame_height, 337 int frame_height,
340 media::VideoCodecProfile profile, 338 media::VideoCodecProfile profile,
341 bool suppress_rendering, 339 bool suppress_rendering,
342 int delay_reuse_after_frame_num, 340 int delay_reuse_after_frame_num,
343 int decode_calls_per_second, 341 int decode_calls_per_second,
344 bool render_as_thumbnails) 342 bool render_as_thumbnails)
345 : rendering_helper_(rendering_helper), 343 : rendering_helper_(rendering_helper),
346 rendering_window_id_(rendering_window_id), 344 frame_size_(frame_width, frame_height),
347 encoded_data_(encoded_data), 345 encoded_data_(encoded_data),
348 num_in_flight_decodes_(num_in_flight_decodes), 346 num_in_flight_decodes_(num_in_flight_decodes),
349 outstanding_decodes_(0), 347 outstanding_decodes_(0),
350 encoded_data_next_pos_to_decode_(0), 348 encoded_data_next_pos_to_decode_(0),
351 next_bitstream_buffer_id_(0), 349 next_bitstream_buffer_id_(0),
352 note_(note), 350 note_(note),
353 remaining_play_throughs_(num_play_throughs), 351 remaining_play_throughs_(num_play_throughs),
354 reset_after_frame_num_(reset_after_frame_num), 352 reset_after_frame_num_(reset_after_frame_num),
355 delete_decoder_state_(delete_decoder_state), 353 delete_decoder_state_(delete_decoder_state),
356 state_(CS_CREATED), 354 state_(CS_CREATED),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 if (decoder_deleted()) 431 if (decoder_deleted())
434 return; 432 return;
435 std::vector<media::PictureBuffer> buffers; 433 std::vector<media::PictureBuffer> buffers;
436 434
437 texture_target_ = texture_target; 435 texture_target_ = texture_target;
438 for (uint32 i = 0; i < requested_num_of_buffers; ++i) { 436 for (uint32 i = 0; i < requested_num_of_buffers; ++i) {
439 uint32 id = picture_buffers_by_id_.size(); 437 uint32 id = picture_buffers_by_id_.size();
440 uint32 texture_id; 438 uint32 texture_id;
441 base::WaitableEvent done(false, false); 439 base::WaitableEvent done(false, false);
442 rendering_helper_->CreateTexture( 440 rendering_helper_->CreateTexture(
443 rendering_window_id_, texture_target_, &texture_id, &done); 441 texture_target_, &texture_id, dimensions, &done);
444 done.Wait(); 442 done.Wait();
445 CHECK(outstanding_texture_ids_.insert(texture_id).second); 443 CHECK(outstanding_texture_ids_.insert(texture_id).second);
446 media::PictureBuffer* buffer = 444 media::PictureBuffer* buffer =
447 new media::PictureBuffer(id, dimensions, texture_id); 445 new media::PictureBuffer(id, dimensions, texture_id);
448 CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second); 446 CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
449 buffers.push_back(*buffer); 447 buffers.push_back(*buffer);
450 } 448 }
451 decoder_->AssignPictureBuffers(buffers); 449 decoder_->AssignPictureBuffers(buffers);
452 } 450 }
453 451
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 picture_buffer->texture_id()); 484 picture_buffer->texture_id());
487 485
488 if (pending_picture_buffer_ids_.size() == 1) { 486 if (pending_picture_buffer_ids_.size() == 1) {
489 pending_picture_updated_ = false; 487 pending_picture_updated_ = false;
490 } else { 488 } else {
491 pending_picture_buffer_ids_.pop_front(); 489 pending_picture_buffer_ids_.pop_front();
492 ReturnPicture(buffer_id); 490 ReturnPicture(buffer_id);
493 } 491 }
494 } 492 }
495 493
494 const gfx::Size& GLRenderingVDAClient::GetWindowSize() {
495 return render_as_thumbnails_ ? kThumbnailsPageSize : frame_size_;
496 }
497
496 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) { 498 void GLRenderingVDAClient::PictureReady(const media::Picture& picture) {
497 // We shouldn't be getting pictures delivered after Reset has completed. 499 // We shouldn't be getting pictures delivered after Reset has completed.
498 CHECK_LT(state_, CS_RESET); 500 CHECK_LT(state_, CS_RESET);
499 501
500 if (decoder_deleted()) 502 if (decoder_deleted())
501 return; 503 return;
502 504
503 base::TimeTicks now = base::TimeTicks::Now(); 505 base::TimeTicks now = base::TimeTicks::Now();
504 // Save the decode time of this picture. 506 // Save the decode time of this picture.
505 std::map<int, base::TimeTicks>::iterator it = 507 std::map<int, base::TimeTicks>::iterator it =
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1097
1096 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. 1098 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1097 const bool suppress_rendering = g_rendering_fps == 0; 1099 const bool suppress_rendering = g_rendering_fps == 0;
1098 1100
1099 std::vector<ClientStateNotification<ClientState>*> 1101 std::vector<ClientStateNotification<ClientState>*>
1100 notes(num_concurrent_decoders, NULL); 1102 notes(num_concurrent_decoders, NULL);
1101 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 1103 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
1102 1104
1103 RenderingHelperParams helper_params; 1105 RenderingHelperParams helper_params;
1104 helper_params.rendering_fps = g_rendering_fps; 1106 helper_params.rendering_fps = g_rendering_fps;
1105 helper_params.num_windows = num_concurrent_decoders;
1106 helper_params.render_as_thumbnails = render_as_thumbnails; 1107 helper_params.render_as_thumbnails = render_as_thumbnails;
1107 if (render_as_thumbnails) { 1108 if (render_as_thumbnails) {
1108 // Only one decoder is supported with thumbnail rendering 1109 // Only one decoder is supported with thumbnail rendering
1109 CHECK_EQ(num_concurrent_decoders, 1U); 1110 CHECK_EQ(num_concurrent_decoders, 1U);
1110 gfx::Size frame_size(test_video_files_[0]->width,
1111 test_video_files_[0]->height);
1112 helper_params.frame_dimensions.push_back(frame_size);
1113 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize);
1114 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1111 helper_params.thumbnails_page_size = kThumbnailsPageSize;
1115 helper_params.thumbnail_size = kThumbnailSize; 1112 helper_params.thumbnail_size = kThumbnailSize;
1116 } else {
1117 for (size_t index = 0; index < test_video_files_.size(); ++index) {
1118 gfx::Size frame_size(test_video_files_[index]->width,
1119 test_video_files_[index]->height);
1120 helper_params.frame_dimensions.push_back(frame_size);
1121 helper_params.window_dimensions.push_back(frame_size);
1122 }
1123 } 1113 }
1124 1114
1125 // First kick off all the decoders. 1115 // First kick off all the decoders.
1126 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1116 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1127 TestVideoFile* video_file = 1117 TestVideoFile* video_file =
1128 test_video_files_[index % test_video_files_.size()]; 1118 test_video_files_[index % test_video_files_.size()];
1129 ClientStateNotification<ClientState>* note = 1119 ClientStateNotification<ClientState>* note =
1130 new ClientStateNotification<ClientState>(); 1120 new ClientStateNotification<ClientState>();
1131 notes[index] = note; 1121 notes[index] = note;
1132 1122
1133 int delay_after_frame_num = std::numeric_limits<int>::max(); 1123 int delay_after_frame_num = std::numeric_limits<int>::max();
1134 if (test_reuse_delay && 1124 if (test_reuse_delay &&
1135 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { 1125 kMaxFramesToDelayReuse * 2 < video_file->num_frames) {
1136 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; 1126 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse;
1137 } 1127 }
1138 1128
1139 GLRenderingVDAClient* client = 1129 GLRenderingVDAClient* client =
1140 new GLRenderingVDAClient(&rendering_helper_, 1130 new GLRenderingVDAClient(&rendering_helper_,
1141 index,
1142 note, 1131 note,
1143 video_file->data_str, 1132 video_file->data_str,
1144 num_in_flight_decodes, 1133 num_in_flight_decodes,
1145 num_play_throughs, 1134 num_play_throughs,
1146 video_file->reset_after_frame_num, 1135 video_file->reset_after_frame_num,
1147 delete_decoder_state, 1136 delete_decoder_state,
1148 video_file->width, 1137 video_file->width,
1149 video_file->height, 1138 video_file->height,
1150 video_file->profile, 1139 video_file->profile,
1151 suppress_rendering, 1140 suppress_rendering,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 ::testing::Values( 1364 ::testing::Values(
1376 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1365 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1377 1366
1378 // Measure the median of the decode time when VDA::Decode is called 30 times per 1367 // Measure the median of the decode time when VDA::Decode is called 30 times per
1379 // second. 1368 // second.
1380 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1369 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1381 RenderingHelperParams helper_params; 1370 RenderingHelperParams helper_params;
1382 1371
1383 // Disable rendering by setting the rendering_fps = 0. 1372 // Disable rendering by setting the rendering_fps = 0.
1384 helper_params.rendering_fps = 0; 1373 helper_params.rendering_fps = 0;
1385 helper_params.num_windows = 1;
1386 helper_params.render_as_thumbnails = false; 1374 helper_params.render_as_thumbnails = false;
1387 gfx::Size frame_size(test_video_files_[0]->width,
1388 test_video_files_[0]->height);
1389 helper_params.frame_dimensions.push_back(frame_size);
1390 helper_params.window_dimensions.push_back(frame_size);
1391 1375
1392 ClientStateNotification<ClientState>* note = 1376 ClientStateNotification<ClientState>* note =
1393 new ClientStateNotification<ClientState>(); 1377 new ClientStateNotification<ClientState>();
1394 GLRenderingVDAClient* client = 1378 GLRenderingVDAClient* client =
1395 new GLRenderingVDAClient(&rendering_helper_, 1379 new GLRenderingVDAClient(&rendering_helper_,
1396 0,
1397 note, 1380 note,
1398 test_video_files_[0]->data_str, 1381 test_video_files_[0]->data_str,
1399 1, 1382 1,
1400 1, 1383 1,
1401 test_video_files_[0]->reset_after_frame_num, 1384 test_video_files_[0]->reset_after_frame_num,
1402 CS_RESET, 1385 CS_RESET,
1403 test_video_files_[0]->width, 1386 test_video_files_[0]->width,
1404 test_video_files_[0]->height, 1387 test_video_files_[0]->height,
1405 test_video_files_[0]->profile, 1388 test_video_files_[0]->profile,
1406 true, 1389 true,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 } 1456 }
1474 if (it->first == "v" || it->first == "vmodule") 1457 if (it->first == "v" || it->first == "vmodule")
1475 continue; 1458 continue;
1476 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1459 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1477 } 1460 }
1478 1461
1479 base::ShadowingAtExitManager at_exit_manager; 1462 base::ShadowingAtExitManager at_exit_manager;
1480 1463
1481 return RUN_ALL_TESTS(); 1464 return RUN_ALL_TESTS();
1482 } 1465 }
OLDNEW
« no previous file with comments | « 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