package y2;

import androidx.media3.common.Format;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.ParserException;
import androidx.media3.common.util.ParsableByteArray;
import androidx.media3.common.util.Util;
import androidx.media3.extractor.b0;
import androidx.media3.extractor.z0;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import okhttp3.internal.http.StatusLine;
import x.i;

/* JADX INFO: loaded from: classes.dex */
public final class a implements b {

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final int[] f36730m = {-1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8};

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public static final int[] f36731n = {7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, TTAdConstant.IMAGE_MODE_VERTICAL_IMG_173, 190, 209, 230, 253, 279, StatusLine.HTTP_TEMP_REDIRECT, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767};

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final byte[] f36736e;

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

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

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

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

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

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

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

    public a(b0 b0Var, z0 z0Var, i iVar) throws ParserException {
        this.f36732a = b0Var;
        this.f36733b = z0Var;
        this.f36734c = iVar;
        int iMax = Math.max(1, iVar.f34309c / 10);
        this.f36738g = iMax;
        ParsableByteArray parsableByteArray = new ParsableByteArray((byte[]) iVar.f34313g);
        parsableByteArray.readLittleEndianUnsignedShort();
        int littleEndianUnsignedShort = parsableByteArray.readLittleEndianUnsignedShort();
        this.f36735d = littleEndianUnsignedShort;
        int i10 = iVar.f34308b;
        int i11 = iVar.f34311e;
        int i12 = (((i11 - (i10 * 4)) * 8) / (iVar.f34312f * i10)) + 1;
        if (littleEndianUnsignedShort != i12) {
            throw ParserException.createForMalformedContainer("Expected frames per block: " + i12 + "; got: " + littleEndianUnsignedShort, null);
        }
        int iCeilDivide = Util.ceilDivide(iMax, littleEndianUnsignedShort);
        this.f36736e = new byte[iCeilDivide * i11];
        this.f36737f = new ParsableByteArray(littleEndianUnsignedShort * 2 * i10 * iCeilDivide);
        int i13 = iVar.f34309c;
        int i14 = ((i11 * i13) * 8) / littleEndianUnsignedShort;
        this.f36739h = new Format.Builder().setSampleMimeType(MimeTypes.AUDIO_RAW).setAverageBitrate(i14).setPeakBitrate(i14).setMaxInputSize(iMax * 2 * i10).setChannelCount(i10).setSampleRate(i13).setPcmEncoding(2).build();
    }

    @Override // y2.b
    public final void a(long j10) {
        this.f36740i = 0;
        this.f36741j = j10;
        this.f36742k = 0;
        this.f36743l = 0L;
    }

    /* JADX WARN: Removed duplicated region for block: B:44:0x0045 A[ADDED_TO_REGION, EDGE_INSN: B:44:0x0045->B:14:0x0045 BREAK  A[LOOP:0: B:6:0x0023->B:13:0x003f], REMOVE, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0027  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:11:0x003c -> B:4:0x0020). Please report as a decompilation issue!!! */
    /*  JADX ERROR: JadxOverflowException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxOverflowException: Regions count limit reached
        	at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:59)
        	at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31)
        	at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:19)
        */
    @Override // y2.b
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean b(androidx.media3.extractor.z r25, long r26) {
        /*
            Method dump skipped, instruction units count: 345
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: y2.a.b(androidx.media3.extractor.z, long):boolean");
    }

    @Override // y2.b
    public final void c(int i10, long j10) {
        f fVar = new f(this.f36734c, this.f36735d, i10, j10);
        this.f36732a.seekMap(fVar);
        z0 z0Var = this.f36733b;
        z0Var.format(this.f36739h);
        z0Var.durationUs(fVar.f36765e);
    }

    public final void d(int i10) {
        long j10 = this.f36741j;
        long j11 = this.f36743l;
        i iVar = this.f36734c;
        long jScaleLargeTimestamp = j10 + Util.scaleLargeTimestamp(j11, 1000000L, iVar.f34309c);
        int i11 = i10 * 2 * iVar.f34308b;
        this.f36733b.sampleMetadata(jScaleLargeTimestamp, 1, i11, this.f36742k - i11, null);
        this.f36743l += (long) i10;
        this.f36742k -= i11;
    }
}
