package com.google.android.gms.internal.ads;

import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class sa implements ja {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public u3 f16369e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public String f16370f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f16371g = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f16372h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f16373i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f16374j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public long f16375k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f16376l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public long f16377m;

    @Nullable
    private final String zzc;

    public sa(@Nullable String str, int i10, String str2) {
        p01 p01Var = new p01(4);
        this.f16365a = p01Var;
        p01Var.f15225a[0] = -1;
        this.f16366b = new i3();
        this.f16377m = -9223372036854775807L;
        this.zzc = str;
        this.f16367c = i10;
        this.f16368d = str2;
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void a(q2 q2Var, x2.o0 o0Var) {
        o0Var.d();
        o0Var.e();
        this.f16370f = o0Var.f34561e;
        o0Var.e();
        this.f16369e = q2Var.e(o0Var.f34560d, 1);
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void b(boolean z10) {
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void c(int i10, long j10) {
        this.f16377m = j10;
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void d(p01 p01Var) {
        this.f16369e.getClass();
        while (p01Var.y() > 0) {
            int i10 = this.f16371g;
            p01 p01Var2 = this.f16365a;
            if (i10 == 0) {
                byte[] bArr = p01Var.f15225a;
                int i11 = p01Var.f15226b;
                int i12 = p01Var.f15227c;
                while (true) {
                    if (i11 >= i12) {
                        p01Var.C(i12);
                        break;
                    }
                    int i13 = i11 + 1;
                    byte b10 = bArr[i11];
                    boolean z10 = (b10 & 255) == 255;
                    boolean z11 = this.f16374j && (b10 & 224) == 224;
                    this.f16374j = z10;
                    if (z11) {
                        p01Var.C(i13);
                        this.f16374j = false;
                        p01Var2.f15225a[1] = bArr[i11];
                        this.f16372h = 2;
                        this.f16371g = 1;
                        break;
                    }
                    i11 = i13;
                }
            } else if (i10 != 1) {
                int iMin = Math.min(p01Var.y(), this.f16376l - this.f16372h);
                this.f16369e.a(p01Var, iMin);
                int i14 = this.f16372h + iMin;
                this.f16372h = i14;
                if (i14 >= this.f16376l) {
                    ih1.b1(this.f16377m != -9223372036854775807L);
                    this.f16369e.zze(this.f16377m, 1, this.f16376l, 0, null);
                    this.f16377m += this.f16375k;
                    this.f16372h = 0;
                    this.f16371g = 0;
                }
            } else {
                int iMin2 = Math.min(p01Var.y(), 4 - this.f16372h);
                p01Var.F(this.f16372h, iMin2, p01Var2.f15225a);
                int i15 = this.f16372h + iMin2;
                this.f16372h = i15;
                if (i15 >= 4) {
                    p01Var2.C(0);
                    int iB = p01Var2.b();
                    i3 i3Var = this.f16366b;
                    if (i3Var.a(iB)) {
                        this.f16376l = i3Var.f12347b;
                        if (!this.f16373i) {
                            this.f16375k = (((long) i3Var.f12351f) * 1000000) / ((long) i3Var.f12348c);
                            sm2 sm2Var = new sm2();
                            sm2Var.zza(this.f16370f);
                            sm2Var.zzl(this.f16368d);
                            sm2Var.zzm(i3Var.zzb);
                            sm2Var.f16483f = 4096;
                            sm2Var.f16496s = i3Var.f12349d;
                            sm2Var.f16497t = i3Var.f12348c;
                            sm2Var.zze(this.zzc);
                            sm2Var.f16480c = this.f16367c;
                            this.f16369e.d(new zn2(sm2Var));
                            this.f16373i = true;
                        }
                        p01Var2.C(0);
                        this.f16369e.a(p01Var2, 4);
                        this.f16371g = 2;
                    } else {
                        this.f16372h = 0;
                        this.f16371g = 1;
                    }
                }
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void zza() {
        this.f16371g = 0;
        this.f16372h = 0;
        this.f16374j = false;
        this.f16377m = -9223372036854775807L;
    }
}
