package A1;

import T0.C0304d;
import T0.C0305e;
import T0.C0307g;
import T0.InterfaceC0306f;
import T0.InterfaceC0308h;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class A {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C0304d f27a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final InterfaceC0308h f28b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public C0305e f29c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final int f30d;

    public A(InterfaceC0306f interfaceC0306f, InterfaceC0308h interfaceC0308h, long j8, long j9, long j10, long j11, long j12, int i) {
        this.f28b = interfaceC0308h;
        this.f30d = i;
        this.f27a = new C0304d(interfaceC0306f, j8, j9, j10, j11, j12);
    }

    public static int a(int i, byte[] bArr) {
        return (bArr[i + 3] & 255) | ((bArr[i] & 255) << 24) | ((bArr[i + 1] & 255) << 16) | ((bArr[i + 2] & 255) << 8);
    }

    public static int c(T0.j jVar, long j8, L4.h hVar) {
        if (j8 == jVar.f6428t) {
            return 0;
        }
        hVar.f4006a = j8;
        return 1;
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x00c6, code lost:
    
        return c(r28, r8, r29);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int b(T0.j jVar, L4.h hVar) {
        while (true) {
            C0305e c0305e = this.f29c;
            AbstractC1709a.k(c0305e);
            long j8 = c0305e.f6412f;
            long j9 = c0305e.f6413g;
            long j10 = c0305e.f6414h;
            long j11 = j9 - j8;
            long j12 = this.f30d;
            InterfaceC0308h interfaceC0308h = this.f28b;
            if (j11 <= j12) {
                this.f29c = null;
                interfaceC0308h.A();
                return c(jVar, j8, hVar);
            }
            long j13 = j10 - jVar.f6428t;
            if (j13 < 0 || j13 > 262144) {
                break;
            }
            jVar.b((int) j13);
            jVar.f6430v = 0;
            C0307g c0307gI = interfaceC0308h.i(jVar, c0305e.f6408b);
            int i = c0307gI.f6416a;
            if (i == -3) {
                this.f29c = null;
                interfaceC0308h.A();
                return c(jVar, j10, hVar);
            }
            long j14 = c0307gI.f6417b;
            long j15 = c0307gI.f6418c;
            if (i == -2) {
                c0305e.f6410d = j14;
                c0305e.f6412f = j15;
                c0305e.f6414h = C0305e.a(c0305e.f6408b, j14, c0305e.f6411e, j15, c0305e.f6413g, c0305e.f6409c);
            } else {
                if (i != -1) {
                    if (i != 0) {
                        throw new IllegalStateException("Invalid case");
                    }
                    long j16 = j15 - jVar.f6428t;
                    if (j16 >= 0 && j16 <= 262144) {
                        jVar.b((int) j16);
                    }
                    this.f29c = null;
                    interfaceC0308h.A();
                    return c(jVar, j15, hVar);
                }
                c0305e.f6411e = j14;
                c0305e.f6413g = j15;
                c0305e.f6414h = C0305e.a(c0305e.f6408b, c0305e.f6410d, j14, c0305e.f6412f, j15, c0305e.f6409c);
            }
        }
    }

    public final void d(long j8) {
        C0305e c0305e = this.f29c;
        if (c0305e == null || c0305e.f6407a != j8) {
            C0304d c0304d = this.f27a;
            this.f29c = new C0305e(j8, c0304d.f6401a.a(j8), c0304d.f6403c, c0304d.f6404d, c0304d.f6405e, c0304d.f6406f);
        }
    }
}
