Chromium Code Reviews| 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 "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 16 matching lines...) Expand all Loading... | |
| 27 #include "third_party/libva/va/va_dec_vp8.h" | 27 #include "third_party/libva/va/va_dec_vp8.h" |
| 28 #include "ui/gl/gl_bindings.h" | 28 #include "ui/gl/gl_bindings.h" |
| 29 #include "ui/gl/gl_image.h" | 29 #include "ui/gl/gl_image.h" |
| 30 | 30 |
| 31 namespace media { | 31 namespace media { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 // UMA errors that the VaapiVideoDecodeAccelerator class reports. | 34 // UMA errors that the VaapiVideoDecodeAccelerator class reports. |
| 35 enum VAVDADecoderFailure { | 35 enum VAVDADecoderFailure { |
| 36 VAAPI_ERROR = 0, | 36 VAAPI_ERROR = 0, |
| 37 // UMA requires that max passed to UMA_HISTOGRAM_ENUMERATION must be greater | |
| 38 // than 1. | |
|
Mark Dittmer
2016/05/12 14:13:51
Ditto.
Pawel Osciak
2016/05/13 06:07:22
Acknowledged.
| |
| 37 VAVDA_DECODER_FAILURES_MAX, | 39 VAVDA_DECODER_FAILURES_MAX, |
| 38 }; | 40 }; |
| 39 } | 41 } |
| 40 | 42 |
| 41 static void ReportToUMA(VAVDADecoderFailure failure) { | 43 static void ReportToUMA(VAVDADecoderFailure failure) { |
| 42 UMA_HISTOGRAM_ENUMERATION("Media.VAVDA.DecoderFailure", failure, | 44 UMA_HISTOGRAM_ENUMERATION("Media.VAVDA.DecoderFailure", failure, |
| 43 VAVDA_DECODER_FAILURES_MAX + 1); | 45 VAVDA_DECODER_FAILURES_MAX + 1); |
|
Mark Dittmer
2016/05/12 14:13:51
Ditto.
Pawel Osciak
2016/05/13 06:07:22
Acknowledged.
| |
| 44 } | 46 } |
| 45 | 47 |
| 46 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \ | 48 #define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \ |
| 47 do { \ | 49 do { \ |
| 48 if (!(result)) { \ | 50 if (!(result)) { \ |
| 49 LOG(ERROR) << log; \ | 51 LOG(ERROR) << log; \ |
| 50 NotifyError(error_code); \ | 52 NotifyError(error_code); \ |
| 51 return ret; \ | 53 return ret; \ |
| 52 } \ | 54 } \ |
| 53 } while (0) | 55 } while (0) |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 DVLOG(3) << "Outputting VASurface " << va_surface->id() | 406 DVLOG(3) << "Outputting VASurface " << va_surface->id() |
| 405 << " into pixmap bound to picture buffer id " << output_id; | 407 << " into pixmap bound to picture buffer id " << output_id; |
| 406 | 408 |
| 407 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface), | 409 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface), |
| 408 "Failed putting surface into pixmap", | 410 "Failed putting surface into pixmap", |
| 409 PLATFORM_FAILURE, ); | 411 PLATFORM_FAILURE, ); |
| 410 | 412 |
| 411 // Notify the client a picture is ready to be displayed. | 413 // Notify the client a picture is ready to be displayed. |
| 412 ++num_frames_at_client_; | 414 ++num_frames_at_client_; |
| 413 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); | 415 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); |
| 414 DVLOG(4) << "Notifying output picture id " << output_id << " for input " | 416 DVLOG(4) << "Notifying output picture id " << output_id |
| 415 << input_id << " is ready"; | 417 << " for input " << input_id << " is ready"; |
| 416 // TODO(posciak): Use visible size from decoder here instead | 418 // TODO(posciak): Use visible size from decoder here instead |
| 417 // (crbug.com/402760). Passing (0, 0) results in the client using the | 419 // (crbug.com/402760). Passing (0, 0) results in the client using the |
| 418 // visible size extracted from the container instead. | 420 // visible size extracted from the container instead. |
| 419 if (client_) | 421 if (client_) |
| 420 client_->PictureReady(media::Picture(output_id, input_id, gfx::Rect(0, 0), | 422 client_->PictureReady(media::Picture(output_id, input_id, gfx::Rect(0, 0), |
| 421 picture->AllowOverlay())); | 423 picture->AllowOverlay())); |
| 422 } | 424 } |
| 423 | 425 |
| 424 void VaapiVideoDecodeAccelerator::TryOutputSurface() { | 426 void VaapiVideoDecodeAccelerator::TryOutputSurface() { |
| 425 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 427 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 } | 497 } |
| 496 | 498 |
| 497 // We could have got woken up in a different state or never got to sleep | 499 // We could have got woken up in a different state or never got to sleep |
| 498 // due to current state; check for that. | 500 // due to current state; check for that. |
| 499 switch (state_) { | 501 switch (state_) { |
| 500 case kFlushing: | 502 case kFlushing: |
| 501 // Here we are only interested in finishing up decoding buffers that are | 503 // Here we are only interested in finishing up decoding buffers that are |
| 502 // already queued up. Otherwise will stop decoding. | 504 // already queued up. Otherwise will stop decoding. |
| 503 if (input_buffers_.empty()) | 505 if (input_buffers_.empty()) |
| 504 return false; | 506 return false; |
| 505 // else fallthrough | 507 // else fallthrough |
| 506 case kDecoding: | 508 case kDecoding: |
| 507 case kIdle: | 509 case kIdle: |
| 508 DCHECK(!input_buffers_.empty()); | 510 DCHECK(!input_buffers_.empty()); |
| 509 | 511 |
| 510 curr_input_buffer_ = input_buffers_.front(); | 512 curr_input_buffer_ = input_buffers_.front(); |
| 511 input_buffers_.pop(); | 513 input_buffers_.pop(); |
| 512 | 514 |
| 513 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id | 515 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id |
| 514 << " size: " << curr_input_buffer_->shm->size(); | 516 << " size: " << curr_input_buffer_->shm->size(); |
| 515 | 517 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 base::AutoLock auto_lock(lock_); | 704 base::AutoLock auto_lock(lock_); |
| 703 switch (state_) { | 705 switch (state_) { |
| 704 case kIdle: | 706 case kIdle: |
| 705 state_ = kDecoding; | 707 state_ = kDecoding; |
| 706 decoder_thread_task_runner_->PostTask( | 708 decoder_thread_task_runner_->PostTask( |
| 707 FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::DecodeTask, | 709 FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::DecodeTask, |
| 708 base::Unretained(this))); | 710 base::Unretained(this))); |
| 709 break; | 711 break; |
| 710 | 712 |
| 711 case kDecoding: | 713 case kDecoding: |
| 712 // Decoder already running, fallthrough. | 714 // Decoder already running, fallthrough. |
| 713 case kResetting: | 715 case kResetting: |
| 714 // When resetting, allow accumulating bitstream buffers, so that | 716 // When resetting, allow accumulating bitstream buffers, so that |
| 715 // the client can queue after-seek-buffers while we are finishing with | 717 // the client can queue after-seek-buffers while we are finishing with |
| 716 // the before-seek one. | 718 // the before-seek one. |
| 717 break; | 719 break; |
| 718 | 720 |
| 719 default: | 721 default: |
| 720 RETURN_AND_NOTIFY_ON_FAILURE( | 722 RETURN_AND_NOTIFY_ON_FAILURE( |
| 721 false, "Decode request from client in invalid state: " << state_, | 723 false, "Decode request from client in invalid state: " << state_, |
| 722 PLATFORM_FAILURE, ); | 724 PLATFORM_FAILURE, ); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 736 void VaapiVideoDecodeAccelerator::AssignPictureBuffers( | 738 void VaapiVideoDecodeAccelerator::AssignPictureBuffers( |
| 737 const std::vector<media::PictureBuffer>& buffers) { | 739 const std::vector<media::PictureBuffer>& buffers) { |
| 738 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 740 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| 739 | 741 |
| 740 base::AutoLock auto_lock(lock_); | 742 base::AutoLock auto_lock(lock_); |
| 741 DCHECK(pictures_.empty()); | 743 DCHECK(pictures_.empty()); |
| 742 | 744 |
| 743 while (!output_buffers_.empty()) | 745 while (!output_buffers_.empty()) |
| 744 output_buffers_.pop(); | 746 output_buffers_.pop(); |
| 745 | 747 |
| 746 RETURN_AND_NOTIFY_ON_FAILURE(buffers.size() >= requested_num_pics_, | 748 RETURN_AND_NOTIFY_ON_FAILURE( |
| 747 "Got an invalid number of picture buffers. (Got " | 749 buffers.size() >= requested_num_pics_, |
| 748 << buffers.size() << ", requested " | 750 "Got an invalid number of picture buffers. (Got " << buffers.size() |
| 749 << requested_num_pics_ << ")", | 751 << ", requested " << requested_num_pics_ << ")", INVALID_ARGUMENT, ); |
| 750 INVALID_ARGUMENT, ); | |
| 751 DCHECK(requested_pic_size_ == buffers[0].size()); | 752 DCHECK(requested_pic_size_ == buffers[0].size()); |
| 752 | 753 |
| 753 std::vector<VASurfaceID> va_surface_ids; | 754 std::vector<VASurfaceID> va_surface_ids; |
| 754 RETURN_AND_NOTIFY_ON_FAILURE( | 755 RETURN_AND_NOTIFY_ON_FAILURE( |
| 755 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_, | 756 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_, |
| 756 buffers.size(), &va_surface_ids), | 757 buffers.size(), &va_surface_ids), |
| 757 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); | 758 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); |
| 758 DCHECK_EQ(va_surface_ids.size(), buffers.size()); | 759 DCHECK_EQ(va_surface_ids.size(), buffers.size()); |
| 759 | 760 |
| 760 for (size_t i = 0; i < buffers.size(); ++i) { | 761 for (size_t i = 0; i < buffers.size(); ++i) { |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1767 return vaapi_pic->dec_surface(); | 1768 return vaapi_pic->dec_surface(); |
| 1768 } | 1769 } |
| 1769 | 1770 |
| 1770 // static | 1771 // static |
| 1771 media::VideoDecodeAccelerator::SupportedProfiles | 1772 media::VideoDecodeAccelerator::SupportedProfiles |
| 1772 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { | 1773 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { |
| 1773 return VaapiWrapper::GetSupportedDecodeProfiles(); | 1774 return VaapiWrapper::GetSupportedDecodeProfiles(); |
| 1774 } | 1775 } |
| 1775 | 1776 |
| 1776 } // namespace media | 1777 } // namespace media |
| OLD | NEW |