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

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

Issue 2348653002: Always allow MediaCodec for encrypted VPx content. (Closed)
Patch Set: cleanup 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 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 // Only support VP8 on Android versions where we don't have to synchronously 1566 // Only support VP8 on Android versions where we don't have to synchronously
1567 // tear down the MediaCodec on surface destruction because VP8 requires 1567 // tear down the MediaCodec on surface destruction because VP8 requires
1568 // us to completely drain the decoder before releasing it, which is difficult 1568 // us to completely drain the decoder before releasing it, which is difficult
1569 // and time consuming to do while the surface is being destroyed. 1569 // and time consuming to do while the surface is being destroyed.
1570 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 18 && 1570 if (base::android::BuildInfo::GetInstance()->sdk_int() >= 18 &&
1571 MediaCodecUtil::IsVp8DecoderAvailable()) { 1571 MediaCodecUtil::IsVp8DecoderAvailable()) {
1572 SupportedProfile profile; 1572 SupportedProfile profile;
1573 profile.profile = VP8PROFILE_ANY; 1573 profile.profile = VP8PROFILE_ANY;
1574 // Since there is little to no power benefit below 360p, don't advertise 1574 // Since there is little to no power benefit below 360p, don't advertise
1575 // support for it. Let libvpx decode it, and save a MediaCodec instance. 1575 // support for it. Let libvpx decode it, and save a MediaCodec instance.
1576 // Note that we allow it anyway for encrypted content, since we push a
1577 // separate profile for that.
1576 profile.min_resolution.SetSize(480, 360); 1578 profile.min_resolution.SetSize(480, 360);
1577 profile.max_resolution.SetSize(3840, 2160); 1579 profile.max_resolution.SetSize(3840, 2160);
1578 // If we know MediaCodec will just create a software codec, prefer our 1580 // If we know MediaCodec will just create a software codec, prefer our
1579 // internal software decoder instead. It's more up to date and secured 1581 // internal software decoder instead. It's more up to date and secured
1580 // within the renderer sandbox. However if the content is encrypted, we 1582 // within the renderer sandbox. However if the content is encrypted, we
1581 // must use MediaCodec anyways since MediaDrm offers no way to decrypt 1583 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1582 // the buffers and let us use our internal software decoders. 1584 // the buffers and let us use our internal software decoders.
1583 profile.encrypted_only = 1585 profile.encrypted_only =
DaleCurtis 2016/09/15 22:20:11 Query outside loop?
liberato (no reviews please) 2016/09/15 22:30:26 what loop do you mean?
DaleCurtis 2016/09/15 22:33:10 https://www.youtube.com/watch?v=mjqysusiZBk
1584 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP8, MEDIA_CODEC_DECODER); 1586 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP8, MEDIA_CODEC_DECODER);
1585 profiles.push_back(profile); 1587 profiles.push_back(profile);
1588
1589 // Always allow encrypted content, even at low resolutions.
1590 profile.min_resolution.SetSize(0, 0);
1591 profile.encrypted_only = true;
1592 profiles.push_back(profile);
1586 } 1593 }
1587 1594
1588 if (MediaCodecUtil::IsVp9DecoderAvailable()) { 1595 if (MediaCodecUtil::IsVp9DecoderAvailable()) {
1589 SupportedProfile profile; 1596 const VideoCodecProfile profile_types[] = {
1590 // Limit to 360p, like we do for vp8. See above. 1597 VP9PROFILE_PROFILE0, VP9PROFILE_PROFILE1, VP9PROFILE_PROFILE2,
1591 profile.min_resolution.SetSize(480, 360); 1598 VP9PROFILE_PROFILE3, VIDEO_CODEC_PROFILE_UNKNOWN};
1592 profile.max_resolution.SetSize(3840, 2160); 1599 for (int i = 0; profile_types[i] != VIDEO_CODEC_PROFILE_UNKNOWN; i++) {
1593 // If we know MediaCodec will just create a software codec, prefer our 1600 SupportedProfile profile;
1594 // internal software decoder instead. It's more up to date and secured 1601 // Limit to 360p, like we do for vp8. See above.
1595 // within the renderer sandbox. However if the content is encrypted, we 1602 profile.min_resolution.SetSize(480, 360);
1596 // must use MediaCodec anyways since MediaDrm offers no way to decrypt 1603 profile.max_resolution.SetSize(3840, 2160);
1597 // the buffers and let us use our internal software decoders. 1604 // If we know MediaCodec will just create a software codec, prefer our
1598 profile.encrypted_only = 1605 // internal software decoder instead. It's more up to date and secured
1599 VideoCodecBridge::IsKnownUnaccelerated(kCodecVP9, MEDIA_CODEC_DECODER); 1606 // within the renderer sandbox. However if the content is encrypted, we
1600 profile.profile = VP9PROFILE_PROFILE0; 1607 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1601 profiles.push_back(profile); 1608 // the buffers and let us use our internal software decoders.
1602 profile.profile = VP9PROFILE_PROFILE1; 1609 profile.encrypted_only = VideoCodecBridge::IsKnownUnaccelerated(
DaleCurtis 2016/09/15 22:20:11 Ditto.
liberato (no reviews please) 2016/09/15 22:30:26 Done.
1603 profiles.push_back(profile); 1610 kCodecVP9, MEDIA_CODEC_DECODER);
1604 profile.profile = VP9PROFILE_PROFILE2; 1611 profile.profile = profile_types[i];
1605 profiles.push_back(profile); 1612 profiles.push_back(profile);
1606 profile.profile = VP9PROFILE_PROFILE3; 1613
1607 profiles.push_back(profile); 1614 // Always allow encrypted content.
1615 profile.min_resolution.SetSize(0, 0);
1616 profile.encrypted_only = true;
1617 profiles.push_back(profile);
1618 }
1608 } 1619 }
1609 1620
1610 for (const auto& supported_profile : kSupportedH264Profiles) { 1621 for (const auto& supported_profile : kSupportedH264Profiles) {
1611 SupportedProfile profile; 1622 SupportedProfile profile;
1612 profile.profile = supported_profile; 1623 profile.profile = supported_profile;
1613 profile.min_resolution.SetSize(0, 0); 1624 profile.min_resolution.SetSize(0, 0);
1614 // Advertise support for 4k and let the MediaCodec fail when decoding if it 1625 // Advertise support for 4k and let the MediaCodec fail when decoding if it
1615 // doesn't support the resolution. It's assumed that consumers won't have 1626 // doesn't support the resolution. It's assumed that consumers won't have
1616 // software fallback for H264 on Android anyway. 1627 // software fallback for H264 on Android anyway.
1617 profile.max_resolution.SetSize(3840, 2160); 1628 profile.max_resolution.SetSize(3840, 2160);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 1660
1650 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() 1661 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden()
1651 const { 1662 const {
1652 // Prevent MediaCodec from using its internal software decoders when we have 1663 // Prevent MediaCodec from using its internal software decoders when we have
1653 // more secure and up to date versions in the renderer process. 1664 // more secure and up to date versions in the renderer process.
1654 return !config_.is_encrypted && (codec_config_->codec_ == kCodecVP8 || 1665 return !config_.is_encrypted && (codec_config_->codec_ == kCodecVP8 ||
1655 codec_config_->codec_ == kCodecVP9); 1666 codec_config_->codec_ == kCodecVP9);
1656 } 1667 }
1657 1668
1658 } // namespace media 1669 } // 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