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

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

Issue 7021020: Clean up video frame sizes, types in Video Decode API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: responses to CR Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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, and GLES2. 7 // - RenderingHelper is charged with interacting with X11, EGL, and GLES2.
8 // - ClientState is an enum for the state of the decode client used by the test. 8 // - ClientState is an enum for the state of the decode client used by the test.
9 // - ClientStateNotification is a barrier abstraction that allows the test code 9 // - ClientStateNotification is a barrier abstraction that allows the test code
10 // to be written sequentially and wait for the decode client to see certain 10 // to be written sequentially and wait for the decode client to see certain
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 std::string* encoded_data, 404 std::string* encoded_data,
405 int num_NALUs_per_decode, 405 int num_NALUs_per_decode,
406 int delete_decoder_state); 406 int delete_decoder_state);
407 virtual ~EglRenderingVDAClient(); 407 virtual ~EglRenderingVDAClient();
408 void CreateDecoder(); 408 void CreateDecoder();
409 409
410 // VideoDecodeAccelerator::Client implementation. 410 // VideoDecodeAccelerator::Client implementation.
411 // The heart of the Client. 411 // The heart of the Client.
412 virtual void ProvidePictureBuffers( 412 virtual void ProvidePictureBuffers(
413 uint32 requested_num_of_buffers, 413 uint32 requested_num_of_buffers,
414 const gfx::Size& dimensions, 414 const gfx::Size& dimensions);
415 VideoDecodeAccelerator::MemoryType type);
416 virtual void DismissPictureBuffer(int32 picture_buffer_id); 415 virtual void DismissPictureBuffer(int32 picture_buffer_id);
417 virtual void PictureReady(const media::Picture& picture); 416 virtual void PictureReady(const media::Picture& picture);
418 // Simple state changes. 417 // Simple state changes.
419 virtual void NotifyInitializeDone(); 418 virtual void NotifyInitializeDone();
420 virtual void NotifyEndOfStream(); 419 virtual void NotifyEndOfStream();
421 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id); 420 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id);
422 virtual void NotifyFlushDone(); 421 virtual void NotifyFlushDone();
423 virtual void NotifyResetDone(); 422 virtual void NotifyResetDone();
424 virtual void NotifyError(VideoDecodeAccelerator::Error error); 423 virtual void NotifyError(VideoDecodeAccelerator::Error error);
425 424
426 // Simple getters for inspecting the state of the Client. 425 // Simple getters for inspecting the state of the Client.
427 ClientState state() { return state_; } 426 ClientState state() { return state_; }
428 VideoDecodeAccelerator::Error error() { return error_; } 427 VideoDecodeAccelerator::Error error() { return error_; }
429 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; } 428 int num_done_bitstream_buffers() { return num_done_bitstream_buffers_; }
430 int num_decoded_frames() { return num_decoded_frames_; } 429 int num_decoded_frames() { return num_decoded_frames_; }
431 EGLDisplay egl_display() { return rendering_helper_->egl_display(); } 430 EGLDisplay egl_display() { return rendering_helper_->egl_display(); }
432 EGLContext egl_context() { return rendering_helper_->egl_context(); } 431 EGLContext egl_context() { return rendering_helper_->egl_context(); }
433 double frames_per_second(); 432 double frames_per_second();
434 bool decoder_deleted() { return !decoder_; } 433 bool decoder_deleted() { return !decoder_; }
435 434
436 private: 435 private:
437 typedef std::map<int, media::GLESBuffer*> PictureBufferById; 436 typedef std::map<int, media::PictureBuffer*> PictureBufferById;
438 437
439 void SetState(ClientState new_state); 438 void SetState(ClientState new_state);
440 439
441 // Delete the associated OMX decoder helper. 440 // Delete the associated OMX decoder helper.
442 void DeleteDecoder(); 441 void DeleteDecoder();
443 442
444 // Compute & return in |*end_pos| the end position for the next batch of NALUs 443 // Compute & return in |*end_pos| the end position for the next batch of NALUs
445 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|). 444 // to ship to the decoder (based on |start_pos| & |num_NALUs_per_decode_|).
446 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos); 445 void GetRangeForNextNALUs(size_t start_pos, size_t* end_pos);
447 446
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 media::VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT, media::VIDEOCOLORFORMAT_RGBA, 504 media::VIDEOATTRIBUTEKEY_VIDEOCOLORFORMAT, media::VIDEOCOLORFORMAT_RGBA,
506 }; 505 };
507 std::vector<uint32> config( 506 std::vector<uint32> config(
508 config_array, config_array + arraysize(config_array)); 507 config_array, config_array + arraysize(config_array));
509 CHECK(decoder_->Initialize(config)); 508 CHECK(decoder_->Initialize(config));
510 } 509 }
511 510
512 511
513 void EglRenderingVDAClient::ProvidePictureBuffers( 512 void EglRenderingVDAClient::ProvidePictureBuffers(
514 uint32 requested_num_of_buffers, 513 uint32 requested_num_of_buffers,
515 const gfx::Size& dimensions, 514 const gfx::Size& dimensions) {
516 VideoDecodeAccelerator::MemoryType type) {
517 if (decoder_deleted()) 515 if (decoder_deleted())
518 return; 516 return;
519 CHECK_EQ(type, VideoDecodeAccelerator::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE); 517 std::vector<media::PictureBuffer> buffers;
520 std::vector<media::GLESBuffer> buffers;
521 CHECK_EQ(dimensions.width(), kFrameWidth); 518 CHECK_EQ(dimensions.width(), kFrameWidth);
522 CHECK_EQ(dimensions.height(), kFrameHeight); 519 CHECK_EQ(dimensions.height(), kFrameHeight);
523 520
524 for (uint32 i = 0; i < requested_num_of_buffers; ++i) { 521 for (uint32 i = 0; i < requested_num_of_buffers; ++i) {
525 uint32 id = picture_buffers_by_id_.size(); 522 uint32 id = picture_buffers_by_id_.size();
526 GLuint texture_id; 523 GLuint texture_id;
527 base::WaitableEvent done(false, false); 524 base::WaitableEvent done(false, false);
528 rendering_helper_->CreateTexture(rendering_window_id_, &texture_id, &done); 525 rendering_helper_->CreateTexture(rendering_window_id_, &texture_id, &done);
529 done.Wait(); 526 done.Wait();
530 media::GLESBuffer* buffer = 527 media::PictureBuffer* buffer =
531 new media::GLESBuffer(id, dimensions, texture_id); 528 new media::PictureBuffer(id, dimensions, texture_id);
532 CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second); 529 CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
533 buffers.push_back(*buffer); 530 buffers.push_back(*buffer);
534 } 531 }
535 decoder_->AssignGLESBuffers(buffers); 532 decoder_->AssignPictureBuffers(buffers);
536 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR); 533 CHECK_EQ(static_cast<int>(glGetError()), GL_NO_ERROR);
537 CHECK_EQ(static_cast<int>(eglGetError()), EGL_SUCCESS); 534 CHECK_EQ(static_cast<int>(eglGetError()), EGL_SUCCESS);
538 } 535 }
539 536
540 void EglRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) { 537 void EglRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) {
541 PictureBufferById::iterator it = 538 PictureBufferById::iterator it =
542 picture_buffers_by_id_.find(picture_buffer_id); 539 picture_buffers_by_id_.find(picture_buffer_id);
543 DCHECK(it != picture_buffers_by_id_.end()); 540 DCHECK(it != picture_buffers_by_id_.end());
544 rendering_helper_->DeleteTexture(it->second->texture_id()); 541 rendering_helper_->DeleteTexture(it->second->texture_id());
545 delete it->second; 542 delete it->second;
546 picture_buffers_by_id_.erase(it); 543 picture_buffers_by_id_.erase(it);
547 } 544 }
548 545
549 void EglRenderingVDAClient::PictureReady(const media::Picture& picture) { 546 void EglRenderingVDAClient::PictureReady(const media::Picture& picture) {
550 // We shouldn't be getting pictures delivered after Reset has completed. 547 // We shouldn't be getting pictures delivered after Reset has completed.
551 DCHECK_LT(state_, CS_RESET); 548 DCHECK_LT(state_, CS_RESET);
552 549
553 if (decoder_deleted()) 550 if (decoder_deleted())
554 return; 551 return;
555 last_frame_delivered_ticks_ = base::TimeTicks::Now(); 552 last_frame_delivered_ticks_ = base::TimeTicks::Now();
556 553
557 // Because we feed the decoder a limited number of NALUs at a time, we can be 554 // Because we feed the decoder a limited number of NALUs at a time, we can be
558 // sure that the bitstream buffer from which a frame comes has a limited 555 // sure that the bitstream buffer from which a frame comes has a limited
559 // range. Assert that. 556 // range. Assert that.
560 CHECK_GE((picture.bitstream_buffer_id() + 1) * num_NALUs_per_decode_, 557 CHECK_GE((picture.bitstream_buffer_id() + 1) * num_NALUs_per_decode_,
561 num_decoded_frames_); 558 num_decoded_frames_);
562 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_); 559 CHECK_LE(picture.bitstream_buffer_id(), next_bitstream_buffer_id_);
563 ++num_decoded_frames_; 560 ++num_decoded_frames_;
564 561
565 media::GLESBuffer* gles_buffer = 562 media::PictureBuffer* picture_buffer =
566 picture_buffers_by_id_[picture.picture_buffer_id()]; 563 picture_buffers_by_id_[picture.picture_buffer_id()];
567 CHECK(gles_buffer); 564 CHECK(picture_buffer);
568 rendering_helper_->RenderTexture(gles_buffer->texture_id()); 565 rendering_helper_->RenderTexture(picture_buffer->texture_id());
569 566
570 decoder_->ReusePictureBuffer(picture.picture_buffer_id()); 567 decoder_->ReusePictureBuffer(picture.picture_buffer_id());
571 } 568 }
572 569
573 void EglRenderingVDAClient::NotifyInitializeDone() { 570 void EglRenderingVDAClient::NotifyInitializeDone() {
574 SetState(CS_INITIALIZED); 571 SetState(CS_INITIALIZED);
575 initialize_done_ticks_ = base::TimeTicks::Now(); 572 initialize_done_ticks_ = base::TimeTicks::Now();
576 DecodeNextNALUs(); 573 DecodeNextNALUs();
577 } 574 }
578 575
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, CS_RESET), 859 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 0, CS_RESET),
863 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, CS_RESET))); 860 MakeTuple(1, kMaxSupportedNumConcurrentDecoders + 1, CS_RESET)));
864 861
865 // TODO(fischman, vrk): add more tests! In particular: 862 // TODO(fischman, vrk): add more tests! In particular:
866 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder. 863 // - Test life-cycle: Seek/Stop/Pause/Play/RePlay for a single decoder.
867 // - Test alternate configurations 864 // - Test alternate configurations
868 // - Test failure conditions. 865 // - Test failure conditions.
869 // - Test frame size changes mid-stream 866 // - Test frame size changes mid-stream
870 867
871 } // namespace 868 } // namespace
OLDNEW
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.cc ('k') | content/renderer/gpu/gpu_video_decode_accelerator_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698