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

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

Issue 1942123002: Plumb decoded video pixel format from GPU process to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test on bots Created 4 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 | « media/filters/gpu_video_decoder.h ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | 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 #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 <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 GpuVideoDecoder::BufferData::~BufferData() {} 71 GpuVideoDecoder::BufferData::~BufferData() {}
72 72
73 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, 73 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories,
74 const RequestSurfaceCB& request_surface_cb) 74 const RequestSurfaceCB& request_surface_cb)
75 : needs_bitstream_conversion_(false), 75 : needs_bitstream_conversion_(false),
76 factories_(factories), 76 factories_(factories),
77 state_(kNormal), 77 state_(kNormal),
78 request_surface_cb_(request_surface_cb), 78 request_surface_cb_(request_surface_cb),
79 decoder_texture_target_(0), 79 decoder_texture_target_(0),
80 pixel_format_(PIXEL_FORMAT_UNKNOWN),
80 next_picture_buffer_id_(0), 81 next_picture_buffer_id_(0),
81 next_bitstream_buffer_id_(0), 82 next_bitstream_buffer_id_(0),
82 available_pictures_(0), 83 available_pictures_(0),
83 needs_all_picture_buffers_to_decode_(false), 84 needs_all_picture_buffers_to_decode_(false),
84 supports_deferred_initialization_(false), 85 supports_deferred_initialization_(false),
85 weak_factory_(this) { 86 weak_factory_(this) {
86 DCHECK(factories_); 87 DCHECK(factories_);
87 } 88 }
88 89
89 void GpuVideoDecoder::Reset(const base::Closure& closure) { 90 void GpuVideoDecoder::Reset(const base::Closure& closure) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 (!needs_all_picture_buffers_to_decode_ && available_pictures_ > 0) || 429 (!needs_all_picture_buffers_to_decode_ && available_pictures_ > 0) ||
429 available_pictures_ == 430 available_pictures_ ==
430 static_cast<int>(assigned_picture_buffers_.size()); 431 static_cast<int>(assigned_picture_buffers_.size());
431 } 432 }
432 433
433 int GpuVideoDecoder::GetMaxDecodeRequests() const { 434 int GpuVideoDecoder::GetMaxDecodeRequests() const {
434 return kMaxInFlightDecodes; 435 return kMaxInFlightDecodes;
435 } 436 }
436 437
437 void GpuVideoDecoder::ProvidePictureBuffers(uint32_t count, 438 void GpuVideoDecoder::ProvidePictureBuffers(uint32_t count,
439 VideoPixelFormat format,
438 uint32_t textures_per_buffer, 440 uint32_t textures_per_buffer,
439 const gfx::Size& size, 441 const gfx::Size& size,
440 uint32_t texture_target) { 442 uint32_t texture_target) {
441 DVLOG(3) << "ProvidePictureBuffers(" << count << ", " 443 DVLOG(3) << "ProvidePictureBuffers(" << count << ", "
442 << size.width() << "x" << size.height() << ")"; 444 << size.width() << "x" << size.height() << ")";
443 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 445 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
444 446
445 std::vector<uint32_t> texture_ids; 447 std::vector<uint32_t> texture_ids;
446 std::vector<gpu::Mailbox> texture_mailboxes; 448 std::vector<gpu::Mailbox> texture_mailboxes;
447 decoder_texture_target_ = texture_target; 449 decoder_texture_target_ = texture_target;
450
451 if (format == PIXEL_FORMAT_UNKNOWN) {
452 format = IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB;
453 }
454
455 // TODO(jbauman): Move decoder_texture_target_ and pixel_format_ to the
456 // picture buffer. http://crbug.com/614789
457 if ((pixel_format_ != PIXEL_FORMAT_UNKNOWN) && (pixel_format_ != format)) {
458 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
459 return;
460 }
461
462 pixel_format_ = format;
448 if (!factories_->CreateTextures(count * textures_per_buffer, size, 463 if (!factories_->CreateTextures(count * textures_per_buffer, size,
449 &texture_ids, &texture_mailboxes, 464 &texture_ids, &texture_mailboxes,
450 decoder_texture_target_)) { 465 decoder_texture_target_)) {
451 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 466 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
452 return; 467 return;
453 } 468 }
454 DCHECK_EQ(count * textures_per_buffer, texture_ids.size()); 469 DCHECK_EQ(count * textures_per_buffer, texture_ids.size());
455 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size()); 470 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size());
456 471
457 if (!vda_) 472 if (!vda_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 visible_rect = picture.visible_rect(); 557 visible_rect = picture.visible_rect();
543 } 558 }
544 if (!gfx::Rect(pb.size()).Contains(visible_rect)) { 559 if (!gfx::Rect(pb.size()).Contains(visible_rect)) {
545 LOG(WARNING) << "Visible size " << visible_rect.ToString() 560 LOG(WARNING) << "Visible size " << visible_rect.ToString()
546 << " is larger than coded size " << pb.size().ToString(); 561 << " is larger than coded size " << pb.size().ToString();
547 visible_rect = gfx::Rect(pb.size()); 562 visible_rect = gfx::Rect(pb.size());
548 } 563 }
549 564
550 DCHECK(decoder_texture_target_); 565 DCHECK(decoder_texture_target_);
551 566
552 VideoPixelFormat pixel_format = vda_->GetOutputFormat();
553 if (pixel_format == PIXEL_FORMAT_UNKNOWN) {
554 pixel_format =
555 IsOpaque(config_.format()) ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB;
556 }
557
558 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 567 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
559 for (size_t i = 0; i < pb.texture_ids().size(); ++i) { 568 for (size_t i = 0; i < pb.texture_ids().size(); ++i) {
560 mailbox_holders[i] = gpu::MailboxHolder( 569 mailbox_holders[i] = gpu::MailboxHolder(
561 pb.texture_mailbox(i), gpu::SyncToken(), decoder_texture_target_); 570 pb.texture_mailbox(i), gpu::SyncToken(), decoder_texture_target_);
562 } 571 }
563 572
564 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures( 573 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures(
565 pixel_format, mailbox_holders, 574 pixel_format_, mailbox_holders,
566 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(), 575 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(),
567 base::Bind(&GpuVideoDecoder::ReleaseMailbox, 576 base::Bind(&GpuVideoDecoder::ReleaseMailbox,
568 weak_factory_.GetWeakPtr(), factories_, 577 weak_factory_.GetWeakPtr(), factories_,
569 picture.picture_buffer_id(), pb.texture_ids())), 578 picture.picture_buffer_id(), pb.texture_ids())),
570 pb.size(), visible_rect, natural_size, timestamp)); 579 pb.size(), visible_rect, natural_size, timestamp));
571 if (!frame) { 580 if (!frame) {
572 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 581 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
573 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 582 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
574 return; 583 return;
575 } 584 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 790 }
782 return false; 791 return false;
783 } 792 }
784 793
785 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 794 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
786 const { 795 const {
787 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 796 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
788 } 797 }
789 798
790 } // namespace media 799 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698