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

Side by Side Diff: media/gpu/vaapi_video_decode_accelerator.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: 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
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/gpu/vaapi_video_decode_accelerator.h" 5 #include "media/gpu/vaapi_video_decode_accelerator.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // we can finish all pending output callbacks, releasing associated surfaces. 630 // we can finish all pending output callbacks, releasing associated surfaces.
631 DVLOG(1) << "Initiating surface set change"; 631 DVLOG(1) << "Initiating surface set change";
632 awaiting_va_surfaces_recycle_ = true; 632 awaiting_va_surfaces_recycle_ = true;
633 633
634 requested_num_pics_ = num_pics; 634 requested_num_pics_ = num_pics;
635 requested_pic_size_ = size; 635 requested_pic_size_ = size;
636 636
637 TryFinishSurfaceSetChange(); 637 TryFinishSurfaceSetChange();
638 } 638 }
639 639
640 static VideoPixelFormat BufferFormatToVideoPixelFormat(
641 gfx::BufferFormat format) {
642 switch (format) {
643 case gfx::BufferFormat::BGRA_8888:
644 return PIXEL_FORMAT_ARGB;
645
646 default:
647 LOG(FATAL) << "Add more cases as needed";
648 return PIXEL_FORMAT_UNKNOWN;
649 }
650 }
651
640 void VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange() { 652 void VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange() {
641 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 653 DCHECK_EQ(message_loop_, base::MessageLoop::current());
642 654
643 if (!awaiting_va_surfaces_recycle_) 655 if (!awaiting_va_surfaces_recycle_)
644 return; 656 return;
645 657
646 if (!pending_output_cbs_.empty() || 658 if (!pending_output_cbs_.empty() ||
647 pictures_.size() != available_va_surfaces_.size()) { 659 pictures_.size() != available_va_surfaces_.size()) {
648 // Either: 660 // Either:
649 // 1. Not all pending pending output callbacks have been executed yet. 661 // 1. Not all pending pending output callbacks have been executed yet.
(...skipping 19 matching lines...) Expand all
669 DVLOG(2) << "Dismissing picture id: " << iter->first; 681 DVLOG(2) << "Dismissing picture id: " << iter->first;
670 if (client_) 682 if (client_)
671 client_->DismissPictureBuffer(iter->first); 683 client_->DismissPictureBuffer(iter->first);
672 } 684 }
673 pictures_.clear(); 685 pictures_.clear();
674 686
675 // And ask for a new set as requested. 687 // And ask for a new set as requested.
676 DVLOG(1) << "Requesting " << requested_num_pics_ 688 DVLOG(1) << "Requesting " << requested_num_pics_
677 << " pictures of size: " << requested_pic_size_.ToString(); 689 << " pictures of size: " << requested_pic_size_.ToString();
678 690
691 VideoPixelFormat format =
692 BufferFormatToVideoPixelFormat(kOutputPictureFormat);
679 message_loop_->PostTask( 693 message_loop_->PostTask(
680 FROM_HERE, 694 FROM_HERE, base::Bind(&Client::ProvidePictureBuffers, client_,
681 base::Bind(&Client::ProvidePictureBuffers, client_, requested_num_pics_, 695 requested_num_pics_, format, 1, requested_pic_size_,
682 1, requested_pic_size_, VaapiPicture::GetGLTextureTarget())); 696 VaapiPicture::GetGLTextureTarget()));
683 } 697 }
684 698
685 void VaapiVideoDecodeAccelerator::Decode( 699 void VaapiVideoDecodeAccelerator::Decode(
686 const media::BitstreamBuffer& bitstream_buffer) { 700 const media::BitstreamBuffer& bitstream_buffer) {
687 DCHECK_EQ(message_loop_, base::MessageLoop::current()); 701 DCHECK_EQ(message_loop_, base::MessageLoop::current());
688 702
689 TRACE_EVENT1("Video Decoder", "VAVDA::Decode", "Buffer id", 703 TRACE_EVENT1("Video Decoder", "VAVDA::Decode", "Buffer id",
690 bitstream_buffer.id()); 704 bitstream_buffer.id());
691 705
692 if (bitstream_buffer.id() < 0) { 706 if (bitstream_buffer.id() < 0) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 Cleanup(); 1051 Cleanup();
1038 delete this; 1052 delete this;
1039 } 1053 }
1040 1054
1041 bool VaapiVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread( 1055 bool VaapiVideoDecodeAccelerator::TryToSetupDecodeOnSeparateThread(
1042 const base::WeakPtr<Client>& decode_client, 1056 const base::WeakPtr<Client>& decode_client,
1043 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) { 1057 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) {
1044 return false; 1058 return false;
1045 } 1059 }
1046 1060
1047 static VideoPixelFormat BufferFormatToVideoPixelFormat(
1048 gfx::BufferFormat format) {
1049 switch (format) {
1050 case gfx::BufferFormat::BGRA_8888:
1051 return PIXEL_FORMAT_ARGB;
1052
1053 default:
1054 LOG(FATAL) << "Add more cases as needed";
1055 return PIXEL_FORMAT_UNKNOWN;
1056 }
1057 }
1058
1059 VideoPixelFormat VaapiVideoDecodeAccelerator::GetOutputFormat() const {
1060 return BufferFormatToVideoPixelFormat(kOutputPictureFormat);
1061 }
1062
1063 bool VaapiVideoDecodeAccelerator::DecodeSurface( 1061 bool VaapiVideoDecodeAccelerator::DecodeSurface(
1064 const scoped_refptr<VaapiDecodeSurface>& dec_surface) { 1062 const scoped_refptr<VaapiDecodeSurface>& dec_surface) {
1065 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers( 1063 if (!vaapi_wrapper_->ExecuteAndDestroyPendingBuffers(
1066 dec_surface->va_surface()->id())) { 1064 dec_surface->va_surface()->id())) {
1067 DVLOG(1) << "Failed decoding picture"; 1065 DVLOG(1) << "Failed decoding picture";
1068 return false; 1066 return false;
1069 } 1067 }
1070 1068
1071 return true; 1069 return true;
1072 } 1070 }
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 return vaapi_pic->dec_surface(); 1829 return vaapi_pic->dec_surface();
1832 } 1830 }
1833 1831
1834 // static 1832 // static
1835 media::VideoDecodeAccelerator::SupportedProfiles 1833 media::VideoDecodeAccelerator::SupportedProfiles
1836 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { 1834 VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
1837 return VaapiWrapper::GetSupportedDecodeProfiles(); 1835 return VaapiWrapper::GetSupportedDecodeProfiles();
1838 } 1836 }
1839 1837
1840 } // namespace media 1838 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698