Merge "Revert "ImageDecoder: Add AVIF to support list"" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
265b4ef66a
@@ -38,11 +38,8 @@ import android.graphics.drawable.AnimatedImageDrawable;
|
|||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.NinePatchDrawable;
|
import android.graphics.drawable.NinePatchDrawable;
|
||||||
import android.media.MediaCodecInfo;
|
|
||||||
import android.media.MediaCodecList;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
@@ -931,8 +928,6 @@ public final class ImageDecoder implements AutoCloseable {
|
|||||||
case "image/x-pentax-pef":
|
case "image/x-pentax-pef":
|
||||||
case "image/x-samsung-srw":
|
case "image/x-samsung-srw":
|
||||||
return true;
|
return true;
|
||||||
case "image/avif":
|
|
||||||
return isP010SupportedForAV1();
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2068,49 +2063,6 @@ public final class ImageDecoder implements AutoCloseable {
|
|||||||
return decodeBitmapImpl(src, null);
|
return decodeBitmapImpl(src, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean sIsP010SupportedForAV1 = false;
|
|
||||||
private static boolean sIsP010SupportedForAV1Initialized = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the device supports decoding 10-bit AV1.
|
|
||||||
*/
|
|
||||||
private static boolean isP010SupportedForAV1() {
|
|
||||||
if (sIsP010SupportedForAV1Initialized) {
|
|
||||||
return sIsP010SupportedForAV1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sIsP010SupportedForAV1Initialized = true;
|
|
||||||
|
|
||||||
if (hasHardwareDecoder("video/av01")) {
|
|
||||||
sIsP010SupportedForAV1 = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sIsP010SupportedForAV1 = SystemProperties.getInt("ro.product.first_api_level", 0) >=
|
|
||||||
Build.VERSION_CODES.S;
|
|
||||||
return sIsP010SupportedForAV1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the device has hardware decoder for the target mime type.
|
|
||||||
*/
|
|
||||||
private static boolean hasHardwareDecoder(String mime) {
|
|
||||||
final MediaCodecList sMCL = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
|
||||||
for (MediaCodecInfo info : sMCL.getCodecInfos()) {
|
|
||||||
if (info.isEncoder() == false && info.isHardwareAccelerated()) {
|
|
||||||
try {
|
|
||||||
if (info.getCapabilitiesForType(mime) != null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// mime is not supported
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private method called by JNI.
|
* Private method called by JNI.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user