OLD | NEW |
---|---|
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/debug/trace_event.h" | 6 #include "base/debug/trace_event.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "content/common/gpu/gpu_channel.h" | 12 #include "content/common/gpu/gpu_channel.h" |
13 #include "content/common/gpu/media/vaapi_picture.h" | 13 #include "content/common/gpu/media/vaapi_picture.h" |
14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 14 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
16 #include "media/video/picture.h" | 16 #include "media/video/picture.h" |
17 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/gl_image.h" | |
18 | 19 |
19 static void ReportToUMA( | 20 static void ReportToUMA( |
20 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { | 21 content::VaapiH264Decoder::VAVDAH264DecoderFailure failure) { |
21 UMA_HISTOGRAM_ENUMERATION( | 22 UMA_HISTOGRAM_ENUMERATION( |
22 "Media.VAVDAH264.DecoderFailure", | 23 "Media.VAVDAH264.DecoderFailure", |
23 failure, | 24 failure, |
24 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX); | 25 content::VaapiH264Decoder::VAVDA_H264_DECODER_FAILURES_MAX); |
25 } | 26 } |
26 | 27 |
27 namespace content { | 28 namespace content { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 Pictures::iterator it = pictures_.find(picture_buffer_id); | 66 Pictures::iterator it = pictures_.find(picture_buffer_id); |
66 if (it == pictures_.end()) { | 67 if (it == pictures_.end()) { |
67 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; | 68 LOG(ERROR) << "Picture id " << picture_buffer_id << " does not exist"; |
68 return NULL; | 69 return NULL; |
69 } | 70 } |
70 | 71 |
71 return it->second.get(); | 72 return it->second.get(); |
72 } | 73 } |
73 | 74 |
74 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( | 75 VaapiVideoDecodeAccelerator::VaapiVideoDecodeAccelerator( |
75 const base::Callback<bool(void)>& make_context_current) | 76 const base::Callback<bool(void)>& make_context_current, |
77 const base::Callback<void(uint32, uint32, scoped_refptr<gfx::GLImage>)>& | |
78 bind_image) | |
Pawel Osciak
2015/01/24 00:58:54
Is this correct indentation?
| |
76 : make_context_current_(make_context_current), | 79 : make_context_current_(make_context_current), |
77 state_(kUninitialized), | 80 state_(kUninitialized), |
78 input_ready_(&lock_), | 81 input_ready_(&lock_), |
79 surfaces_available_(&lock_), | 82 surfaces_available_(&lock_), |
80 message_loop_(base::MessageLoop::current()), | 83 message_loop_(base::MessageLoop::current()), |
81 decoder_thread_("VaapiDecoderThread"), | 84 decoder_thread_("VaapiDecoderThread"), |
82 num_frames_at_client_(0), | 85 num_frames_at_client_(0), |
83 num_stream_bufs_at_decoder_(0), | 86 num_stream_bufs_at_decoder_(0), |
84 finish_flush_pending_(false), | 87 finish_flush_pending_(false), |
85 awaiting_va_surfaces_recycle_(false), | 88 awaiting_va_surfaces_recycle_(false), |
86 requested_num_pics_(0), | 89 requested_num_pics_(0), |
90 bind_image_(bind_image), | |
87 weak_this_factory_(this) { | 91 weak_this_factory_(this) { |
88 weak_this_ = weak_this_factory_.GetWeakPtr(); | 92 weak_this_ = weak_this_factory_.GetWeakPtr(); |
89 va_surface_release_cb_ = media::BindToCurrentLoop( | 93 va_surface_release_cb_ = media::BindToCurrentLoop( |
90 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); | 94 base::Bind(&VaapiVideoDecodeAccelerator::RecycleVASurfaceID, weak_this_)); |
91 } | 95 } |
92 | 96 |
93 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { | 97 VaapiVideoDecodeAccelerator::~VaapiVideoDecodeAccelerator() { |
94 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 98 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
95 } | 99 } |
96 | 100 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 PLATFORM_FAILURE, ); | 184 PLATFORM_FAILURE, ); |
181 | 185 |
182 // Notify the client a picture is ready to be displayed. | 186 // Notify the client a picture is ready to be displayed. |
183 ++num_frames_at_client_; | 187 ++num_frames_at_client_; |
184 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); | 188 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); |
185 DVLOG(4) << "Notifying output picture id " << output_id | 189 DVLOG(4) << "Notifying output picture id " << output_id |
186 << " for input "<< input_id << " is ready"; | 190 << " for input "<< input_id << " is ready"; |
187 // TODO(posciak): Use visible size from decoder here instead | 191 // TODO(posciak): Use visible size from decoder here instead |
188 // (crbug.com/402760). | 192 // (crbug.com/402760). |
189 if (client_) | 193 if (client_) |
190 client_->PictureReady( | 194 client_->PictureReady(media::Picture(output_id, input_id, |
191 media::Picture(output_id, input_id, gfx::Rect(picture->size()))); | 195 gfx::Rect(picture->size()), |
196 picture->allow_overlay())); | |
192 } | 197 } |
193 | 198 |
194 void VaapiVideoDecodeAccelerator::TryOutputSurface() { | 199 void VaapiVideoDecodeAccelerator::TryOutputSurface() { |
195 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 200 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
196 | 201 |
197 // Handle Destroy() arriving while pictures are queued for output. | 202 // Handle Destroy() arriving while pictures are queued for output. |
198 if (!client_) | 203 if (!client_) |
199 return; | 204 return; |
200 | 205 |
201 if (pending_output_cbs_.empty() || output_buffers_.empty()) | 206 if (pending_output_cbs_.empty() || output_buffers_.empty()) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 | 524 |
520 for (size_t i = 0; i < buffers.size(); ++i) { | 525 for (size_t i = 0; i < buffers.size(); ++i) { |
521 DVLOG(2) << "Assigning picture id: " << buffers[i].id() | 526 DVLOG(2) << "Assigning picture id: " << buffers[i].id() |
522 << " to texture id: " << buffers[i].texture_id() | 527 << " to texture id: " << buffers[i].texture_id() |
523 << " VASurfaceID: " << va_surface_ids[i]; | 528 << " VASurfaceID: " << va_surface_ids[i]; |
524 | 529 |
525 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( | 530 linked_ptr<VaapiPicture> picture(VaapiPicture::CreatePicture( |
526 vaapi_wrapper_.get(), make_context_current_, buffers[i].id(), | 531 vaapi_wrapper_.get(), make_context_current_, buffers[i].id(), |
527 buffers[i].texture_id(), requested_pic_size_)); | 532 buffers[i].texture_id(), requested_pic_size_)); |
528 | 533 |
534 scoped_refptr<gfx::GLImage> image = picture->GetImageToBind(); | |
535 if (image) { | |
536 bind_image_.Run(buffers[i].internal_texture_id(), | |
Pawel Osciak
2015/01/24 00:58:54
Sorry, I'm confused, could you please explain why
achaulk
2015/01/27 18:36:48
It's roughly equivalent, but in the case where we
Pawel Osciak
2015/01/28 23:52:02
I think we can't create a GLImage from XPixmap?
| |
537 VaapiPicture::GetGLTextureTarget(), image); | |
538 } | |
539 | |
529 RETURN_AND_NOTIFY_ON_FAILURE( | 540 RETURN_AND_NOTIFY_ON_FAILURE( |
530 picture.get(), "Failed assigning picture buffer to a texture.", | 541 picture.get(), "Failed assigning picture buffer to a texture.", |
531 PLATFORM_FAILURE, ); | 542 PLATFORM_FAILURE, ); |
532 | 543 |
533 bool inserted = | 544 bool inserted = |
534 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; | 545 pictures_.insert(std::make_pair(buffers[i].id(), picture)).second; |
535 DCHECK(inserted); | 546 DCHECK(inserted); |
536 | 547 |
537 output_buffers_.push(buffers[i].id()); | 548 output_buffers_.push(buffers[i].id()); |
538 available_va_surfaces_.push_back(va_surface_ids[i]); | 549 available_va_surfaces_.push_back(va_surface_ids[i]); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
732 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 743 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
733 Cleanup(); | 744 Cleanup(); |
734 delete this; | 745 delete this; |
735 } | 746 } |
736 | 747 |
737 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { | 748 bool VaapiVideoDecodeAccelerator::CanDecodeOnIOThread() { |
738 return false; | 749 return false; |
739 } | 750 } |
740 | 751 |
741 } // namespace content | 752 } // namespace content |
OLD | NEW |