package ඓ.ῲ.K.ᕣ.ᕣ.ʬ;

import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import ඓ.ῲ.K.ᕣ.AbstractC0853;
import ඓ.ῲ.K.ᕣ.C0850;
import ඓ.ῲ.K.ᕣ.C1121;
import ඓ.ῲ.K.ᕣ.ᨨ.AbstractC1027;
import ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0976;
import ඓ.K.K.K.C1293;

/* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ  reason: contains not printable characters */
/* compiled from: VideoDecoder */
public class C0860<T> implements AbstractC0853<T, Bitmap> {

    /* renamed from: ඓ  reason: contains not printable characters */
    public static final C0850<Integer> f4099 = new C0850<>("com.bumptech.glide.load.resource.bitmap.VideoBitmapDecode.FrameOption", 2, new C0863());

    /* renamed from: 㴹  reason: contains not printable characters */
    public static final C0862 f4100 = new C0862();

    /* renamed from: 㸾  reason: contains not printable characters */
    public static final C0850<Long> f4101 = new C0850<>("com.bumptech.glide.load.resource.bitmap.VideoBitmapDecode.TargetFrame", -1L, new C0865());

    /* renamed from: ʬ  reason: contains not printable characters */
    public final C0862 f4102;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AbstractC0976 f4103;

    /* renamed from: K  reason: contains not printable characters */
    public final AbstractC0866<T> f4104;

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$ʬ  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public static final class C0861 implements AbstractC0866<AssetFileDescriptor> {
        public /* synthetic */ C0861(C0865 k) {
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.media.MediaMetadataRetriever, java.lang.Object] */
        @Override // ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0860.AbstractC0866
        /* renamed from: K  reason: contains not printable characters */
        public void m2495(MediaMetadataRetriever mediaMetadataRetriever, AssetFileDescriptor assetFileDescriptor) {
            AssetFileDescriptor assetFileDescriptor2 = assetFileDescriptor;
            mediaMetadataRetriever.setDataSource(assetFileDescriptor2.getFileDescriptor(), assetFileDescriptor2.getStartOffset(), assetFileDescriptor2.getLength());
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$ඓ  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public static class C0862 {
        /* renamed from: K  reason: contains not printable characters */
        public MediaMetadataRetriever m2496() {
            return new MediaMetadataRetriever();
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$ῲ  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public class C0863 implements C0850.AbstractC0851<Integer> {

        /* renamed from: K  reason: contains not printable characters */
        public final ByteBuffer f4105 = ByteBuffer.allocate(4);

        /* renamed from: K  reason: contains not printable characters */
        public void m2498(byte[] bArr, Integer num, MessageDigest messageDigest) {
            if (num != null) {
                messageDigest.update(bArr);
                synchronized (this.f4105) {
                    this.f4105.position(0);
                    messageDigest.update(this.f4105.putInt(num.intValue()).array());
                }
            }
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$ⁱ  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public static final class C0864 implements AbstractC0866<ParcelFileDescriptor> {
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.media.MediaMetadataRetriever, java.lang.Object] */
        @Override // ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0860.AbstractC0866
        /* renamed from: K  reason: contains not printable characters */
        public void m2499(MediaMetadataRetriever mediaMetadataRetriever, ParcelFileDescriptor parcelFileDescriptor) {
            mediaMetadataRetriever.setDataSource(parcelFileDescriptor.getFileDescriptor());
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$K  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public class C0865 implements C0850.AbstractC0851<Long> {

        /* renamed from: K  reason: contains not printable characters */
        public final ByteBuffer f4106 = ByteBuffer.allocate(8);

        /* renamed from: K  reason: contains not printable characters */
        public void m2501(byte[] bArr, Long l, MessageDigest messageDigest) {
            messageDigest.update(bArr);
            synchronized (this.f4106) {
                this.f4106.position(0);
                messageDigest.update(this.f4106.putLong(l.longValue()).array());
            }
        }
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$㴹  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public interface AbstractC0866<T> {
        /* renamed from: K  reason: contains not printable characters */
        void m2502(MediaMetadataRetriever mediaMetadataRetriever, T t);
    }

    /* renamed from: ඓ.ῲ.K.ᕣ.ᕣ.ʬ.ᑓ$㸾  reason: contains not printable characters */
    /* compiled from: VideoDecoder */
    public static final class C0867 implements AbstractC0866<ByteBuffer> {
        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.media.MediaMetadataRetriever, java.lang.Object] */
        @Override // ඓ.ῲ.K.ᕣ.ᕣ.ʬ.C0860.AbstractC0866
        /* renamed from: K  reason: contains not printable characters */
        public void m2503(MediaMetadataRetriever mediaMetadataRetriever, ByteBuffer byteBuffer) {
            mediaMetadataRetriever.setDataSource(new C0880(this, byteBuffer));
        }
    }

    public C0860(AbstractC0976 r2, AbstractC0866<T> r3) {
        C0862 r0 = f4100;
        this.f4103 = r2;
        this.f4104 = r3;
        this.f4102 = r0;
    }

    /* JADX DEBUG: Multi-variable search result rejected for r12v0, resolved type: ඓ.ῲ.K.ᕣ.㸾 */
    /* JADX WARN: Multi-variable type inference failed */
    @Override // ඓ.ῲ.K.ᕣ.AbstractC0853
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC1027<Bitmap> m2493(T t, int i, int i2, C1121 r12) throws IOException {
        long longValue = ((Long) r12.m3002(f4101)).longValue();
        if (longValue >= 0 || longValue == -1) {
            Integer num = (Integer) r12.m3002(f4099);
            if (num == null) {
                num = 2;
            }
            DownsampleStrategy downsampleStrategy = (DownsampleStrategy) r12.m3002(DownsampleStrategy.f2248);
            if (downsampleStrategy == null) {
                downsampleStrategy = DownsampleStrategy.f2244;
            }
            MediaMetadataRetriever r122 = this.f4102.m2496();
            try {
                this.f4104.m2502(r122, t);
                Bitmap r9 = m2492(r122, longValue, num.intValue(), i, i2, downsampleStrategy);
                r122.release();
                return C0859.m2488(r9, this.f4103);
            } catch (RuntimeException e) {
                throw new IOException(e);
            } catch (Throwable th) {
                r122.release();
                throw th;
            }
        } else {
            throw new IllegalArgumentException(C1293.m3409("Requested frame must be non-negative, or DEFAULT_FRAME, given: ", longValue));
        }
    }

    @Override // ඓ.ῲ.K.ᕣ.AbstractC0853
    /* renamed from: K  reason: contains not printable characters */
    public boolean m2494(T t, C1121 r2) {
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Bitmap m2492(MediaMetadataRetriever mediaMetadataRetriever, long j, int i, int i2, int i3, DownsampleStrategy downsampleStrategy) {
        Bitmap bitmap = null;
        if (!(Build.VERSION.SDK_INT < 27 || i2 == Integer.MIN_VALUE || i3 == Integer.MIN_VALUE || downsampleStrategy == DownsampleStrategy.f2249)) {
            try {
                int parseInt = Integer.parseInt(mediaMetadataRetriever.extractMetadata(18));
                int parseInt2 = Integer.parseInt(mediaMetadataRetriever.extractMetadata(19));
                int parseInt3 = Integer.parseInt(mediaMetadataRetriever.extractMetadata(24));
                if (parseInt3 == 90 || parseInt3 == 270) {
                    parseInt2 = parseInt;
                    parseInt = parseInt2;
                }
                float r0 = downsampleStrategy.m1317(parseInt, parseInt2, i2, i3);
                bitmap = mediaMetadataRetriever.getScaledFrameAtTime(j, i, Math.round(((float) parseInt) * r0), Math.round(r0 * ((float) parseInt2)));
            } catch (Throwable th) {
                if (Log.isLoggable("VideoDecoder", 3)) {
                    Log.d("VideoDecoder", "Exception trying to decode frame on oreo+", th);
                }
            }
        }
        return bitmap == null ? mediaMetadataRetriever.getFrameAtTime(j, i) : bitmap;
    }
}
