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

Side by Side Diff: media/gpu/android_video_decode_accelerator.cc

Issue 2347193002: [M54] Roll-up of fixes for VP8/VP9 stability on Android. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/android_video_decode_accelerator.h" 5 #include "media/gpu/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 783
784 return true; 784 return true;
785 } 785 }
786 786
787 bool AndroidVideoDecodeAccelerator::DequeueOutput() { 787 bool AndroidVideoDecodeAccelerator::DequeueOutput() {
788 DCHECK(thread_checker_.CalledOnValidThread()); 788 DCHECK(thread_checker_.CalledOnValidThread());
789 TRACE_EVENT0("media", "AVDA::DequeueOutput"); 789 TRACE_EVENT0("media", "AVDA::DequeueOutput");
790 base::AutoReset<bool> auto_reset(&defer_errors_, true); 790 base::AutoReset<bool> auto_reset(&defer_errors_, true);
791 if (state_ == ERROR || state_ == WAITING_FOR_CODEC) 791 if (state_ == ERROR || state_ == WAITING_FOR_CODEC)
792 return false; 792 return false;
793 if (picturebuffers_requested_ && output_picture_buffers_.empty()) 793 // If we're draining for reset or destroy, then we don't need picture buffers
794 // since we won't send any decoded frames anyway. There might not be any,
795 // since the pipeline might not be sending them back and / or they don't
796 // exist anymore. From the pipeline's point of view, for Destroy at least,
797 // the VDA is already gone.
798 if (picturebuffers_requested_ && output_picture_buffers_.empty() &&
799 !IsDrainingForResetOrDestroy()) {
794 return false; 800 return false;
795 if (!output_picture_buffers_.empty() && free_picture_ids_.empty()) { 801 }
802 if (!output_picture_buffers_.empty() && free_picture_ids_.empty() &&
803 !IsDrainingForResetOrDestroy()) {
796 // Don't have any picture buffer to send. Need to wait. 804 // Don't have any picture buffer to send. Need to wait.
797 return false; 805 return false;
798 } 806 }
799 807
800 bool eos = false; 808 bool eos = false;
801 base::TimeDelta presentation_timestamp; 809 base::TimeDelta presentation_timestamp;
802 int32_t buf_index = 0; 810 int32_t buf_index = 0;
803 do { 811 do {
804 size_t offset = 0; 812 size_t offset = 0;
805 size_t size = 0; 813 size_t size = 0;
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 SupportedProfiles& profiles = capabilities.supported_profiles; 1714 SupportedProfiles& profiles = capabilities.supported_profiles;
1707 1715
1708 // Only support VP8 on Android versions where we don't have to synchronously 1716 // Only support VP8 on Android versions where we don't have to synchronously
1709 // tear down the MediaCodec on surface destruction because VP8 requires 1717 // tear down the MediaCodec on surface destruction because VP8 requires
1710 // us to completely drain the decoder before releasing it, which is difficult 1718 // us to completely drain the decoder before releasing it, which is difficult
1711 // and time consuming to do while the surface is being destroyed. 1719 // and time consuming to do while the surface is being destroyed.
1712 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 18 && 1720 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 18 &&
1713 MediaCodecUtil::IsVp8DecoderAvailable()) { 1721 MediaCodecUtil::IsVp8DecoderAvailable()) {
1714 SupportedProfile profile; 1722 SupportedProfile profile;
1715 profile.profile = VP8PROFILE_ANY; 1723 profile.profile = VP8PROFILE_ANY;
1716 profile.min_resolution.SetSize(0, 0); 1724 // Since there is little to no power benefit below 360p, don't advertise
1725 // support for it. Let libvpx decode it, and save a MediaCodec instance.
1726 // Note that we allow it anyway for encrypted content, since we push a
1727 // separate profile for that.
1728 profile.min_resolution.SetSize(480, 360);
1717 profile.max_resolution.SetSize(3840, 2160); 1729 profile.max_resolution.SetSize(3840, 2160);
1718 // If we know MediaCodec will just create a software codec, prefer our 1730 // If we know MediaCodec will just create a software codec, prefer our
1719 // internal software decoder instead. It's more up to date and secured 1731 // internal software decoder instead. It's more up to date and secured
1720 // within the renderer sandbox. However if the content is encrypted, we 1732 // within the renderer sandbox. However if the content is encrypted, we
1721 // must use MediaCodec anyways since MediaDrm offers no way to decrypt 1733 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1722 // the buffers and let us use our internal software decoders. 1734 // the buffers and let us use our internal software decoders.
1723 profile.encrypted_only = 1735 profile.encrypted_only =
1724 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP8, MEDIA_CODEC_DECODER); 1736 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP8, MEDIA_CODEC_DECODER);
1725 profiles.push_back(profile); 1737 profiles.push_back(profile);
1738
1739 // Always allow encrypted content, even at low resolutions.
1740 profile.min_resolution.SetSize(0, 0);
1741 profile.encrypted_only = true;
1742 profiles.push_back(profile);
1726 } 1743 }
1727 1744
1728 if (MediaCodecUtil::IsVp9DecoderAvailable()) { 1745 if (MediaCodecUtil::IsVp9DecoderAvailable()) {
1729 SupportedProfile profile; 1746 const VideoCodecProfile profile_types[] = {
1730 profile.min_resolution.SetSize(0, 0); 1747 VP9PROFILE_PROFILE0, VP9PROFILE_PROFILE1, VP9PROFILE_PROFILE2,
1731 profile.max_resolution.SetSize(3840, 2160); 1748 VP9PROFILE_PROFILE3, VIDEO_CODEC_PROFILE_UNKNOWN};
1732 // If we know MediaCodec will just create a software codec, prefer our 1749 const bool is_known_unaccelerated =
1733 // internal software decoder instead. It's more up to date and secured
1734 // within the renderer sandbox. However if the content is encrypted, we
1735 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1736 // the buffers and let us use our internal software decoders.
1737 profile.encrypted_only =
1738 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP9, MEDIA_CODEC_DECODER); 1750 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP9, MEDIA_CODEC_DECODER);
1739 profile.profile = VP9PROFILE_PROFILE0; 1751 for (int i = 0; profile_types[i] != VIDEO_CODEC_PROFILE_UNKNOWN; i++) {
1740 profiles.push_back(profile); 1752 SupportedProfile profile;
1741 profile.profile = VP9PROFILE_PROFILE1; 1753 // Limit to 360p, like we do for vp8. See above.
1742 profiles.push_back(profile); 1754 profile.min_resolution.SetSize(480, 360);
1743 profile.profile = VP9PROFILE_PROFILE2; 1755 profile.max_resolution.SetSize(3840, 2160);
1744 profiles.push_back(profile); 1756 // If we know MediaCodec will just create a software codec, prefer our
1745 profile.profile = VP9PROFILE_PROFILE3; 1757 // internal software decoder instead. It's more up to date and secured
1746 profiles.push_back(profile); 1758 // within the renderer sandbox. However if the content is encrypted, we
1759 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1760 // the buffers and let us use our internal software decoders.
1761 profile.encrypted_only = is_known_unaccelerated;
1762 profile.profile = profile_types[i];
1763 profiles.push_back(profile);
1764
1765 // Always allow encrypted content.
1766 profile.min_resolution.SetSize(0, 0);
1767 profile.encrypted_only = true;
1768 profiles.push_back(profile);
1769 }
1747 } 1770 }
1748 1771
1749 for (const auto& supported_profile : kSupportedH264Profiles) { 1772 for (const auto& supported_profile : kSupportedH264Profiles) {
1750 SupportedProfile profile; 1773 SupportedProfile profile;
1751 profile.profile = supported_profile; 1774 profile.profile = supported_profile;
1752 profile.min_resolution.SetSize(0, 0); 1775 profile.min_resolution.SetSize(0, 0);
1753 // Advertise support for 4k and let the MediaCodec fail when decoding if it 1776 // Advertise support for 4k and let the MediaCodec fail when decoding if it
1754 // doesn't support the resolution. It's assumed that consumers won't have 1777 // doesn't support the resolution. It's assumed that consumers won't have
1755 // software fallback for H264 on Android anyway. 1778 // software fallback for H264 on Android anyway.
1756 profile.max_resolution.SetSize(3840, 2160); 1779 profile.max_resolution.SetSize(3840, 2160);
(...skipping 23 matching lines...) Expand all
1780 1803
1781 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() 1804 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden()
1782 const { 1805 const {
1783 // Prevent MediaCodec from using its internal software decoders when we have 1806 // Prevent MediaCodec from using its internal software decoders when we have
1784 // more secure and up to date versions in the renderer process. 1807 // more secure and up to date versions in the renderer process.
1785 return !config_.is_encrypted && (codec_config_->codec_ == media::kCodecVP8 || 1808 return !config_.is_encrypted && (codec_config_->codec_ == media::kCodecVP8 ||
1786 codec_config_->codec_ == media::kCodecVP9); 1809 codec_config_->codec_ == media::kCodecVP9);
1787 } 1810 }
1788 1811
1789 } // namespace media 1812 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698