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

import androidx.annotation.Nullable;
import androidx.media3.common.MimeTypes;
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;

/* JADX INFO: loaded from: classes2.dex */
public final class f4 implements a4 {

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

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

    public f4(int i10, zzguf zzgufVar) {
        this.f11012b = i10;
        this.f11011a = zzgufVar;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    public static f4 a(p01 p01Var, int i10) {
        String str;
        a4 g4Var;
        String str2;
        as1 as1Var = new as1(4);
        int i11 = p01Var.f15227c;
        int iA = -2;
        while (p01Var.y() > 8) {
            int iC = p01Var.c();
            int iC2 = p01Var.f15226b + p01Var.c();
            p01Var.A(iC2);
            if (iC != 1414744396) {
                switch (iC) {
                    case 1718776947:
                        if (iA != 2) {
                            if (iA == 1) {
                                int iK = p01Var.K();
                                String str3 = iK != 1 ? iK != 85 ? iK != 255 ? iK != 8192 ? iK != 8193 ? null : MimeTypes.AUDIO_DTS : MimeTypes.AUDIO_AC3 : MimeTypes.AUDIO_AAC : MimeTypes.AUDIO_MPEG : MimeTypes.AUDIO_RAW;
                                if (str3 != null) {
                                    int iK2 = p01Var.K();
                                    int iC3 = p01Var.c();
                                    p01Var.E(6);
                                    int iV = bb1.v(p01Var.K(), ByteOrder.LITTLE_ENDIAN);
                                    int iK3 = p01Var.y() > 0 ? p01Var.K() : 0;
                                    sm2 sm2Var = new sm2();
                                    sm2Var.zzm(str3);
                                    sm2Var.f16496s = iK2;
                                    sm2Var.f16497t = iC3;
                                    if (str3.equals(MimeTypes.AUDIO_RAW) && iV != 0) {
                                        sm2Var.f16498u = iV;
                                    }
                                    if (str3.equals(MimeTypes.AUDIO_AAC) && iK3 > 0) {
                                        byte[] bArr = new byte[iK3];
                                        p01Var.F(0, iK3, bArr);
                                        sm2Var.zzp(zzguf.o(bArr));
                                    }
                                    g4Var = new g4(new zn2(sm2Var));
                                } else {
                                    com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.q(new StringBuilder(String.valueOf(iK).length() + 43), "Ignoring track with unsupported format tag ", iK);
                                }
                            } else {
                                String str4 = bb1.f9474a;
                                switch (iA) {
                                    case -2:
                                        str = "none";
                                        break;
                                    case -1:
                                        str = "unknown";
                                        break;
                                    case 0:
                                        str = "default";
                                        break;
                                    case 1:
                                        str = "audio";
                                        break;
                                    case 2:
                                        str = "video";
                                        break;
                                    case 3:
                                        str = MimeTypes.BASE_TYPE_TEXT;
                                        break;
                                    case 4:
                                        str = MimeTypes.BASE_TYPE_IMAGE;
                                        break;
                                    case 5:
                                        str = "metadata";
                                        break;
                                    default:
                                        str = "camera motion";
                                        break;
                                }
                                vt0.c("Ignoring strf box for unsupported track type: ".concat(str));
                            }
                            g4Var = null;
                            break;
                        } else {
                            p01Var.E(4);
                            int iC4 = p01Var.c();
                            int iC5 = p01Var.c();
                            p01Var.E(4);
                            int iC6 = p01Var.c();
                            switch (iC6) {
                                case 808802372:
                                case 877677894:
                                case 1145656883:
                                case 1145656920:
                                case 1482049860:
                                case 1684633208:
                                case 2021026148:
                                    str2 = MimeTypes.VIDEO_MP4V;
                                    break;
                                case 826496577:
                                case 828601953:
                                case 875967048:
                                    str2 = MimeTypes.VIDEO_H264;
                                    break;
                                case 842289229:
                                    str2 = MimeTypes.VIDEO_MP42;
                                    break;
                                case 859066445:
                                    str2 = MimeTypes.VIDEO_MP43;
                                    break;
                                case 1196444237:
                                case 1735420525:
                                    str2 = MimeTypes.VIDEO_MJPEG;
                                    break;
                                default:
                                    str2 = null;
                                    break;
                            }
                            if (str2 != null) {
                                sm2 sm2Var2 = new sm2();
                                sm2Var2.f16487j = iC4;
                                sm2Var2.f16488k = iC5;
                                sm2Var2.zzm(str2);
                                g4Var = new g4(new zn2(sm2Var2));
                            } else {
                                com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.q(new StringBuilder(String.valueOf(iC6).length() + 44), "Ignoring track with unsupported compression ", iC6);
                                g4Var = null;
                            }
                        }
                        break;
                    case 1751742049:
                        int iC7 = p01Var.c();
                        p01Var.E(8);
                        int iC8 = p01Var.c();
                        int iC9 = p01Var.c();
                        p01Var.E(4);
                        p01Var.c();
                        p01Var.E(12);
                        g4Var = new c4(iC7, iC8, iC9);
                        break;
                    case 1752331379:
                        int iC10 = p01Var.c();
                        p01Var.E(12);
                        p01Var.c();
                        int iC11 = p01Var.c();
                        int iC12 = p01Var.c();
                        p01Var.E(4);
                        int iC13 = p01Var.c();
                        int iC14 = p01Var.c();
                        p01Var.E(4);
                        g4Var = new d4(iC10, iC11, iC12, iC13, iC14, p01Var.c());
                        break;
                    case 1852994675:
                        g4Var = new h4(p01Var.k(p01Var.y(), StandardCharsets.UTF_8));
                        break;
                    default:
                        g4Var = null;
                        break;
                }
            } else {
                g4Var = a(p01Var, p01Var.c());
            }
            if (g4Var != null) {
                if (g4Var.zza() == 1752331379) {
                    iA = ((d4) g4Var).a();
                }
                as1Var.a(g4Var);
            }
            p01Var.C(iC2);
            p01Var.A(i11);
        }
        return new f4(i10, as1Var.g());
    }

    @Override // com.google.android.gms.internal.ads.a4
    public final int zza() {
        return this.f11012b;
    }

    @Nullable
    public final a4 zzc(Class cls) {
        zzguf zzgufVar = this.f11011a;
        int size = zzgufVar.size();
        int i10 = 0;
        while (i10 < size) {
            a4 a4Var = (a4) zzgufVar.get(i10);
            i10++;
            if (a4Var.getClass() == cls) {
                return a4Var;
            }
        }
        return null;
    }
}
