WebpSupportStatus.smali
.class public Lcom/facebook/common/webp/WebpSupportStatus;
.super Ljava/lang/Object;
.source "SourceFile"
# static fields
.field private static final EXTENDED_WEBP_HEADER_LENGTH:I = 0x15
.field private static final SIMPLE_WEBP_HEADER_LENGTH:I = 0x14
.field private static final VP8X_WEBP_BASE64:Ljava/lang/String; = "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA=="
.field private static final WEBP_NAME_BYTES:[B
.field private static final WEBP_RIFF_BYTES:[B
.field private static final WEBP_VP8L_BYTES:[B
.field private static final WEBP_VP8X_BYTES:[B
.field private static final WEBP_VP8_BYTES:[B
.field public static final sIsExtendedWebpSupported:Z
.field public static final sIsSimpleWebpSupported:Z
.field public static final sIsWebpSupportRequired:Z
.field public static sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.field private static sWebpLibraryChecked:Z
# direct methods
.method public static constructor <clinit>()V
.registers 2
const/4 v0, 0x0
.line 1
sput-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsWebpSupportRequired:Z
const/4 v1, 0x1
.line 2
sput-boolean v1, Lcom/facebook/common/webp/WebpSupportStatus;->sIsSimpleWebpSupported:Z
.line 3
invoke-static {}, Lcom/facebook/common/webp/WebpSupportStatus;->isExtendedWebpSupported()Z
move-result v1
sput-boolean v1, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
const/4 v1, 0x0
.line 4
sput-object v1, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
.line 5
sput-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
const-string v0, "RIFF"
.line 6
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_RIFF_BYTES:[B
const-string v0, "WEBP"
.line 7
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_NAME_BYTES:[B
const-string v0, "VP8 "
.line 8
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8_BYTES:[B
const-string v0, "VP8L"
.line 9
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8L_BYTES:[B
const-string v0, "VP8X"
.line 10
invoke-static {v0}, Lcom/facebook/common/webp/WebpSupportStatus;->asciiBytes(Ljava/lang/String;)[B
move-result-object v0
sput-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
return-void
.end method
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method private static asciiBytes(Ljava/lang/String;)[B
.registers 3
:try_start_0
const-string v0, "ASCII"
.line 1
invoke-virtual {p0, v0}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B
move-result-object p0
:try_end_6
.catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_6} :catch_7
return-object p0
:catch_7
move-exception p0
.line 2
new-instance v0, Ljava/lang/RuntimeException;
const-string v1, "ASCII not found!"
invoke-direct {v0, v1, p0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v0
.end method
.method public static isAnimatedWebpHeader([BI)Z
.registers 5
add-int/lit8 v0, p1, 0xc
.line 1
sget-object v1, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
invoke-static {p0, v0, v1}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result v0
add-int/lit8 p1, p1, 0x14
.line 2
aget-byte p0, p0, p1
const/4 p1, 0x2
and-int/2addr p0, p1
const/4 v1, 0x1
const/4 v2, 0x0
if-ne p0, p1, :cond_14
const/4 p0, 0x1
goto :goto_15
:cond_14
const/4 p0, 0x0
:goto_15
if-eqz v0, :cond_1a
if-eqz p0, :cond_1a
goto :goto_1b
:cond_1a
const/4 v1, 0x0
:goto_1b
return v1
.end method
.method public static isExtendedWebpHeader([BII)Z
.registers 4
const/16 v0, 0x15
if-lt p2, v0, :cond_10
add-int/lit8 p1, p1, 0xc
.line 1
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
.line 2
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
if-eqz p0, :cond_10
const/4 p0, 0x1
goto :goto_11
:cond_10
const/4 p0, 0x0
:goto_11
return p0
.end method
.method public static isExtendedWebpHeaderWithAlpha([BI)Z
.registers 5
add-int/lit8 v0, p1, 0xc
.line 1
sget-object v1, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8X_BYTES:[B
invoke-static {p0, v0, v1}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result v0
add-int/lit8 p1, p1, 0x14
.line 2
aget-byte p0, p0, p1
const/16 p1, 0x10
and-int/2addr p0, p1
const/4 v1, 0x1
const/4 v2, 0x0
if-ne p0, p1, :cond_15
const/4 p0, 0x1
goto :goto_16
:cond_15
const/4 p0, 0x0
:goto_16
if-eqz v0, :cond_1b
if-eqz p0, :cond_1b
goto :goto_1c
:cond_1b
const/4 v1, 0x0
:goto_1c
return v1
.end method
.method private static isExtendedWebpSupported()Z
.registers 1
const/4 v0, 0x1
return v0
.end method
.method public static isLosslessWebpHeader([BI)Z
.registers 3
add-int/lit8 p1, p1, 0xc
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8L_BYTES:[B
invoke-static {p0, p1, v0}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
return p0
.end method
.method public static isSimpleWebpHeader([BI)Z
.registers 3
add-int/lit8 p1, p1, 0xc
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_VP8_BYTES:[B
invoke-static {p0, p1, v0}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
return p0
.end method
.method public static isWebpHeader([BII)Z
.registers 4
const/16 v0, 0x14
if-lt p2, v0, :cond_18
.line 1
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_RIFF_BYTES:[B
.line 2
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p2
if-eqz p2, :cond_18
add-int/lit8 p1, p1, 0x8
sget-object p2, Lcom/facebook/common/webp/WebpSupportStatus;->WEBP_NAME_BYTES:[B
.line 3
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->matchBytePattern([BI[B)Z
move-result p0
if-eqz p0, :cond_18
const/4 p0, 0x1
goto :goto_19
:cond_18
const/4 p0, 0x0
:goto_19
return p0
.end method
.method public static isWebpSupportedByPlatform([BII)Z
.registers 4
.line 1
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isSimpleWebpHeader([BI)Z
move-result v0
if-eqz v0, :cond_9
.line 2
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsSimpleWebpSupported:Z
return p0
.line 3
:cond_9
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isLosslessWebpHeader([BI)Z
move-result v0
if-eqz v0, :cond_12
.line 4
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
return p0
.line 5
:cond_12
invoke-static {p0, p1, p2}, Lcom/facebook/common/webp/WebpSupportStatus;->isExtendedWebpHeader([BII)Z
move-result p2
const/4 v0, 0x0
if-eqz p2, :cond_23
.line 6
invoke-static {p0, p1}, Lcom/facebook/common/webp/WebpSupportStatus;->isAnimatedWebpHeader([BI)Z
move-result p0
if-eqz p0, :cond_20
return v0
.line 7
:cond_20
sget-boolean p0, Lcom/facebook/common/webp/WebpSupportStatus;->sIsExtendedWebpSupported:Z
return p0
:cond_23
return v0
.end method
.method public static loadWebpBitmapFactoryIfExists()Lcom/facebook/common/webp/WebpBitmapFactory;
.registers 2
.line 1
sget-boolean v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
if-eqz v0, :cond_7
.line 2
sget-object v0, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpBitmapFactory:Lcom/facebook/common/webp/WebpBitmapFactory;
return-object v0
:cond_7
const/4 v0, 0x0
:try_start_8
const-string v1, "com.facebook.webpsupport.WebpBitmapFactoryImpl"
.line 3
invoke-static {v1}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
move-result-object v1
.line 4
invoke-virtual {v1}, Ljava/lang/Class;->newInstance()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/facebook/common/webp/WebpBitmapFactory;
:try_end_14
.catchall {:try_start_8 .. :try_end_14} :catchall_15
move-object v0, v1
:catchall_15
const/4 v1, 0x1
.line 5
sput-boolean v1, Lcom/facebook/common/webp/WebpSupportStatus;->sWebpLibraryChecked:Z
return-object v0
.end method
.method private static matchBytePattern([BI[B)Z
.registers 7
const/4 v0, 0x0
if-eqz p2, :cond_1e
if-nez p0, :cond_6
goto :goto_1e
.line 1
:cond_6
array-length v1, p2
add-int/2addr v1, p1
array-length v2, p0
if-le v1, v2, :cond_c
return v0
:cond_c
const/4 v1, 0x0
.line 2
:goto_d
array-length v2, p2
if-ge v1, v2, :cond_1c
add-int v2, v1, p1
.line 3
aget-byte v2, p0, v2
aget-byte v3, p2, v1
if-eq v2, v3, :cond_19
return v0
:cond_19
add-int/lit8 v1, v1, 0x1
goto :goto_d
:cond_1c
const/4 p0, 0x1
return p0
:cond_1e
:goto_1e
return v0
.end method