Refine HW/SW codec approximation for API level 28 and earlier
Hardware audio decoders aren't really a thing, particularly on older devices. SOC vendors do sometimes provide their own software decoders though. Hence we update the approximation to assume that audio decoders on older devices are software. PiperOrigin-RevId: 413757859
This commit is contained in:
parent
e1eb30c8ba
commit
244777234b
@ -322,8 +322,8 @@ public final class MediaCodecUtil {
|
||||
if ((!key.secure && secureRequired) || (key.secure && !secureSupported)) {
|
||||
continue;
|
||||
}
|
||||
boolean hardwareAccelerated = isHardwareAccelerated(codecInfo);
|
||||
boolean softwareOnly = isSoftwareOnly(codecInfo);
|
||||
boolean hardwareAccelerated = isHardwareAccelerated(codecInfo, mimeType);
|
||||
boolean softwareOnly = isSoftwareOnly(codecInfo, mimeType);
|
||||
boolean vendor = isVendor(codecInfo);
|
||||
if ((secureDecodersExplicit && key.secure == secureSupported)
|
||||
|| (!secureDecodersExplicit && !key.secure)) {
|
||||
@ -603,13 +603,14 @@ public final class MediaCodecUtil {
|
||||
* The result of {@link android.media.MediaCodecInfo#isHardwareAccelerated()} for API levels 29+,
|
||||
* or a best-effort approximation for lower levels.
|
||||
*/
|
||||
private static boolean isHardwareAccelerated(android.media.MediaCodecInfo codecInfo) {
|
||||
private static boolean isHardwareAccelerated(
|
||||
android.media.MediaCodecInfo codecInfo, String mimeType) {
|
||||
if (Util.SDK_INT >= 29) {
|
||||
return isHardwareAcceleratedV29(codecInfo);
|
||||
}
|
||||
// codecInfo.isHardwareAccelerated() != codecInfo.isSoftwareOnly() is not necessarily true.
|
||||
// However, we assume this to be true as an approximation.
|
||||
return !isSoftwareOnly(codecInfo);
|
||||
return !isSoftwareOnly(codecInfo, mimeType);
|
||||
}
|
||||
|
||||
@RequiresApi(29)
|
||||
@ -621,12 +622,17 @@ public final class MediaCodecUtil {
|
||||
* The result of {@link android.media.MediaCodecInfo#isSoftwareOnly()} for API levels 29+, or a
|
||||
* best-effort approximation for lower levels.
|
||||
*/
|
||||
private static boolean isSoftwareOnly(android.media.MediaCodecInfo codecInfo) {
|
||||
private static boolean isSoftwareOnly(android.media.MediaCodecInfo codecInfo, String mimeType) {
|
||||
if (Util.SDK_INT >= 29) {
|
||||
return isSoftwareOnlyV29(codecInfo);
|
||||
}
|
||||
if (MimeTypes.isAudio(mimeType)) {
|
||||
// Assume audio decoders are software only.
|
||||
return true;
|
||||
}
|
||||
String codecName = Ascii.toLowerCase(codecInfo.getName());
|
||||
if (codecName.startsWith("arc.")) { // App Runtime for Chrome (ARC) codecs
|
||||
if (codecName.startsWith("arc.")) {
|
||||
// App Runtime for Chrome (ARC) codecs
|
||||
return false;
|
||||
}
|
||||
return codecName.startsWith("omx.google.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user