mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 03:47:18 +01:00
138 lines
7.7 KiB
Java
138 lines
7.7 KiB
Java
package com.facebook.imageutils;
|
|
|
|
import com.dee.app.contacts.common.constants.Constants;
|
|
import com.facebook.common.logging.FLog;
|
|
import com.mapbox.maps.plugin.locationcomponent.ModelSourceWrapper;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import kotlin.Metadata;
|
|
import kotlin.jvm.JvmStatic;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\bÀ\u0002\u0018\u00002\u00020\u0001:\u0001\u0019B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0010\u0010\u000b\u001a\u00020\u00072\u0006\u0010\f\u001a\u00020\u0007H\u0007J\u0018\u0010\r\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u0007H\u0007J \u0010\u0011\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u00072\u0006\u0010\u0012\u001a\u00020\u0013H\u0002J(\u0010\u0014\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u00072\u0006\u0010\u0015\u001a\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u0007H\u0002J \u0010\u0018\u001a\u00020\u00072\u0006\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u00072\u0006\u0010\u0015\u001a\u00020\u0016H\u0002R\u0012\u0010\u0004\u001a\u0006\u0012\u0002\b\u00030\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u001a"}, d2 = {"Lcom/facebook/imageutils/TiffUtil;", "", "<init>", "()V", Constants.LOG_TAG, "Ljava/lang/Class;", "TIFF_BYTE_ORDER_BIG_END", "", "TIFF_BYTE_ORDER_LITTLE_END", "TIFF_TAG_ORIENTATION", "TIFF_TYPE_SHORT", "getAutoRotateAngleFromOrientation", ModelSourceWrapper.ORIENTATION, "readOrientationFromTIFF", "stream", "Ljava/io/InputStream;", "length", "readTiffHeader", "tiffHeader", "Lcom/facebook/imageutils/TiffUtil$TiffHeader;", "moveToTiffEntryWithTag", "isLittleEndian", "", "tagToFind", "getOrientationFromTiffEntry", "TiffHeader", "imagepipeline-base_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
/* loaded from: classes6.dex */
|
|
public final class TiffUtil {
|
|
|
|
@NotNull
|
|
public static final TiffUtil INSTANCE = new TiffUtil();
|
|
|
|
@NotNull
|
|
private static final Class<?> TAG = TiffUtil.class;
|
|
public static final int TIFF_BYTE_ORDER_BIG_END = 1296891946;
|
|
public static final int TIFF_BYTE_ORDER_LITTLE_END = 1229531648;
|
|
public static final int TIFF_TAG_ORIENTATION = 274;
|
|
public static final int TIFF_TYPE_SHORT = 3;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\b\b\u0002\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u0002\u0010\u0003R\u001a\u0010\u0004\u001a\u00020\u0005X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0004\u0010\u0006\"\u0004\b\u0007\u0010\bR\u001a\u0010\t\u001a\u00020\nX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000eR\u001a\u0010\u000f\u001a\u00020\nX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\f\"\u0004\b\u0011\u0010\u000e¨\u0006\u0012"}, d2 = {"Lcom/facebook/imageutils/TiffUtil$TiffHeader;", "", "<init>", "()V", "isLittleEndian", "", "()Z", "setLittleEndian", "(Z)V", "byteOrder", "", "getByteOrder", "()I", "setByteOrder", "(I)V", "firstIfdOffset", "getFirstIfdOffset", "setFirstIfdOffset", "imagepipeline-base_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
|
|
public static final class TiffHeader {
|
|
private int byteOrder;
|
|
private int firstIfdOffset;
|
|
private boolean isLittleEndian;
|
|
|
|
public final int getByteOrder() {
|
|
return this.byteOrder;
|
|
}
|
|
|
|
public final int getFirstIfdOffset() {
|
|
return this.firstIfdOffset;
|
|
}
|
|
|
|
/* renamed from: isLittleEndian, reason: from getter */
|
|
public final boolean getIsLittleEndian() {
|
|
return this.isLittleEndian;
|
|
}
|
|
|
|
public final void setByteOrder(int i) {
|
|
this.byteOrder = i;
|
|
}
|
|
|
|
public final void setFirstIfdOffset(int i) {
|
|
this.firstIfdOffset = i;
|
|
}
|
|
|
|
public final void setLittleEndian(boolean z) {
|
|
this.isLittleEndian = z;
|
|
}
|
|
}
|
|
|
|
private TiffUtil() {
|
|
}
|
|
|
|
@JvmStatic
|
|
public static final int getAutoRotateAngleFromOrientation(int orientation) {
|
|
if (orientation == 0 || orientation == 1) {
|
|
return 0;
|
|
}
|
|
if (orientation == 3) {
|
|
return 180;
|
|
}
|
|
if (orientation != 6) {
|
|
return orientation != 8 ? 0 : 270;
|
|
}
|
|
return 90;
|
|
}
|
|
|
|
private final int getOrientationFromTiffEntry(InputStream stream, int length, boolean isLittleEndian) throws IOException {
|
|
if (length >= 10 && StreamProcessor.readPackedInt(stream, 2, isLittleEndian) == 3 && StreamProcessor.readPackedInt(stream, 4, isLittleEndian) == 1) {
|
|
return StreamProcessor.readPackedInt(stream, 2, isLittleEndian);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
private final int moveToTiffEntryWithTag(InputStream stream, int length, boolean isLittleEndian, int tagToFind) throws IOException {
|
|
if (length < 14) {
|
|
return 0;
|
|
}
|
|
int readPackedInt = StreamProcessor.readPackedInt(stream, 2, isLittleEndian);
|
|
int i = length - 2;
|
|
while (true) {
|
|
int i2 = readPackedInt - 1;
|
|
if (readPackedInt <= 0 || i < 12) {
|
|
break;
|
|
}
|
|
int i3 = i - 2;
|
|
if (StreamProcessor.readPackedInt(stream, 2, isLittleEndian) == tagToFind) {
|
|
return i3;
|
|
}
|
|
stream.skip(10L);
|
|
i -= 12;
|
|
readPackedInt = i2;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@JvmStatic
|
|
public static final int readOrientationFromTIFF(@NotNull InputStream stream, int length) throws IOException {
|
|
stream.getClass();
|
|
TiffHeader tiffHeader = new TiffHeader();
|
|
TiffUtil tiffUtil = INSTANCE;
|
|
int readTiffHeader = tiffUtil.readTiffHeader(stream, length, tiffHeader);
|
|
int firstIfdOffset = tiffHeader.getFirstIfdOffset() - 8;
|
|
if (readTiffHeader == 0 || firstIfdOffset > readTiffHeader) {
|
|
return 0;
|
|
}
|
|
stream.skip(firstIfdOffset);
|
|
return tiffUtil.getOrientationFromTiffEntry(stream, tiffUtil.moveToTiffEntryWithTag(stream, readTiffHeader - firstIfdOffset, tiffHeader.getIsLittleEndian(), 274), tiffHeader.getIsLittleEndian());
|
|
}
|
|
|
|
private final int readTiffHeader(InputStream stream, int length, TiffHeader tiffHeader) throws IOException {
|
|
if (length <= 8) {
|
|
return 0;
|
|
}
|
|
tiffHeader.setByteOrder(StreamProcessor.readPackedInt(stream, 4, false));
|
|
if (tiffHeader.getByteOrder() != 1229531648 && tiffHeader.getByteOrder() != 1296891946) {
|
|
FLog.e(TAG, "Invalid TIFF header");
|
|
return 0;
|
|
}
|
|
tiffHeader.setLittleEndian(tiffHeader.getByteOrder() == 1229531648);
|
|
tiffHeader.setFirstIfdOffset(StreamProcessor.readPackedInt(stream, 4, tiffHeader.getIsLittleEndian()));
|
|
int i = length - 8;
|
|
if (tiffHeader.getFirstIfdOffset() >= 8 && tiffHeader.getFirstIfdOffset() - 8 <= i) {
|
|
return i;
|
|
}
|
|
FLog.e(TAG, "Invalid offset");
|
|
return 0;
|
|
}
|
|
}
|