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

import androidx.annotation.Nullable;
import androidx.media3.common.MimeTypes;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final androidx.media3.extractor.b1 f10715a;

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

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

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

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

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

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

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

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

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

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

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

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

    @Nullable
    private final String zzc;

    public ea(@Nullable String str, int i10, String str2) {
        androidx.media3.extractor.b1 b1Var = new androidx.media3.extractor.b1(new byte[16], 16);
        this.f10715a = b1Var;
        this.f10716b = new p01((byte[]) b1Var.f3327b);
        this.f10721g = 0;
        this.f10722h = 0;
        this.f10723i = false;
        this.f10727m = -9223372036854775807L;
        this.zzc = str;
        this.f10717c = i10;
        this.f10718d = str2;
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void a(q2 q2Var, x2.o0 o0Var) {
        o0Var.d();
        o0Var.e();
        this.f10719e = o0Var.f34561e;
        o0Var.e();
        this.f10720f = 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.f10727m = j10;
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void d(p01 p01Var) {
        this.f10720f.getClass();
        while (p01Var.y() > 0) {
            int i10 = this.f10721g;
            p01 p01Var2 = this.f10716b;
            if (i10 == 0) {
                while (p01Var.y() > 0) {
                    if (this.f10723i) {
                        int I = p01Var.I();
                        this.f10723i = I == 172;
                        if (I != 64) {
                            if (I == 65) {
                                I = 65;
                            }
                        }
                        this.f10721g = 1;
                        byte[] bArr = p01Var2.f15225a;
                        bArr[0] = -84;
                        bArr[1] = I == 65 ? (byte) 65 : (byte) 64;
                        this.f10722h = 2;
                    } else {
                        this.f10723i = p01Var.I() == 172;
                    }
                }
            } else if (i10 != 1) {
                int iMin = Math.min(p01Var.y(), this.f10726l - this.f10722h);
                this.f10720f.a(p01Var, iMin);
                int i11 = this.f10722h + iMin;
                this.f10722h = i11;
                if (i11 == this.f10726l) {
                    ih1.b1(this.f10727m != -9223372036854775807L);
                    this.f10720f.zze(this.f10727m, 1, this.f10726l, 0, null);
                    this.f10727m += this.f10724j;
                    this.f10721g = 0;
                }
            } else {
                byte[] bArr2 = p01Var2.f15225a;
                int iMin2 = Math.min(p01Var.y(), 16 - this.f10722h);
                p01Var.F(this.f10722h, iMin2, bArr2);
                int i12 = this.f10722h + iMin2;
                this.f10722h = i12;
                if (i12 == 16) {
                    androidx.media3.extractor.b1 b1Var = this.f10715a;
                    b1Var.l(0);
                    q0 q0VarA = y1.a(b1Var);
                    zn2 zn2Var = this.f10725k;
                    if (zn2Var == null || zn2Var.f19348u != 2 || q0VarA.f15558a != zn2Var.f19349v || !MimeTypes.AUDIO_AC4.equals(zn2Var.zzo)) {
                        sm2 sm2Var = new sm2();
                        sm2Var.zza(this.f10719e);
                        sm2Var.zzl(this.f10718d);
                        sm2Var.zzm(MimeTypes.AUDIO_AC4);
                        sm2Var.f16496s = 2;
                        sm2Var.f16497t = q0VarA.f15558a;
                        sm2Var.zze(this.zzc);
                        sm2Var.f16480c = this.f10717c;
                        zn2 zn2Var2 = new zn2(sm2Var);
                        this.f10725k = zn2Var2;
                        this.f10720f.d(zn2Var2);
                    }
                    this.f10726l = q0VarA.f15559b;
                    this.f10724j = (((long) q0VarA.f15560c) * 1000000) / ((long) this.f10725k.f19349v);
                    p01Var2.C(0);
                    this.f10720f.a(p01Var2, 16);
                    this.f10721g = 2;
                }
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.ja
    public final void zza() {
        this.f10721g = 0;
        this.f10722h = 0;
        this.f10723i = false;
        this.f10727m = -9223372036854775807L;
    }
}
