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

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

/* JADX INFO: loaded from: classes2.dex */
public abstract class f7 {
    public static int a(p01 p01Var) {
        int iB = p01Var.b();
        if (p01Var.b() == 1684108385) {
            p01Var.E(8);
            int i10 = iB - 16;
            if (i10 == 1) {
                return p01Var.I();
            }
            if (i10 == 2) {
                return p01Var.J();
            }
            if (i10 == 3) {
                return p01Var.M();
            }
            if (i10 == 4 && (p01Var.G() & 128) == 0) {
                return p01Var.h();
            }
        }
        vt0.c("Failed to parse data atom to int");
        return -1;
    }

    public static void zza(int i10, @Nullable ta taVar, sm2 sm2Var, @Nullable ta taVar2, ta... taVarArr) {
        if (taVar2 == null) {
            taVar2 = new ta(new z9[0]);
        }
        if (taVar != null) {
            bs1 bs1Var = zzguf.f19771b;
            as1 as1Var = new as1(4);
            for (z9 z9Var : taVar.f16828a) {
                if (kf1.class.isAssignableFrom(z9Var.getClass())) {
                    as1Var.a((z9) kf1.class.cast(z9Var));
                }
            }
            zzgwa zzgwaVar = (zzgwa) as1Var.g();
            int i11 = zzgwaVar.f19788d;
            for (int i12 = 0; i12 < i11; i12++) {
                kf1 kf1Var = (kf1) zzgwaVar.get(i12);
                if (!kf1Var.f13245a.equals("com.android.capture.fps") || i10 == 2) {
                    taVar2 = taVar2.b(kf1Var);
                }
            }
        }
        for (ta taVar3 : taVarArr) {
            taVar2 = taVar2.zzf(taVar3);
        }
        if (taVar2.f16828a.length > 0) {
            sm2Var.zzk(taVar2);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:137:0x0277 A[Catch: all -> 0x0043, TryCatch #0 {all -> 0x0043, blocks: (B:9:0x002c, B:11:0x0037, B:15:0x0046, B:18:0x0052, B:21:0x005f, B:24:0x006c, B:27:0x0079, B:30:0x0087, B:32:0x0093, B:40:0x00ae, B:41:0x00cc, B:42:0x00de, B:45:0x00ea, B:48:0x00f7, B:51:0x0104, B:54:0x0111, B:57:0x011e, B:60:0x012b, B:63:0x0138, B:66:0x0145, B:69:0x0152, B:72:0x015f, B:76:0x0170, B:78:0x0174, B:80:0x0184, B:81:0x018b, B:83:0x0192, B:88:0x019d, B:93:0x01a9, B:137:0x0277, B:94:0x01be, B:96:0x01c5, B:98:0x01d1, B:99:0x01e5, B:112:0x020f, B:115:0x021c, B:118:0x0229, B:121:0x0236, B:124:0x0242, B:127:0x024e, B:130:0x0258, B:133:0x0264, B:136:0x0270, B:138:0x0294, B:139:0x029b), top: B:144:0x001e }] */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static z9 zzc(p01 p01Var) {
        String str;
        z9 f5Var;
        int iB = p01Var.b() + p01Var.f15226b;
        int iB2 = p01Var.b();
        int i10 = (iB2 >> 24) & 255;
        z9 z9VarZzd = null;
        try {
            if (i10 == 169 || i10 == 253) {
                int i11 = iB2 & 16777215;
                if (i11 == 6516084) {
                    int iB3 = p01Var.b();
                    if (p01Var.b() == 1684108385) {
                        p01Var.E(8);
                        String strL = p01Var.l(iB3 - 16);
                        z9VarZzd = new j5(C.LANGUAGE_UNDETERMINED, strL, strL);
                    } else {
                        vt0.c("Failed to parse comment attribute: ".concat(q1.f.e(iB2)));
                    }
                } else if (i11 == 7233901 || i11 == 7631467) {
                    z9VarZzd = zzd(iB2, "TIT2", p01Var);
                } else if (i11 == 6516589 || i11 == 7828084) {
                    z9VarZzd = zzd(iB2, "TCOM", p01Var);
                } else if (i11 == 6578553) {
                    z9VarZzd = zzd(iB2, "TDRC", p01Var);
                } else if (i11 == 4280916) {
                    z9VarZzd = zzd(iB2, "TPE1", p01Var);
                } else if (i11 == 7630703) {
                    z9VarZzd = zzd(iB2, "TSSE", p01Var);
                } else if (i11 == 6384738) {
                    z9VarZzd = zzd(iB2, "TALB", p01Var);
                } else if (i11 == 7108978) {
                    z9VarZzd = zzd(iB2, "USLT", p01Var);
                } else if (i11 == 6776174) {
                    z9VarZzd = zzd(iB2, "TCON", p01Var);
                } else if (i11 == 6779504) {
                    z9VarZzd = zzd(iB2, "TIT1", p01Var);
                } else if (i11 == 7173742) {
                    z9VarZzd = zzd(iB2, "MVNM", p01Var);
                } else if (i11 == 7173737) {
                    z9VarZzd = zze(iB2, "MVIN", p01Var, true, false);
                } else {
                    String strE = q1.f.e(iB2);
                    StringBuilder sb = new StringBuilder(strE.length() + 32);
                    sb.append("Skipped unknown metadata entry: ");
                    sb.append(strE);
                    vt0.a(sb.toString());
                }
            } else if (iB2 == 1735291493) {
                String strZza = p5.zza(a(p01Var) - 1);
                if (strZza != null) {
                    f5Var = new t5("TCON", null, zzguf.o(strZza));
                    z9VarZzd = f5Var;
                } else {
                    vt0.c("Failed to parse standard genre code");
                }
            } else if (iB2 == 1684632427) {
                z9VarZzd = zzg(1684632427, "TPOS", p01Var);
            } else if (iB2 == 1953655662) {
                z9VarZzd = zzg(1953655662, "TRCK", p01Var);
            } else if (iB2 == 1953329263) {
                z9VarZzd = zze(1953329263, "TBPM", p01Var, true, false);
            } else if (iB2 == 1668311404) {
                z9VarZzd = zze(1668311404, "TCMP", p01Var, true, true);
            } else if (iB2 == 1668249202) {
                int iB4 = p01Var.b();
                if (p01Var.b() == 1684108385) {
                    int iB5 = p01Var.b();
                    byte[] bArr = y6.f18669a;
                    int i12 = iB5 & 16777215;
                    if (i12 == 13) {
                        str = MimeTypes.IMAGE_JPEG;
                    } else if (i12 == 14) {
                        str = MimeTypes.IMAGE_PNG;
                        i12 = 14;
                    } else {
                        str = null;
                    }
                    if (str == null) {
                        StringBuilder sb2 = new StringBuilder(String.valueOf(i12).length() + 30);
                        sb2.append("Unrecognized cover art flags: ");
                        sb2.append(i12);
                        vt0.c(sb2.toString());
                    } else {
                        p01Var.E(4);
                        int i13 = iB4 - 16;
                        byte[] bArr2 = new byte[i13];
                        p01Var.F(0, i13, bArr2);
                        f5Var = new f5(str, null, 3, bArr2);
                        z9VarZzd = f5Var;
                    }
                } else {
                    vt0.c("Failed to parse cover art attribute");
                }
            } else if (iB2 == 1631670868) {
                z9VarZzd = zzd(1631670868, "TPE2", p01Var);
            } else if (iB2 == 1936682605) {
                z9VarZzd = zzd(1936682605, "TSOT", p01Var);
            } else if (iB2 == 1936679276) {
                z9VarZzd = zzd(1936679276, "TSOA", p01Var);
            } else if (iB2 == 1936679282) {
                z9VarZzd = zzd(1936679282, "TSOP", p01Var);
            } else if (iB2 == 1936679265) {
                z9VarZzd = zzd(1936679265, "TSO2", p01Var);
            } else if (iB2 == 1936679791) {
                z9VarZzd = zzd(1936679791, "TSOC", p01Var);
            } else if (iB2 == 1920233063) {
                z9VarZzd = zze(1920233063, "ITUNESADVISORY", p01Var, false, false);
            } else if (iB2 == 1885823344) {
                z9VarZzd = zze(1885823344, "ITUNESGAPLESS", p01Var, false, true);
            } else if (iB2 == 1936683886) {
                z9VarZzd = zzd(1936683886, "TVSHOWSORT", p01Var);
            } else if (iB2 == 1953919848) {
                z9VarZzd = zzd(1953919848, "TVSHOW", p01Var);
            } else if (iB2 == 757935405) {
                int i14 = -1;
                int i15 = -1;
                String strL2 = null;
                String strL3 = null;
                while (true) {
                    int i16 = p01Var.f15226b;
                    if (i16 >= iB) {
                        break;
                    }
                    int iB6 = p01Var.b();
                    int iB7 = p01Var.b();
                    p01Var.E(4);
                    if (iB7 == 1835360622) {
                        strL2 = p01Var.l(iB6 - 12);
                    } else {
                        int i17 = iB6 - 12;
                        if (iB7 == 1851878757) {
                            strL3 = p01Var.l(i17);
                        } else {
                            if (iB7 == 1684108385) {
                                i15 = iB6;
                            }
                            if (iB7 == 1684108385) {
                                i14 = i16;
                            }
                            p01Var.E(i17);
                        }
                    }
                }
                if (strL2 != null && strL3 != null && i14 != -1) {
                    p01Var.C(i14);
                    p01Var.E(16);
                    z9VarZzd = new q5(strL2, strL3, p01Var.l(i15 - 16));
                }
            }
            return z9VarZzd;
        } finally {
            p01Var.C(iB);
        }
    }

    @Nullable
    private static t5 zzd(int i10, String str, p01 p01Var) {
        int iB = p01Var.b();
        if (p01Var.b() == 1684108385) {
            p01Var.E(8);
            return new t5(str, null, zzguf.o(p01Var.l(iB - 16)));
        }
        vt0.c("Failed to parse text attribute: ".concat(q1.f.e(i10)));
        return null;
    }

    @Nullable
    private static o5 zze(int i10, String str, p01 p01Var, boolean z10, boolean z11) {
        int iA = a(p01Var);
        if (z11) {
            iA = Math.min(1, iA);
        }
        if (iA >= 0) {
            return z10 ? new t5(str, null, zzguf.o(Integer.toString(iA))) : new j5(C.LANGUAGE_UNDETERMINED, str, Integer.toString(iA));
        }
        vt0.c("Failed to parse uint8 attribute: ".concat(q1.f.e(i10)));
        return null;
    }

    @Nullable
    private static t5 zzg(int i10, String str, p01 p01Var) {
        int iB = p01Var.b();
        if (p01Var.b() == 1684108385 && iB >= 22) {
            p01Var.E(10);
            int iJ = p01Var.J();
            if (iJ > 0) {
                StringBuilder sb = new StringBuilder(String.valueOf(iJ).length());
                sb.append(iJ);
                String string = sb.toString();
                int iJ2 = p01Var.J();
                if (iJ2 > 0) {
                    StringBuilder sb2 = new StringBuilder(string.length() + 1 + String.valueOf(iJ2).length());
                    sb2.append(string);
                    sb2.append("/");
                    sb2.append(iJ2);
                    string = sb2.toString();
                }
                return new t5(str, null, zzguf.o(string));
            }
        }
        vt0.c("Failed to parse index/count attribute: ".concat(q1.f.e(i10)));
        return null;
    }
}
