2021-07-24 02:37:17 +00:00
package androidx.exifinterface.media ;
import android.annotation.SuppressLint ;
import android.content.res.AssetManager ;
import android.graphics.Bitmap ;
import android.graphics.BitmapFactory ;
import android.location.Location ;
import android.media.MediaDataSource ;
import android.media.MediaMetadataRetriever ;
import android.os.Build ;
import android.system.OsConstants ;
import android.util.Log ;
import android.util.Pair ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.RestrictTo ;
2021-08-09 22:51:56 +00:00
import androidx.core.view.InputDeviceCompat ;
2022-01-13 08:07:50 +00:00
import androidx.exifinterface.media.ExifInterfaceUtils ;
2021-08-09 22:51:56 +00:00
import androidx.media.AudioAttributesCompat ;
2021-12-17 21:59:34 +00:00
import b.d.b.a.a ;
2021-08-09 22:51:56 +00:00
import com.discord.widgets.chat.input.MentionUtilsKt ;
import com.discord.widgets.chat.input.autocomplete.AutocompleteViewModel ;
import com.google.android.material.badge.BadgeDrawable ;
import com.google.android.material.shadow.ShadowDrawableWrapper ;
2021-07-24 02:37:17 +00:00
import java.io.BufferedInputStream ;
import java.io.BufferedOutputStream ;
import java.io.ByteArrayInputStream ;
import java.io.ByteArrayOutputStream ;
2022-03-07 09:34:54 +00:00
import java.io.Closeable ;
2021-07-24 02:37:17 +00:00
import java.io.DataInput ;
import java.io.DataInputStream ;
import java.io.EOFException ;
import java.io.File ;
import java.io.FileDescriptor ;
import java.io.FileInputStream ;
import java.io.FileNotFoundException ;
import java.io.FileOutputStream ;
import java.io.FilterOutputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.io.OutputStream ;
import java.lang.annotation.Retention ;
import java.lang.annotation.RetentionPolicy ;
import java.nio.ByteBuffer ;
import java.nio.ByteOrder ;
import java.nio.charset.Charset ;
import java.text.ParsePosition ;
import java.text.SimpleDateFormat ;
import java.util.Arrays ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.HashSet ;
import java.util.List ;
import java.util.Locale ;
import java.util.Map ;
import java.util.Objects ;
import java.util.Set ;
import java.util.TimeZone ;
import java.util.concurrent.TimeUnit ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;
import java.util.zip.CRC32 ;
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public class ExifInterface {
public static final short ALTITUDE_ABOVE_SEA_LEVEL = 0 ;
public static final short ALTITUDE_BELOW_SEA_LEVEL = 1 ;
public static final Charset ASCII ;
public static final short BYTE_ALIGN_II = 18761 ;
public static final short BYTE_ALIGN_MM = 19789 ;
public static final int COLOR_SPACE_S_RGB = 1 ;
public static final int COLOR_SPACE_UNCALIBRATED = 65535 ;
public static final short CONTRAST_HARD = 2 ;
public static final short CONTRAST_NORMAL = 0 ;
public static final short CONTRAST_SOFT = 1 ;
public static final int DATA_DEFLATE_ZIP = 8 ;
public static final int DATA_HUFFMAN_COMPRESSED = 2 ;
public static final int DATA_JPEG = 6 ;
public static final int DATA_JPEG_COMPRESSED = 7 ;
public static final int DATA_LOSSY_JPEG = 34892 ;
public static final int DATA_PACK_BITS_COMPRESSED = 32773 ;
public static final int DATA_UNCOMPRESSED = 1 ;
2022-03-07 09:34:54 +00:00
private static final Pattern DATETIME_PRIMARY_FORMAT_PATTERN ;
private static final Pattern DATETIME_SECONDARY_FORMAT_PATTERN ;
2021-07-24 02:37:17 +00:00
private static final int DATETIME_VALUE_STRING_LENGTH = 19 ;
public static final ExifTag [ ] [ ] EXIF_TAGS ;
public static final short EXPOSURE_MODE_AUTO = 0 ;
public static final short EXPOSURE_MODE_AUTO_BRACKET = 2 ;
public static final short EXPOSURE_MODE_MANUAL = 1 ;
public static final short EXPOSURE_PROGRAM_ACTION = 6 ;
public static final short EXPOSURE_PROGRAM_APERTURE_PRIORITY = 3 ;
public static final short EXPOSURE_PROGRAM_CREATIVE = 5 ;
public static final short EXPOSURE_PROGRAM_LANDSCAPE_MODE = 8 ;
public static final short EXPOSURE_PROGRAM_MANUAL = 1 ;
public static final short EXPOSURE_PROGRAM_NORMAL = 2 ;
public static final short EXPOSURE_PROGRAM_NOT_DEFINED = 0 ;
public static final short EXPOSURE_PROGRAM_PORTRAIT_MODE = 7 ;
public static final short EXPOSURE_PROGRAM_SHUTTER_PRIORITY = 4 ;
public static final short FILE_SOURCE_DSC = 3 ;
public static final short FILE_SOURCE_OTHER = 0 ;
public static final short FILE_SOURCE_REFLEX_SCANNER = 2 ;
public static final short FILE_SOURCE_TRANSPARENT_SCANNER = 1 ;
public static final short FLAG_FLASH_FIRED = 1 ;
public static final short FLAG_FLASH_MODE_AUTO = 24 ;
public static final short FLAG_FLASH_MODE_COMPULSORY_FIRING = 8 ;
public static final short FLAG_FLASH_MODE_COMPULSORY_SUPPRESSION = 16 ;
public static final short FLAG_FLASH_NO_FLASH_FUNCTION = 32 ;
public static final short FLAG_FLASH_RED_EYE_SUPPORTED = 64 ;
public static final short FLAG_FLASH_RETURN_LIGHT_DETECTED = 6 ;
public static final short FLAG_FLASH_RETURN_LIGHT_NOT_DETECTED = 4 ;
public static final short FORMAT_CHUNKY = 1 ;
public static final short FORMAT_PLANAR = 2 ;
public static final short GAIN_CONTROL_HIGH_GAIN_DOWN = 4 ;
public static final short GAIN_CONTROL_HIGH_GAIN_UP = 2 ;
public static final short GAIN_CONTROL_LOW_GAIN_DOWN = 3 ;
public static final short GAIN_CONTROL_LOW_GAIN_UP = 1 ;
public static final short GAIN_CONTROL_NONE = 0 ;
public static final String GPS_DIRECTION_MAGNETIC = " M " ;
public static final String GPS_DIRECTION_TRUE = " T " ;
public static final String GPS_DISTANCE_KILOMETERS = " K " ;
public static final String GPS_DISTANCE_MILES = " M " ;
public static final String GPS_DISTANCE_NAUTICAL_MILES = " N " ;
public static final String GPS_MEASUREMENT_2D = " 2 " ;
public static final String GPS_MEASUREMENT_3D = " 3 " ;
public static final short GPS_MEASUREMENT_DIFFERENTIAL_CORRECTED = 1 ;
public static final String GPS_MEASUREMENT_INTERRUPTED = " V " ;
public static final String GPS_MEASUREMENT_IN_PROGRESS = " A " ;
public static final short GPS_MEASUREMENT_NO_DIFFERENTIAL = 0 ;
public static final String GPS_SPEED_KILOMETERS_PER_HOUR = " K " ;
public static final String GPS_SPEED_KNOTS = " N " ;
public static final String GPS_SPEED_MILES_PER_HOUR = " M " ;
2022-03-07 09:34:54 +00:00
private static final Pattern GPS_TIMESTAMP_PATTERN ;
2021-07-24 02:37:17 +00:00
public static final byte [ ] IDENTIFIER_EXIF_APP1 ;
private static final byte [ ] IDENTIFIER_XMP_APP1 ;
private static final ExifTag [ ] IFD_EXIF_TAGS ;
private static final int IFD_FORMAT_BYTE = 1 ;
private static final int IFD_FORMAT_DOUBLE = 12 ;
private static final int IFD_FORMAT_IFD = 13 ;
private static final int IFD_FORMAT_SBYTE = 6 ;
private static final int IFD_FORMAT_SINGLE = 11 ;
private static final int IFD_FORMAT_SLONG = 9 ;
private static final int IFD_FORMAT_SRATIONAL = 10 ;
private static final int IFD_FORMAT_SSHORT = 8 ;
private static final int IFD_FORMAT_STRING = 2 ;
private static final int IFD_FORMAT_ULONG = 4 ;
private static final int IFD_FORMAT_UNDEFINED = 7 ;
private static final int IFD_FORMAT_URATIONAL = 5 ;
private static final int IFD_FORMAT_USHORT = 3 ;
private static final ExifTag [ ] IFD_GPS_TAGS ;
private static final ExifTag [ ] IFD_INTEROPERABILITY_TAGS ;
private static final int IFD_OFFSET = 8 ;
private static final ExifTag [ ] IFD_THUMBNAIL_TAGS ;
private static final ExifTag [ ] IFD_TIFF_TAGS ;
private static final int IFD_TYPE_EXIF = 1 ;
private static final int IFD_TYPE_GPS = 2 ;
private static final int IFD_TYPE_INTEROPERABILITY = 3 ;
private static final int IFD_TYPE_ORF_CAMERA_SETTINGS = 7 ;
private static final int IFD_TYPE_ORF_IMAGE_PROCESSING = 8 ;
private static final int IFD_TYPE_ORF_MAKER_NOTE = 6 ;
private static final int IFD_TYPE_PEF = 9 ;
public static final int IFD_TYPE_PREVIEW = 5 ;
public static final int IFD_TYPE_PRIMARY = 0 ;
public static final int IFD_TYPE_THUMBNAIL = 4 ;
2022-01-13 08:07:50 +00:00
public static final int IMAGE_TYPE_ARW = 1 ;
public static final int IMAGE_TYPE_CR2 = 2 ;
public static final int IMAGE_TYPE_DNG = 3 ;
public static final int IMAGE_TYPE_HEIF = 12 ;
public static final int IMAGE_TYPE_JPEG = 4 ;
public static final int IMAGE_TYPE_NEF = 5 ;
public static final int IMAGE_TYPE_NRW = 6 ;
public static final int IMAGE_TYPE_ORF = 7 ;
public static final int IMAGE_TYPE_PEF = 8 ;
public static final int IMAGE_TYPE_PNG = 13 ;
public static final int IMAGE_TYPE_RAF = 9 ;
public static final int IMAGE_TYPE_RW2 = 10 ;
public static final int IMAGE_TYPE_SRW = 11 ;
public static final int IMAGE_TYPE_UNKNOWN = 0 ;
public static final int IMAGE_TYPE_WEBP = 14 ;
2021-07-24 02:37:17 +00:00
public static final String LATITUDE_NORTH = " N " ;
public static final String LATITUDE_SOUTH = " S " ;
public static final short LIGHT_SOURCE_CLOUDY_WEATHER = 10 ;
public static final short LIGHT_SOURCE_COOL_WHITE_FLUORESCENT = 14 ;
public static final short LIGHT_SOURCE_D50 = 23 ;
public static final short LIGHT_SOURCE_D55 = 20 ;
public static final short LIGHT_SOURCE_D65 = 21 ;
public static final short LIGHT_SOURCE_D75 = 22 ;
public static final short LIGHT_SOURCE_DAYLIGHT = 1 ;
public static final short LIGHT_SOURCE_DAYLIGHT_FLUORESCENT = 12 ;
public static final short LIGHT_SOURCE_DAY_WHITE_FLUORESCENT = 13 ;
public static final short LIGHT_SOURCE_FINE_WEATHER = 9 ;
public static final short LIGHT_SOURCE_FLASH = 4 ;
public static final short LIGHT_SOURCE_FLUORESCENT = 2 ;
public static final short LIGHT_SOURCE_ISO_STUDIO_TUNGSTEN = 24 ;
public static final short LIGHT_SOURCE_OTHER = 255 ;
public static final short LIGHT_SOURCE_SHADE = 11 ;
public static final short LIGHT_SOURCE_STANDARD_LIGHT_A = 17 ;
public static final short LIGHT_SOURCE_STANDARD_LIGHT_B = 18 ;
public static final short LIGHT_SOURCE_STANDARD_LIGHT_C = 19 ;
public static final short LIGHT_SOURCE_TUNGSTEN = 3 ;
public static final short LIGHT_SOURCE_UNKNOWN = 0 ;
public static final short LIGHT_SOURCE_WARM_WHITE_FLUORESCENT = 16 ;
public static final short LIGHT_SOURCE_WHITE_FLUORESCENT = 15 ;
public static final String LONGITUDE_EAST = " E " ;
public static final String LONGITUDE_WEST = " W " ;
public static final byte MARKER = - 1 ;
public static final byte MARKER_APP1 = - 31 ;
private static final byte MARKER_COM = - 2 ;
public static final byte MARKER_EOI = - 39 ;
private static final byte MARKER_SOF0 = - 64 ;
private static final byte MARKER_SOF1 = - 63 ;
private static final byte MARKER_SOF10 = - 54 ;
private static final byte MARKER_SOF11 = - 53 ;
private static final byte MARKER_SOF13 = - 51 ;
private static final byte MARKER_SOF14 = - 50 ;
private static final byte MARKER_SOF15 = - 49 ;
private static final byte MARKER_SOF2 = - 62 ;
private static final byte MARKER_SOF3 = - 61 ;
private static final byte MARKER_SOF5 = - 59 ;
private static final byte MARKER_SOF6 = - 58 ;
private static final byte MARKER_SOF7 = - 57 ;
private static final byte MARKER_SOF9 = - 55 ;
private static final byte MARKER_SOS = - 38 ;
private static final int MAX_THUMBNAIL_SIZE = 512 ;
public static final short METERING_MODE_AVERAGE = 1 ;
public static final short METERING_MODE_CENTER_WEIGHT_AVERAGE = 2 ;
public static final short METERING_MODE_MULTI_SPOT = 4 ;
public static final short METERING_MODE_OTHER = 255 ;
public static final short METERING_MODE_PARTIAL = 6 ;
public static final short METERING_MODE_PATTERN = 5 ;
public static final short METERING_MODE_SPOT = 3 ;
public static final short METERING_MODE_UNKNOWN = 0 ;
2022-03-07 09:34:54 +00:00
private static final Pattern NON_ZERO_TIME_PATTERN ;
2021-07-24 02:37:17 +00:00
private static final ExifTag [ ] ORF_CAMERA_SETTINGS_TAGS ;
private static final ExifTag [ ] ORF_IMAGE_PROCESSING_TAGS ;
private static final int ORF_MAKER_NOTE_HEADER_1_SIZE = 8 ;
private static final int ORF_MAKER_NOTE_HEADER_2_SIZE = 12 ;
private static final ExifTag [ ] ORF_MAKER_NOTE_TAGS ;
private static final short ORF_SIGNATURE_1 = 20306 ;
private static final short ORF_SIGNATURE_2 = 21330 ;
public static final int ORIENTATION_FLIP_HORIZONTAL = 2 ;
public static final int ORIENTATION_FLIP_VERTICAL = 4 ;
public static final int ORIENTATION_NORMAL = 1 ;
public static final int ORIENTATION_ROTATE_180 = 3 ;
public static final int ORIENTATION_ROTATE_270 = 8 ;
public static final int ORIENTATION_ROTATE_90 = 6 ;
public static final int ORIENTATION_TRANSPOSE = 5 ;
public static final int ORIENTATION_TRANSVERSE = 7 ;
public static final int ORIENTATION_UNDEFINED = 0 ;
public static final int ORIGINAL_RESOLUTION_IMAGE = 0 ;
private static final int PEF_MAKER_NOTE_SKIP_SIZE = 6 ;
private static final String PEF_SIGNATURE = " PENTAX " ;
private static final ExifTag [ ] PEF_TAGS ;
public static final int PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO = 1 ;
public static final int PHOTOMETRIC_INTERPRETATION_RGB = 2 ;
public static final int PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO = 0 ;
public static final int PHOTOMETRIC_INTERPRETATION_YCBCR = 6 ;
private static final int PNG_CHUNK_CRC_BYTE_LENGTH = 4 ;
private static final int PNG_CHUNK_TYPE_BYTE_LENGTH = 4 ;
private static final int RAF_OFFSET_TO_JPEG_IMAGE_OFFSET = 84 ;
private static final String RAF_SIGNATURE = " FUJIFILMCCD-RAW " ;
public static final int REDUCED_RESOLUTION_IMAGE = 1 ;
public static final short RENDERED_PROCESS_CUSTOM = 1 ;
public static final short RENDERED_PROCESS_NORMAL = 0 ;
public static final short RESOLUTION_UNIT_CENTIMETERS = 3 ;
public static final short RESOLUTION_UNIT_INCHES = 2 ;
private static final short RW2_SIGNATURE = 85 ;
public static final short SATURATION_HIGH = 0 ;
public static final short SATURATION_LOW = 0 ;
public static final short SATURATION_NORMAL = 0 ;
public static final short SCENE_CAPTURE_TYPE_LANDSCAPE = 1 ;
public static final short SCENE_CAPTURE_TYPE_NIGHT = 3 ;
public static final short SCENE_CAPTURE_TYPE_PORTRAIT = 2 ;
public static final short SCENE_CAPTURE_TYPE_STANDARD = 0 ;
public static final short SCENE_TYPE_DIRECTLY_PHOTOGRAPHED = 1 ;
public static final short SENSITIVITY_TYPE_ISO_SPEED = 3 ;
public static final short SENSITIVITY_TYPE_REI = 2 ;
public static final short SENSITIVITY_TYPE_REI_AND_ISO = 6 ;
public static final short SENSITIVITY_TYPE_SOS = 1 ;
public static final short SENSITIVITY_TYPE_SOS_AND_ISO = 5 ;
public static final short SENSITIVITY_TYPE_SOS_AND_REI = 4 ;
public static final short SENSITIVITY_TYPE_SOS_AND_REI_AND_ISO = 7 ;
public static final short SENSITIVITY_TYPE_UNKNOWN = 0 ;
public static final short SENSOR_TYPE_COLOR_SEQUENTIAL = 5 ;
public static final short SENSOR_TYPE_COLOR_SEQUENTIAL_LINEAR = 8 ;
public static final short SENSOR_TYPE_NOT_DEFINED = 1 ;
public static final short SENSOR_TYPE_ONE_CHIP = 2 ;
public static final short SENSOR_TYPE_THREE_CHIP = 4 ;
public static final short SENSOR_TYPE_TRILINEAR = 7 ;
public static final short SENSOR_TYPE_TWO_CHIP = 3 ;
public static final short SHARPNESS_HARD = 2 ;
public static final short SHARPNESS_NORMAL = 0 ;
public static final short SHARPNESS_SOFT = 1 ;
private static final int SIGNATURE_CHECK_SIZE = 5000 ;
2022-01-13 08:07:50 +00:00
private static final int SKIP_BUFFER_SIZE = 8192 ;
2021-07-24 02:37:17 +00:00
public static final int STREAM_TYPE_EXIF_DATA_ONLY = 1 ;
public static final int STREAM_TYPE_FULL_IMAGE_DATA = 0 ;
public static final short SUBJECT_DISTANCE_RANGE_CLOSE_VIEW = 2 ;
public static final short SUBJECT_DISTANCE_RANGE_DISTANT_VIEW = 3 ;
public static final short SUBJECT_DISTANCE_RANGE_MACRO = 1 ;
public static final short SUBJECT_DISTANCE_RANGE_UNKNOWN = 0 ;
public static final String TAG_APERTURE_VALUE = " ApertureValue " ;
public static final String TAG_ARTIST = " Artist " ;
public static final String TAG_BITS_PER_SAMPLE = " BitsPerSample " ;
public static final String TAG_BODY_SERIAL_NUMBER = " BodySerialNumber " ;
public static final String TAG_BRIGHTNESS_VALUE = " BrightnessValue " ;
@Deprecated
public static final String TAG_CAMARA_OWNER_NAME = " CameraOwnerName " ;
public static final String TAG_CAMERA_OWNER_NAME = " CameraOwnerName " ;
public static final String TAG_CFA_PATTERN = " CFAPattern " ;
public static final String TAG_COLOR_SPACE = " ColorSpace " ;
public static final String TAG_COMPONENTS_CONFIGURATION = " ComponentsConfiguration " ;
public static final String TAG_COMPRESSED_BITS_PER_PIXEL = " CompressedBitsPerPixel " ;
public static final String TAG_COMPRESSION = " Compression " ;
public static final String TAG_CONTRAST = " Contrast " ;
public static final String TAG_COPYRIGHT = " Copyright " ;
public static final String TAG_CUSTOM_RENDERED = " CustomRendered " ;
public static final String TAG_DATETIME = " DateTime " ;
public static final String TAG_DATETIME_DIGITIZED = " DateTimeDigitized " ;
public static final String TAG_DATETIME_ORIGINAL = " DateTimeOriginal " ;
public static final String TAG_DEFAULT_CROP_SIZE = " DefaultCropSize " ;
public static final String TAG_DEVICE_SETTING_DESCRIPTION = " DeviceSettingDescription " ;
public static final String TAG_DNG_VERSION = " DNGVersion " ;
public static final String TAG_EXIF_VERSION = " ExifVersion " ;
public static final String TAG_EXPOSURE_BIAS_VALUE = " ExposureBiasValue " ;
public static final String TAG_EXPOSURE_INDEX = " ExposureIndex " ;
public static final String TAG_EXPOSURE_MODE = " ExposureMode " ;
public static final String TAG_EXPOSURE_PROGRAM = " ExposureProgram " ;
public static final String TAG_FILE_SOURCE = " FileSource " ;
public static final String TAG_FLASH = " Flash " ;
public static final String TAG_FLASHPIX_VERSION = " FlashpixVersion " ;
public static final String TAG_FLASH_ENERGY = " FlashEnergy " ;
public static final String TAG_FOCAL_LENGTH = " FocalLength " ;
public static final String TAG_FOCAL_LENGTH_IN_35MM_FILM = " FocalLengthIn35mmFilm " ;
public static final String TAG_FOCAL_PLANE_RESOLUTION_UNIT = " FocalPlaneResolutionUnit " ;
public static final String TAG_FOCAL_PLANE_X_RESOLUTION = " FocalPlaneXResolution " ;
public static final String TAG_FOCAL_PLANE_Y_RESOLUTION = " FocalPlaneYResolution " ;
public static final String TAG_GAIN_CONTROL = " GainControl " ;
public static final String TAG_GAMMA = " Gamma " ;
public static final String TAG_GPS_ALTITUDE = " GPSAltitude " ;
public static final String TAG_GPS_ALTITUDE_REF = " GPSAltitudeRef " ;
public static final String TAG_GPS_AREA_INFORMATION = " GPSAreaInformation " ;
public static final String TAG_GPS_DATESTAMP = " GPSDateStamp " ;
public static final String TAG_GPS_DEST_BEARING = " GPSDestBearing " ;
public static final String TAG_GPS_DEST_BEARING_REF = " GPSDestBearingRef " ;
public static final String TAG_GPS_DEST_DISTANCE = " GPSDestDistance " ;
public static final String TAG_GPS_DEST_DISTANCE_REF = " GPSDestDistanceRef " ;
public static final String TAG_GPS_DEST_LATITUDE = " GPSDestLatitude " ;
public static final String TAG_GPS_DEST_LATITUDE_REF = " GPSDestLatitudeRef " ;
public static final String TAG_GPS_DEST_LONGITUDE = " GPSDestLongitude " ;
public static final String TAG_GPS_DEST_LONGITUDE_REF = " GPSDestLongitudeRef " ;
public static final String TAG_GPS_DIFFERENTIAL = " GPSDifferential " ;
public static final String TAG_GPS_DOP = " GPSDOP " ;
public static final String TAG_GPS_H_POSITIONING_ERROR = " GPSHPositioningError " ;
public static final String TAG_GPS_IMG_DIRECTION = " GPSImgDirection " ;
public static final String TAG_GPS_IMG_DIRECTION_REF = " GPSImgDirectionRef " ;
public static final String TAG_GPS_LATITUDE = " GPSLatitude " ;
public static final String TAG_GPS_LATITUDE_REF = " GPSLatitudeRef " ;
public static final String TAG_GPS_LONGITUDE = " GPSLongitude " ;
public static final String TAG_GPS_LONGITUDE_REF = " GPSLongitudeRef " ;
public static final String TAG_GPS_MAP_DATUM = " GPSMapDatum " ;
public static final String TAG_GPS_MEASURE_MODE = " GPSMeasureMode " ;
public static final String TAG_GPS_PROCESSING_METHOD = " GPSProcessingMethod " ;
public static final String TAG_GPS_SATELLITES = " GPSSatellites " ;
public static final String TAG_GPS_SPEED = " GPSSpeed " ;
public static final String TAG_GPS_SPEED_REF = " GPSSpeedRef " ;
public static final String TAG_GPS_STATUS = " GPSStatus " ;
public static final String TAG_GPS_TRACK = " GPSTrack " ;
public static final String TAG_GPS_TRACK_REF = " GPSTrackRef " ;
public static final String TAG_GPS_VERSION_ID = " GPSVersionID " ;
public static final String TAG_IMAGE_DESCRIPTION = " ImageDescription " ;
public static final String TAG_IMAGE_LENGTH = " ImageLength " ;
public static final String TAG_IMAGE_UNIQUE_ID = " ImageUniqueID " ;
public static final String TAG_IMAGE_WIDTH = " ImageWidth " ;
public static final String TAG_INTEROPERABILITY_INDEX = " InteroperabilityIndex " ;
public static final String TAG_ISO_SPEED = " ISOSpeed " ;
public static final String TAG_ISO_SPEED_LATITUDE_YYY = " ISOSpeedLatitudeyyy " ;
public static final String TAG_ISO_SPEED_LATITUDE_ZZZ = " ISOSpeedLatitudezzz " ;
@Deprecated
public static final String TAG_ISO_SPEED_RATINGS = " ISOSpeedRatings " ;
public static final String TAG_JPEG_INTERCHANGE_FORMAT = " JPEGInterchangeFormat " ;
public static final String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = " JPEGInterchangeFormatLength " ;
public static final String TAG_LENS_MAKE = " LensMake " ;
public static final String TAG_LENS_MODEL = " LensModel " ;
public static final String TAG_LENS_SERIAL_NUMBER = " LensSerialNumber " ;
public static final String TAG_LENS_SPECIFICATION = " LensSpecification " ;
public static final String TAG_LIGHT_SOURCE = " LightSource " ;
public static final String TAG_MAKE = " Make " ;
public static final String TAG_MAKER_NOTE = " MakerNote " ;
public static final String TAG_MAX_APERTURE_VALUE = " MaxApertureValue " ;
public static final String TAG_METERING_MODE = " MeteringMode " ;
public static final String TAG_MODEL = " Model " ;
public static final String TAG_NEW_SUBFILE_TYPE = " NewSubfileType " ;
public static final String TAG_OECF = " OECF " ;
public static final String TAG_OFFSET_TIME = " OffsetTime " ;
public static final String TAG_OFFSET_TIME_DIGITIZED = " OffsetTimeDigitized " ;
public static final String TAG_OFFSET_TIME_ORIGINAL = " OffsetTimeOriginal " ;
public static final String TAG_ORF_ASPECT_FRAME = " AspectFrame " ;
public static final String TAG_ORF_PREVIEW_IMAGE_LENGTH = " PreviewImageLength " ;
public static final String TAG_ORF_PREVIEW_IMAGE_START = " PreviewImageStart " ;
public static final String TAG_ORF_THUMBNAIL_IMAGE = " ThumbnailImage " ;
public static final String TAG_ORIENTATION = " Orientation " ;
public static final String TAG_PHOTOGRAPHIC_SENSITIVITY = " PhotographicSensitivity " ;
public static final String TAG_PHOTOMETRIC_INTERPRETATION = " PhotometricInterpretation " ;
public static final String TAG_PIXEL_X_DIMENSION = " PixelXDimension " ;
public static final String TAG_PIXEL_Y_DIMENSION = " PixelYDimension " ;
public static final String TAG_PLANAR_CONFIGURATION = " PlanarConfiguration " ;
public static final String TAG_PRIMARY_CHROMATICITIES = " PrimaryChromaticities " ;
public static final String TAG_RECOMMENDED_EXPOSURE_INDEX = " RecommendedExposureIndex " ;
public static final String TAG_REFERENCE_BLACK_WHITE = " ReferenceBlackWhite " ;
public static final String TAG_RELATED_SOUND_FILE = " RelatedSoundFile " ;
public static final String TAG_RESOLUTION_UNIT = " ResolutionUnit " ;
public static final String TAG_ROWS_PER_STRIP = " RowsPerStrip " ;
public static final String TAG_RW2_ISO = " ISO " ;
public static final String TAG_RW2_JPG_FROM_RAW = " JpgFromRaw " ;
public static final String TAG_RW2_SENSOR_BOTTOM_BORDER = " SensorBottomBorder " ;
public static final String TAG_RW2_SENSOR_LEFT_BORDER = " SensorLeftBorder " ;
public static final String TAG_RW2_SENSOR_RIGHT_BORDER = " SensorRightBorder " ;
public static final String TAG_RW2_SENSOR_TOP_BORDER = " SensorTopBorder " ;
public static final String TAG_SAMPLES_PER_PIXEL = " SamplesPerPixel " ;
public static final String TAG_SATURATION = " Saturation " ;
public static final String TAG_SCENE_CAPTURE_TYPE = " SceneCaptureType " ;
public static final String TAG_SCENE_TYPE = " SceneType " ;
public static final String TAG_SENSING_METHOD = " SensingMethod " ;
public static final String TAG_SENSITIVITY_TYPE = " SensitivityType " ;
public static final String TAG_SHARPNESS = " Sharpness " ;
public static final String TAG_SHUTTER_SPEED_VALUE = " ShutterSpeedValue " ;
public static final String TAG_SOFTWARE = " Software " ;
public static final String TAG_SPATIAL_FREQUENCY_RESPONSE = " SpatialFrequencyResponse " ;
public static final String TAG_SPECTRAL_SENSITIVITY = " SpectralSensitivity " ;
public static final String TAG_STANDARD_OUTPUT_SENSITIVITY = " StandardOutputSensitivity " ;
public static final String TAG_STRIP_BYTE_COUNTS = " StripByteCounts " ;
public static final String TAG_SUBFILE_TYPE = " SubfileType " ;
public static final String TAG_SUBJECT_AREA = " SubjectArea " ;
public static final String TAG_SUBJECT_DISTANCE_RANGE = " SubjectDistanceRange " ;
public static final String TAG_SUBJECT_LOCATION = " SubjectLocation " ;
public static final String TAG_SUBSEC_TIME = " SubSecTime " ;
public static final String TAG_SUBSEC_TIME_DIGITIZED = " SubSecTimeDigitized " ;
public static final String TAG_SUBSEC_TIME_ORIGINAL = " SubSecTimeOriginal " ;
public static final String TAG_THUMBNAIL_IMAGE_LENGTH = " ThumbnailImageLength " ;
public static final String TAG_THUMBNAIL_IMAGE_WIDTH = " ThumbnailImageWidth " ;
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public static final String TAG_THUMBNAIL_ORIENTATION = " ThumbnailOrientation " ;
public static final String TAG_TRANSFER_FUNCTION = " TransferFunction " ;
public static final String TAG_USER_COMMENT = " UserComment " ;
public static final String TAG_WHITE_BALANCE = " WhiteBalance " ;
public static final String TAG_WHITE_POINT = " WhitePoint " ;
public static final String TAG_XMP = " Xmp " ;
public static final String TAG_X_RESOLUTION = " XResolution " ;
public static final String TAG_Y_CB_CR_COEFFICIENTS = " YCbCrCoefficients " ;
public static final String TAG_Y_CB_CR_POSITIONING = " YCbCrPositioning " ;
public static final String TAG_Y_CB_CR_SUB_SAMPLING = " YCbCrSubSampling " ;
public static final String TAG_Y_RESOLUTION = " YResolution " ;
private static final int WEBP_CHUNK_SIZE_BYTE_LENGTH = 4 ;
private static final int WEBP_CHUNK_TYPE_BYTE_LENGTH = 4 ;
private static final int WEBP_CHUNK_TYPE_VP8X_DEFAULT_LENGTH = 10 ;
private static final int WEBP_FILE_SIZE_BYTE_LENGTH = 4 ;
private static final byte WEBP_VP8L_SIGNATURE = 47 ;
@Deprecated
public static final int WHITEBALANCE_AUTO = 0 ;
@Deprecated
public static final int WHITEBALANCE_MANUAL = 1 ;
public static final short WHITE_BALANCE_AUTO = 0 ;
public static final short WHITE_BALANCE_MANUAL = 1 ;
public static final short Y_CB_CR_POSITIONING_CENTERED = 1 ;
public static final short Y_CB_CR_POSITIONING_CO_SITED = 2 ;
private static final HashMap < Integer , ExifTag > [ ] sExifTagMapsForReading ;
private static final HashMap < String , ExifTag > [ ] sExifTagMapsForWriting ;
private static SimpleDateFormat sFormatterPrimary ;
private static SimpleDateFormat sFormatterSecondary ;
private boolean mAreThumbnailStripsConsecutive ;
private AssetManager . AssetInputStream mAssetInputStream ;
private final HashMap < String , ExifAttribute > [ ] mAttributes ;
private Set < Integer > mAttributesOffsets ;
private ByteOrder mExifByteOrder ;
private String mFilename ;
private boolean mHasThumbnail ;
private boolean mHasThumbnailStrips ;
private boolean mIsExifDataOnly ;
private int mMimeType ;
private boolean mModified ;
private int mOffsetToExifData ;
private int mOrfMakerNoteOffset ;
private int mOrfThumbnailLength ;
private int mOrfThumbnailOffset ;
private FileDescriptor mSeekableFileDescriptor ;
private byte [ ] mThumbnailBytes ;
private int mThumbnailCompression ;
private int mThumbnailLength ;
private int mThumbnailOffset ;
private boolean mXmpIsFromSeparateMarker ;
2022-03-07 09:34:54 +00:00
private static final String TAG = " ExifInterface " ;
private static final boolean DEBUG = Log . isLoggable ( TAG , 3 ) ;
private static final List < Integer > ROTATION_ORDER = Arrays . asList ( 1 , 6 , 3 , 8 ) ;
private static final List < Integer > FLIPPED_ROTATION_ORDER = Arrays . asList ( 2 , 7 , 4 , 5 ) ;
public static final int [ ] BITS_PER_SAMPLE_RGB = { 8 , 8 , 8 } ;
public static final int [ ] BITS_PER_SAMPLE_GREYSCALE_1 = { 4 } ;
public static final int [ ] BITS_PER_SAMPLE_GREYSCALE_2 = { 8 } ;
private static final byte MARKER_SOI = - 40 ;
public static final byte [ ] JPEG_SIGNATURE = { - 1 , MARKER_SOI , - 1 } ;
private static final byte [ ] HEIF_TYPE_FTYP = { 102 , 116 , 121 , 112 } ;
private static final byte [ ] HEIF_BRAND_MIF1 = { 109 , 105 , 102 , 49 } ;
private static final byte [ ] HEIF_BRAND_HEIC = { 104 , 101 , 105 , 99 } ;
private static final byte [ ] ORF_MAKER_NOTE_HEADER_1 = { 79 , 76 , 89 , 77 , 80 , 0 } ;
private static final byte [ ] ORF_MAKER_NOTE_HEADER_2 = { 79 , 76 , 89 , 77 , 80 , 85 , 83 , 0 , 73 , 73 } ;
private static final byte [ ] PNG_SIGNATURE = { - 119 , 80 , 78 , 71 , 13 , 10 , 26 , 10 } ;
private static final byte [ ] PNG_CHUNK_TYPE_EXIF = { 101 , 88 , 73 , 102 } ;
private static final byte [ ] PNG_CHUNK_TYPE_IHDR = { 73 , 72 , 68 , 82 } ;
private static final byte [ ] PNG_CHUNK_TYPE_IEND = { 73 , 69 , 78 , 68 } ;
private static final byte [ ] WEBP_SIGNATURE_1 = { 82 , 73 , 70 , 70 } ;
private static final byte [ ] WEBP_SIGNATURE_2 = { 87 , 69 , 66 , 80 } ;
private static final byte [ ] WEBP_CHUNK_TYPE_EXIF = { 69 , 88 , 73 , 70 } ;
public static final byte START_CODE = 42 ;
private static final byte [ ] WEBP_VP8_SIGNATURE = { - 99 , 1 , START_CODE } ;
private static final byte [ ] WEBP_CHUNK_TYPE_VP8X = " VP8X " . getBytes ( Charset . defaultCharset ( ) ) ;
private static final byte [ ] WEBP_CHUNK_TYPE_VP8L = " VP8L " . getBytes ( Charset . defaultCharset ( ) ) ;
private static final byte [ ] WEBP_CHUNK_TYPE_VP8 = " VP8 " . getBytes ( Charset . defaultCharset ( ) ) ;
private static final byte [ ] WEBP_CHUNK_TYPE_ANIM = " ANIM " . getBytes ( Charset . defaultCharset ( ) ) ;
private static final byte [ ] WEBP_CHUNK_TYPE_ANMF = " ANMF " . getBytes ( Charset . defaultCharset ( ) ) ;
public static final String [ ] IFD_FORMAT_NAMES = { " " , " BYTE " , " STRING " , " USHORT " , " ULONG " , " URATIONAL " , " SBYTE " , " UNDEFINED " , " SSHORT " , " SLONG " , " SRATIONAL " , " SINGLE " , " DOUBLE " , " IFD " } ;
public static final int [ ] IFD_FORMAT_BYTES_PER_FORMAT = { 0 , 1 , 1 , 2 , 4 , 8 , 1 , 1 , 2 , 4 , 8 , 4 , 8 , 1 } ;
public static final byte [ ] EXIF_ASCII_PREFIX = { 65 , 83 , 67 , 73 , 73 , 0 , 0 , 0 } ;
public static final String TAG_STRIP_OFFSETS = " StripOffsets " ;
private static final ExifTag TAG_RAF_IMAGE_SIZE = new ExifTag ( TAG_STRIP_OFFSETS , AudioAttributesCompat . FLAG_ALL_PUBLIC , 3 ) ;
private static final String TAG_SUB_IFD_POINTER = " SubIFDPointer " ;
private static final String TAG_EXIF_IFD_POINTER = " ExifIFDPointer " ;
private static final String TAG_GPS_INFO_IFD_POINTER = " GPSInfoIFDPointer " ;
private static final String TAG_INTEROPERABILITY_IFD_POINTER = " InteroperabilityIFDPointer " ;
private static final String TAG_ORF_CAMERA_SETTINGS_IFD_POINTER = " CameraSettingsIFDPointer " ;
private static final String TAG_ORF_IMAGE_PROCESSING_IFD_POINTER = " ImageProcessingIFDPointer " ;
private static final ExifTag [ ] EXIF_POINTER_TAGS = { new ExifTag ( TAG_SUB_IFD_POINTER , 330 , 4 ) , new ExifTag ( TAG_EXIF_IFD_POINTER , 34665 , 4 ) , new ExifTag ( TAG_GPS_INFO_IFD_POINTER , 34853 , 4 ) , new ExifTag ( TAG_INTEROPERABILITY_IFD_POINTER , 40965 , 4 ) , new ExifTag ( TAG_ORF_CAMERA_SETTINGS_IFD_POINTER , 8224 , 1 ) , new ExifTag ( TAG_ORF_IMAGE_PROCESSING_IFD_POINTER , 8256 , 1 ) } ;
public static final String TAG_F_NUMBER = " FNumber " ;
public static final String TAG_DIGITAL_ZOOM_RATIO = " DigitalZoomRatio " ;
public static final String TAG_EXPOSURE_TIME = " ExposureTime " ;
public static final String TAG_SUBJECT_DISTANCE = " SubjectDistance " ;
public static final String TAG_GPS_TIMESTAMP = " GPSTimeStamp " ;
private static final HashSet < String > sTagSetForCompatibility = new HashSet < > ( Arrays . asList ( TAG_F_NUMBER , TAG_DIGITAL_ZOOM_RATIO , TAG_EXPOSURE_TIME , TAG_SUBJECT_DISTANCE , TAG_GPS_TIMESTAMP ) ) ;
private static final HashMap < Integer , Integer > sExifPointerTagMap = new HashMap < > ( ) ;
2021-07-24 02:37:17 +00:00
/* renamed from: androidx.exifinterface.media.ExifInterface$1 reason: invalid class name */
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public class AnonymousClass1 extends MediaDataSource {
public long mPosition ;
2022-01-13 08:07:50 +00:00
public final /* synthetic */ SeekableByteOrderedDataInputStream val$in ;
2021-07-24 02:37:17 +00:00
2022-01-13 08:07:50 +00:00
public AnonymousClass1 ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) {
this . val$in = seekableByteOrderedDataInputStream ;
2021-07-24 02:37:17 +00:00
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public void close ( ) throws IOException {
}
@Override // android.media.MediaDataSource
public long getSize ( ) throws IOException {
2022-03-07 09:34:54 +00:00
return - 1L ;
2021-07-24 02:37:17 +00:00
}
@Override // android.media.MediaDataSource
public int readAt ( long j , byte [ ] bArr , int i , int i2 ) throws IOException {
if ( i2 = = 0 ) {
return 0 ;
}
if ( j < 0 ) {
return - 1 ;
}
try {
long j2 = this . mPosition ;
if ( j2 ! = j ) {
2022-03-07 09:34:54 +00:00
if ( j2 > = 0 & & j > = j2 + this . val$in . available ( ) ) {
2021-07-24 02:37:17 +00:00
return - 1 ;
}
this . val$in . seek ( j ) ;
this . mPosition = j ;
}
if ( i2 > this . val$in . available ( ) ) {
i2 = this . val$in . available ( ) ;
}
int read = this . val$in . read ( bArr , i , i2 ) ;
if ( read > = 0 ) {
2022-03-07 09:34:54 +00:00
this . mPosition + = read ;
2021-07-24 02:37:17 +00:00
return read ;
}
} catch ( IOException unused ) {
}
2022-03-07 09:34:54 +00:00
this . mPosition = - 1L ;
2021-07-24 02:37:17 +00:00
return - 1 ;
}
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public static class ByteOrderedDataInputStream extends InputStream implements DataInput {
private ByteOrder mByteOrder ;
2022-01-13 08:07:50 +00:00
public final DataInputStream mDataInputStream ;
2021-07-24 02:37:17 +00:00
public int mPosition ;
2022-01-13 08:07:50 +00:00
private byte [ ] mSkipBuffer ;
2022-03-07 09:34:54 +00:00
private static final ByteOrder LITTLE_ENDIAN = ByteOrder . LITTLE_ENDIAN ;
private static final ByteOrder BIG_ENDIAN = ByteOrder . BIG_ENDIAN ;
2021-07-24 02:37:17 +00:00
public ByteOrderedDataInputStream ( InputStream inputStream ) throws IOException {
this ( inputStream , ByteOrder . BIG_ENDIAN ) ;
}
public ByteOrderedDataInputStream ( InputStream inputStream , ByteOrder byteOrder ) throws IOException {
this . mByteOrder = ByteOrder . BIG_ENDIAN ;
DataInputStream dataInputStream = new DataInputStream ( inputStream ) ;
this . mDataInputStream = dataInputStream ;
2022-01-13 08:07:50 +00:00
dataInputStream . mark ( 0 ) ;
2021-07-24 02:37:17 +00:00
this . mPosition = 0 ;
this . mByteOrder = byteOrder ;
}
public ByteOrderedDataInputStream ( byte [ ] bArr ) throws IOException {
2022-01-13 08:07:50 +00:00
this ( new ByteArrayInputStream ( bArr ) , ByteOrder . BIG_ENDIAN ) ;
2021-07-24 02:37:17 +00:00
}
@Override // java.io.InputStream
public int available ( ) throws IOException {
return this . mDataInputStream . available ( ) ;
}
@Override // java.io.InputStream
2022-01-13 08:07:50 +00:00
public void mark ( int i ) {
throw new UnsupportedOperationException ( " Mark is currently unsupported " ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
public int position ( ) {
2021-07-24 02:37:17 +00:00
return this . mPosition ;
}
@Override // java.io.InputStream
public int read ( ) throws IOException {
this . mPosition + + ;
return this . mDataInputStream . read ( ) ;
}
@Override // java.io.InputStream
public int read ( byte [ ] bArr , int i , int i2 ) throws IOException {
int read = this . mDataInputStream . read ( bArr , i , i2 ) ;
this . mPosition + = read ;
return read ;
}
@Override // java.io.DataInput
public boolean readBoolean ( ) throws IOException {
this . mPosition + + ;
return this . mDataInputStream . readBoolean ( ) ;
}
@Override // java.io.DataInput
public byte readByte ( ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + + ;
int read = this . mDataInputStream . read ( ) ;
if ( read > = 0 ) {
return ( byte ) read ;
2021-07-24 02:37:17 +00:00
}
throw new EOFException ( ) ;
}
@Override // java.io.DataInput
public char readChar ( ) throws IOException {
this . mPosition + = 2 ;
return this . mDataInputStream . readChar ( ) ;
}
@Override // java.io.DataInput
public double readDouble ( ) throws IOException {
return Double . longBitsToDouble ( readLong ( ) ) ;
}
@Override // java.io.DataInput
public float readFloat ( ) throws IOException {
return Float . intBitsToFloat ( readInt ( ) ) ;
}
@Override // java.io.DataInput
public void readFully ( byte [ ] bArr ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = bArr . length ;
this . mDataInputStream . readFully ( bArr ) ;
2021-07-24 02:37:17 +00:00
}
@Override // java.io.DataInput
public void readFully ( byte [ ] bArr , int i , int i2 ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = i2 ;
this . mDataInputStream . readFully ( bArr , i , i2 ) ;
2021-07-24 02:37:17 +00:00
}
@Override // java.io.DataInput
public int readInt ( ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = 4 ;
int read = this . mDataInputStream . read ( ) ;
int read2 = this . mDataInputStream . read ( ) ;
int read3 = this . mDataInputStream . read ( ) ;
int read4 = this . mDataInputStream . read ( ) ;
if ( ( read | read2 | read3 | read4 ) > = 0 ) {
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = LITTLE_ENDIAN ) {
return ( read4 < < 24 ) + ( read3 < < 16 ) + ( read2 < < 8 ) + read ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
if ( byteOrder = = BIG_ENDIAN ) {
return ( read < < 24 ) + ( read2 < < 16 ) + ( read3 < < 8 ) + read4 ;
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid byte order: " ) ;
R . append ( this . mByteOrder ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
throw new EOFException ( ) ;
}
@Override // java.io.DataInput
public String readLine ( ) throws IOException {
2021-08-09 22:51:56 +00:00
Log . d ( ExifInterface . TAG , " Currently unsupported " ) ;
2021-07-24 02:37:17 +00:00
return null ;
}
@Override // java.io.DataInput
public long readLong ( ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = 8 ;
int read = this . mDataInputStream . read ( ) ;
int read2 = this . mDataInputStream . read ( ) ;
int read3 = this . mDataInputStream . read ( ) ;
int read4 = this . mDataInputStream . read ( ) ;
int read5 = this . mDataInputStream . read ( ) ;
int read6 = this . mDataInputStream . read ( ) ;
int read7 = this . mDataInputStream . read ( ) ;
int read8 = this . mDataInputStream . read ( ) ;
if ( ( read | read2 | read3 | read4 | read5 | read6 | read7 | read8 ) > = 0 ) {
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = LITTLE_ENDIAN ) {
2022-03-07 09:34:54 +00:00
return ( read8 < < 56 ) + ( read7 < < 48 ) + ( read6 < < 40 ) + ( read5 < < 32 ) + ( read4 < < 24 ) + ( read3 < < 16 ) + ( read2 < < 8 ) + read ;
2022-01-13 08:07:50 +00:00
}
if ( byteOrder = = BIG_ENDIAN ) {
2022-03-07 09:34:54 +00:00
return ( read < < 56 ) + ( read2 < < 48 ) + ( read3 < < 40 ) + ( read4 < < 32 ) + ( read5 < < 24 ) + ( read6 < < 16 ) + ( read7 < < 8 ) + read8 ;
2021-07-24 02:37:17 +00:00
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid byte order: " ) ;
R . append ( this . mByteOrder ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
throw new EOFException ( ) ;
}
@Override // java.io.DataInput
public short readShort ( ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = 2 ;
int read = this . mDataInputStream . read ( ) ;
int read2 = this . mDataInputStream . read ( ) ;
if ( ( read | read2 ) > = 0 ) {
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = LITTLE_ENDIAN ) {
return ( short ) ( ( read2 < < 8 ) + read ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
if ( byteOrder = = BIG_ENDIAN ) {
return ( short ) ( ( read < < 8 ) + read2 ) ;
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid byte order: " ) ;
R . append ( this . mByteOrder ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
throw new EOFException ( ) ;
}
@Override // java.io.DataInput
public String readUTF ( ) throws IOException {
this . mPosition + = 2 ;
return this . mDataInputStream . readUTF ( ) ;
}
@Override // java.io.DataInput
public int readUnsignedByte ( ) throws IOException {
this . mPosition + + ;
return this . mDataInputStream . readUnsignedByte ( ) ;
}
public long readUnsignedInt ( ) throws IOException {
2022-03-07 09:34:54 +00:00
return readInt ( ) & 4294967295L ;
2021-07-24 02:37:17 +00:00
}
@Override // java.io.DataInput
public int readUnsignedShort ( ) throws IOException {
2022-01-13 08:07:50 +00:00
this . mPosition + = 2 ;
int read = this . mDataInputStream . read ( ) ;
int read2 = this . mDataInputStream . read ( ) ;
if ( ( read | read2 ) > = 0 ) {
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = LITTLE_ENDIAN ) {
return ( read2 < < 8 ) + read ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
if ( byteOrder = = BIG_ENDIAN ) {
return ( read < < 8 ) + read2 ;
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid byte order: " ) ;
R . append ( this . mByteOrder ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
throw new EOFException ( ) ;
}
2022-01-13 08:07:50 +00:00
@Override // java.io.InputStream
public void reset ( ) {
throw new UnsupportedOperationException ( " Reset is currently unsupported " ) ;
2021-07-24 02:37:17 +00:00
}
public void setByteOrder ( ByteOrder byteOrder ) {
this . mByteOrder = byteOrder ;
}
@Override // java.io.DataInput
public int skipBytes ( int i ) throws IOException {
2022-01-13 08:07:50 +00:00
throw new UnsupportedOperationException ( " skipBytes is currently unsupported " ) ;
}
public void skipFully ( int i ) throws IOException {
2021-07-24 02:37:17 +00:00
int i2 = 0 ;
2022-01-13 08:07:50 +00:00
while ( i2 < i ) {
int i3 = i - i2 ;
2022-03-07 09:34:54 +00:00
int skip = ( int ) this . mDataInputStream . skip ( i3 ) ;
2022-01-13 08:07:50 +00:00
if ( skip < = 0 ) {
if ( this . mSkipBuffer = = null ) {
this . mSkipBuffer = new byte [ 8192 ] ;
}
skip = this . mDataInputStream . read ( this . mSkipBuffer , 0 , Math . min ( 8192 , i3 ) ) ;
if ( skip = = - 1 ) {
throw new EOFException ( a . q ( " Reached EOF while skipping " , i , " bytes. " ) ) ;
}
}
i2 + = skip ;
2021-07-24 02:37:17 +00:00
}
this . mPosition + = i2 ;
}
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public static class ByteOrderedDataOutputStream extends FilterOutputStream {
private ByteOrder mByteOrder ;
public final OutputStream mOutputStream ;
public ByteOrderedDataOutputStream ( OutputStream outputStream , ByteOrder byteOrder ) {
super ( outputStream ) ;
this . mOutputStream = outputStream ;
this . mByteOrder = byteOrder ;
}
public void setByteOrder ( ByteOrder byteOrder ) {
this . mByteOrder = byteOrder ;
}
@Override // java.io.FilterOutputStream, java.io.OutputStream
public void write ( byte [ ] bArr ) throws IOException {
this . mOutputStream . write ( bArr ) ;
}
@Override // java.io.FilterOutputStream, java.io.OutputStream
public void write ( byte [ ] bArr , int i , int i2 ) throws IOException {
this . mOutputStream . write ( bArr , i , i2 ) ;
}
public void writeByte ( int i ) throws IOException {
this . mOutputStream . write ( i ) ;
}
public void writeInt ( int i ) throws IOException {
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = ByteOrder . LITTLE_ENDIAN ) {
this . mOutputStream . write ( ( i > > > 0 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 8 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 16 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 24 ) & 255 ) ;
} else if ( byteOrder = = ByteOrder . BIG_ENDIAN ) {
this . mOutputStream . write ( ( i > > > 24 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 16 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 8 ) & 255 ) ;
this . mOutputStream . write ( ( i > > > 0 ) & 255 ) ;
}
}
2021-11-02 06:38:17 +00:00
public void writeShort ( short s2 ) throws IOException {
2021-07-24 02:37:17 +00:00
ByteOrder byteOrder = this . mByteOrder ;
if ( byteOrder = = ByteOrder . LITTLE_ENDIAN ) {
2021-11-02 06:38:17 +00:00
this . mOutputStream . write ( ( s2 > > > 0 ) & 255 ) ;
this . mOutputStream . write ( ( s2 > > > 8 ) & 255 ) ;
2021-07-24 02:37:17 +00:00
} else if ( byteOrder = = ByteOrder . BIG_ENDIAN ) {
2021-11-02 06:38:17 +00:00
this . mOutputStream . write ( ( s2 > > > 8 ) & 255 ) ;
this . mOutputStream . write ( ( s2 > > > 0 ) & 255 ) ;
2021-07-24 02:37:17 +00:00
}
}
public void writeUnsignedInt ( long j ) throws IOException {
writeInt ( ( int ) j ) ;
}
public void writeUnsignedShort ( int i ) throws IOException {
writeShort ( ( short ) i ) ;
}
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public static class ExifAttribute {
public static final long BYTES_OFFSET_UNKNOWN = - 1 ;
public final byte [ ] bytes ;
public final long bytesOffset ;
public final int format ;
public final int numberOfComponents ;
public ExifAttribute ( int i , int i2 , long j , byte [ ] bArr ) {
this . format = i ;
this . numberOfComponents = i2 ;
this . bytesOffset = j ;
this . bytes = bArr ;
}
public ExifAttribute ( int i , int i2 , byte [ ] bArr ) {
2022-03-07 09:34:54 +00:00
this ( i , i2 , - 1L , bArr ) ;
2021-07-24 02:37:17 +00:00
}
public static ExifAttribute createByte ( String str ) {
if ( str . length ( ) = = 1 & & str . charAt ( 0 ) > = '0' & & str . charAt ( 0 ) < = '1' ) {
return new ExifAttribute ( 1 , 1 , new byte [ ] { ( byte ) ( str . charAt ( 0 ) - '0' ) } ) ;
}
byte [ ] bytes = str . getBytes ( ExifInterface . ASCII ) ;
return new ExifAttribute ( 1 , bytes . length , bytes ) ;
}
public static ExifAttribute createDouble ( double d , ByteOrder byteOrder ) {
return createDouble ( new double [ ] { d } , byteOrder ) ;
}
public static ExifAttribute createDouble ( double [ ] dArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 12 ] * dArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( double d : dArr ) {
wrap . putDouble ( d ) ;
}
return new ExifAttribute ( 12 , dArr . length , wrap . array ( ) ) ;
}
public static ExifAttribute createSLong ( int i , ByteOrder byteOrder ) {
return createSLong ( new int [ ] { i } , byteOrder ) ;
}
public static ExifAttribute createSLong ( int [ ] iArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 9 ] * iArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( int i : iArr ) {
wrap . putInt ( i ) ;
}
return new ExifAttribute ( 9 , iArr . length , wrap . array ( ) ) ;
}
public static ExifAttribute createSRational ( Rational rational , ByteOrder byteOrder ) {
return createSRational ( new Rational [ ] { rational } , byteOrder ) ;
}
public static ExifAttribute createSRational ( Rational [ ] rationalArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 10 ] * rationalArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( Rational rational : rationalArr ) {
wrap . putInt ( ( int ) rational . numerator ) ;
wrap . putInt ( ( int ) rational . denominator ) ;
}
return new ExifAttribute ( 10 , rationalArr . length , wrap . array ( ) ) ;
}
public static ExifAttribute createString ( String str ) {
byte [ ] bytes = ( str + ( char ) 0 ) . getBytes ( ExifInterface . ASCII ) ;
return new ExifAttribute ( 2 , bytes . length , bytes ) ;
}
public static ExifAttribute createULong ( long j , ByteOrder byteOrder ) {
return createULong ( new long [ ] { j } , byteOrder ) ;
}
public static ExifAttribute createULong ( long [ ] jArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 4 ] * jArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( long j : jArr ) {
wrap . putInt ( ( int ) j ) ;
}
return new ExifAttribute ( 4 , jArr . length , wrap . array ( ) ) ;
}
public static ExifAttribute createURational ( Rational rational , ByteOrder byteOrder ) {
return createURational ( new Rational [ ] { rational } , byteOrder ) ;
}
public static ExifAttribute createURational ( Rational [ ] rationalArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 5 ] * rationalArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( Rational rational : rationalArr ) {
wrap . putInt ( ( int ) rational . numerator ) ;
wrap . putInt ( ( int ) rational . denominator ) ;
}
return new ExifAttribute ( 5 , rationalArr . length , wrap . array ( ) ) ;
}
public static ExifAttribute createUShort ( int i , ByteOrder byteOrder ) {
return createUShort ( new int [ ] { i } , byteOrder ) ;
}
public static ExifAttribute createUShort ( int [ ] iArr , ByteOrder byteOrder ) {
2022-03-07 09:34:54 +00:00
ByteBuffer wrap = ByteBuffer . wrap ( new byte [ ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ 3 ] * iArr . length ] ) ;
2021-07-24 02:37:17 +00:00
wrap . order ( byteOrder ) ;
for ( int i : iArr ) {
wrap . putShort ( ( short ) i ) ;
}
return new ExifAttribute ( 3 , iArr . length , wrap . array ( ) ) ;
}
public double getDoubleValue ( ByteOrder byteOrder ) {
Object value = getValue ( byteOrder ) ;
if ( value = = null ) {
throw new NumberFormatException ( " NULL can't be converted to a double value " ) ;
} else if ( value instanceof String ) {
return Double . parseDouble ( ( String ) value ) ;
} else {
if ( value instanceof long [ ] ) {
long [ ] jArr = ( long [ ] ) value ;
if ( jArr . length = = 1 ) {
2022-03-07 09:34:54 +00:00
return jArr [ 0 ] ;
2021-07-24 02:37:17 +00:00
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else if ( value instanceof int [ ] ) {
int [ ] iArr = ( int [ ] ) value ;
if ( iArr . length = = 1 ) {
2022-03-07 09:34:54 +00:00
return iArr [ 0 ] ;
2021-07-24 02:37:17 +00:00
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else if ( value instanceof double [ ] ) {
double [ ] dArr = ( double [ ] ) value ;
if ( dArr . length = = 1 ) {
return dArr [ 0 ] ;
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else if ( value instanceof Rational [ ] ) {
Rational [ ] rationalArr = ( Rational [ ] ) value ;
if ( rationalArr . length = = 1 ) {
return rationalArr [ 0 ] . calculate ( ) ;
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else {
throw new NumberFormatException ( " Couldn't find a double value " ) ;
}
}
}
public int getIntValue ( ByteOrder byteOrder ) {
Object value = getValue ( byteOrder ) ;
if ( value = = null ) {
throw new NumberFormatException ( " NULL can't be converted to a integer value " ) ;
} else if ( value instanceof String ) {
return Integer . parseInt ( ( String ) value ) ;
} else {
if ( value instanceof long [ ] ) {
long [ ] jArr = ( long [ ] ) value ;
if ( jArr . length = = 1 ) {
return ( int ) jArr [ 0 ] ;
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else if ( value instanceof int [ ] ) {
int [ ] iArr = ( int [ ] ) value ;
if ( iArr . length = = 1 ) {
return iArr [ 0 ] ;
}
throw new NumberFormatException ( " There are more than one component " ) ;
} else {
throw new NumberFormatException ( " Couldn't find a integer value " ) ;
}
}
}
public String getStringValue ( ByteOrder byteOrder ) {
Object value = getValue ( byteOrder ) ;
if ( value = = null ) {
return null ;
}
if ( value instanceof String ) {
return ( String ) value ;
}
StringBuilder sb = new StringBuilder ( ) ;
int i = 0 ;
if ( value instanceof long [ ] ) {
long [ ] jArr = ( long [ ] ) value ;
while ( i < jArr . length ) {
sb . append ( jArr [ i ] ) ;
i + + ;
if ( i ! = jArr . length ) {
sb . append ( " , " ) ;
}
}
return sb . toString ( ) ;
} else if ( value instanceof int [ ] ) {
int [ ] iArr = ( int [ ] ) value ;
while ( i < iArr . length ) {
sb . append ( iArr [ i ] ) ;
i + + ;
if ( i ! = iArr . length ) {
sb . append ( " , " ) ;
}
}
return sb . toString ( ) ;
} else if ( value instanceof double [ ] ) {
double [ ] dArr = ( double [ ] ) value ;
while ( i < dArr . length ) {
sb . append ( dArr [ i ] ) ;
i + + ;
if ( i ! = dArr . length ) {
sb . append ( " , " ) ;
}
}
return sb . toString ( ) ;
} else if ( ! ( value instanceof Rational [ ] ) ) {
return null ;
} else {
Rational [ ] rationalArr = ( Rational [ ] ) value ;
while ( i < rationalArr . length ) {
sb . append ( rationalArr [ i ] . numerator ) ;
2021-08-09 22:51:56 +00:00
sb . append ( MentionUtilsKt . SLASH_CHAR ) ;
2021-07-24 02:37:17 +00:00
sb . append ( rationalArr [ i ] . denominator ) ;
i + + ;
if ( i ! = rationalArr . length ) {
sb . append ( " , " ) ;
}
}
return sb . toString ( ) ;
}
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Not initialized variable reg: 3, insn: 0x01a0: MOVE (r2 I:??[OBJECT, ARRAY]) = (r3 I:??[OBJECT, ARRAY]), block:B:137:0x01a0 */
/* JADX WARN: Removed duplicated region for block: B:154:0x01a3 A[EXC_TOP_SPLITTER, SYNTHETIC] */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
public Object getValue ( ByteOrder byteOrder ) {
Throwable th ;
IOException e ;
ByteOrderedDataInputStream byteOrderedDataInputStream ;
2021-12-17 21:59:34 +00:00
byte b2 ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr ;
2022-03-07 09:34:54 +00:00
InputStream inputStream = null ;
2021-07-24 02:37:17 +00:00
try {
try {
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream = new ByteOrderedDataInputStream ( this . bytes ) ;
try {
byteOrderedDataInputStream . setByteOrder ( byteOrder ) ;
boolean z2 = true ;
int i = 0 ;
switch ( this . format ) {
case 1 :
case 6 :
byte [ ] bArr2 = this . bytes ;
if ( bArr2 . length ! = 1 | | bArr2 [ 0 ] < 0 | | bArr2 [ 0 ] > 1 ) {
String str = new String ( this . bytes , ExifInterface . ASCII ) ;
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e2 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e2 ) ;
}
return str ;
}
String str2 = new String ( new char [ ] { ( char ) ( this . bytes [ 0 ] + 48 ) } ) ;
2021-07-24 02:37:17 +00:00
try {
byteOrderedDataInputStream . close ( ) ;
2022-03-07 09:34:54 +00:00
} catch ( IOException e3 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e3 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
return str2 ;
case 2 :
case 7 :
if ( this . numberOfComponents > = ExifInterface . EXIF_ASCII_PREFIX . length ) {
int i2 = 0 ;
while ( true ) {
bArr = ExifInterface . EXIF_ASCII_PREFIX ;
if ( i2 < bArr . length ) {
if ( this . bytes [ i2 ] ! = bArr [ i2 ] ) {
z2 = false ;
} else {
i2 + + ;
}
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
if ( z2 ) {
i = bArr . length ;
}
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
StringBuilder sb = new StringBuilder ( ) ;
while ( i < this . numberOfComponents & & ( b2 = this . bytes [ i ] ) ! = 0 ) {
if ( b2 > = 32 ) {
sb . append ( ( char ) b2 ) ;
} else {
sb . append ( '?' ) ;
}
i + + ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
String sb2 = sb . toString ( ) ;
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e4 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e4 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
return sb2 ;
case 3 :
int [ ] iArr = new int [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
iArr [ i ] = byteOrderedDataInputStream . readUnsignedShort ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e5 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e5 ) ;
}
return iArr ;
case 4 :
long [ ] jArr = new long [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
jArr [ i ] = byteOrderedDataInputStream . readUnsignedInt ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e6 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e6 ) ;
}
return jArr ;
case 5 :
Rational [ ] rationalArr = new Rational [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
rationalArr [ i ] = new Rational ( byteOrderedDataInputStream . readUnsignedInt ( ) , byteOrderedDataInputStream . readUnsignedInt ( ) ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e7 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e7 ) ;
}
return rationalArr ;
case 8 :
int [ ] iArr2 = new int [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
iArr2 [ i ] = byteOrderedDataInputStream . readShort ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e8 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e8 ) ;
}
return iArr2 ;
case 9 :
int [ ] iArr3 = new int [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
iArr3 [ i ] = byteOrderedDataInputStream . readInt ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e9 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e9 ) ;
}
return iArr3 ;
case 10 :
Rational [ ] rationalArr2 = new Rational [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
rationalArr2 [ i ] = new Rational ( byteOrderedDataInputStream . readInt ( ) , byteOrderedDataInputStream . readInt ( ) ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e10 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e10 ) ;
}
return rationalArr2 ;
case 11 :
double [ ] dArr = new double [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
dArr [ i ] = byteOrderedDataInputStream . readFloat ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e11 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e11 ) ;
}
return dArr ;
case 12 :
double [ ] dArr2 = new double [ this . numberOfComponents ] ;
while ( i < this . numberOfComponents ) {
dArr2 [ i ] = byteOrderedDataInputStream . readDouble ( ) ;
i + + ;
}
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e12 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e12 ) ;
}
return dArr2 ;
default :
try {
byteOrderedDataInputStream . close ( ) ;
} catch ( IOException e13 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e13 ) ;
}
return null ;
}
} catch ( IOException e14 ) {
e = e14 ;
Log . w ( ExifInterface . TAG , " IOException occurred during reading a value " , e ) ;
if ( byteOrderedDataInputStream ! = null ) {
2021-07-24 02:37:17 +00:00
try {
byteOrderedDataInputStream . close ( ) ;
2022-03-07 09:34:54 +00:00
} catch ( IOException e15 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e15 ) ;
2021-07-24 02:37:17 +00:00
}
}
return null ;
2022-03-07 09:34:54 +00:00
}
} catch ( Throwable th2 ) {
th = th2 ;
if ( inputStream ! = null ) {
try {
inputStream . close ( ) ;
} catch ( IOException e16 ) {
Log . e ( ExifInterface . TAG , " IOException occurred while closing InputStream " , e16 ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
throw th ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} catch ( IOException e17 ) {
e = e17 ;
2021-07-24 02:37:17 +00:00
byteOrderedDataInputStream = null ;
} catch ( Throwable th3 ) {
th = th3 ;
2022-03-07 09:34:54 +00:00
if ( inputStream ! = null ) {
2021-07-24 02:37:17 +00:00
}
throw th ;
}
}
public int size ( ) {
return ExifInterface . IFD_FORMAT_BYTES_PER_FORMAT [ this . format ] * this . numberOfComponents ;
}
public String toString ( ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " ( " ) ;
R . append ( ExifInterface . IFD_FORMAT_NAMES [ this . format ] ) ;
R . append ( " , data length: " ) ;
return a . A ( R , this . bytes . length , " ) " ) ;
2021-07-24 02:37:17 +00:00
}
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public @interface ExifStreamType {
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public static class ExifTag {
public final String name ;
public final int number ;
public final int primaryFormat ;
public final int secondaryFormat ;
public ExifTag ( String str , int i , int i2 ) {
this . name = str ;
this . number = i ;
this . primaryFormat = i2 ;
this . secondaryFormat = - 1 ;
}
public ExifTag ( String str , int i , int i2 , int i3 ) {
this . name = str ;
this . number = i ;
this . primaryFormat = i2 ;
this . secondaryFormat = i3 ;
}
public boolean isFormatCompatible ( int i ) {
int i2 ;
int i3 = this . primaryFormat ;
if ( i3 = = 7 | | i = = 7 | | i3 = = i | | ( i2 = this . secondaryFormat ) = = i ) {
return true ;
}
if ( ( i3 = = 4 | | i2 = = 4 ) & & i = = 3 ) {
return true ;
}
if ( ( i3 = = 9 | | i2 = = 9 ) & & i = = 8 ) {
return true ;
}
return ( i3 = = 12 | | i2 = = 12 ) & & i = = 11 ;
}
}
@Retention ( RetentionPolicy . SOURCE )
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public @interface IfdType {
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2021-07-24 02:37:17 +00:00
public static class Rational {
public final long denominator ;
public final long numerator ;
public Rational ( double d ) {
2022-03-07 09:34:54 +00:00
this ( ( long ) ( d * 10000 . 0d ) , 10000L ) ;
2021-07-24 02:37:17 +00:00
}
public Rational ( long j , long j2 ) {
if ( j2 = = 0 ) {
2022-03-07 09:34:54 +00:00
this . numerator = 0L ;
this . denominator = 1L ;
2021-07-24 02:37:17 +00:00
return ;
}
this . numerator = j ;
this . denominator = j2 ;
}
public double calculate ( ) {
2022-03-07 09:34:54 +00:00
return this . numerator / this . denominator ;
2021-07-24 02:37:17 +00:00
}
public String toString ( ) {
2021-08-09 22:51:56 +00:00
return this . numerator + AutocompleteViewModel . COMMAND_DISCOVER_TOKEN + this . denominator ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
/* loaded from: classes.dex */
2022-01-13 08:07:50 +00:00
public static class SeekableByteOrderedDataInputStream extends ByteOrderedDataInputStream {
public SeekableByteOrderedDataInputStream ( InputStream inputStream ) throws IOException {
super ( inputStream ) ;
if ( inputStream . markSupported ( ) ) {
this . mDataInputStream . mark ( Integer . MAX_VALUE ) ;
return ;
}
throw new IllegalArgumentException ( " Cannot create SeekableByteOrderedDataInputStream with stream that does not support mark/reset " ) ;
}
public SeekableByteOrderedDataInputStream ( byte [ ] bArr ) throws IOException {
super ( bArr ) ;
this . mDataInputStream . mark ( Integer . MAX_VALUE ) ;
}
public void seek ( long j ) throws IOException {
int i = this . mPosition ;
2022-03-07 09:34:54 +00:00
if ( i > j ) {
2022-01-13 08:07:50 +00:00
this . mPosition = 0 ;
this . mDataInputStream . reset ( ) ;
} else {
2022-03-07 09:34:54 +00:00
j - = i ;
2022-01-13 08:07:50 +00:00
}
skipFully ( ( int ) j ) ;
}
}
2021-07-24 02:37:17 +00:00
static {
2022-03-07 09:34:54 +00:00
ExifTag [ ] exifTagArr ;
ExifTag [ ] exifTagArr2 = { new ExifTag ( TAG_NEW_SUBFILE_TYPE , 254 , 4 ) , new ExifTag ( TAG_SUBFILE_TYPE , 255 , 4 ) , new ExifTag ( TAG_IMAGE_WIDTH , 256 , 3 , 4 ) , new ExifTag ( TAG_IMAGE_LENGTH , 257 , 3 , 4 ) , new ExifTag ( TAG_BITS_PER_SAMPLE , 258 , 3 ) , new ExifTag ( TAG_COMPRESSION , 259 , 3 ) , new ExifTag ( TAG_PHOTOMETRIC_INTERPRETATION , 262 , 3 ) , new ExifTag ( TAG_IMAGE_DESCRIPTION , 270 , 2 ) , new ExifTag ( TAG_MAKE , 271 , 2 ) , new ExifTag ( TAG_MODEL , 272 , 2 ) , new ExifTag ( TAG_STRIP_OFFSETS , AudioAttributesCompat . FLAG_ALL_PUBLIC , 3 , 4 ) , new ExifTag ( TAG_ORIENTATION , 274 , 3 ) , new ExifTag ( TAG_SAMPLES_PER_PIXEL , 277 , 3 ) , new ExifTag ( TAG_ROWS_PER_STRIP , 278 , 3 , 4 ) , new ExifTag ( TAG_STRIP_BYTE_COUNTS , 279 , 3 , 4 ) , new ExifTag ( TAG_X_RESOLUTION , 282 , 5 ) , new ExifTag ( TAG_Y_RESOLUTION , 283 , 5 ) , new ExifTag ( TAG_PLANAR_CONFIGURATION , 284 , 3 ) , new ExifTag ( TAG_RESOLUTION_UNIT , 296 , 3 ) , new ExifTag ( TAG_TRANSFER_FUNCTION , 301 , 3 ) , new ExifTag ( TAG_SOFTWARE , 305 , 2 ) , new ExifTag ( TAG_DATETIME , 306 , 2 ) , new ExifTag ( TAG_ARTIST , 315 , 2 ) , new ExifTag ( TAG_WHITE_POINT , 318 , 5 ) , new ExifTag ( TAG_PRIMARY_CHROMATICITIES , 319 , 5 ) , new ExifTag ( TAG_SUB_IFD_POINTER , 330 , 4 ) , new ExifTag ( TAG_JPEG_INTERCHANGE_FORMAT , InputDeviceCompat . SOURCE_DPAD , 4 ) , new ExifTag ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH , 514 , 4 ) , new ExifTag ( TAG_Y_CB_CR_COEFFICIENTS , 529 , 5 ) , new ExifTag ( TAG_Y_CB_CR_SUB_SAMPLING , 530 , 3 ) , new ExifTag ( TAG_Y_CB_CR_POSITIONING , 531 , 3 ) , new ExifTag ( TAG_REFERENCE_BLACK_WHITE , 532 , 5 ) , new ExifTag ( TAG_COPYRIGHT , 33432 , 2 ) , new ExifTag ( TAG_EXIF_IFD_POINTER , 34665 , 4 ) , new ExifTag ( TAG_GPS_INFO_IFD_POINTER , 34853 , 4 ) , new ExifTag ( TAG_RW2_SENSOR_TOP_BORDER , 4 , 4 ) , new ExifTag ( TAG_RW2_SENSOR_LEFT_BORDER , 5 , 4 ) , new ExifTag ( TAG_RW2_SENSOR_BOTTOM_BORDER , 6 , 4 ) , new ExifTag ( TAG_RW2_SENSOR_RIGHT_BORDER , 7 , 4 ) , new ExifTag ( TAG_RW2_ISO , 23 , 3 ) , new ExifTag ( TAG_RW2_JPG_FROM_RAW , 46 , 7 ) , new ExifTag ( TAG_XMP , 700 , 1 ) } ;
IFD_TIFF_TAGS = exifTagArr2 ;
ExifTag [ ] exifTagArr3 = { new ExifTag ( TAG_EXPOSURE_TIME , 33434 , 5 ) , new ExifTag ( TAG_F_NUMBER , 33437 , 5 ) , new ExifTag ( TAG_EXPOSURE_PROGRAM , 34850 , 3 ) , new ExifTag ( TAG_SPECTRAL_SENSITIVITY , 34852 , 2 ) , new ExifTag ( TAG_PHOTOGRAPHIC_SENSITIVITY , 34855 , 3 ) , new ExifTag ( TAG_OECF , 34856 , 7 ) , new ExifTag ( TAG_SENSITIVITY_TYPE , 34864 , 3 ) , new ExifTag ( TAG_STANDARD_OUTPUT_SENSITIVITY , 34865 , 4 ) , new ExifTag ( TAG_RECOMMENDED_EXPOSURE_INDEX , 34866 , 4 ) , new ExifTag ( TAG_ISO_SPEED , 34867 , 4 ) , new ExifTag ( TAG_ISO_SPEED_LATITUDE_YYY , 34868 , 4 ) , new ExifTag ( TAG_ISO_SPEED_LATITUDE_ZZZ , 34869 , 4 ) , new ExifTag ( TAG_EXIF_VERSION , 36864 , 2 ) , new ExifTag ( TAG_DATETIME_ORIGINAL , 36867 , 2 ) , new ExifTag ( TAG_DATETIME_DIGITIZED , 36868 , 2 ) , new ExifTag ( TAG_OFFSET_TIME , 36880 , 2 ) , new ExifTag ( TAG_OFFSET_TIME_ORIGINAL , 36881 , 2 ) , new ExifTag ( TAG_OFFSET_TIME_DIGITIZED , 36882 , 2 ) , new ExifTag ( TAG_COMPONENTS_CONFIGURATION , 37121 , 7 ) , new ExifTag ( TAG_COMPRESSED_BITS_PER_PIXEL , 37122 , 5 ) , new ExifTag ( TAG_SHUTTER_SPEED_VALUE , 37377 , 10 ) , new ExifTag ( TAG_APERTURE_VALUE , 37378 , 5 ) , new ExifTag ( TAG_BRIGHTNESS_VALUE , 37379 , 10 ) , new ExifTag ( TAG_EXPOSURE_BIAS_VALUE , 37380 , 10 ) , new ExifTag ( TAG_MAX_APERTURE_VALUE , 37381 , 5 ) , new ExifTag ( TAG_SUBJECT_DISTANCE , 37382 , 5 ) , new ExifTag ( TAG_METERING_MODE , 37383 , 3 ) , new ExifTag ( TAG_LIGHT_SOURCE , 37384 , 3 ) , new ExifTag ( TAG_FLASH , 37385 , 3 ) , new ExifTag ( TAG_FOCAL_LENGTH , 37386 , 5 ) , new ExifTag ( TAG_SUBJECT_AREA , 37396 , 3 ) , new ExifTag ( TAG_MAKER_NOTE , 37500 , 7 ) , new ExifTag ( TAG_USER_COMMENT , 37510 , 7 ) , new ExifTag ( TAG_SUBSEC_TIME , 37520 , 2 ) , new ExifTag ( TAG_SUBSEC_TIME_ORIGINAL , 37521 , 2 ) , new ExifTag ( TAG_SUBSEC_TIME_DIGITIZED , 37522 , 2 ) , new ExifTag ( TAG_FLASHPIX_VERSION , 40960 , 7 ) , new ExifTag ( TAG_COLOR_SPACE , 40961 , 3 ) , new ExifTag ( TAG_PIXEL_X_DIMENSION , 40962 , 3 , 4 ) , new ExifTag ( TAG_PIXEL_Y_DIMENSION , 40963 , 3 , 4 ) , new ExifTag ( TAG_RELATED_SOUND_FILE , 40964 , 2 ) , new ExifTag ( TAG_INTEROPERABILITY_IFD_POINTER , 40965 , 4 ) , new ExifTag ( TAG_FLASH_ENERGY , 41483 , 5 ) , new ExifTag ( TAG_SPATIAL_FREQUENCY_RESPONSE , 41484 , 7 ) , new ExifTag ( TAG_FOCAL_PLANE_X_RESOLUTION , 41486 , 5 ) , new ExifTag ( TAG_FOCAL_PLANE_Y_RESOLUTION , 41487 , 5 ) , new ExifTag ( TAG_FOCAL_PLANE_RESOLUTION_UNIT , 41488 , 3 ) , new ExifTag ( TAG_SUBJECT_LOCATION , 41492 , 3 ) , new ExifTag ( TAG_EXPOSURE_INDEX , 41493 , 5 ) , new ExifTag ( TAG_SENSING_METHOD , 41495 , 3 ) , new ExifTag ( TAG_FILE_SOURCE , 41728 , 7 ) , new ExifTag ( TAG_SCENE_TYPE , 41729 , 7 ) , new ExifTag ( TAG_CFA_PATTERN , 41730 , 7 ) , new ExifTag ( TAG_CUSTOM_RENDERED , 41985 , 3 ) , new ExifTag ( TAG_EXPOSURE_MODE , 41986 , 3 ) , new ExifTag ( TAG_WHITE_BALANCE , 41987 , 3 ) , new ExifTag ( TAG_DIGITAL_ZOOM_RATIO , 41988 , 5 ) , new ExifTag ( TAG_FOCAL_LENGTH_IN_35MM_FILM , 41989 , 3 ) , new ExifTag ( TAG_SCENE_CAPTURE_TYPE , 41990 , 3 ) , new ExifTag ( TAG_GAIN_CONTROL , 41991 , 3 ) , new ExifTag ( TAG_CONTRAST , 41992 , 3 ) , new ExifTag ( TAG_SATURATION , 41993 , 3 ) , new ExifTag ( TAG_SHARPNESS , 41994 , 3 ) , new ExifTag ( TAG_DEVICE_SETTING_DESCRIPTION , 41995 , 7 ) , new ExifTag ( TAG_SUBJECT_DISTANCE_RANGE , 41996 , 3 ) , new ExifTag ( TAG_IMAGE_UNIQUE_ID , 42016 , 2 ) , new ExifTag ( " CameraOwnerName " , 42032 , 2 ) , new ExifTag ( TAG_BODY_SERIAL_NUMBER , 42033 , 2 ) , new ExifTag ( TAG_LENS_SPECIFICATION , 42034 , 5 ) , new ExifTag ( TAG_LENS_MAKE , 42035 , 2 ) , new ExifTag ( TAG_LENS_MODEL , 42036 , 2 ) , new ExifTag ( TAG_GAMMA , 42240 , 5 ) , new ExifTag ( TAG_DNG_VERSION , 50706 , 1 ) , new ExifTag ( TAG_DEFAULT_CROP_SIZE , 50720 , 3 , 4 ) } ;
IFD_EXIF_TAGS = exifTagArr3 ;
ExifTag [ ] exifTagArr4 = { new ExifTag ( TAG_GPS_VERSION_ID , 0 , 1 ) , new ExifTag ( TAG_GPS_LATITUDE_REF , 1 , 2 ) , new ExifTag ( TAG_GPS_LATITUDE , 2 , 5 , 10 ) , new ExifTag ( TAG_GPS_LONGITUDE_REF , 3 , 2 ) , new ExifTag ( TAG_GPS_LONGITUDE , 4 , 5 , 10 ) , new ExifTag ( TAG_GPS_ALTITUDE_REF , 5 , 1 ) , new ExifTag ( TAG_GPS_ALTITUDE , 6 , 5 ) , new ExifTag ( TAG_GPS_TIMESTAMP , 7 , 5 ) , new ExifTag ( TAG_GPS_SATELLITES , 8 , 2 ) , new ExifTag ( TAG_GPS_STATUS , 9 , 2 ) , new ExifTag ( TAG_GPS_MEASURE_MODE , 10 , 2 ) , new ExifTag ( TAG_GPS_DOP , 11 , 5 ) , new ExifTag ( TAG_GPS_SPEED_REF , 12 , 2 ) , new ExifTag ( TAG_GPS_SPEED , 13 , 5 ) , new ExifTag ( TAG_GPS_TRACK_REF , 14 , 2 ) , new ExifTag ( TAG_GPS_TRACK , 15 , 5 ) , new ExifTag ( TAG_GPS_IMG_DIRECTION_REF , 16 , 2 ) , new ExifTag ( TAG_GPS_IMG_DIRECTION , 17 , 5 ) , new ExifTag ( TAG_GPS_MAP_DATUM , 18 , 2 ) , new ExifTag ( TAG_GPS_DEST_LATITUDE_REF , 19 , 2 ) , new ExifTag ( TAG_GPS_DEST_LATITUDE , 20 , 5 ) , new ExifTag ( TAG_GPS_DEST_LONGITUDE_REF , 21 , 2 ) , new ExifTag ( TAG_GPS_DEST_LONGITUDE , 22 , 5 ) , new ExifTag ( TAG_GPS_DEST_BEARING_REF , 23 , 2 ) , new ExifTag ( TAG_GPS_DEST_BEARING , 24 , 5 ) , new ExifTag ( TAG_GPS_DEST_DISTANCE_REF , 25 , 2 ) , new ExifTag ( TAG_GPS_DEST_DISTANCE , 26 , 5 ) , new ExifTag ( TAG_GPS_PROCESSING_METHOD , 27 , 7 ) , new ExifTag ( TAG_GPS_AREA_INFORMATION , 28 , 7 ) , new ExifTag ( TAG_GPS_DATESTAMP , 29 , 2 ) , new ExifTag ( TAG_GPS_DIFFERENTIAL , 30 , 3 ) , new ExifTag ( TAG_GPS_H_POSITIONING_ERROR , 31 , 5 ) } ;
IFD_GPS_TAGS = exifTagArr4 ;
ExifTag [ ] exifTagArr5 = { new ExifTag ( TAG_INTEROPERABILITY_INDEX , 1 , 2 ) } ;
IFD_INTEROPERABILITY_TAGS = exifTagArr5 ;
ExifTag [ ] exifTagArr6 = { new ExifTag ( TAG_NEW_SUBFILE_TYPE , 254 , 4 ) , new ExifTag ( TAG_SUBFILE_TYPE , 255 , 4 ) , new ExifTag ( TAG_THUMBNAIL_IMAGE_WIDTH , 256 , 3 , 4 ) , new ExifTag ( TAG_THUMBNAIL_IMAGE_LENGTH , 257 , 3 , 4 ) , new ExifTag ( TAG_BITS_PER_SAMPLE , 258 , 3 ) , new ExifTag ( TAG_COMPRESSION , 259 , 3 ) , new ExifTag ( TAG_PHOTOMETRIC_INTERPRETATION , 262 , 3 ) , new ExifTag ( TAG_IMAGE_DESCRIPTION , 270 , 2 ) , new ExifTag ( TAG_MAKE , 271 , 2 ) , new ExifTag ( TAG_MODEL , 272 , 2 ) , new ExifTag ( TAG_STRIP_OFFSETS , AudioAttributesCompat . FLAG_ALL_PUBLIC , 3 , 4 ) , new ExifTag ( TAG_THUMBNAIL_ORIENTATION , 274 , 3 ) , new ExifTag ( TAG_SAMPLES_PER_PIXEL , 277 , 3 ) , new ExifTag ( TAG_ROWS_PER_STRIP , 278 , 3 , 4 ) , new ExifTag ( TAG_STRIP_BYTE_COUNTS , 279 , 3 , 4 ) , new ExifTag ( TAG_X_RESOLUTION , 282 , 5 ) , new ExifTag ( TAG_Y_RESOLUTION , 283 , 5 ) , new ExifTag ( TAG_PLANAR_CONFIGURATION , 284 , 3 ) , new ExifTag ( TAG_RESOLUTION_UNIT , 296 , 3 ) , new ExifTag ( TAG_TRANSFER_FUNCTION , 301 , 3 ) , new ExifTag ( TAG_SOFTWARE , 305 , 2 ) , new ExifTag ( TAG_DATETIME , 306 , 2 ) , new ExifTag ( TAG_ARTIST , 315 , 2 ) , new ExifTag ( TAG_WHITE_POINT , 318 , 5 ) , new ExifTag ( TAG_PRIMARY_CHROMATICITIES , 319 , 5 ) , new ExifTag ( TAG_SUB_IFD_POINTER , 330 , 4 ) , new ExifTag ( TAG_JPEG_INTERCHANGE_FORMAT , InputDeviceCompat . SOURCE_DPAD , 4 ) , new ExifTag ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH , 514 , 4 ) , new ExifTag ( TAG_Y_CB_CR_COEFFICIENTS , 529 , 5 ) , new ExifTag ( TAG_Y_CB_CR_SUB_SAMPLING , 530 , 3 ) , new ExifTag ( TAG_Y_CB_CR_POSITIONING , 531 , 3 ) , new ExifTag ( TAG_REFERENCE_BLACK_WHITE , 532 , 5 ) , new ExifTag ( TAG_XMP , 700 , 1 ) , new ExifTag ( TAG_COPYRIGHT , 33432 , 2 ) , new ExifTag ( TAG_EXIF_IFD_POINTER , 34665 , 4 ) , new ExifTag ( TAG_GPS_INFO_IFD_POINTER , 34853 , 4 ) , new ExifTag ( TAG_DNG_VERSION , 50706 , 1 ) , new ExifTag ( TAG_DEFAULT_CROP_SIZE , 50720 , 3 , 4 ) } ;
IFD_THUMBNAIL_TAGS = exifTagArr6 ;
ExifTag [ ] exifTagArr7 = { new ExifTag ( TAG_ORF_THUMBNAIL_IMAGE , 256 , 7 ) , new ExifTag ( TAG_ORF_CAMERA_SETTINGS_IFD_POINTER , 8224 , 4 ) , new ExifTag ( TAG_ORF_IMAGE_PROCESSING_IFD_POINTER , 8256 , 4 ) } ;
ORF_MAKER_NOTE_TAGS = exifTagArr7 ;
ExifTag [ ] exifTagArr8 = { new ExifTag ( TAG_ORF_PREVIEW_IMAGE_START , 257 , 4 ) , new ExifTag ( TAG_ORF_PREVIEW_IMAGE_LENGTH , 258 , 4 ) } ;
ORF_CAMERA_SETTINGS_TAGS = exifTagArr8 ;
ExifTag [ ] exifTagArr9 = { new ExifTag ( TAG_ORF_ASPECT_FRAME , 4371 , 3 ) } ;
ORF_IMAGE_PROCESSING_TAGS = exifTagArr9 ;
ExifTag [ ] exifTagArr10 = { new ExifTag ( TAG_COLOR_SPACE , 55 , 3 ) } ;
PEF_TAGS = exifTagArr10 ;
ExifTag [ ] [ ] exifTagArr11 = { exifTagArr2 , exifTagArr3 , exifTagArr4 , exifTagArr5 , exifTagArr6 , exifTagArr2 , exifTagArr7 , exifTagArr8 , exifTagArr9 , exifTagArr10 } ;
EXIF_TAGS = exifTagArr11 ;
sExifTagMapsForReading = new HashMap [ exifTagArr11 . length ] ;
sExifTagMapsForWriting = new HashMap [ exifTagArr11 . length ] ;
2021-07-24 02:37:17 +00:00
Charset forName = Charset . forName ( " US-ASCII " ) ;
ASCII = forName ;
IDENTIFIER_EXIF_APP1 = " Exif \ u0000 \ u0000 " . getBytes ( forName ) ;
IDENTIFIER_XMP_APP1 = " http://ns.adobe.com/xap/1.0/ \ u0000 " . getBytes ( forName ) ;
Locale locale = Locale . US ;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( " yyyy:MM:dd HH:mm:ss " , locale ) ;
sFormatterPrimary = simpleDateFormat ;
simpleDateFormat . setTimeZone ( TimeZone . getTimeZone ( " UTC " ) ) ;
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat ( " yyyy-MM-dd HH:mm:ss " , locale ) ;
sFormatterSecondary = simpleDateFormat2 ;
simpleDateFormat2 . setTimeZone ( TimeZone . getTimeZone ( " UTC " ) ) ;
int i = 0 ;
while ( true ) {
2022-03-07 09:34:54 +00:00
ExifTag [ ] [ ] exifTagArr12 = EXIF_TAGS ;
if ( i < exifTagArr12 . length ) {
2021-07-24 02:37:17 +00:00
sExifTagMapsForReading [ i ] = new HashMap < > ( ) ;
sExifTagMapsForWriting [ i ] = new HashMap < > ( ) ;
2022-03-07 09:34:54 +00:00
for ( ExifTag exifTag : exifTagArr12 [ i ] ) {
2021-07-24 02:37:17 +00:00
sExifTagMapsForReading [ i ] . put ( Integer . valueOf ( exifTag . number ) , exifTag ) ;
sExifTagMapsForWriting [ i ] . put ( exifTag . name , exifTag ) ;
}
i + + ;
} else {
HashMap < Integer , Integer > hashMap = sExifPointerTagMap ;
ExifTag [ ] exifTagArr13 = EXIF_POINTER_TAGS ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 0 ] . number ) , 5 ) ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 1 ] . number ) , 1 ) ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 2 ] . number ) , 2 ) ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 3 ] . number ) , 3 ) ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 4 ] . number ) , 7 ) ;
hashMap . put ( Integer . valueOf ( exifTagArr13 [ 5 ] . number ) , 8 ) ;
2022-03-07 09:34:54 +00:00
NON_ZERO_TIME_PATTERN = Pattern . compile ( " .*[1-9].* " ) ;
GPS_TIMESTAMP_PATTERN = Pattern . compile ( " ^( \\ d{2}):( \\ d{2}):( \\ d{2})$ " ) ;
DATETIME_PRIMARY_FORMAT_PATTERN = Pattern . compile ( " ^( \\ d{4}):( \\ d{2}):( \\ d{2}) \\ s( \\ d{2}):( \\ d{2}):( \\ d{2})$ " ) ;
DATETIME_SECONDARY_FORMAT_PATTERN = Pattern . compile ( " ^( \\ d{4})-( \\ d{2})-( \\ d{2}) \\ s( \\ d{2}):( \\ d{2}):( \\ d{2})$ " ) ;
2021-07-24 02:37:17 +00:00
return ;
}
}
}
public ExifInterface ( @NonNull File file ) throws IOException {
ExifTag [ ] [ ] exifTagArr = EXIF_TAGS ;
this . mAttributes = new HashMap [ exifTagArr . length ] ;
this . mAttributesOffsets = new HashSet ( exifTagArr . length ) ;
this . mExifByteOrder = ByteOrder . BIG_ENDIAN ;
Objects . requireNonNull ( file , " file cannot be null " ) ;
initForFilename ( file . getAbsolutePath ( ) ) ;
}
public ExifInterface ( @NonNull FileDescriptor fileDescriptor ) throws IOException {
FileInputStream fileInputStream ;
Throwable th ;
ExifTag [ ] [ ] exifTagArr = EXIF_TAGS ;
this . mAttributes = new HashMap [ exifTagArr . length ] ;
this . mAttributesOffsets = new HashSet ( exifTagArr . length ) ;
this . mExifByteOrder = ByteOrder . BIG_ENDIAN ;
Objects . requireNonNull ( fileDescriptor , " fileDescriptor cannot be null " ) ;
this . mAssetInputStream = null ;
this . mFilename = null ;
boolean z2 = false ;
if ( isSeekableFD ( fileDescriptor ) ) {
this . mSeekableFileDescriptor = fileDescriptor ;
try {
2022-01-13 08:07:50 +00:00
fileDescriptor = ExifInterfaceUtils . Api21Impl . dup ( fileDescriptor ) ;
2021-07-24 02:37:17 +00:00
z2 = true ;
} catch ( Exception e ) {
throw new IOException ( " Failed to duplicate file descriptor " , e ) ;
}
} else {
this . mSeekableFileDescriptor = null ;
}
try {
fileInputStream = new FileInputStream ( fileDescriptor ) ;
try {
loadAttributes ( fileInputStream ) ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
2021-07-24 02:37:17 +00:00
if ( z2 ) {
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeFileDescriptor ( fileDescriptor ) ;
2021-07-24 02:37:17 +00:00
}
} catch ( Throwable th2 ) {
th = th2 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
2021-07-24 02:37:17 +00:00
if ( z2 ) {
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeFileDescriptor ( fileDescriptor ) ;
2021-07-24 02:37:17 +00:00
}
throw th ;
}
} catch ( Throwable th3 ) {
th = th3 ;
2022-03-07 09:34:54 +00:00
fileInputStream = null ;
2021-07-24 02:37:17 +00:00
}
}
public ExifInterface ( @NonNull InputStream inputStream ) throws IOException {
this ( inputStream , 0 ) ;
}
public ExifInterface ( @NonNull InputStream inputStream , int i ) throws IOException {
ExifTag [ ] [ ] exifTagArr = EXIF_TAGS ;
this . mAttributes = new HashMap [ exifTagArr . length ] ;
this . mAttributesOffsets = new HashSet ( exifTagArr . length ) ;
this . mExifByteOrder = ByteOrder . BIG_ENDIAN ;
Objects . requireNonNull ( inputStream , " inputStream cannot be null " ) ;
this . mFilename = null ;
if ( i = = 1 ) {
2022-01-13 08:07:50 +00:00
BufferedInputStream bufferedInputStream = new BufferedInputStream ( inputStream , IDENTIFIER_EXIF_APP1 . length ) ;
2021-07-24 02:37:17 +00:00
if ( ! isExifDataOnly ( bufferedInputStream ) ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " Given data does not follow the structure of an Exif-only data. " ) ;
2021-07-24 02:37:17 +00:00
return ;
}
this . mIsExifDataOnly = true ;
this . mAssetInputStream = null ;
this . mSeekableFileDescriptor = null ;
inputStream = bufferedInputStream ;
} else if ( inputStream instanceof AssetManager . AssetInputStream ) {
this . mAssetInputStream = ( AssetManager . AssetInputStream ) inputStream ;
this . mSeekableFileDescriptor = null ;
} else {
if ( inputStream instanceof FileInputStream ) {
FileInputStream fileInputStream = ( FileInputStream ) inputStream ;
if ( isSeekableFD ( fileInputStream . getFD ( ) ) ) {
this . mAssetInputStream = null ;
this . mSeekableFileDescriptor = fileInputStream . getFD ( ) ;
}
}
this . mAssetInputStream = null ;
this . mSeekableFileDescriptor = null ;
}
loadAttributes ( inputStream ) ;
}
public ExifInterface ( @NonNull String str ) throws IOException {
ExifTag [ ] [ ] exifTagArr = EXIF_TAGS ;
this . mAttributes = new HashMap [ exifTagArr . length ] ;
this . mAttributesOffsets = new HashSet ( exifTagArr . length ) ;
this . mExifByteOrder = ByteOrder . BIG_ENDIAN ;
Objects . requireNonNull ( str , " filename cannot be null " ) ;
initForFilename ( str ) ;
}
private void addDefaultValuesForCompatibility ( ) {
2021-08-09 22:51:56 +00:00
String attribute = getAttribute ( TAG_DATETIME_ORIGINAL ) ;
if ( attribute ! = null & & getAttribute ( TAG_DATETIME ) = = null ) {
this . mAttributes [ 0 ] . put ( TAG_DATETIME , ExifAttribute . createString ( attribute ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_IMAGE_WIDTH ) = = null ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( TAG_IMAGE_WIDTH , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_IMAGE_LENGTH ) = = null ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( TAG_IMAGE_LENGTH , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_ORIENTATION ) = = null ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( TAG_ORIENTATION , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_LIGHT_SOURCE ) = = null ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 1 ] . put ( TAG_LIGHT_SOURCE , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
}
private String convertDecimalDegree ( double d ) {
long j = ( long ) d ;
2022-03-07 09:34:54 +00:00
double d2 = d - j ;
2021-07-24 02:37:17 +00:00
long j2 = ( long ) ( d2 * 60 . 0d ) ;
2022-03-07 09:34:54 +00:00
long round = Math . round ( ( d2 - ( j2 / 60 . 0d ) ) * 3600 . 0d * 1 . 0E7d ) ;
2021-07-24 02:37:17 +00:00
return j + " /1, " + j2 + " /1, " + round + " /10000000 " ;
}
private static double convertRationalLatLonToDouble ( String str , String str2 ) {
try {
String [ ] split = str . split ( " , " , - 1 ) ;
2021-08-09 22:51:56 +00:00
String [ ] split2 = split [ 0 ] . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , - 1 ) ;
2021-07-24 02:37:17 +00:00
double parseDouble = Double . parseDouble ( split2 [ 0 ] . trim ( ) ) / Double . parseDouble ( split2 [ 1 ] . trim ( ) ) ;
2021-08-09 22:51:56 +00:00
String [ ] split3 = split [ 1 ] . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , - 1 ) ;
String [ ] split4 = split [ 2 ] . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , - 1 ) ;
2021-07-24 02:37:17 +00:00
double parseDouble2 = ( ( Double . parseDouble ( split4 [ 0 ] . trim ( ) ) / Double . parseDouble ( split4 [ 1 ] . trim ( ) ) ) / 3600 . 0d ) + ( ( Double . parseDouble ( split3 [ 0 ] . trim ( ) ) / Double . parseDouble ( split3 [ 1 ] . trim ( ) ) ) / 60 . 0d ) + parseDouble ;
2022-03-07 09:34:54 +00:00
if ( ! str2 . equals ( LATITUDE_SOUTH ) & & ! str2 . equals ( LONGITUDE_WEST ) ) {
if ( ! str2 . equals ( " N " ) & & ! str2 . equals ( LONGITUDE_EAST ) ) {
throw new IllegalArgumentException ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
return parseDouble2 ;
2021-07-24 02:37:17 +00:00
}
return - parseDouble2 ;
} catch ( ArrayIndexOutOfBoundsException | NumberFormatException unused ) {
throw new IllegalArgumentException ( ) ;
}
}
private void copyChunksUpToGivenChunkType ( ByteOrderedDataInputStream byteOrderedDataInputStream , ByteOrderedDataOutputStream byteOrderedDataOutputStream , byte [ ] bArr , byte [ ] bArr2 ) throws IOException {
String str ;
while ( true ) {
byte [ ] bArr3 = new byte [ 4 ] ;
if ( byteOrderedDataInputStream . read ( bArr3 ) ! = 4 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Encountered invalid length while copying WebP chunks up tochunk type " ) ;
2021-07-24 02:37:17 +00:00
Charset charset = ASCII ;
2022-03-21 18:52:30 +00:00
R . append ( new String ( bArr , charset ) ) ;
2021-07-24 02:37:17 +00:00
if ( bArr2 = = null ) {
str = " " ;
} else {
2022-03-21 18:52:30 +00:00
StringBuilder R2 = a . R ( " or " ) ;
R2 . append ( new String ( bArr2 , charset ) ) ;
str = R2 . toString ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-21 18:52:30 +00:00
R . append ( str ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
copyWebPChunk ( byteOrderedDataInputStream , byteOrderedDataOutputStream , bArr3 ) ;
if ( Arrays . equals ( bArr3 , bArr ) ) {
return ;
}
if ( bArr2 ! = null & & Arrays . equals ( bArr3 , bArr2 ) ) {
return ;
}
}
}
private void copyWebPChunk ( ByteOrderedDataInputStream byteOrderedDataInputStream , ByteOrderedDataOutputStream byteOrderedDataOutputStream , byte [ ] bArr ) throws IOException {
int readInt = byteOrderedDataInputStream . readInt ( ) ;
byteOrderedDataOutputStream . write ( bArr ) ;
byteOrderedDataOutputStream . writeInt ( readInt ) ;
if ( readInt % 2 = = 1 ) {
readInt + + ;
}
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream , readInt ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
private ExifAttribute getExifAttribute ( @NonNull String str ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
2021-08-09 22:51:56 +00:00
if ( TAG_ISO_SPEED_RATINGS . equals ( str ) ) {
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " getExifAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY. " ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
str = TAG_PHOTOGRAPHIC_SENSITIVITY ;
2021-07-24 02:37:17 +00:00
}
for ( int i = 0 ; i < EXIF_TAGS . length ; i + + ) {
ExifAttribute exifAttribute = this . mAttributes [ i ] . get ( str ) ;
if ( exifAttribute ! = null ) {
return exifAttribute ;
}
}
return null ;
}
2022-01-13 08:07:50 +00:00
private void getHeifAttributes ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) throws IOException {
2021-07-24 02:37:17 +00:00
String str ;
String str2 ;
2022-01-13 08:07:50 +00:00
if ( Build . VERSION . SDK_INT > = 28 ) {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever ( ) ;
try {
2022-03-07 09:34:54 +00:00
try {
ExifInterfaceUtils . Api23Impl . setDataSource ( mediaMetadataRetriever , new AnonymousClass1 ( seekableByteOrderedDataInputStream ) ) ;
String extractMetadata = mediaMetadataRetriever . extractMetadata ( 33 ) ;
String extractMetadata2 = mediaMetadataRetriever . extractMetadata ( 34 ) ;
String extractMetadata3 = mediaMetadataRetriever . extractMetadata ( 26 ) ;
String extractMetadata4 = mediaMetadataRetriever . extractMetadata ( 17 ) ;
String str3 = null ;
if ( " yes " . equals ( extractMetadata3 ) ) {
str3 = mediaMetadataRetriever . extractMetadata ( 29 ) ;
str2 = mediaMetadataRetriever . extractMetadata ( 30 ) ;
str = mediaMetadataRetriever . extractMetadata ( 31 ) ;
} else if ( " yes " . equals ( extractMetadata4 ) ) {
str3 = mediaMetadataRetriever . extractMetadata ( 18 ) ;
str2 = mediaMetadataRetriever . extractMetadata ( 19 ) ;
str = mediaMetadataRetriever . extractMetadata ( 24 ) ;
} else {
str2 = null ;
str = null ;
2022-01-13 08:07:50 +00:00
}
2022-03-07 09:34:54 +00:00
if ( str3 ! = null ) {
this . mAttributes [ 0 ] . put ( TAG_IMAGE_WIDTH , ExifAttribute . createUShort ( Integer . parseInt ( str3 ) , this . mExifByteOrder ) ) ;
}
if ( str2 ! = null ) {
this . mAttributes [ 0 ] . put ( TAG_IMAGE_LENGTH , ExifAttribute . createUShort ( Integer . parseInt ( str2 ) , this . mExifByteOrder ) ) ;
}
if ( str ! = null ) {
int i = 1 ;
int parseInt = Integer . parseInt ( str ) ;
if ( parseInt = = 90 ) {
i = 6 ;
} else if ( parseInt = = 180 ) {
i = 3 ;
} else if ( parseInt = = 270 ) {
i = 8 ;
}
this . mAttributes [ 0 ] . put ( TAG_ORIENTATION , ExifAttribute . createUShort ( i , this . mExifByteOrder ) ) ;
}
if ( ! ( extractMetadata = = null | | extractMetadata2 = = null ) ) {
int parseInt2 = Integer . parseInt ( extractMetadata ) ;
int parseInt3 = Integer . parseInt ( extractMetadata2 ) ;
if ( parseInt3 > 6 ) {
seekableByteOrderedDataInputStream . seek ( parseInt2 ) ;
byte [ ] bArr = new byte [ 6 ] ;
if ( seekableByteOrderedDataInputStream . read ( bArr ) = = 6 ) {
int i2 = parseInt2 + 6 ;
int i3 = parseInt3 - 6 ;
if ( Arrays . equals ( bArr , IDENTIFIER_EXIF_APP1 ) ) {
byte [ ] bArr2 = new byte [ i3 ] ;
if ( seekableByteOrderedDataInputStream . read ( bArr2 ) = = i3 ) {
this . mOffsetToExifData = i2 ;
readExifSegment ( bArr2 , 0 ) ;
} else {
throw new IOException ( " Can't read exif " ) ;
}
2022-01-13 08:07:50 +00:00
} else {
2022-03-07 09:34:54 +00:00
throw new IOException ( " Invalid identifier " ) ;
2022-01-13 08:07:50 +00:00
}
2021-07-24 02:37:17 +00:00
} else {
2022-03-07 09:34:54 +00:00
throw new IOException ( " Can't read identifier " ) ;
2021-07-24 02:37:17 +00:00
}
} else {
2022-03-07 09:34:54 +00:00
throw new IOException ( " Invalid exif length " ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
if ( DEBUG ) {
Log . d ( TAG , " Heif meta: " + str3 + " x " + str2 + " , rotation " + str ) ;
}
} catch ( RuntimeException unused ) {
throw new UnsupportedOperationException ( " Failed to read EXIF from HEIF file. Given stream is either malformed or unsupported. " ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} finally {
2022-01-13 08:07:50 +00:00
mediaMetadataRetriever . release ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
} else {
throw new UnsupportedOperationException ( " Reading EXIF from HEIF files is supported from SDK 28 and above " ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
/ * JADX WARN : Code restructure failed : missing block : B : 64 : 0x0180 , code lost :
r19 . setByteOrder ( r18 . mExifByteOrder ) ;
* /
/ * JADX WARN : Code restructure failed : missing block : B : 65 : 0x0185 , code lost :
return ;
* /
/* JADX WARN: Removed duplicated region for block: B:32:0x00b0 A[FALL_THROUGH] */
/* JADX WARN: Removed duplicated region for block: B:59:0x016c A[LOOP:0: B:10:0x0038->B:59:0x016c, LOOP_END] */
/* JADX WARN: Removed duplicated region for block: B:75:0x0174 A[SYNTHETIC] */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
private void getJpegAttributes ( ByteOrderedDataInputStream byteOrderedDataInputStream , int i , int i2 ) throws IOException {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " getJpegAttributes starting with: " + byteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
}
byteOrderedDataInputStream . setByteOrder ( ByteOrder . BIG_ENDIAN ) ;
byte readByte = byteOrderedDataInputStream . readByte ( ) ;
2021-12-17 21:59:34 +00:00
byte b2 = - 1 ;
2021-07-24 02:37:17 +00:00
if ( readByte ! = - 1 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid marker: " ) ;
R . append ( Integer . toHexString ( readByte & 255 ) ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
} else if ( byteOrderedDataInputStream . readByte ( ) = = - 40 ) {
int i3 = 2 ;
int i4 = 2 ;
while ( true ) {
byte readByte2 = byteOrderedDataInputStream . readByte ( ) ;
2021-12-17 21:59:34 +00:00
if ( readByte2 = = b2 ) {
2021-07-24 02:37:17 +00:00
int i5 = i4 + 1 ;
byte readByte3 = byteOrderedDataInputStream . readByte ( ) ;
boolean z2 = DEBUG ;
if ( z2 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R2 = a . R ( " Found JPEG segment indicator: " ) ;
R2 . append ( Integer . toHexString ( readByte3 & 255 ) ) ;
Log . d ( TAG , R2 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
int i6 = i5 + 1 ;
if ( readByte3 ! = - 39 & & readByte3 ! = - 38 ) {
int readUnsignedShort = byteOrderedDataInputStream . readUnsignedShort ( ) - i3 ;
int i7 = i6 + i3 ;
if ( z2 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R3 = a . R ( " JPEG segment: " ) ;
R3 . append ( Integer . toHexString ( readByte3 & 255 ) ) ;
R3 . append ( " (length: " ) ;
R3 . append ( readUnsignedShort + 2 ) ;
R3 . append ( " ) " ) ;
Log . d ( TAG , R3 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( readUnsignedShort > = 0 ) {
if ( readByte3 = = - 31 ) {
byte [ ] bArr = new byte [ readUnsignedShort ] ;
byteOrderedDataInputStream . readFully ( bArr ) ;
2022-03-07 09:34:54 +00:00
i7 + = readUnsignedShort ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr2 = IDENTIFIER_EXIF_APP1 ;
2022-01-13 08:07:50 +00:00
if ( ExifInterfaceUtils . startsWith ( bArr , bArr2 ) ) {
2021-07-24 02:37:17 +00:00
byte [ ] copyOfRange = Arrays . copyOfRange ( bArr , bArr2 . length , readUnsignedShort ) ;
this . mOffsetToExifData = i + i7 + bArr2 . length ;
readExifSegment ( copyOfRange , i2 ) ;
setThumbnailData ( new ByteOrderedDataInputStream ( copyOfRange ) ) ;
} else {
byte [ ] bArr3 = IDENTIFIER_XMP_APP1 ;
2022-01-13 08:07:50 +00:00
if ( ExifInterfaceUtils . startsWith ( bArr , bArr3 ) ) {
2021-07-24 02:37:17 +00:00
int length = i7 + bArr3 . length ;
byte [ ] copyOfRange2 = Arrays . copyOfRange ( bArr , bArr3 . length , readUnsignedShort ) ;
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_XMP ) = = null ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( TAG_XMP , new ExifAttribute ( 1 , copyOfRange2 . length , length , copyOfRange2 ) ) ;
2021-07-24 02:37:17 +00:00
this . mXmpIsFromSeparateMarker = true ;
}
}
}
} else if ( readByte3 ! = - 2 ) {
switch ( readByte3 ) {
default :
switch ( readByte3 ) {
default :
switch ( readByte3 ) {
default :
switch ( readByte3 ) {
}
case - 55 :
case - 54 :
case - 53 :
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( 1 ) ;
2022-03-07 09:34:54 +00:00
this . mAttributes [ i2 ] . put ( i2 ! = 4 ? TAG_IMAGE_LENGTH : TAG_THUMBNAIL_IMAGE_LENGTH , ExifAttribute . createULong ( byteOrderedDataInputStream . readUnsignedShort ( ) , this . mExifByteOrder ) ) ;
this . mAttributes [ i2 ] . put ( i2 ! = 4 ? TAG_IMAGE_WIDTH : TAG_THUMBNAIL_IMAGE_WIDTH , ExifAttribute . createULong ( byteOrderedDataInputStream . readUnsignedShort ( ) , this . mExifByteOrder ) ) ;
2022-01-13 08:07:50 +00:00
readUnsignedShort - = 5 ;
break ;
2021-07-24 02:37:17 +00:00
}
case - 59 :
case - 58 :
case - 57 :
break ;
}
case - 64 :
case - 63 :
case - 62 :
case - 61 :
break ;
}
2022-01-13 08:07:50 +00:00
if ( readUnsignedShort < 0 ) {
byteOrderedDataInputStream . skipFully ( readUnsignedShort ) ;
2021-07-24 02:37:17 +00:00
i4 = i7 + readUnsignedShort ;
i3 = 2 ;
2021-12-17 21:59:34 +00:00
b2 = - 1 ;
2021-07-24 02:37:17 +00:00
} else {
2022-01-13 08:07:50 +00:00
throw new IOException ( " Invalid length " ) ;
2021-07-24 02:37:17 +00:00
}
} else {
byte [ ] bArr4 = new byte [ readUnsignedShort ] ;
if ( byteOrderedDataInputStream . read ( bArr4 ) ! = readUnsignedShort ) {
throw new IOException ( " Invalid exif " ) ;
2021-08-09 22:51:56 +00:00
} else if ( getAttribute ( TAG_USER_COMMENT ) = = null ) {
this . mAttributes [ 1 ] . put ( TAG_USER_COMMENT , ExifAttribute . createString ( new String ( bArr4 , ASCII ) ) ) ;
2021-07-24 02:37:17 +00:00
}
}
readUnsignedShort = 0 ;
2022-01-13 08:07:50 +00:00
if ( readUnsignedShort < 0 ) {
2021-07-24 02:37:17 +00:00
}
} else {
throw new IOException ( " Invalid length " ) ;
}
}
} else {
2022-03-21 18:52:30 +00:00
StringBuilder R4 = a . R ( " Invalid marker: " ) ;
R4 . append ( Integer . toHexString ( readByte2 & 255 ) ) ;
throw new IOException ( R4 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
} else {
2022-03-21 18:52:30 +00:00
StringBuilder R5 = a . R ( " Invalid marker: " ) ;
R5 . append ( Integer . toHexString ( readByte & 255 ) ) ;
throw new IOException ( R5 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
private int getMimeType ( BufferedInputStream bufferedInputStream ) throws IOException {
2021-08-09 22:51:56 +00:00
bufferedInputStream . mark ( SIGNATURE_CHECK_SIZE ) ;
byte [ ] bArr = new byte [ SIGNATURE_CHECK_SIZE ] ;
2021-07-24 02:37:17 +00:00
bufferedInputStream . read ( bArr ) ;
bufferedInputStream . reset ( ) ;
if ( isJpegFormat ( bArr ) ) {
return 4 ;
}
if ( isRafFormat ( bArr ) ) {
return 9 ;
}
if ( isHeifFormat ( bArr ) ) {
return 12 ;
}
if ( isOrfFormat ( bArr ) ) {
return 7 ;
}
if ( isRw2Format ( bArr ) ) {
return 10 ;
}
if ( isPngFormat ( bArr ) ) {
return 13 ;
}
return isWebpFormat ( bArr ) ? 14 : 0 ;
}
2022-01-13 08:07:50 +00:00
private void getOrfAttributes ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) throws IOException {
getRawAttributes ( seekableByteOrderedDataInputStream ) ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = this . mAttributes [ 1 ] . get ( TAG_MAKER_NOTE ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute ! = null ) {
2022-01-13 08:07:50 +00:00
SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream2 = new SeekableByteOrderedDataInputStream ( exifAttribute . bytes ) ;
seekableByteOrderedDataInputStream2 . setByteOrder ( this . mExifByteOrder ) ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr = ORF_MAKER_NOTE_HEADER_1 ;
byte [ ] bArr2 = new byte [ bArr . length ] ;
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream2 . readFully ( bArr2 ) ;
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream2 . seek ( 0L ) ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr3 = ORF_MAKER_NOTE_HEADER_2 ;
byte [ ] bArr4 = new byte [ bArr3 . length ] ;
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream2 . readFully ( bArr4 ) ;
2021-07-24 02:37:17 +00:00
if ( Arrays . equals ( bArr2 , bArr ) ) {
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream2 . seek ( 8L ) ;
2021-07-24 02:37:17 +00:00
} else if ( Arrays . equals ( bArr4 , bArr3 ) ) {
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream2 . seek ( 12L ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
readImageFileDirectory ( seekableByteOrderedDataInputStream2 , 6 ) ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute2 = this . mAttributes [ 7 ] . get ( TAG_ORF_PREVIEW_IMAGE_START ) ;
ExifAttribute exifAttribute3 = this . mAttributes [ 7 ] . get ( TAG_ORF_PREVIEW_IMAGE_LENGTH ) ;
2021-07-24 02:37:17 +00:00
if ( ! ( exifAttribute2 = = null | | exifAttribute3 = = null ) ) {
2021-08-09 22:51:56 +00:00
this . mAttributes [ 5 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT , exifAttribute2 ) ;
this . mAttributes [ 5 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH , exifAttribute3 ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute4 = this . mAttributes [ 8 ] . get ( TAG_ORF_ASPECT_FRAME ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute4 ! = null ) {
int [ ] iArr = ( int [ ] ) exifAttribute4 . getValue ( this . mExifByteOrder ) ;
if ( iArr = = null | | iArr . length ! = 4 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid aspect frame values. frame= " ) ;
R . append ( Arrays . toString ( iArr ) ) ;
Log . w ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
} else if ( iArr [ 2 ] > iArr [ 0 ] & & iArr [ 3 ] > iArr [ 1 ] ) {
int i = ( iArr [ 2 ] - iArr [ 0 ] ) + 1 ;
int i2 = ( iArr [ 3 ] - iArr [ 1 ] ) + 1 ;
if ( i < i2 ) {
int i3 = i + i2 ;
i2 = i3 - i2 ;
i = i3 - i2 ;
}
ExifAttribute createUShort = ExifAttribute . createUShort ( i , this . mExifByteOrder ) ;
ExifAttribute createUShort2 = ExifAttribute . createUShort ( i2 , this . mExifByteOrder ) ;
2021-08-09 22:51:56 +00:00
this . mAttributes [ 0 ] . put ( TAG_IMAGE_WIDTH , createUShort ) ;
this . mAttributes [ 0 ] . put ( TAG_IMAGE_LENGTH , createUShort2 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
}
private void getPngAttributes ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " getPngAttributes starting with: " + byteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
}
byteOrderedDataInputStream . setByteOrder ( ByteOrder . BIG_ENDIAN ) ;
byte [ ] bArr = PNG_SIGNATURE ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( bArr . length ) ;
2021-07-24 02:37:17 +00:00
int length = bArr . length + 0 ;
while ( true ) {
try {
int readInt = byteOrderedDataInputStream . readInt ( ) ;
int i = length + 4 ;
byte [ ] bArr2 = new byte [ 4 ] ;
if ( byteOrderedDataInputStream . read ( bArr2 ) = = 4 ) {
int i2 = i + 4 ;
2022-03-07 09:34:54 +00:00
if ( i2 = = 16 & & ! Arrays . equals ( bArr2 , PNG_CHUNK_TYPE_IHDR ) ) {
throw new IOException ( " Encountered invalid PNG file--IHDR chunk should appearas the first chunk " ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! Arrays . equals ( bArr2 , PNG_CHUNK_TYPE_IEND ) ) {
if ( Arrays . equals ( bArr2 , PNG_CHUNK_TYPE_EXIF ) ) {
byte [ ] bArr3 = new byte [ readInt ] ;
if ( byteOrderedDataInputStream . read ( bArr3 ) = = readInt ) {
int readInt2 = byteOrderedDataInputStream . readInt ( ) ;
CRC32 crc32 = new CRC32 ( ) ;
crc32 . update ( bArr2 ) ;
crc32 . update ( bArr3 ) ;
if ( ( ( int ) crc32 . getValue ( ) ) = = readInt2 ) {
this . mOffsetToExifData = i2 ;
readExifSegment ( bArr3 , 0 ) ;
validateImages ( ) ;
setThumbnailData ( new ByteOrderedDataInputStream ( bArr3 ) ) ;
return ;
}
throw new IOException ( " Encountered invalid CRC value for PNG-EXIF chunk. \ n recorded CRC value: " + readInt2 + " , calculated CRC value: " + crc32 . getValue ( ) ) ;
}
2022-01-13 08:07:50 +00:00
throw new IOException ( " Failed to read given length for given PNG chunk type: " + ExifInterfaceUtils . byteArrayToHexString ( bArr2 ) ) ;
2021-07-24 02:37:17 +00:00
}
int i3 = readInt + 4 ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( i3 ) ;
2021-07-24 02:37:17 +00:00
length = i2 + i3 ;
} else {
return ;
}
} else {
throw new IOException ( " Encountered invalid length while parsing PNG chunktype " ) ;
}
} catch ( EOFException unused ) {
throw new IOException ( " Encountered corrupt PNG file. " ) ;
}
}
}
private void getRafAttributes ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
boolean z2 = DEBUG ;
if ( z2 ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " getRafAttributes starting with: " + byteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( 84 ) ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr = new byte [ 4 ] ;
byte [ ] bArr2 = new byte [ 4 ] ;
byte [ ] bArr3 = new byte [ 4 ] ;
byteOrderedDataInputStream . read ( bArr ) ;
byteOrderedDataInputStream . read ( bArr2 ) ;
byteOrderedDataInputStream . read ( bArr3 ) ;
int i = ByteBuffer . wrap ( bArr ) . getInt ( ) ;
int i2 = ByteBuffer . wrap ( bArr2 ) . getInt ( ) ;
int i3 = ByteBuffer . wrap ( bArr3 ) . getInt ( ) ;
byte [ ] bArr4 = new byte [ i2 ] ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( i - byteOrderedDataInputStream . position ( ) ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataInputStream . read ( bArr4 ) ;
getJpegAttributes ( new ByteOrderedDataInputStream ( bArr4 ) , i , 5 ) ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( i3 - byteOrderedDataInputStream . position ( ) ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataInputStream . setByteOrder ( ByteOrder . BIG_ENDIAN ) ;
int readInt = byteOrderedDataInputStream . readInt ( ) ;
if ( z2 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " numberOfDirectoryEntry: " , readInt , TAG ) ;
2021-07-24 02:37:17 +00:00
}
for ( int i4 = 0 ; i4 < readInt ; i4 + + ) {
int readUnsignedShort = byteOrderedDataInputStream . readUnsignedShort ( ) ;
int readUnsignedShort2 = byteOrderedDataInputStream . readUnsignedShort ( ) ;
if ( readUnsignedShort = = TAG_RAF_IMAGE_SIZE . number ) {
short readShort = byteOrderedDataInputStream . readShort ( ) ;
short readShort2 = byteOrderedDataInputStream . readShort ( ) ;
ExifAttribute createUShort = ExifAttribute . createUShort ( readShort , this . mExifByteOrder ) ;
ExifAttribute createUShort2 = ExifAttribute . createUShort ( readShort2 , this . mExifByteOrder ) ;
2021-08-09 22:51:56 +00:00
this . mAttributes [ 0 ] . put ( TAG_IMAGE_LENGTH , createUShort ) ;
this . mAttributes [ 0 ] . put ( TAG_IMAGE_WIDTH , createUShort2 ) ;
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Updated to length: " + ( ( int ) readShort ) + " , width: " + ( ( int ) readShort2 ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
return ;
}
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( readUnsignedShort2 ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-01-13 08:07:50 +00:00
private void getRawAttributes ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) throws IOException {
2021-07-24 02:37:17 +00:00
ExifAttribute exifAttribute ;
2022-01-13 08:07:50 +00:00
parseTiffHeaders ( seekableByteOrderedDataInputStream ) ;
readImageFileDirectory ( seekableByteOrderedDataInputStream , 0 ) ;
updateImageSizeValues ( seekableByteOrderedDataInputStream , 0 ) ;
updateImageSizeValues ( seekableByteOrderedDataInputStream , 5 ) ;
updateImageSizeValues ( seekableByteOrderedDataInputStream , 4 ) ;
2021-07-24 02:37:17 +00:00
validateImages ( ) ;
2021-08-09 22:51:56 +00:00
if ( this . mMimeType = = 8 & & ( exifAttribute = this . mAttributes [ 1 ] . get ( TAG_MAKER_NOTE ) ) ! = null ) {
2022-01-13 08:07:50 +00:00
SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream2 = new SeekableByteOrderedDataInputStream ( exifAttribute . bytes ) ;
seekableByteOrderedDataInputStream2 . setByteOrder ( this . mExifByteOrder ) ;
seekableByteOrderedDataInputStream2 . skipFully ( 6 ) ;
readImageFileDirectory ( seekableByteOrderedDataInputStream2 , 9 ) ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute2 = this . mAttributes [ 9 ] . get ( TAG_COLOR_SPACE ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute2 ! = null ) {
2021-08-09 22:51:56 +00:00
this . mAttributes [ 1 ] . put ( TAG_COLOR_SPACE , exifAttribute2 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
2022-01-13 08:07:50 +00:00
private void getRw2Attributes ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) throws IOException {
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2022-01-13 08:07:50 +00:00
Log . d ( TAG , " getRw2Attributes starting with: " + seekableByteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
getRawAttributes ( seekableByteOrderedDataInputStream ) ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = this . mAttributes [ 0 ] . get ( TAG_RW2_JPG_FROM_RAW ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute ! = null ) {
getJpegAttributes ( new ByteOrderedDataInputStream ( exifAttribute . bytes ) , ( int ) exifAttribute . bytesOffset , 5 ) ;
}
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute2 = this . mAttributes [ 0 ] . get ( TAG_RW2_ISO ) ;
ExifAttribute exifAttribute3 = this . mAttributes [ 1 ] . get ( TAG_PHOTOGRAPHIC_SENSITIVITY ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute2 ! = null & & exifAttribute3 = = null ) {
2021-08-09 22:51:56 +00:00
this . mAttributes [ 1 ] . put ( TAG_PHOTOGRAPHIC_SENSITIVITY , exifAttribute2 ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-01-13 08:07:50 +00:00
private void getStandaloneAttributes ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream ) throws IOException {
2021-07-24 02:37:17 +00:00
byte [ ] bArr = IDENTIFIER_EXIF_APP1 ;
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream . skipFully ( bArr . length ) ;
byte [ ] bArr2 = new byte [ seekableByteOrderedDataInputStream . available ( ) ] ;
seekableByteOrderedDataInputStream . readFully ( bArr2 ) ;
2021-07-24 02:37:17 +00:00
this . mOffsetToExifData = bArr . length ;
readExifSegment ( bArr2 , 0 ) ;
}
private void getWebpAttributes ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " getWebpAttributes starting with: " + byteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
}
byteOrderedDataInputStream . setByteOrder ( ByteOrder . LITTLE_ENDIAN ) ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( WEBP_SIGNATURE_1 . length ) ;
2021-07-24 02:37:17 +00:00
int readInt = byteOrderedDataInputStream . readInt ( ) + 8 ;
2022-01-13 08:07:50 +00:00
byte [ ] bArr = WEBP_SIGNATURE_2 ;
byteOrderedDataInputStream . skipFully ( bArr . length ) ;
int length = bArr . length + 8 ;
2021-07-24 02:37:17 +00:00
while ( true ) {
try {
2022-01-13 08:07:50 +00:00
byte [ ] bArr2 = new byte [ 4 ] ;
if ( byteOrderedDataInputStream . read ( bArr2 ) = = 4 ) {
2021-07-24 02:37:17 +00:00
int readInt2 = byteOrderedDataInputStream . readInt ( ) ;
2022-01-13 08:07:50 +00:00
int i = length + 4 + 4 ;
if ( Arrays . equals ( WEBP_CHUNK_TYPE_EXIF , bArr2 ) ) {
byte [ ] bArr3 = new byte [ readInt2 ] ;
if ( byteOrderedDataInputStream . read ( bArr3 ) = = readInt2 ) {
2021-07-24 02:37:17 +00:00
this . mOffsetToExifData = i ;
2022-01-13 08:07:50 +00:00
readExifSegment ( bArr3 , 0 ) ;
setThumbnailData ( new ByteOrderedDataInputStream ( bArr3 ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
2022-01-13 08:07:50 +00:00
throw new IOException ( " Failed to read given length for given PNG chunk type: " + ExifInterfaceUtils . byteArrayToHexString ( bArr2 ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( readInt2 % 2 = = 1 ) {
readInt2 + + ;
}
2022-01-13 08:07:50 +00:00
length = i + readInt2 ;
if ( length ! = readInt ) {
if ( length < = readInt ) {
byteOrderedDataInputStream . skipFully ( readInt2 ) ;
2021-07-24 02:37:17 +00:00
} else {
throw new IOException ( " Encountered WebP file with invalid chunk size " ) ;
}
} else {
return ;
}
} else {
throw new IOException ( " Encountered invalid length while parsing WebP chunktype " ) ;
}
} catch ( EOFException unused ) {
throw new IOException ( " Encountered corrupt WebP file. " ) ;
}
}
}
private static Pair < Integer , Integer > guessDataFormat ( String str ) {
if ( str . contains ( " , " ) ) {
String [ ] split = str . split ( " , " , - 1 ) ;
Pair < Integer , Integer > guessDataFormat = guessDataFormat ( split [ 0 ] ) ;
if ( ( ( Integer ) guessDataFormat . first ) . intValue ( ) = = 2 ) {
return guessDataFormat ;
}
for ( int i = 1 ; i < split . length ; i + + ) {
Pair < Integer , Integer > guessDataFormat2 = guessDataFormat ( split [ i ] ) ;
int intValue = ( ( ( Integer ) guessDataFormat2 . first ) . equals ( guessDataFormat . first ) | | ( ( Integer ) guessDataFormat2 . second ) . equals ( guessDataFormat . first ) ) ? ( ( Integer ) guessDataFormat . first ) . intValue ( ) : - 1 ;
int intValue2 = ( ( ( Integer ) guessDataFormat . second ) . intValue ( ) = = - 1 | | ( ! ( ( Integer ) guessDataFormat2 . first ) . equals ( guessDataFormat . second ) & & ! ( ( Integer ) guessDataFormat2 . second ) . equals ( guessDataFormat . second ) ) ) ? - 1 : ( ( Integer ) guessDataFormat . second ) . intValue ( ) ;
if ( intValue = = - 1 & & intValue2 = = - 1 ) {
return new Pair < > ( 2 , - 1 ) ;
}
if ( intValue = = - 1 ) {
guessDataFormat = new Pair < > ( Integer . valueOf ( intValue2 ) , - 1 ) ;
} else if ( intValue2 = = - 1 ) {
guessDataFormat = new Pair < > ( Integer . valueOf ( intValue ) , - 1 ) ;
}
}
return guessDataFormat ;
2021-08-09 22:51:56 +00:00
} else if ( str . contains ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN ) ) {
String [ ] split2 = str . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , - 1 ) ;
2021-07-24 02:37:17 +00:00
if ( split2 . length = = 2 ) {
try {
long parseDouble = ( long ) Double . parseDouble ( split2 [ 0 ] ) ;
long parseDouble2 = ( long ) Double . parseDouble ( split2 [ 1 ] ) ;
2022-03-07 09:34:54 +00:00
if ( parseDouble > = 0 & & parseDouble2 > = 0 ) {
if ( parseDouble < = 2147483647L & & parseDouble2 < = 2147483647L ) {
return new Pair < > ( 10 , 5 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
return new Pair < > ( 5 , - 1 ) ;
2021-07-24 02:37:17 +00:00
}
return new Pair < > ( 10 , - 1 ) ;
} catch ( NumberFormatException unused ) {
}
}
return new Pair < > ( 2 , - 1 ) ;
} else {
try {
try {
2022-03-07 09:34:54 +00:00
Long valueOf = Long . valueOf ( Long . parseLong ( str ) ) ;
return ( valueOf . longValue ( ) < 0 | | valueOf . longValue ( ) > 65535 ) ? valueOf . longValue ( ) < 0 ? new Pair < > ( 9 , - 1 ) : new Pair < > ( 4 , - 1 ) : new Pair < > ( 3 , 4 ) ;
} catch ( NumberFormatException unused2 ) {
2021-07-24 02:37:17 +00:00
return new Pair < > ( 2 , - 1 ) ;
}
2022-03-07 09:34:54 +00:00
} catch ( NumberFormatException unused3 ) {
Double . parseDouble ( str ) ;
return new Pair < > ( 12 , - 1 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
private void handleThumbnailFromJfif ( ByteOrderedDataInputStream byteOrderedDataInputStream , HashMap hashMap ) throws IOException {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = ( ExifAttribute ) hashMap . get ( TAG_JPEG_INTERCHANGE_FORMAT ) ;
ExifAttribute exifAttribute2 = ( ExifAttribute ) hashMap . get ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute ! = null & & exifAttribute2 ! = null ) {
int intValue = exifAttribute . getIntValue ( this . mExifByteOrder ) ;
int intValue2 = exifAttribute2 . getIntValue ( this . mExifByteOrder ) ;
if ( this . mMimeType = = 7 ) {
intValue + = this . mOrfMakerNoteOffset ;
}
2022-01-13 08:07:50 +00:00
if ( intValue > 0 & & intValue2 > 0 ) {
2021-07-24 02:37:17 +00:00
this . mHasThumbnail = true ;
if ( this . mFilename = = null & & this . mAssetInputStream = = null & & this . mSeekableFileDescriptor = = null ) {
2022-01-13 08:07:50 +00:00
byte [ ] bArr = new byte [ intValue2 ] ;
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream . skip ( intValue ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataInputStream . read ( bArr ) ;
this . mThumbnailBytes = bArr ;
}
this . mThumbnailOffset = intValue ;
2022-01-13 08:07:50 +00:00
this . mThumbnailLength = intValue2 ;
2021-07-24 02:37:17 +00:00
}
if ( DEBUG ) {
2022-01-13 08:07:50 +00:00
Log . d ( TAG , " Setting thumbnail attributes with offset: " + intValue + " , length: " + intValue2 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
private void handleThumbnailFromStrips ( ByteOrderedDataInputStream byteOrderedDataInputStream , HashMap hashMap ) throws IOException {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = ( ExifAttribute ) hashMap . get ( TAG_STRIP_OFFSETS ) ;
ExifAttribute exifAttribute2 = ( ExifAttribute ) hashMap . get ( TAG_STRIP_BYTE_COUNTS ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute ! = null & & exifAttribute2 ! = null ) {
2022-01-13 08:07:50 +00:00
long [ ] convertToLongArray = ExifInterfaceUtils . convertToLongArray ( exifAttribute . getValue ( this . mExifByteOrder ) ) ;
long [ ] convertToLongArray2 = ExifInterfaceUtils . convertToLongArray ( exifAttribute2 . getValue ( this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
if ( convertToLongArray = = null | | convertToLongArray . length = = 0 ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " stripOffsets should not be null or have zero length. " ) ;
2021-07-24 02:37:17 +00:00
} else if ( convertToLongArray2 = = null | | convertToLongArray2 . length = = 0 ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " stripByteCounts should not be null or have zero length. " ) ;
2021-07-24 02:37:17 +00:00
} else if ( convertToLongArray . length ! = convertToLongArray2 . length ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " stripOffsets and stripByteCounts should have same length. " ) ;
2021-07-24 02:37:17 +00:00
} else {
long j = 0 ;
for ( long j2 : convertToLongArray2 ) {
j + = j2 ;
}
int i = ( int ) j ;
byte [ ] bArr = new byte [ i ] ;
int i2 = 1 ;
this . mAreThumbnailStripsConsecutive = true ;
this . mHasThumbnailStrips = true ;
this . mHasThumbnail = true ;
int i3 = 0 ;
int i4 = 0 ;
int i5 = 0 ;
while ( i3 < convertToLongArray . length ) {
int i6 = ( int ) convertToLongArray [ i3 ] ;
int i7 = ( int ) convertToLongArray2 [ i3 ] ;
2022-03-07 09:34:54 +00:00
if ( i3 < convertToLongArray . length - i2 & & i6 + i7 ! = convertToLongArray [ i3 + 1 ] ) {
2021-07-24 02:37:17 +00:00
this . mAreThumbnailStripsConsecutive = false ;
}
int i8 = i6 - i4 ;
if ( i8 < 0 ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Invalid strip offset value " ) ;
2021-07-24 02:37:17 +00:00
return ;
}
2022-03-07 09:34:54 +00:00
long j3 = i8 ;
2021-07-24 02:37:17 +00:00
if ( byteOrderedDataInputStream . skip ( j3 ) ! = j3 ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Failed to skip " + i8 + " bytes. " ) ;
2021-07-24 02:37:17 +00:00
return ;
}
int i9 = i4 + i8 ;
byte [ ] bArr2 = new byte [ i7 ] ;
if ( byteOrderedDataInputStream . read ( bArr2 ) ! = i7 ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Failed to read " + i7 + " bytes. " ) ;
2021-07-24 02:37:17 +00:00
return ;
}
i4 = i9 + i7 ;
System . arraycopy ( bArr2 , 0 , bArr , i5 , i7 ) ;
i5 + = i7 ;
i3 + + ;
i2 = 1 ;
}
this . mThumbnailBytes = bArr ;
if ( this . mAreThumbnailStripsConsecutive ) {
this . mThumbnailOffset = ( int ) convertToLongArray [ 0 ] ;
this . mThumbnailLength = i ;
}
}
}
}
private void initForFilename ( String str ) throws IOException {
Throwable th ;
Objects . requireNonNull ( str , " filename cannot be null " ) ;
FileInputStream fileInputStream = null ;
this . mAssetInputStream = null ;
this . mFilename = str ;
try {
FileInputStream fileInputStream2 = new FileInputStream ( str ) ;
try {
if ( isSeekableFD ( fileInputStream2 . getFD ( ) ) ) {
this . mSeekableFileDescriptor = fileInputStream2 . getFD ( ) ;
} else {
this . mSeekableFileDescriptor = null ;
}
loadAttributes ( fileInputStream2 ) ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream2 ) ;
2021-07-24 02:37:17 +00:00
} catch ( Throwable th2 ) {
th = th2 ;
fileInputStream = fileInputStream2 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
2021-07-24 02:37:17 +00:00
throw th ;
}
} catch ( Throwable th3 ) {
th = th3 ;
}
}
private static boolean isExifDataOnly ( BufferedInputStream bufferedInputStream ) throws IOException {
byte [ ] bArr = IDENTIFIER_EXIF_APP1 ;
bufferedInputStream . mark ( bArr . length ) ;
byte [ ] bArr2 = new byte [ bArr . length ] ;
bufferedInputStream . read ( bArr2 ) ;
bufferedInputStream . reset ( ) ;
2022-03-07 09:34:54 +00:00
int i = 0 ;
while ( true ) {
byte [ ] bArr3 = IDENTIFIER_EXIF_APP1 ;
if ( i > = bArr3 . length ) {
return true ;
}
if ( bArr2 [ i ] ! = bArr3 [ i ] ) {
2021-07-24 02:37:17 +00:00
return false ;
2022-03-07 09:34:54 +00:00
}
i + + ;
}
}
private boolean isHeifFormat ( byte [ ] bArr ) throws IOException {
Throwable th ;
Exception e ;
ByteOrderedDataInputStream byteOrderedDataInputStream ;
long readInt ;
byte [ ] bArr2 ;
ByteOrderedDataInputStream byteOrderedDataInputStream2 = null ;
try {
try {
byteOrderedDataInputStream = new ByteOrderedDataInputStream ( bArr ) ;
2021-07-24 02:37:17 +00:00
} catch ( Exception e2 ) {
e = e2 ;
}
2022-03-07 09:34:54 +00:00
} catch ( Throwable th2 ) {
th = th2 ;
}
try {
readInt = byteOrderedDataInputStream . readInt ( ) ;
bArr2 = new byte [ 4 ] ;
byteOrderedDataInputStream . read ( bArr2 ) ;
2021-07-24 02:37:17 +00:00
} catch ( Exception e3 ) {
e = e3 ;
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream2 = byteOrderedDataInputStream ;
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Exception parsing HEIF file type box. " , e ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
if ( byteOrderedDataInputStream2 ! = null ) {
byteOrderedDataInputStream2 . close ( ) ;
}
return false ;
} catch ( Throwable th3 ) {
th = th3 ;
byteOrderedDataInputStream2 = byteOrderedDataInputStream ;
if ( byteOrderedDataInputStream2 ! = null ) {
byteOrderedDataInputStream2 . close ( ) ;
}
throw th ;
}
if ( ! Arrays . equals ( bArr2 , HEIF_TYPE_FTYP ) ) {
byteOrderedDataInputStream . close ( ) ;
return false ;
}
long j = 16 ;
if ( readInt = = 1 ) {
readInt = byteOrderedDataInputStream . readLong ( ) ;
if ( readInt < 16 ) {
2021-07-24 02:37:17 +00:00
byteOrderedDataInputStream . close ( ) ;
2022-03-07 09:34:54 +00:00
return false ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} else {
j = 8 ;
}
if ( readInt > bArr . length ) {
readInt = bArr . length ;
}
long j2 = readInt - j ;
if ( j2 < 8 ) {
byteOrderedDataInputStream . close ( ) ;
2021-07-24 02:37:17 +00:00
return false ;
}
2022-03-07 09:34:54 +00:00
byte [ ] bArr3 = new byte [ 4 ] ;
boolean z2 = false ;
boolean z3 = false ;
for ( long j3 = 0 ; j3 < j2 / 4 ; j3 + + ) {
if ( byteOrderedDataInputStream . read ( bArr3 ) ! = 4 ) {
byteOrderedDataInputStream . close ( ) ;
return false ;
}
if ( j3 ! = 1 ) {
if ( Arrays . equals ( bArr3 , HEIF_BRAND_MIF1 ) ) {
z2 = true ;
} else if ( Arrays . equals ( bArr3 , HEIF_BRAND_HEIC ) ) {
z3 = true ;
}
if ( z2 & & z3 ) {
byteOrderedDataInputStream . close ( ) ;
return true ;
}
}
}
byteOrderedDataInputStream . close ( ) ;
return false ;
2021-07-24 02:37:17 +00:00
}
private static boolean isJpegFormat ( byte [ ] bArr ) throws IOException {
int i = 0 ;
while ( true ) {
byte [ ] bArr2 = JPEG_SIGNATURE ;
if ( i > = bArr2 . length ) {
return true ;
}
if ( bArr [ i ] ! = bArr2 [ i ] ) {
return false ;
}
i + + ;
}
}
private boolean isOrfFormat ( byte [ ] bArr ) throws IOException {
Throwable th ;
boolean z2 = false ;
ByteOrderedDataInputStream byteOrderedDataInputStream = null ;
try {
ByteOrderedDataInputStream byteOrderedDataInputStream2 = new ByteOrderedDataInputStream ( bArr ) ;
try {
ByteOrder readByteOrder = readByteOrder ( byteOrderedDataInputStream2 ) ;
this . mExifByteOrder = readByteOrder ;
byteOrderedDataInputStream2 . setByteOrder ( readByteOrder ) ;
short readShort = byteOrderedDataInputStream2 . readShort ( ) ;
if ( readShort = = 20306 | | readShort = = 21330 ) {
z2 = true ;
}
byteOrderedDataInputStream2 . close ( ) ;
return z2 ;
} catch ( Exception unused ) {
byteOrderedDataInputStream = byteOrderedDataInputStream2 ;
if ( byteOrderedDataInputStream ! = null ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream . close ( ) ;
2021-07-24 02:37:17 +00:00
}
return false ;
} catch ( Throwable th2 ) {
th = th2 ;
byteOrderedDataInputStream = byteOrderedDataInputStream2 ;
if ( byteOrderedDataInputStream ! = null ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream . close ( ) ;
2021-07-24 02:37:17 +00:00
}
throw th ;
}
} catch ( Exception unused2 ) {
} catch ( Throwable th3 ) {
th = th3 ;
}
}
private boolean isPngFormat ( byte [ ] bArr ) throws IOException {
int i = 0 ;
while ( true ) {
byte [ ] bArr2 = PNG_SIGNATURE ;
if ( i > = bArr2 . length ) {
return true ;
}
if ( bArr [ i ] ! = bArr2 [ i ] ) {
return false ;
}
i + + ;
}
}
private boolean isRafFormat ( byte [ ] bArr ) throws IOException {
2021-08-09 22:51:56 +00:00
byte [ ] bytes = RAF_SIGNATURE . getBytes ( Charset . defaultCharset ( ) ) ;
2021-07-24 02:37:17 +00:00
for ( int i = 0 ; i < bytes . length ; i + + ) {
if ( bArr [ i ] ! = bytes [ i ] ) {
return false ;
}
}
return true ;
}
private boolean isRw2Format ( byte [ ] bArr ) throws IOException {
Throwable th ;
boolean z2 = false ;
ByteOrderedDataInputStream byteOrderedDataInputStream = null ;
try {
ByteOrderedDataInputStream byteOrderedDataInputStream2 = new ByteOrderedDataInputStream ( bArr ) ;
try {
ByteOrder readByteOrder = readByteOrder ( byteOrderedDataInputStream2 ) ;
this . mExifByteOrder = readByteOrder ;
byteOrderedDataInputStream2 . setByteOrder ( readByteOrder ) ;
if ( byteOrderedDataInputStream2 . readShort ( ) = = 85 ) {
z2 = true ;
}
byteOrderedDataInputStream2 . close ( ) ;
return z2 ;
} catch ( Exception unused ) {
byteOrderedDataInputStream = byteOrderedDataInputStream2 ;
if ( byteOrderedDataInputStream ! = null ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream . close ( ) ;
2021-07-24 02:37:17 +00:00
}
return false ;
} catch ( Throwable th2 ) {
th = th2 ;
byteOrderedDataInputStream = byteOrderedDataInputStream2 ;
if ( byteOrderedDataInputStream ! = null ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataInputStream . close ( ) ;
2021-07-24 02:37:17 +00:00
}
throw th ;
}
} catch ( Exception unused2 ) {
} catch ( Throwable th3 ) {
th = th3 ;
}
}
private static boolean isSeekableFD ( FileDescriptor fileDescriptor ) {
try {
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . Api21Impl . lseek ( fileDescriptor , 0L , OsConstants . SEEK_CUR ) ;
2021-07-24 02:37:17 +00:00
return true ;
} catch ( Exception unused ) {
if ( ! DEBUG ) {
return false ;
}
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " The file descriptor for the given input is not seekable " ) ;
2021-07-24 02:37:17 +00:00
return false ;
}
}
private boolean isSupportedDataType ( HashMap hashMap ) throws IOException {
ExifAttribute exifAttribute ;
int intValue ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute2 = ( ExifAttribute ) hashMap . get ( TAG_BITS_PER_SAMPLE ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute2 ! = null ) {
int [ ] iArr = ( int [ ] ) exifAttribute2 . getValue ( this . mExifByteOrder ) ;
int [ ] iArr2 = BITS_PER_SAMPLE_RGB ;
if ( Arrays . equals ( iArr2 , iArr ) ) {
return true ;
}
2021-08-09 22:51:56 +00:00
if ( this . mMimeType = = 3 & & ( exifAttribute = ( ExifAttribute ) hashMap . get ( TAG_PHOTOMETRIC_INTERPRETATION ) ) ! = null & & ( ( ( intValue = exifAttribute . getIntValue ( this . mExifByteOrder ) ) = = 1 & & Arrays . equals ( iArr , BITS_PER_SAMPLE_GREYSCALE_2 ) ) | | ( intValue = = 6 & & Arrays . equals ( iArr , iArr2 ) ) ) ) {
2021-07-24 02:37:17 +00:00
return true ;
}
}
if ( ! DEBUG ) {
return false ;
}
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Unsupported data type value " ) ;
2021-07-24 02:37:17 +00:00
return false ;
}
2022-01-13 08:07:50 +00:00
private static boolean isSupportedFormatForSavingAttributes ( int i ) {
return i = = 4 | | i = = 13 | | i = = 14 | | i = = 3 | | i = = 0 ;
2021-07-24 02:37:17 +00:00
}
public static boolean isSupportedMimeType ( @NonNull String str ) {
Objects . requireNonNull ( str , " mimeType shouldn't be null " ) ;
String lowerCase = str . toLowerCase ( Locale . ROOT ) ;
lowerCase . hashCode ( ) ;
2021-12-17 21:59:34 +00:00
char c = 65535 ;
2021-07-24 02:37:17 +00:00
switch ( lowerCase . hashCode ( ) ) {
case - 1875291391 :
if ( lowerCase . equals ( " image/x-fuji-raf " ) ) {
2021-12-17 21:59:34 +00:00
c = 0 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1635437028 :
if ( lowerCase . equals ( " image/x-samsung-srw " ) ) {
2021-12-17 21:59:34 +00:00
c = 1 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1594371159 :
if ( lowerCase . equals ( " image/x-sony-arw " ) ) {
2021-12-17 21:59:34 +00:00
c = 2 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1487464693 :
if ( lowerCase . equals ( " image/heic " ) ) {
2021-12-17 21:59:34 +00:00
c = 3 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1487464690 :
if ( lowerCase . equals ( " image/heif " ) ) {
2021-12-17 21:59:34 +00:00
c = 4 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1487394660 :
if ( lowerCase . equals ( " image/jpeg " ) ) {
2021-12-17 21:59:34 +00:00
c = 5 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1487018032 :
if ( lowerCase . equals ( " image/webp " ) ) {
2021-12-17 21:59:34 +00:00
c = 6 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 1423313290 :
if ( lowerCase . equals ( " image/x-adobe-dng " ) ) {
2021-12-17 21:59:34 +00:00
c = 7 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 985160897 :
if ( lowerCase . equals ( " image/x-panasonic-rw2 " ) ) {
2021-12-17 21:59:34 +00:00
c = '\b' ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 879258763 :
if ( lowerCase . equals ( " image/png " ) ) {
2021-12-17 21:59:34 +00:00
c = '\t' ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case - 332763809 :
if ( lowerCase . equals ( " image/x-pentax-pef " ) ) {
2021-12-17 21:59:34 +00:00
c = '\n' ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case 1378106698 :
if ( lowerCase . equals ( " image/x-olympus-orf " ) ) {
2021-12-17 21:59:34 +00:00
c = 11 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case 2099152104 :
if ( lowerCase . equals ( " image/x-nikon-nef " ) ) {
2021-12-17 21:59:34 +00:00
c = '\f' ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case 2099152524 :
if ( lowerCase . equals ( " image/x-nikon-nrw " ) ) {
2021-12-17 21:59:34 +00:00
c = '\r' ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
case 2111234748 :
if ( lowerCase . equals ( " image/x-canon-cr2 " ) ) {
2021-12-17 21:59:34 +00:00
c = 14 ;
2021-07-24 02:37:17 +00:00
break ;
}
break ;
}
2021-12-17 21:59:34 +00:00
switch ( c ) {
2021-07-24 02:37:17 +00:00
case 0 :
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case '\b' :
case '\t' :
case '\n' :
case 11 :
case '\f' :
case '\r' :
case 14 :
return true ;
default :
return false ;
}
}
private boolean isThumbnail ( HashMap hashMap ) throws IOException {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = ( ExifAttribute ) hashMap . get ( TAG_IMAGE_LENGTH ) ;
ExifAttribute exifAttribute2 = ( ExifAttribute ) hashMap . get ( TAG_IMAGE_WIDTH ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute = = null | | exifAttribute2 = = null ) {
return false ;
}
return exifAttribute . getIntValue ( this . mExifByteOrder ) < = 512 & & exifAttribute2 . getIntValue ( this . mExifByteOrder ) < = 512 ;
}
private boolean isWebpFormat ( byte [ ] bArr ) throws IOException {
int i = 0 ;
while ( true ) {
byte [ ] bArr2 = WEBP_SIGNATURE_1 ;
if ( i > = bArr2 . length ) {
int i2 = 0 ;
while ( true ) {
byte [ ] bArr3 = WEBP_SIGNATURE_2 ;
if ( i2 > = bArr3 . length ) {
return true ;
}
if ( bArr [ WEBP_SIGNATURE_1 . length + i2 + 4 ] ! = bArr3 [ i2 ] ) {
return false ;
}
i2 + + ;
}
} else if ( bArr [ i ] ! = bArr2 [ i ] ) {
return false ;
} else {
i + + ;
}
}
}
private void loadAttributes ( @NonNull InputStream inputStream ) {
Objects . requireNonNull ( inputStream , " inputstream shouldn't be null " ) ;
for ( int i = 0 ; i < EXIF_TAGS . length ; i + + ) {
try {
2022-03-07 09:34:54 +00:00
try {
this . mAttributes [ i ] = new HashMap < > ( ) ;
} finally {
addDefaultValuesForCompatibility ( ) ;
if ( DEBUG ) {
printAttributes ( ) ;
}
}
2022-01-13 08:07:50 +00:00
} catch ( IOException | UnsupportedOperationException e ) {
2021-07-24 02:37:17 +00:00
boolean z2 = DEBUG ;
if ( z2 ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " Invalid image: ExifInterface got an unsupported image format file(ExifInterface supports JPEG and some RAW image formats only) or a corrupted JPEG file to ExifInterface. " , e ) ;
2021-07-24 02:37:17 +00:00
}
addDefaultValuesForCompatibility ( ) ;
if ( ! z2 ) {
return ;
}
}
}
if ( ! this . mIsExifDataOnly ) {
2021-08-09 22:51:56 +00:00
BufferedInputStream bufferedInputStream = new BufferedInputStream ( inputStream , SIGNATURE_CHECK_SIZE ) ;
2021-07-24 02:37:17 +00:00
this . mMimeType = getMimeType ( bufferedInputStream ) ;
inputStream = bufferedInputStream ;
}
2022-01-13 08:07:50 +00:00
if ( shouldSupportSeek ( this . mMimeType ) ) {
SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream = new SeekableByteOrderedDataInputStream ( inputStream ) ;
if ( this . mIsExifDataOnly ) {
getStandaloneAttributes ( seekableByteOrderedDataInputStream ) ;
} else {
int i2 = this . mMimeType ;
if ( i2 = = 12 ) {
getHeifAttributes ( seekableByteOrderedDataInputStream ) ;
} else if ( i2 = = 7 ) {
getOrfAttributes ( seekableByteOrderedDataInputStream ) ;
} else if ( i2 = = 10 ) {
getRw2Attributes ( seekableByteOrderedDataInputStream ) ;
} else {
getRawAttributes ( seekableByteOrderedDataInputStream ) ;
}
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream . seek ( this . mOffsetToExifData ) ;
2022-01-13 08:07:50 +00:00
setThumbnailData ( seekableByteOrderedDataInputStream ) ;
2021-07-24 02:37:17 +00:00
} else {
2022-01-13 08:07:50 +00:00
ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream ( inputStream ) ;
int i3 = this . mMimeType ;
if ( i3 = = 4 ) {
getJpegAttributes ( byteOrderedDataInputStream , 0 , 0 ) ;
} else if ( i3 = = 13 ) {
getPngAttributes ( byteOrderedDataInputStream ) ;
} else if ( i3 = = 9 ) {
getRafAttributes ( byteOrderedDataInputStream ) ;
} else if ( i3 = = 14 ) {
getWebpAttributes ( byteOrderedDataInputStream ) ;
}
2021-07-24 02:37:17 +00:00
}
}
private static Long parseDateTime ( @Nullable String str , @Nullable String str2 , @Nullable String str3 ) {
if ( str ! = null & & NON_ZERO_TIME_PATTERN . matcher ( str ) . matches ( ) ) {
ParsePosition parsePosition = new ParsePosition ( 0 ) ;
try {
Date parse = sFormatterPrimary . parse ( str , parsePosition ) ;
if ( parse = = null & & ( parse = sFormatterSecondary . parse ( str , parsePosition ) ) = = null ) {
return null ;
}
long time = parse . getTime ( ) ;
if ( str3 ! = null ) {
int i = 1 ;
String substring = str3 . substring ( 0 , 1 ) ;
int parseInt = Integer . parseInt ( str3 . substring ( 1 , 3 ) ) ;
int parseInt2 = Integer . parseInt ( str3 . substring ( 4 , 6 ) ) ;
2021-08-09 22:51:56 +00:00
if ( ( BadgeDrawable . DEFAULT_EXCEED_MAX_BADGE_NUMBER_SUFFIX . equals ( substring ) | | " - " . equals ( substring ) ) & & " : " . equals ( str3 . substring ( 3 , 4 ) ) & & parseInt < = 14 ) {
2021-07-24 02:37:17 +00:00
int i2 = ( ( parseInt * 60 ) + parseInt2 ) * 60 * 1000 ;
if ( ! " - " . equals ( substring ) ) {
i = - 1 ;
}
2022-03-07 09:34:54 +00:00
time + = i2 * i ;
2021-07-24 02:37:17 +00:00
}
}
if ( str2 ! = null ) {
2022-01-13 08:07:50 +00:00
time + = ExifInterfaceUtils . parseSubSeconds ( str2 ) ;
2021-07-24 02:37:17 +00:00
}
return Long . valueOf ( time ) ;
2022-01-13 08:07:50 +00:00
} catch ( IllegalArgumentException unused ) {
2021-07-24 02:37:17 +00:00
}
}
return null ;
}
2022-01-13 08:07:50 +00:00
private void parseTiffHeaders ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
2021-07-24 02:37:17 +00:00
ByteOrder readByteOrder = readByteOrder ( byteOrderedDataInputStream ) ;
this . mExifByteOrder = readByteOrder ;
byteOrderedDataInputStream . setByteOrder ( readByteOrder ) ;
int readUnsignedShort = byteOrderedDataInputStream . readUnsignedShort ( ) ;
2022-01-13 08:07:50 +00:00
int i = this . mMimeType ;
if ( i = = 7 | | i = = 10 | | readUnsignedShort = = 42 ) {
2021-07-24 02:37:17 +00:00
int readInt = byteOrderedDataInputStream . readInt ( ) ;
2022-01-13 08:07:50 +00:00
if ( readInt > = 8 ) {
int i2 = readInt - 8 ;
if ( i2 > 0 ) {
byteOrderedDataInputStream . skipFully ( i2 ) ;
return ;
}
return ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
throw new IOException ( a . p ( " Invalid first Ifd offset: " , readInt ) ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid start code: " ) ;
R . append ( Integer . toHexString ( readUnsignedShort ) ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
private void printAttributes ( ) {
for ( int i = 0 ; i < this . mAttributes . length ; i + + ) {
2022-03-21 18:52:30 +00:00
StringBuilder S = a . S ( " The size of tag group[ " , i , " ]: " ) ;
S . append ( this . mAttributes [ i ] . size ( ) ) ;
Log . d ( TAG , S . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
for ( Map . Entry < String , ExifAttribute > entry : this . mAttributes [ i ] . entrySet ( ) ) {
ExifAttribute value = entry . getValue ( ) ;
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " tagName: " ) ;
R . append ( entry . getKey ( ) ) ;
R . append ( " , tagType: " ) ;
R . append ( value . toString ( ) ) ;
R . append ( " , tagValue: ' " ) ;
R . append ( value . getStringValue ( this . mExifByteOrder ) ) ;
R . append ( " ' " ) ;
Log . d ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}
private ByteOrder readByteOrder ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
short readShort = byteOrderedDataInputStream . readShort ( ) ;
if ( readShort = = 18761 ) {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " readExifSegment: Byte Align II " ) ;
2021-07-24 02:37:17 +00:00
}
return ByteOrder . LITTLE_ENDIAN ;
} else if ( readShort = = 19789 ) {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " readExifSegment: Byte Align MM " ) ;
2021-07-24 02:37:17 +00:00
}
return ByteOrder . BIG_ENDIAN ;
} else {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid byte order: " ) ;
R . append ( Integer . toHexString ( readShort ) ) ;
throw new IOException ( R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
private void readExifSegment ( byte [ ] bArr , int i ) throws IOException {
2022-01-13 08:07:50 +00:00
SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream = new SeekableByteOrderedDataInputStream ( bArr ) ;
parseTiffHeaders ( seekableByteOrderedDataInputStream ) ;
readImageFileDirectory ( seekableByteOrderedDataInputStream , i ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Removed duplicated region for block: B:44:0x00f5 */
/* JADX WARN: Removed duplicated region for block: B:45:0x00fa */
/* JADX WARN: Removed duplicated region for block: B:83:0x01cc */
/* JADX WARN: Removed duplicated region for block: B:86:0x01ea */
/* JADX WARN: Removed duplicated region for block: B:91:0x0226 */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2022-01-13 08:07:50 +00:00
private void readImageFileDirectory ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream , int i ) throws IOException {
2021-07-24 02:37:17 +00:00
short s2 ;
boolean z2 ;
long j ;
int i2 ;
2022-01-13 08:07:50 +00:00
long j2 ;
2021-07-24 02:37:17 +00:00
int i3 ;
2022-03-07 09:34:54 +00:00
int [ ] iArr ;
2022-01-13 08:07:50 +00:00
int i4 = i ;
this . mAttributesOffsets . add ( Integer . valueOf ( seekableByteOrderedDataInputStream . mPosition ) ) ;
short readShort = seekableByteOrderedDataInputStream . readShort ( ) ;
if ( DEBUG ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " numberOfDirectoryEntry: " , readShort , TAG ) ;
2022-01-13 08:07:50 +00:00
}
if ( readShort > 0 ) {
char c = 0 ;
2022-03-07 09:34:54 +00:00
short s3 = 0 ;
while ( s3 < readShort ) {
2022-01-13 08:07:50 +00:00
int readUnsignedShort = seekableByteOrderedDataInputStream . readUnsignedShort ( ) ;
int readUnsignedShort2 = seekableByteOrderedDataInputStream . readUnsignedShort ( ) ;
int readInt = seekableByteOrderedDataInputStream . readInt ( ) ;
2022-03-07 09:34:54 +00:00
long position = seekableByteOrderedDataInputStream . position ( ) + 4 ;
2022-01-13 08:07:50 +00:00
ExifTag exifTag = sExifTagMapsForReading [ i4 ] . get ( Integer . valueOf ( readUnsignedShort ) ) ;
boolean z3 = DEBUG ;
if ( z3 ) {
Object [ ] objArr = new Object [ 5 ] ;
objArr [ c ] = Integer . valueOf ( i ) ;
objArr [ 1 ] = Integer . valueOf ( readUnsignedShort ) ;
objArr [ 2 ] = exifTag ! = null ? exifTag . name : null ;
objArr [ 3 ] = Integer . valueOf ( readUnsignedShort2 ) ;
objArr [ 4 ] = Integer . valueOf ( readInt ) ;
Log . d ( TAG , String . format ( " ifdType: %d, tagNumber: %d, tagName: %s, dataFormat: %d, numberOfComponents: %d " , objArr ) ) ;
}
if ( exifTag ! = null ) {
if ( readUnsignedShort2 > 0 ) {
2022-03-07 09:34:54 +00:00
if ( readUnsignedShort2 < IFD_FORMAT_BYTES_PER_FORMAT . length ) {
2022-01-13 08:07:50 +00:00
if ( exifTag . isFormatCompatible ( readUnsignedShort2 ) ) {
if ( readUnsignedShort2 = = 7 ) {
readUnsignedShort2 = exifTag . primaryFormat ;
}
2022-03-07 09:34:54 +00:00
readShort = readShort ;
s2 = s3 ;
j = readInt * iArr [ readUnsignedShort2 ] ;
2022-01-13 08:07:50 +00:00
if ( j < 0 | | j > 2147483647L ) {
if ( z3 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Skip the tag entry since the number of components is invalid: " , readInt , TAG ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
z2 = false ;
if ( z2 ) {
seekableByteOrderedDataInputStream . seek ( position ) ;
} else {
if ( j > 4 ) {
int readInt2 = seekableByteOrderedDataInputStream . readInt ( ) ;
if ( z3 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " seek to data offset: " , readInt2 , TAG ) ;
2022-01-13 08:07:50 +00:00
}
j2 = position ;
if ( this . mMimeType = = 7 ) {
if ( TAG_MAKER_NOTE . equals ( exifTag . name ) ) {
this . mOrfMakerNoteOffset = readInt2 ;
} else if ( i4 = = 6 & & TAG_ORF_THUMBNAIL_IMAGE . equals ( exifTag . name ) ) {
this . mOrfThumbnailOffset = readInt2 ;
this . mOrfThumbnailLength = readInt ;
ExifAttribute createUShort = ExifAttribute . createUShort ( 6 , this . mExifByteOrder ) ;
2022-03-07 09:34:54 +00:00
ExifAttribute createULong = ExifAttribute . createULong ( this . mOrfThumbnailOffset , this . mExifByteOrder ) ;
2022-01-13 08:07:50 +00:00
i2 = readInt ;
2022-03-07 09:34:54 +00:00
ExifAttribute createULong2 = ExifAttribute . createULong ( this . mOrfThumbnailLength , this . mExifByteOrder ) ;
2022-01-13 08:07:50 +00:00
this . mAttributes [ 4 ] . put ( TAG_COMPRESSION , createUShort ) ;
this . mAttributes [ 4 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT , createULong ) ;
this . mAttributes [ 4 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH , createULong2 ) ;
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream . seek ( readInt2 ) ;
2022-01-13 08:07:50 +00:00
}
}
i2 = readInt ;
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream . seek ( readInt2 ) ;
2022-01-13 08:07:50 +00:00
} else {
j2 = position ;
i2 = readInt ;
}
Integer num = sExifPointerTagMap . get ( Integer . valueOf ( readUnsignedShort ) ) ;
2021-07-24 02:37:17 +00:00
if ( z3 ) {
2022-01-13 08:07:50 +00:00
Log . d ( TAG , " nextIfdType: " + num + " byteCount: " + j ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
if ( num ! = null ) {
long j3 = - 1 ;
if ( readUnsignedShort2 ! = 3 ) {
if ( readUnsignedShort2 = = 4 ) {
j3 = seekableByteOrderedDataInputStream . readUnsignedInt ( ) ;
} else if ( readUnsignedShort2 = = 8 ) {
i3 = seekableByteOrderedDataInputStream . readShort ( ) ;
} else if ( readUnsignedShort2 = = 9 | | readUnsignedShort2 = = 13 ) {
i3 = seekableByteOrderedDataInputStream . readInt ( ) ;
}
2021-07-24 02:37:17 +00:00
if ( z3 ) {
2022-01-13 08:07:50 +00:00
Log . d ( TAG , String . format ( " Offset: %d, tagName: %s " , Long . valueOf ( j3 ) , exifTag . name ) ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
if ( j3 < = 0 ) {
if ( ! this . mAttributesOffsets . contains ( Integer . valueOf ( ( int ) j3 ) ) ) {
seekableByteOrderedDataInputStream . seek ( j3 ) ;
readImageFileDirectory ( seekableByteOrderedDataInputStream , num . intValue ( ) ) ;
} else if ( z3 ) {
Log . d ( TAG , " Skip jump into the IFD since it has already been read: IfdType " + num + " (at " + j3 + " ) " ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
} else if ( z3 ) {
Log . d ( TAG , " Skip jump into the IFD since its offset is invalid: " + j3 ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream . seek ( j2 ) ;
2021-07-24 02:37:17 +00:00
} else {
2022-01-13 08:07:50 +00:00
i3 = seekableByteOrderedDataInputStream . readUnsignedShort ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
j3 = i3 ;
2021-07-24 02:37:17 +00:00
if ( z3 ) {
}
2022-01-13 08:07:50 +00:00
if ( j3 < = 0 ) {
}
seekableByteOrderedDataInputStream . seek ( j2 ) ;
} else {
2022-03-07 09:34:54 +00:00
byte [ ] bArr = new byte [ ( int ) j ] ;
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream . readFully ( bArr ) ;
2022-03-07 09:34:54 +00:00
ExifAttribute exifAttribute = new ExifAttribute ( readUnsignedShort2 , i2 , seekableByteOrderedDataInputStream . position ( ) + this . mOffsetToExifData , bArr ) ;
2022-01-13 08:07:50 +00:00
this . mAttributes [ i ] . put ( exifTag . name , exifAttribute ) ;
if ( TAG_DNG_VERSION . equals ( exifTag . name ) ) {
this . mMimeType = 3 ;
}
if ( ( ( TAG_MAKE . equals ( exifTag . name ) | | TAG_MODEL . equals ( exifTag . name ) ) & & exifAttribute . getStringValue ( this . mExifByteOrder ) . contains ( PEF_SIGNATURE ) ) | | ( TAG_COMPRESSION . equals ( exifTag . name ) & & exifAttribute . getIntValue ( this . mExifByteOrder ) = = 65535 ) ) {
this . mMimeType = 8 ;
}
2022-03-07 09:34:54 +00:00
if ( seekableByteOrderedDataInputStream . position ( ) ! = j2 ) {
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream . seek ( j2 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
2022-03-07 09:34:54 +00:00
s3 = ( short ) ( s2 + 1 ) ;
2022-01-13 08:07:50 +00:00
c = 0 ;
i4 = i ;
} else {
z2 = true ;
if ( z2 ) {
}
2022-03-07 09:34:54 +00:00
s3 = ( short ) ( s2 + 1 ) ;
2022-01-13 08:07:50 +00:00
c = 0 ;
i4 = i ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
} else if ( z3 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Skip the tag entry since data format ( " ) ;
R . append ( IFD_FORMAT_NAMES [ readUnsignedShort2 ] ) ;
R . append ( " ) is unexpected for tag: " ) ;
R . append ( exifTag . name ) ;
Log . d ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}
2022-03-07 09:34:54 +00:00
readShort = readShort ;
s2 = s3 ;
2022-01-13 08:07:50 +00:00
if ( z3 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Skip the tag entry since data format is invalid: " , readUnsignedShort2 , TAG ) ;
2022-01-13 08:07:50 +00:00
}
2021-07-24 02:37:17 +00:00
j = 0 ;
z2 = false ;
if ( z2 ) {
}
2022-03-07 09:34:54 +00:00
s3 = ( short ) ( s2 + 1 ) ;
2021-12-17 21:59:34 +00:00
c = 0 ;
2022-01-13 08:07:50 +00:00
i4 = i ;
} else if ( z3 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Skip the tag entry since tag number is not defined: " , readUnsignedShort , TAG ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
readShort = readShort ;
s2 = s3 ;
2022-01-13 08:07:50 +00:00
j = 0 ;
z2 = false ;
if ( z2 ) {
}
2022-03-07 09:34:54 +00:00
s3 = ( short ) ( s2 + 1 ) ;
2022-01-13 08:07:50 +00:00
c = 0 ;
i4 = i ;
}
int readInt3 = seekableByteOrderedDataInputStream . readInt ( ) ;
boolean z4 = DEBUG ;
if ( z4 ) {
Log . d ( TAG , String . format ( " nextIfdOffset: %d " , Integer . valueOf ( readInt3 ) ) ) ;
}
2022-03-07 09:34:54 +00:00
long j4 = readInt3 ;
2022-01-13 08:07:50 +00:00
if ( j4 > 0 ) {
if ( ! this . mAttributesOffsets . contains ( Integer . valueOf ( readInt3 ) ) ) {
seekableByteOrderedDataInputStream . seek ( j4 ) ;
if ( this . mAttributes [ 4 ] . isEmpty ( ) ) {
readImageFileDirectory ( seekableByteOrderedDataInputStream , 4 ) ;
} else if ( this . mAttributes [ 5 ] . isEmpty ( ) ) {
readImageFileDirectory ( seekableByteOrderedDataInputStream , 5 ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
} else if ( z4 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Stop reading file since re-reading an IFD may cause an infinite loop: " , readInt3 , TAG ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
} else if ( z4 ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Stop reading file since a wrong offset may cause an infinite loop: " , readInt3 , TAG ) ;
2021-07-24 02:37:17 +00:00
}
}
}
private void removeAttribute ( String str ) {
for ( int i = 0 ; i < EXIF_TAGS . length ; i + + ) {
this . mAttributes [ i ] . remove ( str ) ;
}
}
2022-01-13 08:07:50 +00:00
private void replaceInvalidTags ( int i , String str , String str2 ) {
if ( ! this . mAttributes [ i ] . isEmpty ( ) & & this . mAttributes [ i ] . get ( str ) ! = null ) {
HashMap < String , ExifAttribute > [ ] hashMapArr = this . mAttributes ;
hashMapArr [ i ] . put ( str2 , hashMapArr [ i ] . get ( str ) ) ;
this . mAttributes [ i ] . remove ( str ) ;
}
}
private void retrieveJpegImageSize ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream , int i ) throws IOException {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = this . mAttributes [ i ] . get ( TAG_IMAGE_LENGTH ) ;
ExifAttribute exifAttribute2 = this . mAttributes [ i ] . get ( TAG_IMAGE_WIDTH ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute = = null | | exifAttribute2 = = null ) {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute3 = this . mAttributes [ i ] . get ( TAG_JPEG_INTERCHANGE_FORMAT ) ;
ExifAttribute exifAttribute4 = this . mAttributes [ i ] . get ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute3 ! = null & & exifAttribute4 ! = null ) {
int intValue = exifAttribute3 . getIntValue ( this . mExifByteOrder ) ;
int intValue2 = exifAttribute3 . getIntValue ( this . mExifByteOrder ) ;
2022-03-07 09:34:54 +00:00
seekableByteOrderedDataInputStream . seek ( intValue ) ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr = new byte [ intValue2 ] ;
2022-01-13 08:07:50 +00:00
seekableByteOrderedDataInputStream . read ( bArr ) ;
2021-07-24 02:37:17 +00:00
getJpegAttributes ( new ByteOrderedDataInputStream ( bArr ) , intValue , i ) ;
}
}
}
private void saveJpegAttributes ( InputStream inputStream , OutputStream outputStream ) throws IOException {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " saveJpegAttributes starting with (inputStream: " + inputStream + " , outputStream: " + outputStream + " ) " ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream ( inputStream ) ;
2021-07-24 02:37:17 +00:00
ByteOrderedDataOutputStream byteOrderedDataOutputStream = new ByteOrderedDataOutputStream ( outputStream , ByteOrder . BIG_ENDIAN ) ;
2022-01-13 08:07:50 +00:00
if ( byteOrderedDataInputStream . readByte ( ) = = - 1 ) {
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream . writeByte ( - 1 ) ;
2022-01-13 08:07:50 +00:00
if ( byteOrderedDataInputStream . readByte ( ) = = - 40 ) {
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream . writeByte ( - 40 ) ;
ExifAttribute exifAttribute = null ;
2021-08-09 22:51:56 +00:00
if ( getAttribute ( TAG_XMP ) ! = null & & this . mXmpIsFromSeparateMarker ) {
exifAttribute = this . mAttributes [ 0 ] . remove ( TAG_XMP ) ;
2021-07-24 02:37:17 +00:00
}
byteOrderedDataOutputStream . writeByte ( - 1 ) ;
byteOrderedDataOutputStream . writeByte ( - 31 ) ;
writeExifSegment ( byteOrderedDataOutputStream ) ;
if ( exifAttribute ! = null ) {
2021-08-09 22:51:56 +00:00
this . mAttributes [ 0 ] . put ( TAG_XMP , exifAttribute ) ;
2021-07-24 02:37:17 +00:00
}
byte [ ] bArr = new byte [ 4096 ] ;
2022-01-13 08:07:50 +00:00
while ( byteOrderedDataInputStream . readByte ( ) = = - 1 ) {
byte readByte = byteOrderedDataInputStream . readByte ( ) ;
2021-07-24 02:37:17 +00:00
if ( readByte = = - 39 | | readByte = = - 38 ) {
byteOrderedDataOutputStream . writeByte ( - 1 ) ;
byteOrderedDataOutputStream . writeByte ( readByte ) ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream ) ;
2021-07-24 02:37:17 +00:00
return ;
} else if ( readByte ! = - 31 ) {
byteOrderedDataOutputStream . writeByte ( - 1 ) ;
byteOrderedDataOutputStream . writeByte ( readByte ) ;
2022-01-13 08:07:50 +00:00
int readUnsignedShort = byteOrderedDataInputStream . readUnsignedShort ( ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream . writeUnsignedShort ( readUnsignedShort ) ;
int i = readUnsignedShort - 2 ;
if ( i > = 0 ) {
while ( i > 0 ) {
2022-01-13 08:07:50 +00:00
int read = byteOrderedDataInputStream . read ( bArr , 0 , Math . min ( i , 4096 ) ) ;
2022-03-07 09:34:54 +00:00
if ( read > = 0 ) {
byteOrderedDataOutputStream . write ( bArr , 0 , read ) ;
i - = read ;
2021-07-24 02:37:17 +00:00
}
}
} else {
throw new IOException ( " Invalid length " ) ;
}
} else {
2022-01-13 08:07:50 +00:00
int readUnsignedShort2 = byteOrderedDataInputStream . readUnsignedShort ( ) - 2 ;
2021-07-24 02:37:17 +00:00
if ( readUnsignedShort2 > = 0 ) {
byte [ ] bArr2 = new byte [ 6 ] ;
if ( readUnsignedShort2 > = 6 ) {
2022-01-13 08:07:50 +00:00
if ( byteOrderedDataInputStream . read ( bArr2 ) ! = 6 ) {
2021-07-24 02:37:17 +00:00
throw new IOException ( " Invalid exif " ) ;
} else if ( Arrays . equals ( bArr2 , IDENTIFIER_EXIF_APP1 ) ) {
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( readUnsignedShort2 - 6 ) ;
2021-07-24 02:37:17 +00:00
}
}
byteOrderedDataOutputStream . writeByte ( - 1 ) ;
byteOrderedDataOutputStream . writeByte ( readByte ) ;
byteOrderedDataOutputStream . writeUnsignedShort ( readUnsignedShort2 + 2 ) ;
if ( readUnsignedShort2 > = 6 ) {
readUnsignedShort2 - = 6 ;
byteOrderedDataOutputStream . write ( bArr2 ) ;
}
while ( readUnsignedShort2 > 0 ) {
2022-01-13 08:07:50 +00:00
int read2 = byteOrderedDataInputStream . read ( bArr , 0 , Math . min ( readUnsignedShort2 , 4096 ) ) ;
2022-03-07 09:34:54 +00:00
if ( read2 > = 0 ) {
byteOrderedDataOutputStream . write ( bArr , 0 , read2 ) ;
readUnsignedShort2 - = read2 ;
2021-07-24 02:37:17 +00:00
}
}
} else {
throw new IOException ( " Invalid length " ) ;
}
}
}
throw new IOException ( " Invalid marker " ) ;
}
throw new IOException ( " Invalid marker " ) ;
}
throw new IOException ( " Invalid marker " ) ;
}
private void savePngAttributes ( InputStream inputStream , OutputStream outputStream ) throws IOException {
Throwable th ;
2022-03-07 09:34:54 +00:00
ByteArrayOutputStream byteArrayOutputStream ;
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " savePngAttributes starting with (inputStream: " + inputStream + " , outputStream: " + outputStream + " ) " ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream ( inputStream ) ;
2021-07-24 02:37:17 +00:00
ByteOrder byteOrder = ByteOrder . BIG_ENDIAN ;
ByteOrderedDataOutputStream byteOrderedDataOutputStream = new ByteOrderedDataOutputStream ( outputStream , byteOrder ) ;
byte [ ] bArr = PNG_SIGNATURE ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream , bArr . length ) ;
2021-07-24 02:37:17 +00:00
int i = this . mOffsetToExifData ;
if ( i = = 0 ) {
2022-01-13 08:07:50 +00:00
int readInt = byteOrderedDataInputStream . readInt ( ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream . writeInt ( readInt ) ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream , readInt + 4 + 4 ) ;
2021-07-24 02:37:17 +00:00
} else {
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream , ( ( i - bArr . length ) - 4 ) - 4 ) ;
byteOrderedDataInputStream . skipFully ( byteOrderedDataInputStream . readInt ( ) + 4 + 4 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
ByteArrayOutputStream byteArrayOutputStream2 = null ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
byteArrayOutputStream = new ByteArrayOutputStream ( ) ;
} catch ( Throwable th2 ) {
th = th2 ;
}
try {
ByteOrderedDataOutputStream byteOrderedDataOutputStream2 = new ByteOrderedDataOutputStream ( byteArrayOutputStream , byteOrder ) ;
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
byte [ ] byteArray = ( ( ByteArrayOutputStream ) byteOrderedDataOutputStream2 . mOutputStream ) . toByteArray ( ) ;
byteOrderedDataOutputStream . write ( byteArray ) ;
CRC32 crc32 = new CRC32 ( ) ;
crc32 . update ( byteArray , 4 , byteArray . length - 4 ) ;
byteOrderedDataOutputStream . writeInt ( ( int ) crc32 . getValue ( ) ) ;
ExifInterfaceUtils . closeQuietly ( byteArrayOutputStream ) ;
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream ) ;
2021-07-24 02:37:17 +00:00
} catch ( Throwable th3 ) {
th = th3 ;
2022-03-07 09:34:54 +00:00
byteArrayOutputStream2 = byteArrayOutputStream ;
ExifInterfaceUtils . closeQuietly ( byteArrayOutputStream2 ) ;
2021-07-24 02:37:17 +00:00
throw th ;
}
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Removed duplicated region for block: B:58:0x01ac A[Catch: all -> 0x01ee, Exception -> 0x01f1, TryCatch #4 {Exception -> 0x01f1, all -> 0x01ee, blocks: (B:7:0x004e, B:9:0x0057, B:10:0x0070, B:12:0x0078, B:14:0x0084, B:16:0x008c, B:18:0x0090, B:22:0x00a3, B:24:0x00ae, B:25:0x00b3, B:27:0x00c0, B:28:0x00c5, B:29:0x00c9, B:30:0x00d5, B:32:0x00dd, B:34:0x00e5, B:36:0x00ed, B:38:0x00f1, B:40:0x00fc, B:42:0x0107, B:44:0x010f, B:45:0x011e, B:46:0x0125, B:47:0x0126, B:49:0x012e, B:51:0x0134, B:52:0x014d, B:53:0x0154, B:56:0x015a, B:58:0x01ac, B:59:0x01b8, B:61:0x01c0, B:62:0x01c8, B:63:0x01ce, B:66:0x01e6, B:67:0x01ed), top: B:80:0x004e }] */
/* JADX WARN: Removed duplicated region for block: B:59:0x01b8 A[Catch: all -> 0x01ee, Exception -> 0x01f1, TryCatch #4 {Exception -> 0x01f1, all -> 0x01ee, blocks: (B:7:0x004e, B:9:0x0057, B:10:0x0070, B:12:0x0078, B:14:0x0084, B:16:0x008c, B:18:0x0090, B:22:0x00a3, B:24:0x00ae, B:25:0x00b3, B:27:0x00c0, B:28:0x00c5, B:29:0x00c9, B:30:0x00d5, B:32:0x00dd, B:34:0x00e5, B:36:0x00ed, B:38:0x00f1, B:40:0x00fc, B:42:0x0107, B:44:0x010f, B:45:0x011e, B:46:0x0125, B:47:0x0126, B:49:0x012e, B:51:0x0134, B:52:0x014d, B:53:0x0154, B:56:0x015a, B:58:0x01ac, B:59:0x01b8, B:61:0x01c0, B:62:0x01c8, B:63:0x01ce, B:66:0x01e6, B:67:0x01ed), top: B:80:0x004e }] */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
private void saveWebpAttributes ( InputStream inputStream , OutputStream outputStream ) throws IOException {
Throwable th ;
Exception e ;
2022-03-07 09:34:54 +00:00
ByteArrayOutputStream byteArrayOutputStream ;
2021-07-24 02:37:17 +00:00
int i ;
int i2 ;
int i3 ;
int i4 ;
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " saveWebpAttributes starting with (inputStream: " + inputStream + " , outputStream: " + outputStream + " ) " ) ;
2021-07-24 02:37:17 +00:00
}
ByteOrder byteOrder = ByteOrder . LITTLE_ENDIAN ;
ByteOrderedDataInputStream byteOrderedDataInputStream = new ByteOrderedDataInputStream ( inputStream , byteOrder ) ;
ByteOrderedDataOutputStream byteOrderedDataOutputStream = new ByteOrderedDataOutputStream ( outputStream , byteOrder ) ;
byte [ ] bArr = WEBP_SIGNATURE_1 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream , bArr . length ) ;
2021-07-24 02:37:17 +00:00
byte [ ] bArr2 = WEBP_SIGNATURE_2 ;
2022-01-13 08:07:50 +00:00
byteOrderedDataInputStream . skipFully ( bArr2 . length + 4 ) ;
2022-03-07 09:34:54 +00:00
ByteArrayOutputStream byteArrayOutputStream2 = null ;
2021-07-24 02:37:17 +00:00
try {
try {
2022-03-07 09:34:54 +00:00
byteArrayOutputStream = new ByteArrayOutputStream ( ) ;
} catch ( Throwable th2 ) {
th = th2 ;
}
} catch ( Exception e2 ) {
e = e2 ;
}
try {
ByteOrderedDataOutputStream byteOrderedDataOutputStream2 = new ByteOrderedDataOutputStream ( byteArrayOutputStream , byteOrder ) ;
int i5 = this . mOffsetToExifData ;
if ( i5 ! = 0 ) {
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , ( ( i5 - ( ( bArr . length + 4 ) + bArr2 . length ) ) - 4 ) - 4 ) ;
byteOrderedDataInputStream . skipFully ( 4 ) ;
byteOrderedDataInputStream . skipFully ( byteOrderedDataInputStream . readInt ( ) ) ;
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
} else {
byte [ ] bArr3 = new byte [ 4 ] ;
if ( byteOrderedDataInputStream . read ( bArr3 ) = = 4 ) {
byte [ ] bArr4 = WEBP_CHUNK_TYPE_VP8X ;
boolean z2 = true ;
if ( Arrays . equals ( bArr3 , bArr4 ) ) {
int readInt = byteOrderedDataInputStream . readInt ( ) ;
byte [ ] bArr5 = new byte [ readInt % 2 = = 1 ? readInt + 1 : readInt ] ;
byteOrderedDataInputStream . read ( bArr5 ) ;
bArr5 [ 0 ] = ( byte ) ( 8 | bArr5 [ 0 ] ) ;
if ( ( ( bArr5 [ 0 ] > > 1 ) & 1 ) ! = 1 ) {
z2 = false ;
}
byteOrderedDataOutputStream2 . write ( bArr4 ) ;
byteOrderedDataOutputStream2 . writeInt ( readInt ) ;
byteOrderedDataOutputStream2 . write ( bArr5 ) ;
if ( z2 ) {
copyChunksUpToGivenChunkType ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , WEBP_CHUNK_TYPE_ANIM , null ) ;
while ( true ) {
byte [ ] bArr6 = new byte [ 4 ] ;
inputStream . read ( bArr6 ) ;
if ( ! Arrays . equals ( bArr6 , WEBP_CHUNK_TYPE_ANMF ) ) {
break ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
copyWebPChunk ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , bArr6 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
2021-07-24 02:37:17 +00:00
} else {
2022-03-07 09:34:54 +00:00
copyChunksUpToGivenChunkType ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , WEBP_CHUNK_TYPE_VP8 , WEBP_CHUNK_TYPE_VP8L ) ;
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
}
} else {
byte [ ] bArr7 = WEBP_CHUNK_TYPE_VP8 ;
if ( Arrays . equals ( bArr3 , bArr7 ) | | Arrays . equals ( bArr3 , WEBP_CHUNK_TYPE_VP8L ) ) {
int readInt2 = byteOrderedDataInputStream . readInt ( ) ;
int i6 = readInt2 % 2 = = 1 ? readInt2 + 1 : readInt2 ;
byte [ ] bArr8 = new byte [ 3 ] ;
if ( Arrays . equals ( bArr3 , bArr7 ) ) {
byteOrderedDataInputStream . read ( bArr8 ) ;
byte [ ] bArr9 = new byte [ 3 ] ;
if ( byteOrderedDataInputStream . read ( bArr9 ) ! = 3 | | ! Arrays . equals ( WEBP_VP8_SIGNATURE , bArr9 ) ) {
throw new IOException ( " Encountered error while checking VP8 signature " ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
i4 = byteOrderedDataInputStream . readInt ( ) ;
i3 = ( i4 < < 18 ) > > 18 ;
i2 = ( i4 < < 2 ) > > 18 ;
i6 - = 10 ;
} else if ( ! Arrays . equals ( bArr3 , WEBP_CHUNK_TYPE_VP8L ) ) {
i4 = 0 ;
i3 = 0 ;
i2 = 0 ;
} else if ( byteOrderedDataInputStream . readByte ( ) = = 47 ) {
i4 = byteOrderedDataInputStream . readInt ( ) ;
i3 = ( ( i4 < < 18 ) > > 18 ) + 1 ;
i2 = ( ( i4 < < 4 ) > > 18 ) + 1 ;
i = i4 & 8 ;
i6 - = 5 ;
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream2 . write ( bArr4 ) ;
byteOrderedDataOutputStream2 . writeInt ( 10 ) ;
byte [ ] bArr10 = new byte [ 10 ] ;
bArr10 [ 0 ] = ( byte ) ( bArr10 [ 0 ] | 8 ) ;
bArr10 [ 0 ] = ( byte ) ( bArr10 [ 0 ] | ( i < < 4 ) ) ;
int i7 = i3 - 1 ;
int i8 = i2 - 1 ;
bArr10 [ 4 ] = ( byte ) i7 ;
bArr10 [ 5 ] = ( byte ) ( i7 > > 8 ) ;
bArr10 [ 6 ] = ( byte ) ( i7 > > 16 ) ;
bArr10 [ 7 ] = ( byte ) i8 ;
bArr10 [ 8 ] = ( byte ) ( i8 > > 8 ) ;
bArr10 [ 9 ] = ( byte ) ( i8 > > 16 ) ;
byteOrderedDataOutputStream2 . write ( bArr10 ) ;
byteOrderedDataOutputStream2 . write ( bArr3 ) ;
byteOrderedDataOutputStream2 . writeInt ( readInt2 ) ;
if ( ! Arrays . equals ( bArr3 , bArr7 ) ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataOutputStream2 . write ( bArr8 ) ;
byteOrderedDataOutputStream2 . write ( WEBP_VP8_SIGNATURE ) ;
byteOrderedDataOutputStream2 . writeInt ( i4 ) ;
} else if ( Arrays . equals ( bArr3 , WEBP_CHUNK_TYPE_VP8L ) ) {
byteOrderedDataOutputStream2 . write ( 47 ) ;
byteOrderedDataOutputStream2 . writeInt ( i4 ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , i6 ) ;
2021-07-24 02:37:17 +00:00
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
2022-03-07 09:34:54 +00:00
} else {
throw new IOException ( " Encountered error while checking VP8L signature " ) ;
}
i = 0 ;
byteOrderedDataOutputStream2 . write ( bArr4 ) ;
byteOrderedDataOutputStream2 . writeInt ( 10 ) ;
byte [ ] bArr102 = new byte [ 10 ] ;
bArr102 [ 0 ] = ( byte ) ( bArr102 [ 0 ] | 8 ) ;
bArr102 [ 0 ] = ( byte ) ( bArr102 [ 0 ] | ( i < < 4 ) ) ;
int i72 = i3 - 1 ;
int i82 = i2 - 1 ;
bArr102 [ 4 ] = ( byte ) i72 ;
bArr102 [ 5 ] = ( byte ) ( i72 > > 8 ) ;
bArr102 [ 6 ] = ( byte ) ( i72 > > 16 ) ;
bArr102 [ 7 ] = ( byte ) i82 ;
bArr102 [ 8 ] = ( byte ) ( i82 > > 8 ) ;
bArr102 [ 9 ] = ( byte ) ( i82 > > 16 ) ;
byteOrderedDataOutputStream2 . write ( bArr102 ) ;
byteOrderedDataOutputStream2 . write ( bArr3 ) ;
byteOrderedDataOutputStream2 . writeInt ( readInt2 ) ;
if ( ! Arrays . equals ( bArr3 , bArr7 ) ) {
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 , i6 ) ;
writeExifSegment ( byteOrderedDataOutputStream2 ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
} else {
throw new IOException ( " Encountered invalid length while parsing WebP chunk type " ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . copy ( byteOrderedDataInputStream , byteOrderedDataOutputStream2 ) ;
int size = byteArrayOutputStream . size ( ) ;
byte [ ] bArr11 = WEBP_SIGNATURE_2 ;
byteOrderedDataOutputStream . writeInt ( size + bArr11 . length ) ;
byteOrderedDataOutputStream . write ( bArr11 ) ;
byteArrayOutputStream . writeTo ( byteOrderedDataOutputStream ) ;
ExifInterfaceUtils . closeQuietly ( byteArrayOutputStream ) ;
2021-07-24 02:37:17 +00:00
} catch ( Exception e3 ) {
e = e3 ;
throw new IOException ( " Failed to save WebP file " , e ) ;
2022-03-07 09:34:54 +00:00
} catch ( Throwable th3 ) {
th = th3 ;
byteArrayOutputStream2 = byteArrayOutputStream ;
ExifInterfaceUtils . closeQuietly ( byteArrayOutputStream2 ) ;
throw th ;
2021-07-24 02:37:17 +00:00
}
}
private void setThumbnailData ( ByteOrderedDataInputStream byteOrderedDataInputStream ) throws IOException {
HashMap < String , ExifAttribute > hashMap = this . mAttributes [ 4 ] ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = hashMap . get ( TAG_COMPRESSION ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute ! = null ) {
int intValue = exifAttribute . getIntValue ( this . mExifByteOrder ) ;
this . mThumbnailCompression = intValue ;
if ( intValue ! = 1 ) {
if ( intValue = = 6 ) {
handleThumbnailFromJfif ( byteOrderedDataInputStream , hashMap ) ;
return ;
} else if ( intValue ! = 7 ) {
return ;
}
}
if ( isSupportedDataType ( hashMap ) ) {
handleThumbnailFromStrips ( byteOrderedDataInputStream , hashMap ) ;
return ;
}
return ;
}
this . mThumbnailCompression = 6 ;
handleThumbnailFromJfif ( byteOrderedDataInputStream , hashMap ) ;
}
2022-01-13 08:07:50 +00:00
private static boolean shouldSupportSeek ( int i ) {
return ( i = = 4 | | i = = 9 | | i = = 13 | | i = = 14 ) ? false : true ;
2021-07-24 02:37:17 +00:00
}
private void swapBasedOnImageSize ( int i , int i2 ) throws IOException {
if ( ! this . mAttributes [ i ] . isEmpty ( ) & & ! this . mAttributes [ i2 ] . isEmpty ( ) ) {
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = this . mAttributes [ i ] . get ( TAG_IMAGE_LENGTH ) ;
ExifAttribute exifAttribute2 = this . mAttributes [ i ] . get ( TAG_IMAGE_WIDTH ) ;
ExifAttribute exifAttribute3 = this . mAttributes [ i2 ] . get ( TAG_IMAGE_LENGTH ) ;
ExifAttribute exifAttribute4 = this . mAttributes [ i2 ] . get ( TAG_IMAGE_WIDTH ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute = = null | | exifAttribute2 = = null ) {
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " First image does not contain valid size information " ) ;
2021-07-24 02:37:17 +00:00
}
} else if ( exifAttribute3 ! = null & & exifAttribute4 ! = null ) {
int intValue = exifAttribute . getIntValue ( this . mExifByteOrder ) ;
int intValue2 = exifAttribute2 . getIntValue ( this . mExifByteOrder ) ;
int intValue3 = exifAttribute3 . getIntValue ( this . mExifByteOrder ) ;
int intValue4 = exifAttribute4 . getIntValue ( this . mExifByteOrder ) ;
if ( intValue < intValue3 & & intValue2 < intValue4 ) {
HashMap < String , ExifAttribute > [ ] hashMapArr = this . mAttributes ;
HashMap < String , ExifAttribute > hashMap = hashMapArr [ i ] ;
hashMapArr [ i ] = hashMapArr [ i2 ] ;
hashMapArr [ i2 ] = hashMap ;
}
} else if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Second image does not contain valid size information " ) ;
2021-07-24 02:37:17 +00:00
}
} else if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Cannot perform swap since only one image data exists " ) ;
2021-07-24 02:37:17 +00:00
}
}
2022-01-13 08:07:50 +00:00
private void updateImageSizeValues ( SeekableByteOrderedDataInputStream seekableByteOrderedDataInputStream , int i ) throws IOException {
2021-07-24 02:37:17 +00:00
ExifAttribute exifAttribute ;
ExifAttribute exifAttribute2 ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute3 = this . mAttributes [ i ] . get ( TAG_DEFAULT_CROP_SIZE ) ;
ExifAttribute exifAttribute4 = this . mAttributes [ i ] . get ( TAG_RW2_SENSOR_TOP_BORDER ) ;
ExifAttribute exifAttribute5 = this . mAttributes [ i ] . get ( TAG_RW2_SENSOR_LEFT_BORDER ) ;
ExifAttribute exifAttribute6 = this . mAttributes [ i ] . get ( TAG_RW2_SENSOR_BOTTOM_BORDER ) ;
ExifAttribute exifAttribute7 = this . mAttributes [ i ] . get ( TAG_RW2_SENSOR_RIGHT_BORDER ) ;
2021-07-24 02:37:17 +00:00
if ( exifAttribute3 ! = null ) {
if ( exifAttribute3 . format = = 5 ) {
Rational [ ] rationalArr = ( Rational [ ] ) exifAttribute3 . getValue ( this . mExifByteOrder ) ;
if ( rationalArr = = null | | rationalArr . length ! = 2 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid crop size values. cropSize= " ) ;
R . append ( Arrays . toString ( rationalArr ) ) ;
Log . w ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
exifAttribute2 = ExifAttribute . createURational ( rationalArr [ 0 ] , this . mExifByteOrder ) ;
exifAttribute = ExifAttribute . createURational ( rationalArr [ 1 ] , this . mExifByteOrder ) ;
} else {
int [ ] iArr = ( int [ ] ) exifAttribute3 . getValue ( this . mExifByteOrder ) ;
if ( iArr = = null | | iArr . length ! = 2 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R2 = a . R ( " Invalid crop size values. cropSize= " ) ;
R2 . append ( Arrays . toString ( iArr ) ) ;
Log . w ( TAG , R2 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
exifAttribute2 = ExifAttribute . createUShort ( iArr [ 0 ] , this . mExifByteOrder ) ;
exifAttribute = ExifAttribute . createUShort ( iArr [ 1 ] , this . mExifByteOrder ) ;
}
2021-08-09 22:51:56 +00:00
this . mAttributes [ i ] . put ( TAG_IMAGE_WIDTH , exifAttribute2 ) ;
this . mAttributes [ i ] . put ( TAG_IMAGE_LENGTH , exifAttribute ) ;
2021-07-24 02:37:17 +00:00
} else if ( exifAttribute4 = = null | | exifAttribute5 = = null | | exifAttribute6 = = null | | exifAttribute7 = = null ) {
2022-01-13 08:07:50 +00:00
retrieveJpegImageSize ( seekableByteOrderedDataInputStream , i ) ;
2021-07-24 02:37:17 +00:00
} else {
int intValue = exifAttribute4 . getIntValue ( this . mExifByteOrder ) ;
int intValue2 = exifAttribute6 . getIntValue ( this . mExifByteOrder ) ;
int intValue3 = exifAttribute7 . getIntValue ( this . mExifByteOrder ) ;
int intValue4 = exifAttribute5 . getIntValue ( this . mExifByteOrder ) ;
if ( intValue2 > intValue & & intValue3 > intValue4 ) {
ExifAttribute createUShort = ExifAttribute . createUShort ( intValue2 - intValue , this . mExifByteOrder ) ;
ExifAttribute createUShort2 = ExifAttribute . createUShort ( intValue3 - intValue4 , this . mExifByteOrder ) ;
2021-08-09 22:51:56 +00:00
this . mAttributes [ i ] . put ( TAG_IMAGE_LENGTH , createUShort ) ;
this . mAttributes [ i ] . put ( TAG_IMAGE_WIDTH , createUShort2 ) ;
2021-07-24 02:37:17 +00:00
}
}
}
private void validateImages ( ) throws IOException {
swapBasedOnImageSize ( 0 , 5 ) ;
swapBasedOnImageSize ( 0 , 4 ) ;
swapBasedOnImageSize ( 5 , 4 ) ;
2021-08-09 22:51:56 +00:00
ExifAttribute exifAttribute = this . mAttributes [ 1 ] . get ( TAG_PIXEL_X_DIMENSION ) ;
ExifAttribute exifAttribute2 = this . mAttributes [ 1 ] . get ( TAG_PIXEL_Y_DIMENSION ) ;
2021-07-24 02:37:17 +00:00
if ( ! ( exifAttribute = = null | | exifAttribute2 = = null ) ) {
2021-08-09 22:51:56 +00:00
this . mAttributes [ 0 ] . put ( TAG_IMAGE_WIDTH , exifAttribute ) ;
this . mAttributes [ 0 ] . put ( TAG_IMAGE_LENGTH , exifAttribute2 ) ;
2021-07-24 02:37:17 +00:00
}
if ( this . mAttributes [ 4 ] . isEmpty ( ) & & isThumbnail ( this . mAttributes [ 5 ] ) ) {
HashMap < String , ExifAttribute > [ ] hashMapArr = this . mAttributes ;
hashMapArr [ 4 ] = hashMapArr [ 5 ] ;
hashMapArr [ 5 ] = new HashMap < > ( ) ;
}
if ( ! isThumbnail ( this . mAttributes [ 4 ] ) ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " No image meets the size requirements of a thumbnail image. " ) ;
2021-07-24 02:37:17 +00:00
}
2022-01-13 08:07:50 +00:00
replaceInvalidTags ( 0 , TAG_THUMBNAIL_ORIENTATION , TAG_ORIENTATION ) ;
replaceInvalidTags ( 0 , TAG_THUMBNAIL_IMAGE_LENGTH , TAG_IMAGE_LENGTH ) ;
replaceInvalidTags ( 0 , TAG_THUMBNAIL_IMAGE_WIDTH , TAG_IMAGE_WIDTH ) ;
replaceInvalidTags ( 5 , TAG_THUMBNAIL_ORIENTATION , TAG_ORIENTATION ) ;
replaceInvalidTags ( 5 , TAG_THUMBNAIL_IMAGE_LENGTH , TAG_IMAGE_LENGTH ) ;
replaceInvalidTags ( 5 , TAG_THUMBNAIL_IMAGE_WIDTH , TAG_IMAGE_WIDTH ) ;
replaceInvalidTags ( 4 , TAG_ORIENTATION , TAG_THUMBNAIL_ORIENTATION ) ;
replaceInvalidTags ( 4 , TAG_IMAGE_LENGTH , TAG_THUMBNAIL_IMAGE_LENGTH ) ;
replaceInvalidTags ( 4 , TAG_IMAGE_WIDTH , TAG_THUMBNAIL_IMAGE_WIDTH ) ;
2021-07-24 02:37:17 +00:00
}
private int writeExifSegment ( ByteOrderedDataOutputStream byteOrderedDataOutputStream ) throws IOException {
ExifTag [ ] [ ] exifTagArr = EXIF_TAGS ;
int [ ] iArr = new int [ exifTagArr . length ] ;
int [ ] iArr2 = new int [ exifTagArr . length ] ;
for ( ExifTag exifTag : EXIF_POINTER_TAGS ) {
removeAttribute ( exifTag . name ) ;
}
2022-01-13 08:07:50 +00:00
if ( this . mHasThumbnail ) {
if ( this . mHasThumbnailStrips ) {
removeAttribute ( TAG_STRIP_OFFSETS ) ;
removeAttribute ( TAG_STRIP_BYTE_COUNTS ) ;
} else {
removeAttribute ( TAG_JPEG_INTERCHANGE_FORMAT ) ;
removeAttribute ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH ) ;
}
}
2021-07-24 02:37:17 +00:00
for ( int i = 0 ; i < EXIF_TAGS . length ; i + + ) {
for ( Object obj : this . mAttributes [ i ] . entrySet ( ) . toArray ( ) ) {
Map . Entry entry = ( Map . Entry ) obj ;
if ( entry . getValue ( ) = = null ) {
this . mAttributes [ i ] . remove ( entry . getKey ( ) ) ;
}
}
}
if ( ! this . mAttributes [ 1 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( EXIF_POINTER_TAGS [ 1 ] . name , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mAttributes [ 2 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( EXIF_POINTER_TAGS [ 2 ] . name , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mAttributes [ 3 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 1 ] . put ( EXIF_POINTER_TAGS [ 3 ] . name , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( this . mHasThumbnail ) {
2022-01-13 08:07:50 +00:00
if ( this . mHasThumbnailStrips ) {
this . mAttributes [ 4 ] . put ( TAG_STRIP_OFFSETS , ExifAttribute . createUShort ( 0 , this . mExifByteOrder ) ) ;
this . mAttributes [ 4 ] . put ( TAG_STRIP_BYTE_COUNTS , ExifAttribute . createUShort ( this . mThumbnailLength , this . mExifByteOrder ) ) ;
} else {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 4 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT , ExifAttribute . createULong ( 0L , this . mExifByteOrder ) ) ;
this . mAttributes [ 4 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT_LENGTH , ExifAttribute . createULong ( this . mThumbnailLength , this . mExifByteOrder ) ) ;
2022-01-13 08:07:50 +00:00
}
2021-07-24 02:37:17 +00:00
}
for ( int i2 = 0 ; i2 < EXIF_TAGS . length ; i2 + + ) {
int i3 = 0 ;
for ( Map . Entry < String , ExifAttribute > entry2 : this . mAttributes [ i2 ] . entrySet ( ) ) {
int size = entry2 . getValue ( ) . size ( ) ;
if ( size > 4 ) {
i3 + = size ;
}
}
iArr2 [ i2 ] = iArr2 [ i2 ] + i3 ;
}
int i4 = 8 ;
for ( int i5 = 0 ; i5 < EXIF_TAGS . length ; i5 + + ) {
if ( ! this . mAttributes [ i5 ] . isEmpty ( ) ) {
iArr [ i5 ] = i4 ;
i4 = ( this . mAttributes [ i5 ] . size ( ) * 12 ) + 2 + 4 + iArr2 [ i5 ] + i4 ;
}
}
if ( this . mHasThumbnail ) {
2022-01-13 08:07:50 +00:00
if ( this . mHasThumbnailStrips ) {
this . mAttributes [ 4 ] . put ( TAG_STRIP_OFFSETS , ExifAttribute . createUShort ( i4 , this . mExifByteOrder ) ) ;
} else {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 4 ] . put ( TAG_JPEG_INTERCHANGE_FORMAT , ExifAttribute . createULong ( i4 , this . mExifByteOrder ) ) ;
2022-01-13 08:07:50 +00:00
}
2021-07-24 02:37:17 +00:00
this . mThumbnailOffset = i4 ;
i4 + = this . mThumbnailLength ;
}
if ( this . mMimeType = = 4 ) {
i4 + = 8 ;
}
if ( DEBUG ) {
for ( int i6 = 0 ; i6 < EXIF_TAGS . length ; i6 + + ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , String . format ( " index: %d, offsets: %d, tag count: %d, data sizes: %d, total size: %d " , Integer . valueOf ( i6 ) , Integer . valueOf ( iArr [ i6 ] ) , Integer . valueOf ( this . mAttributes [ i6 ] . size ( ) ) , Integer . valueOf ( iArr2 [ i6 ] ) , Integer . valueOf ( i4 ) ) ) ;
2021-07-24 02:37:17 +00:00
}
}
if ( ! this . mAttributes [ 1 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( EXIF_POINTER_TAGS [ 1 ] . name , ExifAttribute . createULong ( iArr [ 1 ] , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mAttributes [ 2 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 0 ] . put ( EXIF_POINTER_TAGS [ 2 ] . name , ExifAttribute . createULong ( iArr [ 2 ] , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
if ( ! this . mAttributes [ 3 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
this . mAttributes [ 1 ] . put ( EXIF_POINTER_TAGS [ 3 ] . name , ExifAttribute . createULong ( iArr [ 3 ] , this . mExifByteOrder ) ) ;
2021-07-24 02:37:17 +00:00
}
int i7 = this . mMimeType ;
if ( i7 = = 4 ) {
byteOrderedDataOutputStream . writeUnsignedShort ( i4 ) ;
byteOrderedDataOutputStream . write ( IDENTIFIER_EXIF_APP1 ) ;
} else if ( i7 = = 13 ) {
byteOrderedDataOutputStream . writeInt ( i4 ) ;
byteOrderedDataOutputStream . write ( PNG_CHUNK_TYPE_EXIF ) ;
} else if ( i7 = = 14 ) {
byteOrderedDataOutputStream . write ( WEBP_CHUNK_TYPE_EXIF ) ;
byteOrderedDataOutputStream . writeInt ( i4 ) ;
}
2021-08-09 22:51:56 +00:00
byteOrderedDataOutputStream . writeShort ( this . mExifByteOrder = = ByteOrder . BIG_ENDIAN ? BYTE_ALIGN_MM : BYTE_ALIGN_II ) ;
2021-07-24 02:37:17 +00:00
byteOrderedDataOutputStream . setByteOrder ( this . mExifByteOrder ) ;
byteOrderedDataOutputStream . writeUnsignedShort ( 42 ) ;
2022-03-07 09:34:54 +00:00
byteOrderedDataOutputStream . writeUnsignedInt ( 8L ) ;
2021-07-24 02:37:17 +00:00
for ( int i8 = 0 ; i8 < EXIF_TAGS . length ; i8 + + ) {
if ( ! this . mAttributes [ i8 ] . isEmpty ( ) ) {
byteOrderedDataOutputStream . writeUnsignedShort ( this . mAttributes [ i8 ] . size ( ) ) ;
int size2 = ( this . mAttributes [ i8 ] . size ( ) * 12 ) + iArr [ i8 ] + 2 + 4 ;
for ( Map . Entry < String , ExifAttribute > entry3 : this . mAttributes [ i8 ] . entrySet ( ) ) {
int i9 = sExifTagMapsForWriting [ i8 ] . get ( entry3 . getKey ( ) ) . number ;
ExifAttribute value = entry3 . getValue ( ) ;
int size3 = value . size ( ) ;
byteOrderedDataOutputStream . writeUnsignedShort ( i9 ) ;
byteOrderedDataOutputStream . writeUnsignedShort ( value . format ) ;
byteOrderedDataOutputStream . writeInt ( value . numberOfComponents ) ;
if ( size3 > 4 ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataOutputStream . writeUnsignedInt ( size2 ) ;
2021-07-24 02:37:17 +00:00
size2 + = size3 ;
} else {
byteOrderedDataOutputStream . write ( value . bytes ) ;
if ( size3 < 4 ) {
while ( size3 < 4 ) {
byteOrderedDataOutputStream . writeByte ( 0 ) ;
size3 + + ;
}
}
}
}
if ( i8 ! = 0 | | this . mAttributes [ 4 ] . isEmpty ( ) ) {
2022-03-07 09:34:54 +00:00
byteOrderedDataOutputStream . writeUnsignedInt ( 0L ) ;
2021-07-24 02:37:17 +00:00
} else {
2022-03-07 09:34:54 +00:00
byteOrderedDataOutputStream . writeUnsignedInt ( iArr [ 4 ] ) ;
2021-07-24 02:37:17 +00:00
}
for ( Map . Entry < String , ExifAttribute > entry4 : this . mAttributes [ i8 ] . entrySet ( ) ) {
byte [ ] bArr = entry4 . getValue ( ) . bytes ;
if ( bArr . length > 4 ) {
byteOrderedDataOutputStream . write ( bArr , 0 , bArr . length ) ;
}
}
}
}
if ( this . mHasThumbnail ) {
byteOrderedDataOutputStream . write ( getThumbnailBytes ( ) ) ;
}
if ( this . mMimeType = = 14 & & i4 % 2 = = 1 ) {
byteOrderedDataOutputStream . writeByte ( 0 ) ;
}
byteOrderedDataOutputStream . setByteOrder ( ByteOrder . BIG_ENDIAN ) ;
return i4 ;
}
public void flipHorizontally ( ) {
int i = 1 ;
2021-08-09 22:51:56 +00:00
switch ( getAttributeInt ( TAG_ORIENTATION , 1 ) ) {
2021-07-24 02:37:17 +00:00
case 1 :
i = 2 ;
break ;
case 2 :
break ;
case 3 :
i = 4 ;
break ;
case 4 :
i = 3 ;
break ;
case 5 :
i = 6 ;
break ;
case 6 :
i = 5 ;
break ;
case 7 :
i = 8 ;
break ;
case 8 :
i = 7 ;
break ;
default :
i = 0 ;
break ;
}
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_ORIENTATION , Integer . toString ( i ) ) ;
2021-07-24 02:37:17 +00:00
}
public void flipVertically ( ) {
int i = 1 ;
2021-08-09 22:51:56 +00:00
switch ( getAttributeInt ( TAG_ORIENTATION , 1 ) ) {
2021-07-24 02:37:17 +00:00
case 1 :
i = 4 ;
break ;
case 2 :
i = 3 ;
break ;
case 3 :
i = 2 ;
break ;
case 4 :
break ;
case 5 :
i = 8 ;
break ;
case 6 :
i = 7 ;
break ;
case 7 :
i = 6 ;
break ;
case 8 :
i = 5 ;
break ;
default :
i = 0 ;
break ;
}
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_ORIENTATION , Integer . toString ( i ) ) ;
2021-07-24 02:37:17 +00:00
}
public double getAltitude ( double d ) {
2021-08-09 22:51:56 +00:00
double attributeDouble = getAttributeDouble ( TAG_GPS_ALTITUDE , - 1 . 0d ) ;
2021-07-24 02:37:17 +00:00
int i = - 1 ;
2021-08-09 22:51:56 +00:00
int attributeInt = getAttributeInt ( TAG_GPS_ALTITUDE_REF , - 1 ) ;
if ( attributeDouble < ShadowDrawableWrapper . COS_45 | | attributeInt < 0 ) {
2021-07-24 02:37:17 +00:00
return d ;
}
if ( attributeInt ! = 1 ) {
i = 1 ;
}
2022-03-07 09:34:54 +00:00
return attributeDouble * i ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public String getAttribute ( @NonNull String str ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
ExifAttribute exifAttribute = getExifAttribute ( str ) ;
if ( exifAttribute ! = null ) {
if ( ! sTagSetForCompatibility . contains ( str ) ) {
return exifAttribute . getStringValue ( this . mExifByteOrder ) ;
}
2021-08-09 22:51:56 +00:00
if ( str . equals ( TAG_GPS_TIMESTAMP ) ) {
2021-07-24 02:37:17 +00:00
int i = exifAttribute . format ;
if ( i = = 5 | | i = = 10 ) {
Rational [ ] rationalArr = ( Rational [ ] ) exifAttribute . getValue ( this . mExifByteOrder ) ;
if ( rationalArr ! = null & & rationalArr . length = = 3 ) {
return String . format ( " %02d:%02d:%02d " , Integer . valueOf ( ( int ) ( ( ( float ) rationalArr [ 0 ] . numerator ) / ( ( float ) rationalArr [ 0 ] . denominator ) ) ) , Integer . valueOf ( ( int ) ( ( ( float ) rationalArr [ 1 ] . numerator ) / ( ( float ) rationalArr [ 1 ] . denominator ) ) ) , Integer . valueOf ( ( int ) ( ( ( float ) rationalArr [ 2 ] . numerator ) / ( ( float ) rationalArr [ 2 ] . denominator ) ) ) ) ;
}
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Invalid GPS Timestamp array. array= " ) ;
R . append ( Arrays . toString ( rationalArr ) ) ;
Log . w ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return null ;
}
2022-03-21 18:52:30 +00:00
StringBuilder R2 = a . R ( " GPS Timestamp format is not rational. format= " ) ;
R2 . append ( exifAttribute . format ) ;
Log . w ( TAG , R2 . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return null ;
}
try {
return Double . toString ( exifAttribute . getDoubleValue ( this . mExifByteOrder ) ) ;
} catch ( NumberFormatException unused ) {
}
}
return null ;
}
@Nullable
public byte [ ] getAttributeBytes ( @NonNull String str ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
ExifAttribute exifAttribute = getExifAttribute ( str ) ;
if ( exifAttribute ! = null ) {
return exifAttribute . bytes ;
}
return null ;
}
public double getAttributeDouble ( @NonNull String str , double d ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
ExifAttribute exifAttribute = getExifAttribute ( str ) ;
if ( exifAttribute = = null ) {
return d ;
}
try {
return exifAttribute . getDoubleValue ( this . mExifByteOrder ) ;
} catch ( NumberFormatException unused ) {
return d ;
}
}
public int getAttributeInt ( @NonNull String str , int i ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
ExifAttribute exifAttribute = getExifAttribute ( str ) ;
if ( exifAttribute = = null ) {
return i ;
}
try {
return exifAttribute . getIntValue ( this . mExifByteOrder ) ;
} catch ( NumberFormatException unused ) {
return i ;
}
}
@Nullable
public long [ ] getAttributeRange ( @NonNull String str ) {
Objects . requireNonNull ( str , " tag shouldn't be null " ) ;
if ( ! this . mModified ) {
ExifAttribute exifAttribute = getExifAttribute ( str ) ;
if ( exifAttribute ! = null ) {
2022-03-07 09:34:54 +00:00
return new long [ ] { exifAttribute . bytesOffset , exifAttribute . bytes . length } ;
2021-07-24 02:37:17 +00:00
}
return null ;
}
throw new IllegalStateException ( " The underlying file has been modified since being parsed " ) ;
}
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public Long getDateTime ( ) {
2021-08-09 22:51:56 +00:00
return parseDateTime ( getAttribute ( TAG_DATETIME ) , getAttribute ( TAG_SUBSEC_TIME ) , getAttribute ( TAG_OFFSET_TIME ) ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public Long getDateTimeDigitized ( ) {
2021-08-09 22:51:56 +00:00
return parseDateTime ( getAttribute ( TAG_DATETIME_DIGITIZED ) , getAttribute ( TAG_SUBSEC_TIME_DIGITIZED ) , getAttribute ( TAG_OFFSET_TIME_DIGITIZED ) ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public Long getDateTimeOriginal ( ) {
2021-08-09 22:51:56 +00:00
return parseDateTime ( getAttribute ( TAG_DATETIME_ORIGINAL ) , getAttribute ( TAG_SUBSEC_TIME_ORIGINAL ) , getAttribute ( TAG_OFFSET_TIME_ORIGINAL ) ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
@SuppressLint ( { " AutoBoxing " } )
public Long getGpsDateTime ( ) {
2021-08-09 22:51:56 +00:00
String attribute = getAttribute ( TAG_GPS_DATESTAMP ) ;
String attribute2 = getAttribute ( TAG_GPS_TIMESTAMP ) ;
2021-07-24 02:37:17 +00:00
if ( ! ( attribute = = null | | attribute2 = = null ) ) {
Pattern pattern = NON_ZERO_TIME_PATTERN ;
if ( pattern . matcher ( attribute ) . matches ( ) | | pattern . matcher ( attribute2 ) . matches ( ) ) {
String str = attribute + ' ' + attribute2 ;
ParsePosition parsePosition = new ParsePosition ( 0 ) ;
try {
Date parse = sFormatterPrimary . parse ( str , parsePosition ) ;
if ( parse = = null & & ( parse = sFormatterSecondary . parse ( str , parsePosition ) ) = = null ) {
return null ;
}
return Long . valueOf ( parse . getTime ( ) ) ;
} catch ( IllegalArgumentException unused ) {
}
}
}
return null ;
}
@Deprecated
public boolean getLatLong ( float [ ] fArr ) {
double [ ] latLong = getLatLong ( ) ;
if ( latLong = = null ) {
return false ;
}
fArr [ 0 ] = ( float ) latLong [ 0 ] ;
fArr [ 1 ] = ( float ) latLong [ 1 ] ;
return true ;
}
@Nullable
public double [ ] getLatLong ( ) {
2021-08-09 22:51:56 +00:00
String attribute = getAttribute ( TAG_GPS_LATITUDE ) ;
String attribute2 = getAttribute ( TAG_GPS_LATITUDE_REF ) ;
String attribute3 = getAttribute ( TAG_GPS_LONGITUDE ) ;
String attribute4 = getAttribute ( TAG_GPS_LONGITUDE_REF ) ;
2021-07-24 02:37:17 +00:00
if ( attribute = = null | | attribute2 = = null | | attribute3 = = null | | attribute4 = = null ) {
return null ;
}
try {
return new double [ ] { convertRationalLatLonToDouble ( attribute , attribute2 ) , convertRationalLatLonToDouble ( attribute3 , attribute4 ) } ;
} catch ( IllegalArgumentException unused ) {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " Latitude/longitude values are not parsable. " ) ;
R . append ( String . format ( " latValue=%s, latRef=%s, lngValue=%s, lngRef=%s " , attribute , attribute2 , attribute3 , attribute4 ) ) ;
Log . w ( TAG , R . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
return null ;
}
}
public int getRotationDegrees ( ) {
2021-08-09 22:51:56 +00:00
switch ( getAttributeInt ( TAG_ORIENTATION , 1 ) ) {
2021-07-24 02:37:17 +00:00
case 3 :
case 4 :
2022-03-07 09:34:54 +00:00
return 180 ;
2021-07-24 02:37:17 +00:00
case 5 :
case 8 :
return 270 ;
case 6 :
case 7 :
return 90 ;
default :
return 0 ;
}
}
@Nullable
public byte [ ] getThumbnail ( ) {
int i = this . mThumbnailCompression ;
if ( i = = 6 | | i = = 7 ) {
return getThumbnailBytes ( ) ;
}
return null ;
}
@Nullable
public Bitmap getThumbnailBitmap ( ) {
if ( ! this . mHasThumbnail ) {
return null ;
}
if ( this . mThumbnailBytes = = null ) {
this . mThumbnailBytes = getThumbnailBytes ( ) ;
}
int i = this . mThumbnailCompression ;
if ( i = = 6 | | i = = 7 ) {
return BitmapFactory . decodeByteArray ( this . mThumbnailBytes , 0 , this . mThumbnailLength ) ;
}
if ( i = = 1 ) {
int length = this . mThumbnailBytes . length / 3 ;
int [ ] iArr = new int [ length ] ;
for ( int i2 = 0 ; i2 < length ; i2 + + ) {
byte [ ] bArr = this . mThumbnailBytes ;
int i3 = i2 * 3 ;
iArr [ i2 ] = ( bArr [ i3 ] < < 16 ) + 0 + ( bArr [ i3 + 1 ] < < 8 ) + bArr [ i3 + 2 ] ;
}
2022-01-13 08:07:50 +00:00
ExifAttribute exifAttribute = this . mAttributes [ 4 ] . get ( TAG_THUMBNAIL_IMAGE_LENGTH ) ;
ExifAttribute exifAttribute2 = this . mAttributes [ 4 ] . get ( TAG_THUMBNAIL_IMAGE_WIDTH ) ;
2021-07-24 02:37:17 +00:00
if ( ! ( exifAttribute = = null | | exifAttribute2 = = null ) ) {
return Bitmap . createBitmap ( iArr , exifAttribute2 . getIntValue ( this . mExifByteOrder ) , exifAttribute . getIntValue ( this . mExifByteOrder ) , Bitmap . Config . ARGB_8888 ) ;
}
}
return null ;
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Removed duplicated region for block: B:29:0x0051 A[Catch: Exception -> 0x008a, all -> 0x00af, TRY_ENTER, TRY_LEAVE, TryCatch #3 {Exception -> 0x008a, blocks: (B:29:0x0051, B:32:0x0067, B:34:0x0073, B:39:0x007e, B:40:0x0083, B:41:0x0084, B:42:0x0089, B:45:0x008c, B:46:0x0091), top: B:66:0x004f }] */
/* JADX WARN: Removed duplicated region for block: B:45:0x008c A[Catch: Exception -> 0x008a, all -> 0x00af, TryCatch #3 {Exception -> 0x008a, blocks: (B:29:0x0051, B:32:0x0067, B:34:0x0073, B:39:0x007e, B:40:0x0083, B:41:0x0084, B:42:0x0089, B:45:0x008c, B:46:0x0091), top: B:66:0x004f }] */
/* JADX WARN: Removed duplicated region for block: B:58:0x00ab */
/* JADX WARN: Removed duplicated region for block: B:64:0x00b6 */
/* JADX WARN: Unknown variable types count: 1 */
2021-07-24 02:37:17 +00:00
@Nullable
2022-03-07 09:34:54 +00:00
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
public byte [ ] getThumbnailBytes ( ) {
FileDescriptor fileDescriptor ;
Throwable th ;
Exception e ;
2022-03-07 09:34:54 +00:00
FileDescriptor fileDescriptor2 ;
FileInputStream fileInputStream ;
FileInputStream fileInputStream2 ;
FileInputStream fileInputStream3 ;
Closeable closeable = null ;
closeable = null ;
2021-07-24 02:37:17 +00:00
if ( ! this . mHasThumbnail ) {
return null ;
}
2022-03-07 09:34:54 +00:00
? ? r1 = this . mThumbnailBytes ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
if ( r1 ! = 0 ) {
return r1 ;
}
try {
r1 = this . mAssetInputStream ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
if ( r1 ! = 0 ) {
try {
if ( r1 . markSupported ( ) ) {
r1 . reset ( ) ;
fileInputStream3 = r1 ;
} else {
Log . d ( TAG , " Cannot read thumbnail from inputstream without mark/reset support " ) ;
ExifInterfaceUtils . closeQuietly ( r1 ) ;
return null ;
}
} catch ( Exception e2 ) {
e = e2 ;
fileDescriptor2 = null ;
fileInputStream = r1 ;
Log . d ( TAG , " Encountered exception while getting thumbnail " , e ) ;
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
if ( fileDescriptor2 ! = null ) {
}
return null ;
} catch ( Throwable th2 ) {
th = th2 ;
fileDescriptor = null ;
closeable = r1 ;
ExifInterfaceUtils . closeQuietly ( closeable ) ;
if ( fileDescriptor ! = null ) {
}
throw th ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} else if ( this . mFilename ! = null ) {
fileInputStream3 = new FileInputStream ( this . mFilename ) ;
} else {
FileDescriptor dup = ExifInterfaceUtils . Api21Impl . dup ( this . mSeekableFileDescriptor ) ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . Api21Impl . lseek ( dup , 0L , OsConstants . SEEK_SET ) ;
fileDescriptor2 = dup ;
fileInputStream2 = new FileInputStream ( dup ) ;
if ( fileInputStream2 = = null ) {
if ( fileInputStream2 . skip ( this . mThumbnailOffset + this . mOffsetToExifData ) = = this . mThumbnailOffset + this . mOffsetToExifData ) {
byte [ ] bArr = new byte [ this . mThumbnailLength ] ;
if ( fileInputStream2 . read ( bArr ) = = this . mThumbnailLength ) {
this . mThumbnailBytes = bArr ;
ExifInterfaceUtils . closeQuietly ( fileInputStream2 ) ;
if ( fileDescriptor2 ! = null ) {
ExifInterfaceUtils . closeFileDescriptor ( fileDescriptor2 ) ;
}
return bArr ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
throw new IOException ( " Corrupted image " ) ;
2021-07-24 02:37:17 +00:00
}
throw new IOException ( " Corrupted image " ) ;
}
2022-03-07 09:34:54 +00:00
throw new FileNotFoundException ( ) ;
2021-07-24 02:37:17 +00:00
} catch ( Exception e3 ) {
e = e3 ;
2022-03-07 09:34:54 +00:00
fileDescriptor2 = dup ;
fileInputStream = null ;
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Encountered exception while getting thumbnail " , e ) ;
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
if ( fileDescriptor2 ! = null ) {
2021-07-24 02:37:17 +00:00
}
return null ;
2022-03-07 09:34:54 +00:00
} catch ( Throwable th3 ) {
th = th3 ;
fileDescriptor = dup ;
ExifInterfaceUtils . closeQuietly ( closeable ) ;
if ( fileDescriptor ! = null ) {
ExifInterfaceUtils . closeFileDescriptor ( fileDescriptor ) ;
}
throw th ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
}
if ( fileInputStream2 = = null ) {
2021-07-24 02:37:17 +00:00
}
} catch ( Exception e4 ) {
e = e4 ;
2022-03-07 09:34:54 +00:00
fileInputStream = fileInputStream2 ;
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " Encountered exception while getting thumbnail " , e ) ;
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
if ( fileDescriptor2 ! = null ) {
ExifInterfaceUtils . closeFileDescriptor ( fileDescriptor2 ) ;
2021-07-24 02:37:17 +00:00
}
return null ;
}
2022-03-07 09:34:54 +00:00
fileDescriptor2 = null ;
fileInputStream2 = fileInputStream3 ;
} catch ( Exception e5 ) {
e = e5 ;
fileInputStream = null ;
fileDescriptor2 = null ;
} catch ( Throwable th4 ) {
th = th4 ;
fileDescriptor = null ;
2021-07-24 02:37:17 +00:00
}
} catch ( Throwable th5 ) {
th = th5 ;
}
}
@Nullable
public long [ ] getThumbnailRange ( ) {
if ( this . mModified ) {
throw new IllegalStateException ( " The underlying file has been modified since being parsed " ) ;
} else if ( ! this . mHasThumbnail ) {
return null ;
} else {
if ( ! this . mHasThumbnailStrips | | this . mAreThumbnailStripsConsecutive ) {
2022-03-07 09:34:54 +00:00
return new long [ ] { this . mThumbnailOffset + this . mOffsetToExifData , this . mThumbnailLength } ;
2021-07-24 02:37:17 +00:00
}
return null ;
}
}
public boolean hasAttribute ( @NonNull String str ) {
return getExifAttribute ( str ) ! = null ;
}
public boolean hasThumbnail ( ) {
return this . mHasThumbnail ;
}
public boolean isFlipped ( ) {
2021-08-09 22:51:56 +00:00
int attributeInt = getAttributeInt ( TAG_ORIENTATION , 1 ) ;
2021-07-24 02:37:17 +00:00
return attributeInt = = 2 | | attributeInt = = 7 | | attributeInt = = 4 | | attributeInt = = 5 ;
}
public boolean isThumbnailCompressed ( ) {
if ( ! this . mHasThumbnail ) {
return false ;
}
int i = this . mThumbnailCompression ;
return i = = 6 | | i = = 7 ;
}
public void resetOrientation ( ) {
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_ORIENTATION , Integer . toString ( 1 ) ) ;
2021-07-24 02:37:17 +00:00
}
public void rotate ( int i ) {
if ( i % 90 = = 0 ) {
2021-08-09 22:51:56 +00:00
int attributeInt = getAttributeInt ( TAG_ORIENTATION , 1 ) ;
2021-07-24 02:37:17 +00:00
List < Integer > list = ROTATION_ORDER ;
int i2 = 0 ;
if ( list . contains ( Integer . valueOf ( attributeInt ) ) ) {
int indexOf = ( ( i / 90 ) + list . indexOf ( Integer . valueOf ( attributeInt ) ) ) % 4 ;
if ( indexOf < 0 ) {
i2 = 4 ;
}
i2 = list . get ( indexOf + i2 ) . intValue ( ) ;
} else {
List < Integer > list2 = FLIPPED_ROTATION_ORDER ;
if ( list2 . contains ( Integer . valueOf ( attributeInt ) ) ) {
int indexOf2 = ( ( i / 90 ) + list2 . indexOf ( Integer . valueOf ( attributeInt ) ) ) % 4 ;
if ( indexOf2 < 0 ) {
i2 = 4 ;
}
i2 = list2 . get ( indexOf2 + i2 ) . intValue ( ) ;
}
}
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_ORIENTATION , Integer . toString ( i2 ) ) ;
2021-07-24 02:37:17 +00:00
return ;
}
throw new IllegalArgumentException ( " degree should be a multiple of 90 " ) ;
}
2022-03-07 09:34:54 +00:00
/* JADX WARN: Removed duplicated region for block: B:66:0x00f6 A[Catch: all -> 0x011e, Exception -> 0x0121, TryCatch #15 {Exception -> 0x0121, all -> 0x011e, blocks: (B:64:0x00f2, B:66:0x00f6, B:67:0x0105, B:68:0x010c), top: B:128:0x00f2 }] */
/* JADX WARN: Removed duplicated region for block: B:67:0x0105 A[Catch: all -> 0x011e, Exception -> 0x0121, TryCatch #15 {Exception -> 0x0121, all -> 0x011e, blocks: (B:64:0x00f2, B:66:0x00f6, B:67:0x0105, B:68:0x010c), top: B:128:0x00f2 }] */
/* JADX WARN: Removed duplicated region for block: B:87:0x0158 */
/ *
Code decompiled incorrectly , please refer to instructions dump .
* /
2021-07-24 02:37:17 +00:00
public void saveAttributes ( ) throws IOException {
FileOutputStream fileOutputStream ;
Exception e ;
2022-03-07 09:34:54 +00:00
File createTempFile ;
2021-07-24 02:37:17 +00:00
FileInputStream fileInputStream ;
FileOutputStream fileOutputStream2 ;
2022-03-07 09:34:54 +00:00
Exception e2 ;
Exception e3 ;
Closeable closeable ;
FileInputStream fileInputStream2 ;
2022-01-13 08:07:50 +00:00
if ( ! isSupportedFormatForSavingAttributes ( this . mMimeType ) ) {
throw new IOException ( " ExifInterface only supports saving attributes for JPEG, PNG, WebP, and DNG formats. " ) ;
2021-07-24 02:37:17 +00:00
} else if ( this . mSeekableFileDescriptor = = null & & this . mFilename = = null ) {
throw new IOException ( " ExifInterface does not support saving attributes for the current input. " ) ;
2022-01-13 08:07:50 +00:00
} else if ( ! this . mHasThumbnail | | ! this . mHasThumbnailStrips | | this . mAreThumbnailStripsConsecutive ) {
2021-07-24 02:37:17 +00:00
this . mModified = true ;
this . mThumbnailBytes = getThumbnail ( ) ;
FileInputStream fileInputStream3 = null ;
try {
2022-03-07 09:34:54 +00:00
createTempFile = File . createTempFile ( " temp " , " tmp " ) ;
2021-07-24 02:37:17 +00:00
if ( this . mFilename ! = null ) {
fileInputStream = new FileInputStream ( this . mFilename ) ;
} else {
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . Api21Impl . lseek ( this . mSeekableFileDescriptor , 0L , OsConstants . SEEK_SET ) ;
2021-07-24 02:37:17 +00:00
fileInputStream = new FileInputStream ( this . mSeekableFileDescriptor ) ;
}
try {
fileOutputStream = new FileOutputStream ( createTempFile ) ;
2022-03-07 09:34:54 +00:00
} catch ( Exception e4 ) {
e = e4 ;
2022-01-13 08:07:50 +00:00
fileOutputStream = null ;
2022-03-07 09:34:54 +00:00
} catch ( Throwable th ) {
th = th ;
fileOutputStream = null ;
}
} catch ( Exception e5 ) {
e = e5 ;
fileOutputStream = null ;
} catch ( Throwable th2 ) {
th = th2 ;
fileOutputStream = null ;
}
try {
ExifInterfaceUtils . copy ( fileInputStream , fileOutputStream ) ;
ExifInterfaceUtils . closeQuietly ( fileInputStream ) ;
ExifInterfaceUtils . closeQuietly ( fileOutputStream ) ;
try {
} catch ( Throwable th3 ) {
th = th3 ;
}
try {
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
fileInputStream2 = new FileInputStream ( createTempFile ) ;
2022-01-13 08:07:50 +00:00
} catch ( Throwable th4 ) {
th = th4 ;
2022-03-07 09:34:54 +00:00
closeable = null ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . closeQuietly ( closeable ) ;
if ( 0 = = 0 ) {
createTempFile . delete ( ) ;
}
2022-01-13 08:07:50 +00:00
throw th ;
}
try {
if ( this . mFilename ! = null ) {
2022-03-07 09:34:54 +00:00
fileOutputStream2 = new FileOutputStream ( this . mFilename ) ;
2022-01-13 08:07:50 +00:00
} else {
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . Api21Impl . lseek ( this . mSeekableFileDescriptor , 0L , OsConstants . SEEK_SET ) ;
fileOutputStream2 = new FileOutputStream ( this . mSeekableFileDescriptor ) ;
2022-01-13 08:07:50 +00:00
}
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
BufferedInputStream bufferedInputStream = new BufferedInputStream ( fileInputStream2 ) ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream ( fileOutputStream2 ) ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
int i = this . mMimeType ;
if ( i = = 4 ) {
saveJpegAttributes ( bufferedInputStream , bufferedOutputStream ) ;
} else if ( i = = 13 ) {
savePngAttributes ( bufferedInputStream , bufferedOutputStream ) ;
} else if ( i = = 14 ) {
saveWebpAttributes ( bufferedInputStream , bufferedOutputStream ) ;
} else if ( i = = 3 | | i = = 0 ) {
writeExifSegment ( new ByteOrderedDataOutputStream ( bufferedOutputStream , ByteOrder . BIG_ENDIAN ) ) ;
}
ExifInterfaceUtils . closeQuietly ( bufferedInputStream ) ;
ExifInterfaceUtils . closeQuietly ( bufferedOutputStream ) ;
createTempFile . delete ( ) ;
this . mThumbnailBytes = null ;
} catch ( Exception e6 ) {
e2 = e6 ;
fileInputStream3 = fileInputStream2 ;
try {
fileInputStream3 = new FileInputStream ( createTempFile ) ;
} catch ( Exception e7 ) {
e3 = e7 ;
fileInputStream3 = fileInputStream3 ;
} catch ( Throwable th5 ) {
th = th5 ;
}
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
if ( this . mFilename ! = null ) {
ExifInterfaceUtils . Api21Impl . lseek ( this . mSeekableFileDescriptor , 0L , OsConstants . SEEK_SET ) ;
fileOutputStream2 = new FileOutputStream ( this . mSeekableFileDescriptor ) ;
} else {
fileOutputStream2 = new FileOutputStream ( this . mFilename ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . copy ( fileInputStream3 , fileOutputStream2 ) ;
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
ExifInterfaceUtils . closeQuietly ( fileOutputStream2 ) ;
throw new IOException ( " Failed to save new file " , e2 ) ;
} catch ( Exception e8 ) {
e3 = e8 ;
2021-07-24 02:37:17 +00:00
try {
2022-03-07 09:34:54 +00:00
throw new IOException ( " Failed to save new file. Original file is stored in " + createTempFile . getAbsolutePath ( ) , e3 ) ;
2021-07-24 02:37:17 +00:00
} catch ( Throwable th6 ) {
2022-03-07 09:34:54 +00:00
th = th6 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . closeQuietly ( fileOutputStream2 ) ;
throw th ;
2021-07-24 02:37:17 +00:00
}
} catch ( Throwable th7 ) {
2022-03-07 09:34:54 +00:00
th = th7 ;
fileInputStream3 = fileInputStream3 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . closeQuietly ( fileOutputStream2 ) ;
throw th ;
2021-07-24 02:37:17 +00:00
}
}
2022-03-07 09:34:54 +00:00
} catch ( Exception e9 ) {
e2 = e9 ;
fileInputStream3 = fileInputStream2 ;
} catch ( Throwable th8 ) {
th = th8 ;
closeable = null ;
fileInputStream3 = bufferedInputStream ;
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
ExifInterfaceUtils . closeQuietly ( closeable ) ;
if ( 0 = = 0 ) {
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
throw th ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} catch ( Exception e10 ) {
e2 = e10 ;
fileInputStream3 = fileInputStream2 ;
2022-01-13 08:07:50 +00:00
}
2022-03-07 09:34:54 +00:00
} catch ( Exception e11 ) {
e2 = e11 ;
fileOutputStream2 = null ;
fileInputStream3 = fileInputStream2 ;
fileInputStream3 = new FileInputStream ( createTempFile ) ;
if ( this . mFilename ! = null ) {
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
ExifInterfaceUtils . copy ( fileInputStream3 , fileOutputStream2 ) ;
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileOutputStream2 ) ;
2022-03-07 09:34:54 +00:00
throw new IOException ( " Failed to save new file " , e2 ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-07 09:34:54 +00:00
} catch ( Exception e12 ) {
e2 = e12 ;
fileOutputStream2 = null ;
}
} catch ( Exception e13 ) {
e = e13 ;
fileInputStream3 = fileInputStream ;
try {
2021-07-24 02:37:17 +00:00
throw new IOException ( " Failed to copy original file to temp file " , e ) ;
2022-03-07 09:34:54 +00:00
} catch ( Throwable th9 ) {
th = th9 ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
ExifInterfaceUtils . closeQuietly ( fileOutputStream ) ;
2021-07-24 02:37:17 +00:00
throw th ;
}
2022-03-07 09:34:54 +00:00
} catch ( Throwable th10 ) {
th = th10 ;
fileInputStream3 = fileInputStream ;
2022-01-13 08:07:50 +00:00
ExifInterfaceUtils . closeQuietly ( fileInputStream3 ) ;
ExifInterfaceUtils . closeQuietly ( fileOutputStream ) ;
2021-07-24 02:37:17 +00:00
throw th ;
}
2022-01-13 08:07:50 +00:00
} else {
throw new IOException ( " ExifInterface does not support saving attributes when the image file has non-consecutive thumbnail strips " ) ;
2021-07-24 02:37:17 +00:00
}
}
public void setAltitude ( double d ) {
2021-08-09 22:51:56 +00:00
String str = d > = ShadowDrawableWrapper . COS_45 ? " 0 " : " 1 " ;
setAttribute ( TAG_GPS_ALTITUDE , new Rational ( Math . abs ( d ) ) . toString ( ) ) ;
setAttribute ( TAG_GPS_ALTITUDE_REF , str ) ;
2021-07-24 02:37:17 +00:00
}
public void setAttribute ( @NonNull String str , @Nullable String str2 ) {
ExifTag exifTag ;
int i ;
String str3 ;
2022-03-07 09:34:54 +00:00
Matcher matcher ;
2021-07-24 02:37:17 +00:00
String str4 = str ;
String str5 = str2 ;
Objects . requireNonNull ( str4 , " tag shouldn't be null " ) ;
2021-08-09 22:51:56 +00:00
if ( ( TAG_DATETIME . equals ( str4 ) | | TAG_DATETIME_ORIGINAL . equals ( str4 ) | | TAG_DATETIME_DIGITIZED . equals ( str4 ) ) & & str5 ! = null ) {
2021-07-24 02:37:17 +00:00
boolean find = DATETIME_PRIMARY_FORMAT_PATTERN . matcher ( str5 ) . find ( ) ;
boolean find2 = DATETIME_SECONDARY_FORMAT_PATTERN . matcher ( str5 ) . find ( ) ;
if ( str2 . length ( ) ! = 19 | | ( ! find & & ! find2 ) ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " Invalid value for " + str4 + " : " + str5 ) ;
2021-07-24 02:37:17 +00:00
return ;
} else if ( find2 ) {
str5 = str5 . replaceAll ( " - " , " : " ) ;
}
}
2021-08-09 22:51:56 +00:00
if ( TAG_ISO_SPEED_RATINGS . equals ( str4 ) ) {
2021-07-24 02:37:17 +00:00
if ( DEBUG ) {
2021-08-09 22:51:56 +00:00
Log . d ( TAG , " setAttribute: Replacing TAG_ISO_SPEED_RATINGS with TAG_PHOTOGRAPHIC_SENSITIVITY. " ) ;
2021-07-24 02:37:17 +00:00
}
2021-08-09 22:51:56 +00:00
str4 = TAG_PHOTOGRAPHIC_SENSITIVITY ;
2021-07-24 02:37:17 +00:00
}
int i2 = 2 ;
int i3 = 1 ;
if ( str5 ! = null & & sTagSetForCompatibility . contains ( str4 ) ) {
2021-08-09 22:51:56 +00:00
if ( str4 . equals ( TAG_GPS_TIMESTAMP ) ) {
2022-03-07 09:34:54 +00:00
if ( ! GPS_TIMESTAMP_PATTERN . matcher ( str5 ) . find ( ) ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " Invalid value for " + str4 + " : " + str5 ) ;
2021-07-24 02:37:17 +00:00
return ;
}
str5 = Integer . parseInt ( matcher . group ( 1 ) ) + " /1, " + Integer . parseInt ( matcher . group ( 2 ) ) + " /1, " + Integer . parseInt ( matcher . group ( 3 ) ) + " /1 " ;
} else {
try {
str5 = new Rational ( Double . parseDouble ( str5 ) ) . toString ( ) ;
} catch ( NumberFormatException unused ) {
2021-08-09 22:51:56 +00:00
Log . w ( TAG , " Invalid value for " + str4 + " : " + str5 ) ;
2021-07-24 02:37:17 +00:00
return ;
}
}
}
2021-12-17 21:59:34 +00:00
char c = 0 ;
2021-07-24 02:37:17 +00:00
int i4 = 0 ;
while ( i4 < EXIF_TAGS . length ) {
if ( ( i4 ! = 4 | | this . mHasThumbnail ) & & ( exifTag = sExifTagMapsForWriting [ i4 ] . get ( str4 ) ) ! = null ) {
if ( str5 = = null ) {
this . mAttributes [ i4 ] . remove ( str4 ) ;
} else {
Pair < Integer , Integer > guessDataFormat = guessDataFormat ( str5 ) ;
int i5 = - 1 ;
if ( exifTag . primaryFormat = = ( ( Integer ) guessDataFormat . first ) . intValue ( ) | | exifTag . primaryFormat = = ( ( Integer ) guessDataFormat . second ) . intValue ( ) ) {
i = exifTag . primaryFormat ;
} else {
int i6 = exifTag . secondaryFormat ;
if ( i6 = = - 1 | | ! ( i6 = = ( ( Integer ) guessDataFormat . first ) . intValue ( ) | | exifTag . secondaryFormat = = ( ( Integer ) guessDataFormat . second ) . intValue ( ) ) ) {
int i7 = exifTag . primaryFormat ;
if ( i7 = = i3 | | i7 = = 7 | | i7 = = i2 ) {
i = i7 ;
} else if ( DEBUG ) {
2022-03-21 18:52:30 +00:00
StringBuilder W = a . W ( " Given tag ( " , str4 , " ) value didn't match with one of expected formats: " ) ;
2021-07-24 02:37:17 +00:00
String [ ] strArr = IFD_FORMAT_NAMES ;
2022-03-21 18:52:30 +00:00
W . append ( strArr [ exifTag . primaryFormat ] ) ;
2021-07-24 02:37:17 +00:00
String str6 = " " ;
if ( exifTag . secondaryFormat = = - 1 ) {
str3 = str6 ;
} else {
2022-03-21 18:52:30 +00:00
StringBuilder R = a . R ( " , " ) ;
R . append ( strArr [ exifTag . secondaryFormat ] ) ;
str3 = R . toString ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-21 18:52:30 +00:00
W . append ( str3 ) ;
W . append ( " (guess: " ) ;
W . append ( strArr [ ( ( Integer ) guessDataFormat . first ) . intValue ( ) ] ) ;
2021-07-24 02:37:17 +00:00
if ( ( ( Integer ) guessDataFormat . second ) . intValue ( ) ! = - 1 ) {
2022-03-21 18:52:30 +00:00
StringBuilder R2 = a . R ( " , " ) ;
R2 . append ( strArr [ ( ( Integer ) guessDataFormat . second ) . intValue ( ) ] ) ;
str6 = R2 . toString ( ) ;
2021-07-24 02:37:17 +00:00
}
2022-03-21 18:52:30 +00:00
W . append ( str6 ) ;
W . append ( " ) " ) ;
Log . d ( TAG , W . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
}
} else {
i = exifTag . secondaryFormat ;
}
}
switch ( i ) {
case 1 :
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createByte ( str5 ) ) ;
continue ;
case 2 :
case 7 :
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createString ( str5 ) ) ;
continue ;
case 3 :
String [ ] split = str5 . split ( " , " , - 1 ) ;
int [ ] iArr = new int [ split . length ] ;
for ( int i8 = 0 ; i8 < split . length ; i8 + + ) {
iArr [ i8 ] = Integer . parseInt ( split [ i8 ] ) ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createUShort ( iArr , this . mExifByteOrder ) ) ;
continue ;
case 4 :
String [ ] split2 = str5 . split ( " , " , - 1 ) ;
long [ ] jArr = new long [ split2 . length ] ;
for ( int i9 = 0 ; i9 < split2 . length ; i9 + + ) {
jArr [ i9 ] = Long . parseLong ( split2 [ i9 ] ) ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createULong ( jArr , this . mExifByteOrder ) ) ;
continue ;
case 5 :
String [ ] split3 = str5 . split ( " , " , - 1 ) ;
Rational [ ] rationalArr = new Rational [ split3 . length ] ;
int i10 = 0 ;
while ( i10 < split3 . length ) {
2021-08-09 22:51:56 +00:00
String [ ] split4 = split3 [ i10 ] . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , i5 ) ;
2021-07-24 02:37:17 +00:00
rationalArr [ i10 ] = new Rational ( ( long ) Double . parseDouble ( split4 [ 0 ] ) , ( long ) Double . parseDouble ( split4 [ 1 ] ) ) ;
i10 + + ;
i5 = - 1 ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createURational ( rationalArr , this . mExifByteOrder ) ) ;
continue ;
case 6 :
case 8 :
case 11 :
default :
if ( DEBUG ) {
2022-03-21 18:52:30 +00:00
a . l0 ( " Data format isn't one of expected formats: " , i , TAG ) ;
2021-07-24 02:37:17 +00:00
break ;
} else {
continue ;
}
case 9 :
String [ ] split5 = str5 . split ( " , " , - 1 ) ;
int [ ] iArr2 = new int [ split5 . length ] ;
for ( int i11 = 0 ; i11 < split5 . length ; i11 + + ) {
iArr2 [ i11 ] = Integer . parseInt ( split5 [ i11 ] ) ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createSLong ( iArr2 , this . mExifByteOrder ) ) ;
continue ;
case 10 :
String [ ] split6 = str5 . split ( " , " , - 1 ) ;
Rational [ ] rationalArr2 = new Rational [ split6 . length ] ;
int i12 = 0 ;
while ( i12 < split6 . length ) {
2021-08-09 22:51:56 +00:00
String [ ] split7 = split6 [ i12 ] . split ( AutocompleteViewModel . COMMAND_DISCOVER_TOKEN , - 1 ) ;
2021-12-17 21:59:34 +00:00
rationalArr2 [ i12 ] = new Rational ( ( long ) Double . parseDouble ( split7 [ c ] ) , ( long ) Double . parseDouble ( split7 [ i3 ] ) ) ;
2021-07-24 02:37:17 +00:00
i12 + + ;
2021-12-17 21:59:34 +00:00
c = 0 ;
2021-07-24 02:37:17 +00:00
i3 = 1 ;
split6 = split6 ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createSRational ( rationalArr2 , this . mExifByteOrder ) ) ;
continue ;
case 12 :
String [ ] split8 = str5 . split ( " , " , - 1 ) ;
double [ ] dArr = new double [ split8 . length ] ;
for ( int i13 = 0 ; i13 < split8 . length ; i13 + + ) {
dArr [ i13 ] = Double . parseDouble ( split8 [ i13 ] ) ;
}
this . mAttributes [ i4 ] . put ( str4 , ExifAttribute . createDouble ( dArr , this . mExifByteOrder ) ) ;
continue ;
}
}
}
i4 + + ;
i2 = 2 ;
2021-12-17 21:59:34 +00:00
c = 0 ;
2021-07-24 02:37:17 +00:00
i3 = 1 ;
}
}
@RestrictTo ( { RestrictTo . Scope . LIBRARY } )
public void setDateTime ( @NonNull Long l ) {
2022-01-13 08:07:50 +00:00
Objects . requireNonNull ( l , " Timestamp should not be null. " ) ;
if ( l . longValue ( ) > = 0 ) {
String l2 = Long . toString ( l . longValue ( ) % 1000 ) ;
for ( int length = l2 . length ( ) ; length < 3 ; length + + ) {
l2 = a . v ( " 0 " , l2 ) ;
}
setAttribute ( TAG_DATETIME , sFormatterPrimary . format ( new Date ( l . longValue ( ) ) ) ) ;
setAttribute ( TAG_SUBSEC_TIME , l2 ) ;
return ;
}
throw new IllegalArgumentException ( " Timestamp should a positive value. " ) ;
2021-07-24 02:37:17 +00:00
}
public void setGpsInfo ( Location location ) {
if ( location ! = null ) {
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_GPS_PROCESSING_METHOD , location . getProvider ( ) ) ;
2021-07-24 02:37:17 +00:00
setLatLong ( location . getLatitude ( ) , location . getLongitude ( ) ) ;
setAltitude ( location . getAltitude ( ) ) ;
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_GPS_SPEED_REF , " K " ) ;
2022-03-07 09:34:54 +00:00
setAttribute ( TAG_GPS_SPEED , new Rational ( ( location . getSpeed ( ) * ( ( float ) TimeUnit . HOURS . toSeconds ( 1L ) ) ) / 1000 . 0f ) . toString ( ) ) ;
2021-07-24 02:37:17 +00:00
String [ ] split = sFormatterPrimary . format ( new Date ( location . getTime ( ) ) ) . split ( " \\ s+ " , - 1 ) ;
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_GPS_DATESTAMP , split [ 0 ] ) ;
setAttribute ( TAG_GPS_TIMESTAMP , split [ 1 ] ) ;
2021-07-24 02:37:17 +00:00
}
}
public void setLatLong ( double d , double d2 ) {
if ( d < - 90 . 0d | | d > 90 . 0d | | Double . isNaN ( d ) ) {
throw new IllegalArgumentException ( " Latitude value " + d + " is not valid. " ) ;
} else if ( d2 < - 180 . 0d | | d2 > 180 . 0d | | Double . isNaN ( d2 ) ) {
throw new IllegalArgumentException ( " Longitude value " + d2 + " is not valid. " ) ;
} else {
2021-08-09 22:51:56 +00:00
setAttribute ( TAG_GPS_LATITUDE_REF , d > = ShadowDrawableWrapper . COS_45 ? " N " : LATITUDE_SOUTH ) ;
setAttribute ( TAG_GPS_LATITUDE , convertDecimalDegree ( Math . abs ( d ) ) ) ;
setAttribute ( TAG_GPS_LONGITUDE_REF , d2 > = ShadowDrawableWrapper . COS_45 ? LONGITUDE_EAST : LONGITUDE_WEST ) ;
setAttribute ( TAG_GPS_LONGITUDE , convertDecimalDegree ( Math . abs ( d2 ) ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}