package O;

import I.c;
import I.g;
import I.h;
import M.i;
import android.graphics.Bitmap;
import androidx.core.location.LocationRequestCompat;
import b0.AbstractC0399d;
import b0.D;
import b0.o;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class b implements g {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private long[] f1460a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private long[] f1461b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private i f1462c;

    public b() {
        long[] jArr = {0, LocationRequestCompat.PASSIVE_INTERVAL};
        this.f1460a = jArr;
        long[] jArrCopyOf = Arrays.copyOf(jArr, jArr.length);
        this.f1461b = jArrCopyOf;
        Arrays.sort(jArrCopyOf);
    }

    @Override // I.g
    public int a(long j2) {
        AbstractC0399d.a(j2 >= 0);
        int iB = D.b(this.f1461b, j2, false, false);
        if (iB < this.f1461b.length) {
            return iB;
        }
        return -1;
    }

    @Override // I.g
    public long b(int i2) {
        AbstractC0399d.a(i2 >= 0);
        AbstractC0399d.a(i2 < this.f1461b.length);
        return this.f1461b[i2];
    }

    @Override // I.g
    public List c(long j2) {
        if (this.f1462c == null) {
            return Collections.emptyList();
        }
        o.d("PGSSubtitle", "getCues timeUs = " + j2, 16);
        int size = this.f1462c.h().size();
        ArrayList arrayList = null;
        for (int i2 = 0; i2 < size; i2++) {
            long[] jArr = this.f1460a;
            if (jArr[0] <= j2 && j2 < jArr[1]) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                try {
                    this.f1462c.a(i2);
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
                M.a aVarE = this.f1462c.e();
                if (aVarE != null) {
                    float f2 = this.f1462c.f(i2);
                    float fG = this.f1462c.g(i2);
                    Bitmap bitmapC = aVarE.c();
                    h.a(bitmapC, j2, i2);
                    arrayList.add((f2 <= 1.0E-6f || fG <= 1.0E-6f) ? new c(bitmapC) : new c(bitmapC, f2, fG));
                    o.d("PGSSubtitle", "getCues bmp width = " + bitmapC.getWidth() + " heigth = " + bitmapC.getHeight() + ", imageNum =" + size, 16);
                }
            }
        }
        return arrayList != null ? arrayList : Collections.emptyList();
    }

    @Override // I.g
    public int d() {
        return this.f1461b.length;
    }

    public b(i iVar, long j2) {
        this.f1462c = iVar;
        this.f1460a = new long[]{j2, 0};
        o.d("PGSSubtitle", " start = " + this.f1460a[0], 16);
        this.f1460a[1] = Long.MAX_VALUE;
        o.d("PGSSubtitle", " end = " + this.f1460a[1], 16);
        long[] jArr = this.f1460a;
        long[] jArrCopyOf = Arrays.copyOf(jArr, jArr.length);
        this.f1461b = jArrCopyOf;
        Arrays.sort(jArrCopyOf);
    }
}
