| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 DVLOG(3) << "Outputting VASurface " << va_surface->id() | 404 DVLOG(3) << "Outputting VASurface " << va_surface->id() |
| 405 << " into pixmap bound to picture buffer id " << output_id; | 405 << " into pixmap bound to picture buffer id " << output_id; |
| 406 | 406 |
| 407 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface), | 407 RETURN_AND_NOTIFY_ON_FAILURE(picture->DownloadFromSurface(va_surface), |
| 408 "Failed putting surface into pixmap", | 408 "Failed putting surface into pixmap", |
| 409 PLATFORM_FAILURE, ); | 409 PLATFORM_FAILURE, ); |
| 410 | 410 |
| 411 // Notify the client a picture is ready to be displayed. | 411 // Notify the client a picture is ready to be displayed. |
| 412 ++num_frames_at_client_; | 412 ++num_frames_at_client_; |
| 413 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); | 413 TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_); |
| 414 DVLOG(4) << "Notifying output picture id " << output_id << " for input " | 414 DVLOG(4) << "Notifying output picture id " << output_id |
| 415 << input_id << " is ready"; | 415 << " for input " << input_id << " is ready"; |
| 416 // TODO(posciak): Use visible size from decoder here instead | 416 // TODO(posciak): Use visible size from decoder here instead |
| 417 // (crbug.com/402760). Passing (0, 0) results in the client using the | 417 // (crbug.com/402760). Passing (0, 0) results in the client using the |
| 418 // visible size extracted from the container instead. | 418 // visible size extracted from the container instead. |
| 419 if (client_) | 419 if (client_) |
| 420 client_->PictureReady(media::Picture(output_id, input_id, gfx::Rect(0, 0), | 420 client_->PictureReady(media::Picture(output_id, input_id, gfx::Rect(0, 0), |
| 421 picture->AllowOverlay())); | 421 picture->AllowOverlay())); |
| 422 } | 422 } |
| 423 | 423 |
| 424 void VaapiVideoDecodeAccelerator::TryOutputSurface() { | 424 void VaapiVideoDecodeAccelerator::TryOutputSurface() { |
| 425 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 425 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 495 } |
| 496 | 496 |
| 497 // We could have got woken up in a different state or never got to sleep | 497 // We could have got woken up in a different state or never got to sleep |
| 498 // due to current state; check for that. | 498 // due to current state; check for that. |
| 499 switch (state_) { | 499 switch (state_) { |
| 500 case kFlushing: | 500 case kFlushing: |
| 501 // Here we are only interested in finishing up decoding buffers that are | 501 // Here we are only interested in finishing up decoding buffers that are |
| 502 // already queued up. Otherwise will stop decoding. | 502 // already queued up. Otherwise will stop decoding. |
| 503 if (input_buffers_.empty()) | 503 if (input_buffers_.empty()) |
| 504 return false; | 504 return false; |
| 505 // else fallthrough | 505 // else fallthrough |
| 506 case kDecoding: | 506 case kDecoding: |
| 507 case kIdle: | 507 case kIdle: |
| 508 DCHECK(!input_buffers_.empty()); | 508 DCHECK(!input_buffers_.empty()); |
| 509 | 509 |
| 510 curr_input_buffer_ = input_buffers_.front(); | 510 curr_input_buffer_ = input_buffers_.front(); |
| 511 input_buffers_.pop(); | 511 input_buffers_.pop(); |
| 512 | 512 |
| 513 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id | 513 DVLOG(4) << "New current bitstream buffer, id: " << curr_input_buffer_->id |
| 514 << " size: " << curr_input_buffer_->shm->size(); | 514 << " size: " << curr_input_buffer_->shm->size(); |
| 515 | 515 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 base::AutoLock auto_lock(lock_); | 702 base::AutoLock auto_lock(lock_); |
| 703 switch (state_) { | 703 switch (state_) { |
| 704 case kIdle: | 704 case kIdle: |
| 705 state_ = kDecoding; | 705 state_ = kDecoding; |
| 706 decoder_thread_task_runner_->PostTask( | 706 decoder_thread_task_runner_->PostTask( |
| 707 FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::DecodeTask, | 707 FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::DecodeTask, |
| 708 base::Unretained(this))); | 708 base::Unretained(this))); |
| 709 break; | 709 break; |
| 710 | 710 |
| 711 case kDecoding: | 711 case kDecoding: |
| 712 // Decoder already running, fallthrough. | 712 // Decoder already running, fallthrough. |
| 713 case kResetting: | 713 case kResetting: |
| 714 // When resetting, allow accumulating bitstream buffers, so that | 714 // When resetting, allow accumulating bitstream buffers, so that |
| 715 // the client can queue after-seek-buffers while we are finishing with | 715 // the client can queue after-seek-buffers while we are finishing with |
| 716 // the before-seek one. | 716 // the before-seek one. |
| 717 break; | 717 break; |
| 718 | 718 |
| 719 default: | 719 default: |
| 720 RETURN_AND_NOTIFY_ON_FAILURE( | 720 RETURN_AND_NOTIFY_ON_FAILURE( |
| 721 false, "Decode request from client in invalid state: " << state_, | 721 false, "Decode request from client in invalid state: " << state_, |
| 722 PLATFORM_FAILURE, ); | 722 PLATFORM_FAILURE, ); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 736 void VaapiVideoDecodeAccelerator::AssignPictureBuffers( | 736 void VaapiVideoDecodeAccelerator::AssignPictureBuffers( |
| 737 const std::vector<media::PictureBuffer>& buffers) { | 737 const std::vector<media::PictureBuffer>& buffers) { |
| 738 DCHECK_EQ(message_loop_, base::MessageLoop::current()); | 738 DCHECK_EQ(message_loop_, base::MessageLoop::current()); |
| 739 | 739 |
| 740 base::AutoLock auto_lock(lock_); | 740 base::AutoLock auto_lock(lock_); |
| 741 DCHECK(pictures_.empty()); | 741 DCHECK(pictures_.empty()); |
| 742 | 742 |
| 743 while (!output_buffers_.empty()) | 743 while (!output_buffers_.empty()) |
| 744 output_buffers_.pop(); | 744 output_buffers_.pop(); |
| 745 | 745 |
| 746 RETURN_AND_NOTIFY_ON_FAILURE(buffers.size() >= requested_num_pics_, | 746 RETURN_AND_NOTIFY_ON_FAILURE( |
| 747 "Got an invalid number of picture buffers. (Got " | 747 buffers.size() >= requested_num_pics_, |
| 748 << buffers.size() << ", requested " | 748 "Got an invalid number of picture buffers. (Got " << buffers.size() |
| 749 << requested_num_pics_ << ")", | 749 << ", requested " << requested_num_pics_ << ")", INVALID_ARGUMENT, ); |
| 750 INVALID_ARGUMENT, ); | |
| 751 DCHECK(requested_pic_size_ == buffers[0].size()); | 750 DCHECK(requested_pic_size_ == buffers[0].size()); |
| 752 | 751 |
| 753 std::vector<VASurfaceID> va_surface_ids; | 752 std::vector<VASurfaceID> va_surface_ids; |
| 754 RETURN_AND_NOTIFY_ON_FAILURE( | 753 RETURN_AND_NOTIFY_ON_FAILURE( |
| 755 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_, | 754 vaapi_wrapper_->CreateSurfaces(VA_RT_FORMAT_YUV420, requested_pic_size_, |
| 756 buffers.size(), &va_surface_ids), | 755 buffers.size(), &va_surface_ids), |
| 757 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); | 756 "Failed creating VA Surfaces", PLATFORM_FAILURE, ); |
| 758 DCHECK_EQ(va_surface_ids.size(), buffers.size()); | 757 DCHECK_EQ(va_surface_ids.size(), buffers.size()); |
| 759 | 758 |
| 760 for (size_t i = 0; i < buffers.size(); ++i) { | 759 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(); | 1766 return vaapi_pic->dec_surface(); |
| 1768 } | 1767 } |
| 1769 | 1768 |
| 1770 // static | 1769 // static |
| 1771 media::VideoDecodeAccelerator::SupportedProfiles | 1770 media::VideoDecodeAccelerator::SupportedProfiles |
| 1772 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { | 1771 VaapiVideoDecodeAccelerator::GetSupportedProfiles() { |
| 1773 return VaapiWrapper::GetSupportedDecodeProfiles(); | 1772 return VaapiWrapper::GetSupportedDecodeProfiles(); |
| 1774 } | 1773 } |
| 1775 | 1774 |
| 1776 } // namespace media | 1775 } // namespace media |
| OLD | NEW |