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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 2881553002: Add |texture_target_| and |pixel_format_| to media::PictureBuffer (Closed)
Patch Set: Created 3 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 #include "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <array> 8 #include <array>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, 114 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories,
115 const RequestSurfaceCB& request_surface_cb, 115 const RequestSurfaceCB& request_surface_cb,
116 MediaLog* media_log) 116 MediaLog* media_log)
117 : needs_bitstream_conversion_(false), 117 : needs_bitstream_conversion_(false),
118 factories_(factories), 118 factories_(factories),
119 request_surface_cb_(request_surface_cb), 119 request_surface_cb_(request_surface_cb),
120 media_log_(media_log), 120 media_log_(media_log),
121 vda_initialized_(false), 121 vda_initialized_(false),
122 state_(kNormal), 122 state_(kNormal),
123 decoder_texture_target_(0),
124 pixel_format_(PIXEL_FORMAT_UNKNOWN),
125 next_picture_buffer_id_(0), 123 next_picture_buffer_id_(0),
126 next_bitstream_buffer_id_(0), 124 next_bitstream_buffer_id_(0),
127 available_pictures_(0), 125 available_pictures_(0),
128 needs_all_picture_buffers_to_decode_(false), 126 needs_all_picture_buffers_to_decode_(false),
129 supports_deferred_initialization_(false), 127 supports_deferred_initialization_(false),
130 requires_texture_copy_(false), 128 requires_texture_copy_(false),
131 cdm_id_(CdmContext::kInvalidCdmId), 129 cdm_id_(CdmContext::kInvalidCdmId),
132 weak_factory_(this) { 130 weak_factory_(this) {
133 DCHECK(factories_); 131 DCHECK(factories_);
134 } 132 }
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 VideoPixelFormat format, 522 VideoPixelFormat format,
525 uint32_t textures_per_buffer, 523 uint32_t textures_per_buffer,
526 const gfx::Size& size, 524 const gfx::Size& size,
527 uint32_t texture_target) { 525 uint32_t texture_target) {
528 DVLOG(3) << "ProvidePictureBuffers(" << count << ", " 526 DVLOG(3) << "ProvidePictureBuffers(" << count << ", "
529 << size.width() << "x" << size.height() << ")"; 527 << size.width() << "x" << size.height() << ")";
530 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 528 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
531 529
532 std::vector<uint32_t> texture_ids; 530 std::vector<uint32_t> texture_ids;
533 std::vector<gpu::Mailbox> texture_mailboxes; 531 std::vector<gpu::Mailbox> texture_mailboxes;
534 decoder_texture_target_ = texture_target;
535 532
536 if (format == PIXEL_FORMAT_UNKNOWN) { 533 if (format == PIXEL_FORMAT_UNKNOWN) {
537 format = IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB; 534 format = IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB;
538 } 535 }
539 536
540 // TODO(jbauman): Move decoder_texture_target_ and pixel_format_ to the 537 if (!factories_->CreateTextures(count * textures_per_buffer, size,
541 // picture buffer. http://crbug.com/614789 538 &texture_ids, &texture_mailboxes,
542 if ((pixel_format_ != PIXEL_FORMAT_UNKNOWN) && (pixel_format_ != format)) { 539 texture_target)) {
543 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 540 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
544 return; 541 return;
545 } 542 }
546
547 pixel_format_ = format;
548 if (!factories_->CreateTextures(count * textures_per_buffer, size,
549 &texture_ids, &texture_mailboxes,
550 decoder_texture_target_)) {
551 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
552 return;
553 }
554 sync_token_ = factories_->CreateSyncToken(); 543 sync_token_ = factories_->CreateSyncToken();
555 DCHECK_EQ(count * textures_per_buffer, texture_ids.size()); 544 DCHECK_EQ(count * textures_per_buffer, texture_ids.size());
556 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size()); 545 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size());
557 546
558 if (!vda_) 547 if (!vda_)
559 return; 548 return;
560 549
561 std::vector<PictureBuffer> picture_buffers; 550 std::vector<PictureBuffer> picture_buffers;
562 size_t index = 0; 551 size_t index = 0;
563 for (size_t i = 0; i < count; ++i) { 552 for (size_t i = 0; i < count; ++i) {
564 PictureBuffer::TextureIds ids; 553 PictureBuffer::TextureIds ids;
565 std::vector<gpu::Mailbox> mailboxes; 554 std::vector<gpu::Mailbox> mailboxes;
566 for (size_t j = 0; j < textures_per_buffer; j++) { 555 for (size_t j = 0; j < textures_per_buffer; j++) {
567 ids.push_back(texture_ids[index]); 556 ids.push_back(texture_ids[index]);
568 mailboxes.push_back(texture_mailboxes[index]); 557 mailboxes.push_back(texture_mailboxes[index]);
569 index++; 558 index++;
570 } 559 }
571 560
572 picture_buffers.push_back( 561 picture_buffers.push_back(PictureBuffer(next_picture_buffer_id_++, size,
573 PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); 562 ids, texture_target, format,
563 mailboxes));
574 bool inserted = assigned_picture_buffers_.insert(std::make_pair( 564 bool inserted = assigned_picture_buffers_.insert(std::make_pair(
575 picture_buffers.back().id(), picture_buffers.back())).second; 565 picture_buffers.back().id(), picture_buffers.back())).second;
576 DCHECK(inserted); 566 DCHECK(inserted);
577 } 567 }
578 568
579 available_pictures_ += count; 569 available_pictures_ += count;
580 570
581 vda_->AssignPictureBuffers(picture_buffers); 571 vda_->AssignPictureBuffers(picture_buffers);
liberato (no reviews please) 2017/05/11 16:24:40 the picture buffer received by GPU clients will no
Chandan 2017/05/12 13:47:51 Sure. I have added these fields to the IPC. Howeve
582 } 572 }
583 573
584 void GpuVideoDecoder::DismissPictureBuffer(int32_t id) { 574 void GpuVideoDecoder::DismissPictureBuffer(int32_t id) {
585 DVLOG(3) << "DismissPictureBuffer(" << id << ")"; 575 DVLOG(3) << "DismissPictureBuffer(" << id << ")";
586 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 576 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
587 577
588 PictureBufferMap::iterator it = assigned_picture_buffers_.find(id); 578 PictureBufferMap::iterator it = assigned_picture_buffers_.find(id);
589 if (it == assigned_picture_buffers_.end()) { 579 if (it == assigned_picture_buffers_.end()) {
590 NOTREACHED() << "Missing picture buffer: " << id; 580 NOTREACHED() << "Missing picture buffer: " << id;
591 return; 581 return;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 632
643 if (!picture.visible_rect().IsEmpty()) { 633 if (!picture.visible_rect().IsEmpty()) {
644 visible_rect = picture.visible_rect(); 634 visible_rect = picture.visible_rect();
645 } 635 }
646 if (!gfx::Rect(pb.size()).Contains(visible_rect)) { 636 if (!gfx::Rect(pb.size()).Contains(visible_rect)) {
647 LOG(WARNING) << "Visible size " << visible_rect.ToString() 637 LOG(WARNING) << "Visible size " << visible_rect.ToString()
648 << " is larger than coded size " << pb.size().ToString(); 638 << " is larger than coded size " << pb.size().ToString();
649 visible_rect = gfx::Rect(pb.size()); 639 visible_rect = gfx::Rect(pb.size());
650 } 640 }
651 641
652 DCHECK(decoder_texture_target_); 642 DCHECK(pb.texture_target());
653 643
654 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 644 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
655 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) { 645 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) {
656 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_, 646 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_,
657 decoder_texture_target_); 647 pb.texture_target());
658 } 648 }
659 649
660 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures( 650 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures(
661 pixel_format_, mailbox_holders, 651 pb.pixel_format(), mailbox_holders,
662 // Always post ReleaseMailbox to avoid deadlock with the compositor when 652 // Always post ReleaseMailbox to avoid deadlock with the compositor when
663 // releasing video frames on the media thread; http://crbug.com/710209. 653 // releasing video frames on the media thread; http://crbug.com/710209.
664 BindToCurrentLoop(base::Bind( 654 BindToCurrentLoop(base::Bind(
665 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), 655 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
666 factories_, picture.picture_buffer_id(), pb.client_texture_ids())), 656 factories_, picture.picture_buffer_id(), pb.client_texture_ids())),
667 pb.size(), visible_rect, natural_size, timestamp)); 657 pb.size(), visible_rect, natural_size, timestamp));
668 if (!frame) { 658 if (!frame) {
669 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 659 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
670 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 660 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
671 return; 661 return;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 880 }
891 return false; 881 return false;
892 } 882 }
893 883
894 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 884 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
895 const { 885 const {
896 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 886 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
897 } 887 }
898 888
899 } // namespace media 889 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/video/picture.h » ('j') | media/video/picture.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698