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

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: 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
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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 1096
1095 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. 1097 // Suppress GL rendering for all tests when the "--rendering_fps" is 0.
1096 const bool suppress_rendering = g_rendering_fps == 0; 1098 const bool suppress_rendering = g_rendering_fps == 0;
1097 1099
1098 std::vector<ClientStateNotification<ClientState>*> 1100 std::vector<ClientStateNotification<ClientState>*>
1099 notes(num_concurrent_decoders, NULL); 1101 notes(num_concurrent_decoders, NULL);
1100 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL); 1102 std::vector<GLRenderingVDAClient*> clients(num_concurrent_decoders, NULL);
1101 1103
1102 RenderingHelperParams helper_params; 1104 RenderingHelperParams helper_params;
1103 helper_params.rendering_fps = g_rendering_fps; 1105 helper_params.rendering_fps = g_rendering_fps;
1104 helper_params.num_windows = num_concurrent_decoders;
1105 helper_params.render_as_thumbnails = render_as_thumbnails; 1106 helper_params.render_as_thumbnails = render_as_thumbnails;
1106 if (render_as_thumbnails) { 1107 if (render_as_thumbnails) {
1107 // Only one decoder is supported with thumbnail rendering 1108 // Only one decoder is supported with thumbnail rendering
1108 CHECK_EQ(num_concurrent_decoders, 1U); 1109 CHECK_EQ(num_concurrent_decoders, 1U);
1109 gfx::Size frame_size(test_video_files_[0]->width,
1110 test_video_files_[0]->height);
1111 helper_params.frame_dimensions.push_back(frame_size);
1112 helper_params.window_dimensions.push_back(kThumbnailsDisplaySize);
1113 helper_params.thumbnails_page_size = kThumbnailsPageSize; 1110 helper_params.thumbnails_page_size = kThumbnailsPageSize;
1114 helper_params.thumbnail_size = kThumbnailSize; 1111 helper_params.thumbnail_size = kThumbnailSize;
1115 } else {
1116 for (size_t index = 0; index < test_video_files_.size(); ++index) {
1117 gfx::Size frame_size(test_video_files_[index]->width,
1118 test_video_files_[index]->height);
1119 helper_params.frame_dimensions.push_back(frame_size);
1120 helper_params.window_dimensions.push_back(frame_size);
1121 }
1122 } 1112 }
1123 1113
1124 // First kick off all the decoders. 1114 // First kick off all the decoders.
1125 for (size_t index = 0; index < num_concurrent_decoders; ++index) { 1115 for (size_t index = 0; index < num_concurrent_decoders; ++index) {
1126 TestVideoFile* video_file = 1116 TestVideoFile* video_file =
1127 test_video_files_[index % test_video_files_.size()]; 1117 test_video_files_[index % test_video_files_.size()];
1128 ClientStateNotification<ClientState>* note = 1118 ClientStateNotification<ClientState>* note =
1129 new ClientStateNotification<ClientState>(); 1119 new ClientStateNotification<ClientState>();
1130 notes[index] = note; 1120 notes[index] = note;
1131 1121
1132 int delay_after_frame_num = std::numeric_limits<int>::max(); 1122 int delay_after_frame_num = std::numeric_limits<int>::max();
1133 if (test_reuse_delay && 1123 if (test_reuse_delay &&
1134 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { 1124 kMaxFramesToDelayReuse * 2 < video_file->num_frames) {
1135 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; 1125 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse;
1136 } 1126 }
1137 1127
1138 GLRenderingVDAClient* client = 1128 GLRenderingVDAClient* client =
1139 new GLRenderingVDAClient(&rendering_helper_, 1129 new GLRenderingVDAClient(&rendering_helper_,
1140 index,
1141 note, 1130 note,
1142 video_file->data_str, 1131 video_file->data_str,
1143 num_in_flight_decodes, 1132 num_in_flight_decodes,
1144 num_play_throughs, 1133 num_play_throughs,
1145 video_file->reset_after_frame_num, 1134 video_file->reset_after_frame_num,
1146 delete_decoder_state, 1135 delete_decoder_state,
1147 video_file->width, 1136 video_file->width,
1148 video_file->height, 1137 video_file->height,
1149 video_file->profile, 1138 video_file->profile,
1150 suppress_rendering, 1139 suppress_rendering,
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 ::testing::Values( 1363 ::testing::Values(
1375 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1364 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1376 1365
1377 // Measure the median of the decode time when VDA::Decode is called 30 times per 1366 // Measure the median of the decode time when VDA::Decode is called 30 times per
1378 // second. 1367 // second.
1379 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1368 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1380 RenderingHelperParams helper_params; 1369 RenderingHelperParams helper_params;
1381 1370
1382 // Disable rendering by setting the rendering_fps = 0. 1371 // Disable rendering by setting the rendering_fps = 0.
1383 helper_params.rendering_fps = 0; 1372 helper_params.rendering_fps = 0;
1384 helper_params.num_windows = 1;
1385 helper_params.render_as_thumbnails = false; 1373 helper_params.render_as_thumbnails = false;
1386 gfx::Size frame_size(test_video_files_[0]->width,
1387 test_video_files_[0]->height);
1388 helper_params.frame_dimensions.push_back(frame_size);
1389 helper_params.window_dimensions.push_back(frame_size);
1390 1374
1391 ClientStateNotification<ClientState>* note = 1375 ClientStateNotification<ClientState>* note =
1392 new ClientStateNotification<ClientState>(); 1376 new ClientStateNotification<ClientState>();
1393 GLRenderingVDAClient* client = 1377 GLRenderingVDAClient* client =
1394 new GLRenderingVDAClient(&rendering_helper_, 1378 new GLRenderingVDAClient(&rendering_helper_,
1395 0,
1396 note, 1379 note,
1397 test_video_files_[0]->data_str, 1380 test_video_files_[0]->data_str,
1398 1, 1381 1,
1399 1, 1382 1,
1400 test_video_files_[0]->reset_after_frame_num, 1383 test_video_files_[0]->reset_after_frame_num,
1401 CS_RESET, 1384 CS_RESET,
1402 test_video_files_[0]->width, 1385 test_video_files_[0]->width,
1403 test_video_files_[0]->height, 1386 test_video_files_[0]->height,
1404 test_video_files_[0]->profile, 1387 test_video_files_[0]->profile,
1405 true, 1388 true,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 } 1455 }
1473 if (it->first == "v" || it->first == "vmodule") 1456 if (it->first == "v" || it->first == "vmodule")
1474 continue; 1457 continue;
1475 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; 1458 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
1476 } 1459 }
1477 1460
1478 base::ShadowingAtExitManager at_exit_manager; 1461 base::ShadowingAtExitManager at_exit_manager;
1479 1462
1480 return RUN_ALL_TESTS(); 1463 return RUN_ALL_TESTS();
1481 } 1464 }
OLDNEW
« content/common/gpu/media/rendering_helper.cc ('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