package androidx.media3.extractor;

import androidx.annotation.Nullable;
import androidx.media3.common.ParserException;
import androidx.media3.common.util.CodecSpecificDataUtil;
import androidx.media3.common.util.ParsableByteArray;
import java.util.ArrayList;
import java.util.List;

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

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

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

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

    @Nullable
    public final String codecs;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final float f3378k;

    private h(List<byte[]> list, int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, float f10, @Nullable String str) {
        this.f3368a = list;
        this.f3369b = i10;
        this.f3370c = i11;
        this.f3371d = i12;
        this.f3372e = i13;
        this.f3373f = i14;
        this.f3374g = i15;
        this.f3375h = i16;
        this.f3376i = i17;
        this.f3377j = i18;
        this.f3378k = f10;
        this.codecs = str;
    }

    public static h a(ParsableByteArray parsableByteArray) throws ParserException {
        int i10;
        int i11;
        int i12;
        int i13;
        int i14;
        int i15;
        int i16;
        float f10;
        String strBuildAvcCodecString;
        int i17;
        try {
            parsableByteArray.skipBytes(4);
            int unsignedByte = (parsableByteArray.readUnsignedByte() & 3) + 1;
            if (unsignedByte == 3) {
                throw new IllegalStateException();
            }
            ArrayList arrayList = new ArrayList();
            int unsignedByte2 = parsableByteArray.readUnsignedByte() & 31;
            for (int i18 = 0; i18 < unsignedByte2; i18++) {
                int unsignedShort = parsableByteArray.readUnsignedShort();
                int position = parsableByteArray.getPosition();
                parsableByteArray.skipBytes(unsignedShort);
                arrayList.add(CodecSpecificDataUtil.buildNalUnit(parsableByteArray.getData(), position, unsignedShort));
            }
            int unsignedByte3 = parsableByteArray.readUnsignedByte();
            for (int i19 = 0; i19 < unsignedByte3; i19++) {
                int unsignedShort2 = parsableByteArray.readUnsignedShort();
                int position2 = parsableByteArray.getPosition();
                parsableByteArray.skipBytes(unsignedShort2);
                arrayList.add(CodecSpecificDataUtil.buildNalUnit(parsableByteArray.getData(), position2, unsignedShort2));
            }
            if (unsignedByte2 > 0) {
                byte[] bArr = (byte[]) arrayList.get(0);
                byte[] bArr2 = (byte[]) arrayList.get(0);
                byte[] bArr3 = q1.v.f32164a;
                q1.u uVarG = q1.v.g(4, bArr.length, bArr2);
                int i20 = uVarG.f32149e;
                int i21 = uVarG.f32150f;
                int i22 = uVarG.f32152h + 8;
                int i23 = uVarG.f32153i + 8;
                int i24 = uVarG.f32160p;
                int i25 = uVarG.f32161q;
                int i26 = uVarG.f32162r;
                int i27 = uVarG.f32163s;
                float f11 = uVarG.f32151g;
                strBuildAvcCodecString = CodecSpecificDataUtil.buildAvcCodecString(uVarG.f32145a, uVarG.f32146b, uVarG.f32147c);
                i15 = i25;
                i16 = i26;
                i17 = i27;
                f10 = f11;
                i11 = i21;
                i12 = i22;
                i13 = i23;
                i14 = i24;
                i10 = i20;
            } else {
                i10 = -1;
                i11 = -1;
                i12 = -1;
                i13 = -1;
                i14 = -1;
                i15 = -1;
                i16 = -1;
                f10 = 1.0f;
                strBuildAvcCodecString = null;
                i17 = 16;
            }
            return new h(arrayList, unsignedByte, i10, i11, i12, i13, i14, i15, i16, i17, f10, strBuildAvcCodecString);
        } catch (ArrayIndexOutOfBoundsException e10) {
            throw ParserException.createForMalformedContainer("Error parsing AVC config", e10);
        }
    }
}
