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

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

Issue 2019333004: Revert of Plumb decoded video pixel format from GPU process to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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),
81 next_picture_buffer_id_(0), 80 next_picture_buffer_id_(0),
82 next_bitstream_buffer_id_(0), 81 next_bitstream_buffer_id_(0),
83 available_pictures_(0), 82 available_pictures_(0),
84 needs_all_picture_buffers_to_decode_(false), 83 needs_all_picture_buffers_to_decode_(false),
85 supports_deferred_initialization_(false), 84 supports_deferred_initialization_(false),
86 weak_factory_(this) { 85 weak_factory_(this) {
87 DCHECK(factories_); 86 DCHECK(factories_);
88 } 87 }
89 88
90 void GpuVideoDecoder::Reset(const base::Closure& closure) { 89 void GpuVideoDecoder::Reset(const base::Closure& closure) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 (!needs_all_picture_buffers_to_decode_ && available_pictures_ > 0) || 428 (!needs_all_picture_buffers_to_decode_ && available_pictures_ > 0) ||
430 available_pictures_ == 429 available_pictures_ ==
431 static_cast<int>(assigned_picture_buffers_.size()); 430 static_cast<int>(assigned_picture_buffers_.size());
432 } 431 }
433 432
434 int GpuVideoDecoder::GetMaxDecodeRequests() const { 433 int GpuVideoDecoder::GetMaxDecodeRequests() const {
435 return kMaxInFlightDecodes; 434 return kMaxInFlightDecodes;
436 } 435 }
437 436
438 void GpuVideoDecoder::ProvidePictureBuffers(uint32_t count, 437 void GpuVideoDecoder::ProvidePictureBuffers(uint32_t count,
439 VideoPixelFormat format,
440 uint32_t textures_per_buffer, 438 uint32_t textures_per_buffer,
441 const gfx::Size& size, 439 const gfx::Size& size,
442 uint32_t texture_target) { 440 uint32_t texture_target) {
443 DVLOG(3) << "ProvidePictureBuffers(" << count << ", " 441 DVLOG(3) << "ProvidePictureBuffers(" << count << ", "
444 << size.width() << "x" << size.height() << ")"; 442 << size.width() << "x" << size.height() << ")";
445 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 443 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
446 444
447 std::vector<uint32_t> texture_ids; 445 std::vector<uint32_t> texture_ids;
448 std::vector<gpu::Mailbox> texture_mailboxes; 446 std::vector<gpu::Mailbox> texture_mailboxes;
449 decoder_texture_target_ = texture_target; 447 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;
463 if (!factories_->CreateTextures(count * textures_per_buffer, size, 448 if (!factories_->CreateTextures(count * textures_per_buffer, size,
464 &texture_ids, &texture_mailboxes, 449 &texture_ids, &texture_mailboxes,
465 decoder_texture_target_)) { 450 decoder_texture_target_)) {
466 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 451 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
467 return; 452 return;
468 } 453 }
469 DCHECK_EQ(count * textures_per_buffer, texture_ids.size()); 454 DCHECK_EQ(count * textures_per_buffer, texture_ids.size());
470 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size()); 455 DCHECK_EQ(count * textures_per_buffer, texture_mailboxes.size());
471 456
472 if (!vda_) 457 if (!vda_)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 visible_rect = picture.visible_rect(); 542 visible_rect = picture.visible_rect();
558 } 543 }
559 if (!gfx::Rect(pb.size()).Contains(visible_rect)) { 544 if (!gfx::Rect(pb.size()).Contains(visible_rect)) {
560 LOG(WARNING) << "Visible size " << visible_rect.ToString() 545 LOG(WARNING) << "Visible size " << visible_rect.ToString()
561 << " is larger than coded size " << pb.size().ToString(); 546 << " is larger than coded size " << pb.size().ToString();
562 visible_rect = gfx::Rect(pb.size()); 547 visible_rect = gfx::Rect(pb.size());
563 } 548 }
564 549
565 DCHECK(decoder_texture_target_); 550 DCHECK(decoder_texture_target_);
566 551
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
567 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 558 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
568 for (size_t i = 0; i < pb.texture_ids().size(); ++i) { 559 for (size_t i = 0; i < pb.texture_ids().size(); ++i) {
569 mailbox_holders[i] = gpu::MailboxHolder( 560 mailbox_holders[i] = gpu::MailboxHolder(
570 pb.texture_mailbox(i), gpu::SyncToken(), decoder_texture_target_); 561 pb.texture_mailbox(i), gpu::SyncToken(), decoder_texture_target_);
571 } 562 }
572 563
573 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures( 564 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures(
574 pixel_format_, mailbox_holders, 565 pixel_format, mailbox_holders,
575 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(), 566 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(),
576 base::Bind(&GpuVideoDecoder::ReleaseMailbox, 567 base::Bind(&GpuVideoDecoder::ReleaseMailbox,
577 weak_factory_.GetWeakPtr(), factories_, 568 weak_factory_.GetWeakPtr(), factories_,
578 picture.picture_buffer_id(), pb.texture_ids())), 569 picture.picture_buffer_id(), pb.texture_ids())),
579 pb.size(), visible_rect, natural_size, timestamp)); 570 pb.size(), visible_rect, natural_size, timestamp));
580 if (!frame) { 571 if (!frame) {
581 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 572 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
582 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 573 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
583 return; 574 return;
584 } 575 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 } 781 }
791 return false; 782 return false;
792 } 783 }
793 784
794 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 785 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
795 const { 786 const {
796 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 787 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
797 } 788 }
798 789
799 } // namespace media 790 } // 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