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

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

Issue 2881553002: Add |texture_target_| and |pixel_format_| to media::PictureBuffer (Closed)
Patch Set: addressed review comments 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 543
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(); 544 sync_token_ = factories_->CreateSyncToken();
555 DCHECK_EQ(count * textures_per_buffer, texture_ids.size()); 545 DCHECK_EQ(count * textures_per_buffer, texture_ids.size());
556 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size()); 546 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size());
557 547
558 if (!vda_) 548 if (!vda_)
559 return; 549 return;
560 550
561 std::vector<PictureBuffer> picture_buffers; 551 std::vector<PictureBuffer> picture_buffers;
562 size_t index = 0; 552 size_t index = 0;
563 for (size_t i = 0; i < count; ++i) { 553 for (size_t i = 0; i < count; ++i) {
564 PictureBuffer::TextureIds ids; 554 PictureBuffer::TextureIds ids;
565 std::vector<gpu::Mailbox> mailboxes; 555 std::vector<gpu::Mailbox> mailboxes;
566 for (size_t j = 0; j < textures_per_buffer; j++) { 556 for (size_t j = 0; j < textures_per_buffer; j++) {
567 ids.push_back(texture_ids[index]); 557 ids.push_back(texture_ids[index]);
568 mailboxes.push_back(texture_mailboxes[index]); 558 mailboxes.push_back(texture_mailboxes[index]);
569 index++; 559 index++;
570 } 560 }
571 561
572 picture_buffers.push_back( 562 picture_buffers.push_back(PictureBuffer(next_picture_buffer_id_++, size,
573 PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); 563 ids, texture_target, format,
564 mailboxes));
574 bool inserted = assigned_picture_buffers_.insert(std::make_pair( 565 bool inserted = assigned_picture_buffers_.insert(std::make_pair(
575 picture_buffers.back().id(), picture_buffers.back())).second; 566 picture_buffers.back().id(), picture_buffers.back())).second;
576 DCHECK(inserted); 567 DCHECK(inserted);
577 } 568 }
578 569
579 available_pictures_ += count; 570 available_pictures_ += count;
580 571
581 vda_->AssignPictureBuffers(picture_buffers); 572 vda_->AssignPictureBuffers(picture_buffers);
582 } 573 }
583 574
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 633
643 if (!picture.visible_rect().IsEmpty()) { 634 if (!picture.visible_rect().IsEmpty()) {
644 visible_rect = picture.visible_rect(); 635 visible_rect = picture.visible_rect();
645 } 636 }
646 if (!gfx::Rect(pb.size()).Contains(visible_rect)) { 637 if (!gfx::Rect(pb.size()).Contains(visible_rect)) {
647 LOG(WARNING) << "Visible size " << visible_rect.ToString() 638 LOG(WARNING) << "Visible size " << visible_rect.ToString()
648 << " is larger than coded size " << pb.size().ToString(); 639 << " is larger than coded size " << pb.size().ToString();
649 visible_rect = gfx::Rect(pb.size()); 640 visible_rect = gfx::Rect(pb.size());
650 } 641 }
651 642
652 DCHECK(decoder_texture_target_); 643 DCHECK(pb.texture_target());
653 644
654 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 645 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
655 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) { 646 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) {
656 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_, 647 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_,
657 decoder_texture_target_); 648 pb.texture_target());
658 } 649 }
659 650
660 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures( 651 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures(
661 pixel_format_, mailbox_holders, 652 pb.pixel_format(), mailbox_holders,
662 // Always post ReleaseMailbox to avoid deadlock with the compositor when 653 // Always post ReleaseMailbox to avoid deadlock with the compositor when
663 // releasing video frames on the media thread; http://crbug.com/710209. 654 // releasing video frames on the media thread; http://crbug.com/710209.
664 BindToCurrentLoop(base::Bind( 655 BindToCurrentLoop(base::Bind(
665 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), 656 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
666 factories_, picture.picture_buffer_id(), pb.client_texture_ids())), 657 factories_, picture.picture_buffer_id(), pb.client_texture_ids())),
667 pb.size(), visible_rect, natural_size, timestamp)); 658 pb.size(), visible_rect, natural_size, timestamp));
668 if (!frame) { 659 if (!frame) {
669 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 660 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
670 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 661 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
671 return; 662 return;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 881 }
891 return false; 882 return false;
892 } 883 }
893 884
894 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 885 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
895 const { 886 const {
896 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 887 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
897 } 888 }
898 889
899 } // namespace media 890 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698