package com.google.android.exoplayer2.c.d;

import android.util.Pair;
import android.util.SparseArray;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.c.d.a.a;
import com.google.android.exoplayer2.c.d.a.b;
import com.google.android.exoplayer2.c.f;
import com.google.android.exoplayer2.c.g;
import com.google.android.exoplayer2.c.h;
import com.google.android.exoplayer2.c.m;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
import com.google.android.exoplayer2.i.j;
import com.google.android.exoplayer2.i.l;
import com.google.android.exoplayer2.i.s;
import com.google.android.exoplayer2.i.v;
import com.google.android.exoplayer2.o;
import com.tencent.matrix.trace.core.AppMethodBeat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
import java.util.UUID;

public final class e implements com.google.android.exoplayer2.c.e {
    public static final h aTh = new 1();
    private static final int aXX = v.aT("seig");
    private static final byte[] aXY = new byte[]{(byte) -94, (byte) 57, (byte) 79, (byte) 82, (byte) 90, (byte) -101, (byte) 79, (byte) 20, (byte) -94, (byte) 68, (byte) 108, (byte) 66, (byte) 124, (byte) 100, (byte) -115, (byte) -12};
    private long aOz;
    private g aTn;
    private int aTo;
    private final l aTx;
    private int aUF;
    private int aUG;
    private final j aXZ;
    private final SparseArray<b> aYa;
    private final l aYb;
    private final l aYc;
    private final l aYd;
    private final l aYe;
    private final s aYf;
    private final l aYg;
    private final byte[] aYh;
    private final Stack<a> aYi;
    private final LinkedList<a> aYj;
    private int aYk;
    private long aYl;
    private int aYm;
    private l aYn;
    private long aYo;
    private int aYp;
    private long aYq;
    private b aYr;
    private boolean aYs;
    private m aYt;
    private m[] aYu;
    private boolean aYv;
    private final int flags;
    private int sampleSize;

    static {
        AppMethodBeat.i(94989);
        AppMethodBeat.o(94989);
    }

    public e() {
        this(0);
    }

    public e(int i) {
        this(i, null);
    }

    public e(int i, s sVar) {
        this(i, sVar, (byte) 0);
    }

    private e(int i, s sVar, byte b) {
        AppMethodBeat.i(94965);
        this.flags = i | 0;
        this.aYf = sVar;
        this.aXZ = null;
        this.aYg = new l(16);
        this.aTx = new l(j.bqY);
        this.aYb = new l(5);
        this.aYc = new l();
        this.aYd = new l(1);
        this.aYe = new l();
        this.aYh = new byte[16];
        this.aYi = new Stack();
        this.aYj = new LinkedList();
        this.aYa = new SparseArray();
        this.aOz = -9223372036854775807L;
        this.aYq = -9223372036854775807L;
        ri();
        AppMethodBeat.o(94965);
    }

    public final boolean a(f fVar) {
        AppMethodBeat.i(94966);
        boolean g = i.g(fVar);
        AppMethodBeat.o(94966);
        return g;
    }

    public final void a(g gVar) {
        AppMethodBeat.i(94967);
        this.aTn = gVar;
        if (this.aXZ != null) {
            b bVar = new b(gVar.dM(0));
            bVar.a(this.aXZ, new c(0, 0, 0, 0));
            this.aYa.put(0, bVar);
            rj();
            this.aTn.rb();
        }
        AppMethodBeat.o(94967);
    }

    public final void g(long j, long j2) {
        AppMethodBeat.i(94968);
        int size = this.aYa.size();
        for (int i = 0; i < size; i++) {
            ((b) this.aYa.valueAt(i)).reset();
        }
        this.aYj.clear();
        this.aYp = 0;
        this.aYi.clear();
        ri();
        AppMethodBeat.o(94968);
    }

    /* JADX WARNING: Removed duplicated region for block: B:279:0x0006 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:273:0x0501 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:275:0x0006 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:267:0x0066 A:{SYNTHETIC} */
    public final int a(com.google.android.exoplayer2.c.f r26, com.google.android.exoplayer2.c.k r27) {
        /*
        r25 = this;
        r4 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r4);
    L_0x0006:
        r0 = r25;
        r4 = r0.aTo;
        switch(r4) {
            case 0: goto L_0x004b;
            case 1: goto L_0x02c5;
            case 2: goto L_0x0463;
            default: goto L_0x000d;
        };
    L_0x000d:
        r0 = r25;
        r4 = r0.aTo;
        r5 = 3;
        if (r4 != r5) goto L_0x05bf;
    L_0x0014:
        r0 = r25;
        r4 = r0.aYr;
        if (r4 != 0) goto L_0x0524;
    L_0x001a:
        r0 = r25;
        r11 = r0.aYa;
        r5 = 0;
        r8 = 9223372036854775807; // 0x7fffffffffffffff float:NaN double:NaN;
        r12 = r11.size();
        r4 = 0;
        r10 = r4;
    L_0x002a:
        if (r10 >= r12) goto L_0x04d9;
    L_0x002c:
        r4 = r11.valueAt(r10);
        r4 = (com.google.android.exoplayer2.c.d.e.b) r4;
        r6 = r4.aYC;
        r7 = r4.aYx;
        r7 = r7.aZA;
        if (r6 == r7) goto L_0x081f;
    L_0x003a:
        r6 = r4.aYx;
        r6 = r6.aZB;
        r7 = r4.aYC;
        r6 = r6[r7];
        r13 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r13 >= 0) goto L_0x081f;
    L_0x0046:
        r10 = r10 + 1;
        r8 = r6;
        r5 = r4;
        goto L_0x002a;
    L_0x004b:
        r0 = r25;
        r4 = r0.aYm;
        if (r4 != 0) goto L_0x0094;
    L_0x0051:
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.data;
        r5 = 0;
        r6 = 8;
        r7 = 1;
        r0 = r26;
        r4 = r0.a(r4, r5, r6, r7);
        if (r4 != 0) goto L_0x006e;
    L_0x0063:
        r4 = 0;
    L_0x0064:
        if (r4 != 0) goto L_0x0006;
    L_0x0066:
        r4 = -1;
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
    L_0x006d:
        return r4;
    L_0x006e:
        r4 = 8;
        r0 = r25;
        r0.aYm = r4;
        r0 = r25;
        r4 = r0.aYg;
        r5 = 0;
        r4.setPosition(r5);
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.cM();
        r0 = r25;
        r0.aYl = r4;
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.readInt();
        r0 = r25;
        r0.aYk = r4;
    L_0x0094:
        r0 = r25;
        r4 = r0.aYl;
        r6 = 1;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 != 0) goto L_0x00df;
    L_0x009e:
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.data;
        r5 = 8;
        r6 = 8;
        r0 = r26;
        r0.readFully(r4, r5, r6);
        r0 = r25;
        r4 = r0.aYm;
        r4 = r4 + 8;
        r0 = r25;
        r0.aYm = r4;
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.tK();
        r0 = r25;
        r0.aYl = r4;
    L_0x00c3:
        r0 = r25;
        r4 = r0.aYl;
        r0 = r25;
        r6 = r0.aYm;
        r6 = (long) r6;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 >= 0) goto L_0x011f;
    L_0x00d0:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Atom size less than header length (unsupported).";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x00df:
        r0 = r25;
        r4 = r0.aYl;
        r6 = 0;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 != 0) goto L_0x00c3;
    L_0x00e9:
        r4 = r26.getLength();
        r6 = -1;
        r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r6 != 0) goto L_0x0109;
    L_0x00f3:
        r0 = r25;
        r6 = r0.aYi;
        r6 = r6.isEmpty();
        if (r6 != 0) goto L_0x0109;
    L_0x00fd:
        r0 = r25;
        r4 = r0.aYi;
        r4 = r4.peek();
        r4 = (com.google.android.exoplayer2.c.d.a.a) r4;
        r4 = r4.aXw;
    L_0x0109:
        r6 = -1;
        r6 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r6 == 0) goto L_0x00c3;
    L_0x010f:
        r6 = r26.getPosition();
        r4 = r4 - r6;
        r0 = r25;
        r6 = r0.aYm;
        r6 = (long) r6;
        r4 = r4 + r6;
        r0 = r25;
        r0.aYl = r4;
        goto L_0x00c3;
    L_0x011f:
        r4 = r26.getPosition();
        r0 = r25;
        r6 = r0.aYm;
        r6 = (long) r6;
        r6 = r4 - r6;
        r0 = r25;
        r4 = r0.aYk;
        r5 = com.google.android.exoplayer2.c.d.a.aWr;
        if (r4 != r5) goto L_0x0154;
    L_0x0132:
        r0 = r25;
        r4 = r0.aYa;
        r8 = r4.size();
        r4 = 0;
        r5 = r4;
    L_0x013c:
        if (r5 >= r8) goto L_0x0154;
    L_0x013e:
        r0 = r25;
        r4 = r0.aYa;
        r4 = r4.valueAt(r5);
        r4 = (com.google.android.exoplayer2.c.d.e.b) r4;
        r4 = r4.aYx;
        r4.aZx = r6;
        r4.aZz = r6;
        r4.aZy = r6;
        r4 = r5 + 1;
        r5 = r4;
        goto L_0x013c;
    L_0x0154:
        r0 = r25;
        r4 = r0.aYk;
        r5 = com.google.android.exoplayer2.c.d.a.aVO;
        if (r4 != r5) goto L_0x018d;
    L_0x015c:
        r4 = 0;
        r0 = r25;
        r0.aYr = r4;
        r0 = r25;
        r4 = r0.aYl;
        r4 = r4 + r6;
        r0 = r25;
        r0.aYo = r4;
        r0 = r25;
        r4 = r0.aYv;
        if (r4 != 0) goto L_0x0185;
    L_0x0170:
        r0 = r25;
        r4 = r0.aTn;
        r5 = new com.google.android.exoplayer2.c.l$a;
        r0 = r25;
        r6 = r0.aOz;
        r5.<init>(r6);
        r4.a(r5);
        r4 = 1;
        r0 = r25;
        r0.aYv = r4;
    L_0x0185:
        r4 = 2;
        r0 = r25;
        r0.aTo = r4;
    L_0x018a:
        r4 = 1;
        goto L_0x0064;
    L_0x018d:
        r0 = r25;
        r4 = r0.aYk;
        r5 = com.google.android.exoplayer2.c.d.a.aWi;
        if (r4 == r5) goto L_0x01b5;
    L_0x0195:
        r5 = com.google.android.exoplayer2.c.d.a.aWk;
        if (r4 == r5) goto L_0x01b5;
    L_0x0199:
        r5 = com.google.android.exoplayer2.c.d.a.aWl;
        if (r4 == r5) goto L_0x01b5;
    L_0x019d:
        r5 = com.google.android.exoplayer2.c.d.a.aWm;
        if (r4 == r5) goto L_0x01b5;
    L_0x01a1:
        r5 = com.google.android.exoplayer2.c.d.a.aWn;
        if (r4 == r5) goto L_0x01b5;
    L_0x01a5:
        r5 = com.google.android.exoplayer2.c.d.a.aWr;
        if (r4 == r5) goto L_0x01b5;
    L_0x01a9:
        r5 = com.google.android.exoplayer2.c.d.a.aWs;
        if (r4 == r5) goto L_0x01b5;
    L_0x01ad:
        r5 = com.google.android.exoplayer2.c.d.a.aWt;
        if (r4 == r5) goto L_0x01b5;
    L_0x01b1:
        r5 = com.google.android.exoplayer2.c.d.a.aWw;
        if (r4 != r5) goto L_0x01e7;
    L_0x01b5:
        r4 = 1;
    L_0x01b6:
        if (r4 == 0) goto L_0x01ed;
    L_0x01b8:
        r4 = r26.getPosition();
        r0 = r25;
        r6 = r0.aYl;
        r4 = r4 + r6;
        r6 = 8;
        r4 = r4 - r6;
        r0 = r25;
        r6 = r0.aYi;
        r7 = new com.google.android.exoplayer2.c.d.a$a;
        r0 = r25;
        r8 = r0.aYk;
        r7.<init>(r8, r4);
        r6.add(r7);
        r0 = r25;
        r6 = r0.aYl;
        r0 = r25;
        r8 = r0.aYm;
        r8 = (long) r8;
        r6 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r6 != 0) goto L_0x01e9;
    L_0x01e1:
        r0 = r25;
        r0.P(r4);
        goto L_0x018a;
    L_0x01e7:
        r4 = 0;
        goto L_0x01b6;
    L_0x01e9:
        r25.ri();
        goto L_0x018a;
    L_0x01ed:
        r0 = r25;
        r4 = r0.aYk;
        r5 = com.google.android.exoplayer2.c.d.a.aWz;
        if (r4 == r5) goto L_0x0241;
    L_0x01f5:
        r5 = com.google.android.exoplayer2.c.d.a.aWy;
        if (r4 == r5) goto L_0x0241;
    L_0x01f9:
        r5 = com.google.android.exoplayer2.c.d.a.aWj;
        if (r4 == r5) goto L_0x0241;
    L_0x01fd:
        r5 = com.google.android.exoplayer2.c.d.a.aWh;
        if (r4 == r5) goto L_0x0241;
    L_0x0201:
        r5 = com.google.android.exoplayer2.c.d.a.aWA;
        if (r4 == r5) goto L_0x0241;
    L_0x0205:
        r5 = com.google.android.exoplayer2.c.d.a.aWd;
        if (r4 == r5) goto L_0x0241;
    L_0x0209:
        r5 = com.google.android.exoplayer2.c.d.a.aWe;
        if (r4 == r5) goto L_0x0241;
    L_0x020d:
        r5 = com.google.android.exoplayer2.c.d.a.aWv;
        if (r4 == r5) goto L_0x0241;
    L_0x0211:
        r5 = com.google.android.exoplayer2.c.d.a.aWf;
        if (r4 == r5) goto L_0x0241;
    L_0x0215:
        r5 = com.google.android.exoplayer2.c.d.a.aWg;
        if (r4 == r5) goto L_0x0241;
    L_0x0219:
        r5 = com.google.android.exoplayer2.c.d.a.aWB;
        if (r4 == r5) goto L_0x0241;
    L_0x021d:
        r5 = com.google.android.exoplayer2.c.d.a.aWJ;
        if (r4 == r5) goto L_0x0241;
    L_0x0221:
        r5 = com.google.android.exoplayer2.c.d.a.aWK;
        if (r4 == r5) goto L_0x0241;
    L_0x0225:
        r5 = com.google.android.exoplayer2.c.d.a.aWO;
        if (r4 == r5) goto L_0x0241;
    L_0x0229:
        r5 = com.google.android.exoplayer2.c.d.a.aWN;
        if (r4 == r5) goto L_0x0241;
    L_0x022d:
        r5 = com.google.android.exoplayer2.c.d.a.aWL;
        if (r4 == r5) goto L_0x0241;
    L_0x0231:
        r5 = com.google.android.exoplayer2.c.d.a.aWM;
        if (r4 == r5) goto L_0x0241;
    L_0x0235:
        r5 = com.google.android.exoplayer2.c.d.a.aWx;
        if (r4 == r5) goto L_0x0241;
    L_0x0239:
        r5 = com.google.android.exoplayer2.c.d.a.aWu;
        if (r4 == r5) goto L_0x0241;
    L_0x023d:
        r5 = com.google.android.exoplayer2.c.d.a.aXn;
        if (r4 != r5) goto L_0x025b;
    L_0x0241:
        r4 = 1;
    L_0x0242:
        if (r4 == 0) goto L_0x029f;
    L_0x0244:
        r0 = r25;
        r4 = r0.aYm;
        r5 = 8;
        if (r4 == r5) goto L_0x025d;
    L_0x024c:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Leaf atom defines extended atom size (unsupported).";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x025b:
        r4 = 0;
        goto L_0x0242;
    L_0x025d:
        r0 = r25;
        r4 = r0.aYl;
        r6 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 <= 0) goto L_0x0277;
    L_0x0268:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Leaf atom with length > 2147483647 (unsupported).";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x0277:
        r4 = new com.google.android.exoplayer2.i.l;
        r0 = r25;
        r6 = r0.aYl;
        r5 = (int) r6;
        r4.<init>(r5);
        r0 = r25;
        r0.aYn = r4;
        r0 = r25;
        r4 = r0.aYg;
        r4 = r4.data;
        r5 = 0;
        r0 = r25;
        r6 = r0.aYn;
        r6 = r6.data;
        r7 = 0;
        r8 = 8;
        java.lang.System.arraycopy(r4, r5, r6, r7, r8);
        r4 = 1;
        r0 = r25;
        r0.aTo = r4;
        goto L_0x018a;
    L_0x029f:
        r0 = r25;
        r4 = r0.aYl;
        r6 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r4 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r4 <= 0) goto L_0x02b9;
    L_0x02aa:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Skipping atom with length > 2147483647 (unsupported).";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x02b9:
        r4 = 0;
        r0 = r25;
        r0.aYn = r4;
        r4 = 1;
        r0 = r25;
        r0.aTo = r4;
        goto L_0x018a;
    L_0x02c5:
        r0 = r25;
        r4 = r0.aYl;
        r4 = (int) r4;
        r0 = r25;
        r5 = r0.aYm;
        r4 = r4 - r5;
        r0 = r25;
        r5 = r0.aYn;
        if (r5 == 0) goto L_0x045c;
    L_0x02d5:
        r0 = r25;
        r5 = r0.aYn;
        r5 = r5.data;
        r6 = 8;
        r0 = r26;
        r0.readFully(r5, r6, r4);
        r5 = new com.google.android.exoplayer2.c.d.a$b;
        r0 = r25;
        r4 = r0.aYk;
        r0 = r25;
        r6 = r0.aYn;
        r5.<init>(r4, r6);
        r6 = r26.getPosition();
        r0 = r25;
        r4 = r0.aYi;
        r4 = r4.isEmpty();
        if (r4 != 0) goto L_0x0315;
    L_0x02fd:
        r0 = r25;
        r4 = r0.aYi;
        r4 = r4.peek();
        r4 = (com.google.android.exoplayer2.c.d.a.a) r4;
        r4.a(r5);
    L_0x030a:
        r4 = r26.getPosition();
        r0 = r25;
        r0.P(r4);
        goto L_0x0006;
    L_0x0315:
        r4 = r5.type;
        r8 = com.google.android.exoplayer2.c.d.a.aWh;
        if (r4 != r8) goto L_0x03ef;
    L_0x031b:
        r13 = r5.aXz;
        r4 = 8;
        r13.setPosition(r4);
        r4 = r13.readInt();
        r4 = com.google.android.exoplayer2.c.d.a.dT(r4);
        r5 = 4;
        r13.eM(r5);
        r8 = r13.cM();
        if (r4 != 0) goto L_0x0387;
    L_0x0334:
        r4 = r13.cM();
        r10 = r13.cM();
        r6 = r6 + r10;
        r10 = r6;
    L_0x033e:
        r6 = 1000000; // 0xf4240 float:1.401298E-39 double:4.940656E-318;
        r16 = com.google.android.exoplayer2.i.v.b(r4, r6, r8);
        r6 = 2;
        r13.eM(r6);
        r20 = r13.readUnsignedShort();
        r0 = r20;
        r0 = new int[r0];
        r21 = r0;
        r0 = r20;
        r0 = new long[r0];
        r22 = r0;
        r0 = r20;
        r0 = new long[r0];
        r23 = r0;
        r0 = r20;
        r0 = new long[r0];
        r24 = r0;
        r6 = 0;
        r12 = r6;
        r14 = r16;
        r18 = r10;
    L_0x036b:
        r0 = r20;
        if (r12 >= r0) goto L_0x03bc;
    L_0x036f:
        r6 = r13.readInt();
        r7 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        r7 = r7 & r6;
        if (r7 == 0) goto L_0x0392;
    L_0x0378:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Unhandled indirect reference";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x0387:
        r4 = r13.tK();
        r10 = r13.tK();
        r6 = r6 + r10;
        r10 = r6;
        goto L_0x033e;
    L_0x0392:
        r10 = r13.cM();
        r7 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r6 = r6 & r7;
        r21[r12] = r6;
        r22[r12] = r18;
        r24[r12] = r14;
        r4 = r4 + r10;
        r6 = 1000000; // 0xf4240 float:1.401298E-39 double:4.940656E-318;
        r10 = com.google.android.exoplayer2.i.v.b(r4, r6, r8);
        r6 = r24[r12];
        r6 = r10 - r6;
        r23[r12] = r6;
        r6 = 4;
        r13.eM(r6);
        r6 = r21[r12];
        r6 = (long) r6;
        r18 = r18 + r6;
        r6 = r12 + 1;
        r12 = r6;
        r14 = r10;
        goto L_0x036b;
    L_0x03bc:
        r4 = java.lang.Long.valueOf(r16);
        r5 = new com.google.android.exoplayer2.c.a;
        r0 = r21;
        r1 = r22;
        r2 = r23;
        r3 = r24;
        r5.<init>(r0, r1, r2, r3);
        r5 = android.util.Pair.create(r4, r5);
        r4 = r5.first;
        r4 = (java.lang.Long) r4;
        r6 = r4.longValue();
        r0 = r25;
        r0.aYq = r6;
        r0 = r25;
        r6 = r0.aTn;
        r4 = r5.second;
        r4 = (com.google.android.exoplayer2.c.l) r4;
        r6.a(r4);
        r4 = 1;
        r0 = r25;
        r0.aYv = r4;
        goto L_0x030a;
    L_0x03ef:
        r4 = r5.type;
        r6 = com.google.android.exoplayer2.c.d.a.aXn;
        if (r4 != r6) goto L_0x030a;
    L_0x03f5:
        r10 = r5.aXz;
        r0 = r25;
        r4 = r0.aYt;
        if (r4 == 0) goto L_0x030a;
    L_0x03fd:
        r4 = 12;
        r10.setPosition(r4);
        r10.tL();
        r10.tL();
        r8 = r10.cM();
        r4 = r10.cM();
        r6 = 1000000; // 0xf4240 float:1.401298E-39 double:4.940656E-318;
        r6 = com.google.android.exoplayer2.i.v.b(r4, r6, r8);
        r4 = 12;
        r10.setPosition(r4);
        r9 = r10.tB();
        r0 = r25;
        r4 = r0.aYt;
        r4.a(r10, r9);
        r0 = r25;
        r4 = r0.aYq;
        r10 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r4 = (r4 > r10 ? 1 : (r4 == r10 ? 0 : -1));
        if (r4 == 0) goto L_0x0445;
    L_0x0434:
        r0 = r25;
        r5 = r0.aYt;
        r0 = r25;
        r10 = r0.aYq;
        r6 = r6 + r10;
        r8 = 1;
        r10 = 0;
        r11 = 0;
        r5.a(r6, r8, r9, r10, r11);
        goto L_0x030a;
    L_0x0445:
        r0 = r25;
        r4 = r0.aYj;
        r5 = new com.google.android.exoplayer2.c.d.e$a;
        r5.<init>(r6, r9);
        r4.addLast(r5);
        r0 = r25;
        r4 = r0.aYp;
        r4 = r4 + r9;
        r0 = r25;
        r0.aYp = r4;
        goto L_0x030a;
    L_0x045c:
        r0 = r26;
        r0.dG(r4);
        goto L_0x030a;
    L_0x0463:
        r5 = 0;
        r6 = 9223372036854775807; // 0x7fffffffffffffff float:NaN double:NaN;
        r0 = r25;
        r4 = r0.aYa;
        r9 = r4.size();
        r4 = 0;
        r8 = r4;
    L_0x0473:
        if (r8 >= r9) goto L_0x049b;
    L_0x0475:
        r0 = r25;
        r4 = r0.aYa;
        r4 = r4.valueAt(r8);
        r4 = (com.google.android.exoplayer2.c.d.e.b) r4;
        r4 = r4.aYx;
        r10 = r4.aZM;
        if (r10 == 0) goto L_0x0823;
    L_0x0485:
        r10 = r4.aZz;
        r10 = (r10 > r6 ? 1 : (r10 == r6 ? 0 : -1));
        if (r10 >= 0) goto L_0x0823;
    L_0x048b:
        r6 = r4.aZz;
        r0 = r25;
        r4 = r0.aYa;
        r4 = r4.valueAt(r8);
        r4 = (com.google.android.exoplayer2.c.d.e.b) r4;
    L_0x0497:
        r8 = r8 + 1;
        r5 = r4;
        goto L_0x0473;
    L_0x049b:
        if (r5 != 0) goto L_0x04a4;
    L_0x049d:
        r4 = 3;
        r0 = r25;
        r0.aTo = r4;
        goto L_0x0006;
    L_0x04a4:
        r8 = r26.getPosition();
        r6 = r6 - r8;
        r4 = (int) r6;
        if (r4 >= 0) goto L_0x04bb;
    L_0x04ac:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Offset to encryption data was negative.";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x04bb:
        r0 = r26;
        r0.dG(r4);
        r4 = r5.aYx;
        r5 = r4.aZL;
        r5 = r5.data;
        r6 = 0;
        r7 = r4.aZK;
        r0 = r26;
        r0.readFully(r5, r6, r7);
        r5 = r4.aZL;
        r6 = 0;
        r5.setPosition(r6);
        r5 = 0;
        r4.aZM = r5;
        goto L_0x0006;
    L_0x04d9:
        if (r5 != 0) goto L_0x050a;
    L_0x04db:
        r0 = r25;
        r4 = r0.aYo;
        r6 = r26.getPosition();
        r4 = r4 - r6;
        r4 = (int) r4;
        if (r4 >= 0) goto L_0x04f6;
    L_0x04e7:
        r4 = new com.google.android.exoplayer2.o;
        r5 = "Offset to end of mdat was negative.";
        r4.<init>(r5);
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        throw r4;
    L_0x04f6:
        r0 = r26;
        r0.dG(r4);
        r25.ri();
        r4 = 0;
    L_0x04ff:
        if (r4 == 0) goto L_0x0006;
    L_0x0501:
        r4 = 0;
        r5 = 94969; // 0x172f9 float:1.3308E-40 double:4.6921E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r5);
        goto L_0x006d;
    L_0x050a:
        r4 = r5.aYx;
        r4 = r4.aZB;
        r6 = r5.aYC;
        r6 = r4[r6];
        r8 = r26.getPosition();
        r6 = r6 - r8;
        r4 = (int) r6;
        if (r4 >= 0) goto L_0x051b;
    L_0x051a:
        r4 = 0;
    L_0x051b:
        r0 = r26;
        r0.dG(r4);
        r0 = r25;
        r0.aYr = r5;
    L_0x0524:
        r0 = r25;
        r4 = r0.aYr;
        r4 = r4.aYx;
        r4 = r4.aZD;
        r0 = r25;
        r5 = r0.aYr;
        r5 = r5.aYA;
        r4 = r4[r5];
        r0 = r25;
        r0.sampleSize = r4;
        r0 = r25;
        r4 = r0.aYr;
        r4 = r4.aYx;
        r4 = r4.aZH;
        if (r4 == 0) goto L_0x0698;
    L_0x0542:
        r0 = r25;
        r7 = r0.aYr;
        r8 = r7.aYx;
        r4 = r8.aZw;
        r4 = r4.aXT;
        r5 = r8.aZJ;
        if (r5 == 0) goto L_0x0666;
    L_0x0550:
        r4 = r8.aZJ;
    L_0x0552:
        r5 = r4.aZu;
        if (r5 == 0) goto L_0x066e;
    L_0x0556:
        r5 = r8.aZL;
        r4 = r4.aZu;
    L_0x055a:
        r6 = r8.aZI;
        r9 = r7.aYA;
        r9 = r6[r9];
        r0 = r25;
        r6 = r0.aYd;
        r10 = r6.data;
        r11 = 0;
        if (r9 == 0) goto L_0x067f;
    L_0x0569:
        r6 = 128; // 0x80 float:1.794E-43 double:6.32E-322;
    L_0x056b:
        r6 = r6 | r4;
        r6 = (byte) r6;
        r10[r11] = r6;
        r0 = r25;
        r6 = r0.aYd;
        r10 = 0;
        r6.setPosition(r10);
        r6 = r7.aTw;
        r0 = r25;
        r7 = r0.aYd;
        r10 = 1;
        r6.a(r7, r10);
        r6.a(r5, r4);
        if (r9 != 0) goto L_0x0682;
    L_0x0586:
        r4 = r4 + 1;
    L_0x0588:
        r0 = r25;
        r0.aUG = r4;
        r0 = r25;
        r4 = r0.sampleSize;
        r0 = r25;
        r5 = r0.aUG;
        r4 = r4 + r5;
        r0 = r25;
        r0.sampleSize = r4;
    L_0x0599:
        r0 = r25;
        r4 = r0.aYr;
        r4 = r4.aYy;
        r4 = r4.aZo;
        r5 = 1;
        if (r4 != r5) goto L_0x05b5;
    L_0x05a4:
        r0 = r25;
        r4 = r0.sampleSize;
        r4 = r4 + -8;
        r0 = r25;
        r0.sampleSize = r4;
        r4 = 8;
        r0 = r26;
        r0.dG(r4);
    L_0x05b5:
        r4 = 4;
        r0 = r25;
        r0.aTo = r4;
        r4 = 0;
        r0 = r25;
        r0.aUF = r4;
    L_0x05bf:
        r0 = r25;
        r4 = r0.aYr;
        r0 = r4.aYx;
        r16 = r0;
        r0 = r25;
        r4 = r0.aYr;
        r9 = r4.aYy;
        r0 = r25;
        r4 = r0.aYr;
        r5 = r4.aTw;
        r0 = r25;
        r4 = r0.aYr;
        r8 = r4.aYA;
        r4 = r9.aTz;
        if (r4 == 0) goto L_0x0735;
    L_0x05dd:
        r0 = r25;
        r4 = r0.aYb;
        r7 = r4.data;
        r4 = 0;
        r6 = 0;
        r7[r4] = r6;
        r4 = 1;
        r6 = 0;
        r7[r4] = r6;
        r4 = 2;
        r6 = 0;
        r7[r4] = r6;
        r4 = r9.aTz;
        r10 = r4 + 1;
        r4 = r9.aTz;
        r11 = 4 - r4;
    L_0x05f7:
        r0 = r25;
        r4 = r0.aUG;
        r0 = r25;
        r6 = r0.sampleSize;
        if (r4 >= r6) goto L_0x0759;
    L_0x0601:
        r0 = r25;
        r4 = r0.aUF;
        if (r4 != 0) goto L_0x06a1;
    L_0x0607:
        r0 = r26;
        r0.readFully(r7, r11, r10);
        r0 = r25;
        r4 = r0.aYb;
        r6 = 0;
        r4.setPosition(r6);
        r0 = r25;
        r4 = r0.aYb;
        r4 = r4.tI();
        r4 = r4 + -1;
        r0 = r25;
        r0.aUF = r4;
        r0 = r25;
        r4 = r0.aTx;
        r6 = 0;
        r4.setPosition(r6);
        r0 = r25;
        r4 = r0.aTx;
        r6 = 4;
        r5.a(r4, r6);
        r0 = r25;
        r4 = r0.aYb;
        r6 = 1;
        r5.a(r4, r6);
        r0 = r25;
        r4 = r0.aYu;
        if (r4 == 0) goto L_0x069f;
    L_0x0640:
        r4 = r9.aOv;
        r4 = r4.aOd;
        r6 = 4;
        r6 = r7[r6];
        r4 = com.google.android.exoplayer2.i.j.b(r4, r6);
        if (r4 == 0) goto L_0x069f;
    L_0x064d:
        r4 = 1;
    L_0x064e:
        r0 = r25;
        r0.aYs = r4;
        r0 = r25;
        r4 = r0.aUG;
        r4 = r4 + 5;
        r0 = r25;
        r0.aUG = r4;
        r0 = r25;
        r4 = r0.sampleSize;
        r4 = r4 + r11;
        r0 = r25;
        r0.sampleSize = r4;
        goto L_0x05f7;
    L_0x0666:
        r5 = r7.aYy;
        r4 = r5.dZ(r4);
        goto L_0x0552;
    L_0x066e:
        r4 = r4.aZv;
        r0 = r25;
        r5 = r0.aYe;
        r6 = r4.length;
        r5.n(r4, r6);
        r0 = r25;
        r5 = r0.aYe;
        r4 = r4.length;
        goto L_0x055a;
    L_0x067f:
        r6 = 0;
        goto L_0x056b;
    L_0x0682:
        r5 = r8.aZL;
        r7 = r5.readUnsignedShort();
        r8 = -2;
        r5.eM(r8);
        r7 = r7 * 6;
        r7 = r7 + 2;
        r6.a(r5, r7);
        r4 = r4 + 1;
        r4 = r4 + r7;
        goto L_0x0588;
    L_0x0698:
        r4 = 0;
        r0 = r25;
        r0.aUG = r4;
        goto L_0x0599;
    L_0x069f:
        r4 = 0;
        goto L_0x064e;
    L_0x06a1:
        r0 = r25;
        r4 = r0.aYs;
        if (r4 == 0) goto L_0x0729;
    L_0x06a7:
        r0 = r25;
        r4 = r0.aYc;
        r0 = r25;
        r6 = r0.aUF;
        r4.reset(r6);
        r0 = r25;
        r4 = r0.aYc;
        r4 = r4.data;
        r6 = 0;
        r0 = r25;
        r12 = r0.aUF;
        r0 = r26;
        r0.readFully(r4, r6, r12);
        r0 = r25;
        r4 = r0.aYc;
        r0 = r25;
        r6 = r0.aUF;
        r5.a(r4, r6);
        r0 = r25;
        r6 = r0.aUF;
        r0 = r25;
        r4 = r0.aYc;
        r4 = r4.data;
        r0 = r25;
        r12 = r0.aYc;
        r12 = r12.limit;
        r12 = com.google.android.exoplayer2.i.j.j(r4, r12);
        r0 = r25;
        r13 = r0.aYc;
        r4 = "video/hevc";
        r14 = r9.aOv;
        r14 = r14.aOd;
        r4 = r4.equals(r14);
        if (r4 == 0) goto L_0x0727;
    L_0x06f2:
        r4 = 1;
    L_0x06f3:
        r13.setPosition(r4);
        r0 = r25;
        r4 = r0.aYc;
        r4.eL(r12);
        r0 = r16;
        r12 = r0.eb(r8);
        r14 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r12 = r12 * r14;
        r0 = r25;
        r4 = r0.aYc;
        r0 = r25;
        r14 = r0.aYu;
        com.google.android.exoplayer2.f.a.g.a(r12, r4, r14);
        r4 = r6;
    L_0x0712:
        r0 = r25;
        r6 = r0.aUG;
        r6 = r6 + r4;
        r0 = r25;
        r0.aUG = r6;
        r0 = r25;
        r6 = r0.aUF;
        r4 = r6 - r4;
        r0 = r25;
        r0.aUF = r4;
        goto L_0x05f7;
    L_0x0727:
        r4 = 0;
        goto L_0x06f3;
    L_0x0729:
        r0 = r25;
        r4 = r0.aUF;
        r6 = 0;
        r0 = r26;
        r4 = r5.a(r0, r4, r6);
        goto L_0x0712;
    L_0x0735:
        r0 = r25;
        r4 = r0.aUG;
        r0 = r25;
        r6 = r0.sampleSize;
        if (r4 >= r6) goto L_0x0759;
    L_0x073f:
        r0 = r25;
        r4 = r0.sampleSize;
        r0 = r25;
        r6 = r0.aUG;
        r4 = r4 - r6;
        r6 = 0;
        r0 = r26;
        r4 = r5.a(r0, r4, r6);
        r0 = r25;
        r6 = r0.aUG;
        r4 = r4 + r6;
        r0 = r25;
        r0.aUG = r4;
        goto L_0x0735;
    L_0x0759:
        r0 = r16;
        r6 = r0.eb(r8);
        r10 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r6 = r6 * r10;
        r0 = r25;
        r4 = r0.aYf;
        if (r4 == 0) goto L_0x0770;
    L_0x0768:
        r0 = r25;
        r4 = r0.aYf;
        r6 = r4.ap(r6);
    L_0x0770:
        r0 = r16;
        r4 = r0.aZG;
        r4 = r4[r8];
        if (r4 == 0) goto L_0x07c9;
    L_0x0778:
        r4 = 1;
    L_0x0779:
        r11 = 0;
        r0 = r16;
        r8 = r0.aZH;
        if (r8 == 0) goto L_0x081c;
    L_0x0780:
        r8 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
        r8 = r8 | r4;
        r0 = r16;
        r4 = r0.aZJ;
        if (r4 == 0) goto L_0x07cb;
    L_0x0789:
        r0 = r16;
        r4 = r0.aZJ;
    L_0x078d:
        r11 = r4.aUO;
    L_0x078f:
        r0 = r25;
        r9 = r0.sampleSize;
        r10 = 0;
        r5.a(r6, r8, r9, r10, r11);
    L_0x0797:
        r0 = r25;
        r4 = r0.aYj;
        r4 = r4.isEmpty();
        if (r4 != 0) goto L_0x07d6;
    L_0x07a1:
        r0 = r25;
        r4 = r0.aYj;
        r4 = r4.removeFirst();
        r4 = (com.google.android.exoplayer2.c.d.e.a) r4;
        r0 = r25;
        r5 = r0.aYp;
        r8 = r4.size;
        r5 = r5 - r8;
        r0 = r25;
        r0.aYp = r5;
        r0 = r25;
        r9 = r0.aYt;
        r10 = r4.aYw;
        r10 = r10 + r6;
        r12 = 1;
        r13 = r4.size;
        r0 = r25;
        r14 = r0.aYp;
        r15 = 0;
        r9.a(r10, r12, r13, r14, r15);
        goto L_0x0797;
    L_0x07c9:
        r4 = 0;
        goto L_0x0779;
    L_0x07cb:
        r0 = r16;
        r4 = r0.aZw;
        r4 = r4.aXT;
        r4 = r9.dZ(r4);
        goto L_0x078d;
    L_0x07d6:
        r0 = r25;
        r4 = r0.aYr;
        r5 = r4.aYA;
        r5 = r5 + 1;
        r4.aYA = r5;
        r0 = r25;
        r4 = r0.aYr;
        r5 = r4.aYB;
        r5 = r5 + 1;
        r4.aYB = r5;
        r0 = r25;
        r4 = r0.aYr;
        r4 = r4.aYB;
        r0 = r16;
        r5 = r0.aZC;
        r0 = r25;
        r6 = r0.aYr;
        r6 = r6.aYC;
        r5 = r5[r6];
        if (r4 != r5) goto L_0x0814;
    L_0x07fe:
        r0 = r25;
        r4 = r0.aYr;
        r5 = r4.aYC;
        r5 = r5 + 1;
        r4.aYC = r5;
        r0 = r25;
        r4 = r0.aYr;
        r5 = 0;
        r4.aYB = r5;
        r4 = 0;
        r0 = r25;
        r0.aYr = r4;
    L_0x0814:
        r4 = 3;
        r0 = r25;
        r0.aTo = r4;
        r4 = 1;
        goto L_0x04ff;
    L_0x081c:
        r8 = r4;
        goto L_0x078f;
    L_0x081f:
        r6 = r8;
        r4 = r5;
        goto L_0x0046;
    L_0x0823:
        r4 = r5;
        goto L_0x0497;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.exoplayer2.c.d.e.a(com.google.android.exoplayer2.c.f, com.google.android.exoplayer2.c.k):int");
    }

    private void ri() {
        this.aTo = 0;
        this.aYm = 0;
    }

    private void P(long j) {
        AppMethodBeat.i(94970);
        while (!this.aYi.isEmpty() && ((a) this.aYi.peek()).aXw == j) {
            c((a) this.aYi.pop());
        }
        ri();
        AppMethodBeat.o(94970);
    }

    private void c(a aVar) {
        AppMethodBeat.i(94971);
        if (aVar.type == a.aWi) {
            d(aVar);
            AppMethodBeat.o(94971);
        } else if (aVar.type == a.aWr) {
            e(aVar);
            AppMethodBeat.o(94971);
        } else {
            if (!this.aYi.isEmpty()) {
                ((a) this.aYi.peek()).a(aVar);
            }
            AppMethodBeat.o(94971);
        }
    }

    private void d(a aVar) {
        j a;
        boolean z = true;
        int i = 0;
        AppMethodBeat.i(94972);
        com.google.android.exoplayer2.i.a.checkState(this.aXZ == null, "Unexpected moov box.");
        DrmInitData u = u(aVar.aXx);
        a dX = aVar.dX(a.aWt);
        SparseArray sparseArray = new SparseArray();
        long j = -9223372036854775807L;
        int size = dX.aXx.size();
        for (int i2 = 0; i2 < size; i2++) {
            b bVar = (b) dX.aXx.get(i2);
            if (bVar.type == a.aWf) {
                Pair l = l(bVar.aXz);
                sparseArray.put(((Integer) l.first).intValue(), l.second);
            } else if (bVar.type == a.aWu) {
                j = m(bVar.aXz);
            }
        }
        SparseArray sparseArray2 = new SparseArray();
        int size2 = aVar.aXy.size();
        for (size = 0; size < size2; size++) {
            a aVar2 = (a) aVar.aXy.get(size);
            if (aVar2.type == a.aWk) {
                boolean z2;
                b dW = aVar.dW(a.aWj);
                if ((this.flags & 32) != 0) {
                    z2 = true;
                } else {
                    z2 = false;
                }
                a = b.a(aVar2, dW, j, u, z2, false);
                if (a != null) {
                    sparseArray2.put(a.id, a);
                }
            }
        }
        int size3 = sparseArray2.size();
        if (this.aYa.size() == 0) {
            while (i < size3) {
                j jVar = (j) sparseArray2.valueAt(i);
                b bVar2 = new b(this.aTn.dM(i));
                bVar2.a(jVar, (c) sparseArray.get(jVar.id));
                this.aYa.put(jVar.id, bVar2);
                this.aOz = Math.max(this.aOz, jVar.aOz);
                i++;
            }
            rj();
            this.aTn.rb();
            AppMethodBeat.o(94972);
            return;
        }
        if (this.aYa.size() != size3) {
            z = false;
        }
        com.google.android.exoplayer2.i.a.checkState(z);
        while (i < size3) {
            a = (j) sparseArray2.valueAt(i);
            ((b) this.aYa.get(a.id)).a(a, (c) sparseArray.get(a.id));
            i++;
        }
        AppMethodBeat.o(94972);
    }

    private void e(a aVar) {
        AppMethodBeat.i(94973);
        a(aVar, this.aYa, this.flags, this.aYh);
        DrmInitData u = u(aVar.aXx);
        if (u != null) {
            int size = this.aYa.size();
            for (int i = 0; i < size; i++) {
                ((b) this.aYa.valueAt(i)).b(u);
            }
        }
        AppMethodBeat.o(94973);
    }

    private void rj() {
        AppMethodBeat.i(94974);
        if ((this.flags & 4) != 0 && this.aYt == null) {
            this.aYt = this.aTn.dM(this.aYa.size());
            this.aYt.f(Format.c("application/x-emsg", Long.MAX_VALUE));
        }
        if ((this.flags & 8) != 0 && this.aYu == null) {
            this.aTn.dM(this.aYa.size() + 1).f(Format.as("application/cea-608"));
            this.aYu = new m[]{r0};
        }
        AppMethodBeat.o(94974);
    }

    private static Pair<Integer, c> l(l lVar) {
        AppMethodBeat.i(94975);
        lVar.setPosition(12);
        Pair create = Pair.create(Integer.valueOf(lVar.readInt()), new c(lVar.tI() - 1, lVar.tI(), lVar.tI(), lVar.readInt()));
        AppMethodBeat.o(94975);
        return create;
    }

    private static long m(l lVar) {
        AppMethodBeat.i(94976);
        lVar.setPosition(8);
        long cM;
        if (a.dT(lVar.readInt()) == 0) {
            cM = lVar.cM();
            AppMethodBeat.o(94976);
            return cM;
        }
        cM = lVar.tK();
        AppMethodBeat.o(94976);
        return cM;
    }

    private static void a(a aVar, SparseArray<b> sparseArray, int i, byte[] bArr) {
        AppMethodBeat.i(94977);
        int size = aVar.aXy.size();
        for (int i2 = 0; i2 < size; i2++) {
            a aVar2 = (a) aVar.aXy.get(i2);
            if (aVar2.type == a.aWs) {
                b(aVar2, sparseArray, i, bArr);
            }
        }
        AppMethodBeat.o(94977);
    }

    private static void b(a aVar, SparseArray<b> sparseArray, int i, byte[] bArr) {
        AppMethodBeat.i(94978);
        b a = a(aVar.dW(a.aWe).aXz, (SparseArray) sparseArray, i);
        if (a == null) {
            AppMethodBeat.o(94978);
            return;
        }
        l lVar = a.aYx;
        long j = lVar.aZN;
        a.reset();
        if (aVar.dW(a.aWd) != null && (i & 2) == 0) {
            j = n(aVar.dW(a.aWd).aXz);
        }
        a(aVar, a, j, i);
        k dZ = a.aYy.dZ(lVar.aZw.aXT);
        b dW = aVar.dW(a.aWJ);
        if (dW != null) {
            a(dZ, dW.aXz, lVar);
        }
        dW = aVar.dW(a.aWK);
        if (dW != null) {
            a(dW.aXz, lVar);
        }
        dW = aVar.dW(a.aWO);
        if (dW != null) {
            a(dW.aXz, 0, lVar);
        }
        dW = aVar.dW(a.aWL);
        b dW2 = aVar.dW(a.aWM);
        if (!(dW == null || dW2 == null)) {
            a(dW.aXz, dW2.aXz, dZ != null ? dZ.aZt : null, lVar);
        }
        int size = aVar.aXx.size();
        for (int i2 = 0; i2 < size; i2++) {
            b bVar = (b) aVar.aXx.get(i2);
            if (bVar.type == a.aWN) {
                a(bVar.aXz, lVar, bArr);
            }
        }
        AppMethodBeat.o(94978);
    }

    private static void a(a aVar, b bVar, long j, int i) {
        b bVar2;
        AppMethodBeat.i(94979);
        int i2 = 0;
        int i3 = 0;
        List list = aVar.aXx;
        int size = list.size();
        int i4 = 0;
        while (i4 < size) {
            int tI;
            bVar2 = (b) list.get(i4);
            if (bVar2.type == a.aWg) {
                l lVar = bVar2.aXz;
                lVar.setPosition(12);
                tI = lVar.tI();
                if (tI > 0) {
                    tI += i3;
                    i2++;
                    i4++;
                    i3 = tI;
                }
            }
            tI = i3;
            i4++;
            i3 = tI;
        }
        bVar.aYC = 0;
        bVar.aYB = 0;
        bVar.aYA = 0;
        bVar.aYx.bd(i2, i3);
        i3 = 0;
        int i5 = 0;
        for (int i6 = 0; i6 < size; i6++) {
            bVar2 = (b) list.get(i6);
            if (bVar2.type == a.aWg) {
                int i7 = i3 + 1;
                i5 = a(bVar, i3, j, i, bVar2.aXz, i5);
                i3 = i7;
            }
        }
        AppMethodBeat.o(94979);
    }

    private static void a(k kVar, l lVar, l lVar2) {
        boolean z = true;
        AppMethodBeat.i(94980);
        int i = kVar.aZu;
        lVar.setPosition(8);
        if ((a.dU(lVar.readInt()) & 1) == 1) {
            lVar.eM(8);
        }
        int readUnsignedByte = lVar.readUnsignedByte();
        int tI = lVar.tI();
        if (tI != lVar2.sampleCount) {
            o oVar = new o("Length mismatch: " + tI + ", " + lVar2.sampleCount);
            AppMethodBeat.o(94980);
            throw oVar;
        }
        if (readUnsignedByte == 0) {
            boolean[] zArr = lVar2.aZI;
            readUnsignedByte = 0;
            int i2 = 0;
            while (i2 < tI) {
                boolean z2;
                int readUnsignedByte2 = lVar.readUnsignedByte();
                int i3 = readUnsignedByte + readUnsignedByte2;
                if (readUnsignedByte2 > i) {
                    z2 = true;
                } else {
                    z2 = false;
                }
                zArr[i2] = z2;
                i2++;
                readUnsignedByte = i3;
            }
        } else {
            if (readUnsignedByte <= i) {
                z = false;
            }
            readUnsignedByte = (readUnsignedByte * tI) + 0;
            Arrays.fill(lVar2.aZI, 0, tI, z);
        }
        lVar2.ea(readUnsignedByte);
        AppMethodBeat.o(94980);
    }

    private static void a(l lVar, l lVar2) {
        AppMethodBeat.i(94981);
        lVar.setPosition(8);
        int readInt = lVar.readInt();
        if ((a.dU(readInt) & 1) == 1) {
            lVar.eM(8);
        }
        int tI = lVar.tI();
        if (tI != 1) {
            o oVar = new o("Unexpected saio entry count: ".concat(String.valueOf(tI)));
            AppMethodBeat.o(94981);
            throw oVar;
        }
        readInt = a.dT(readInt);
        lVar2.aZz = (readInt == 0 ? lVar.cM() : lVar.tK()) + lVar2.aZz;
        AppMethodBeat.o(94981);
    }

    private static b a(l lVar, SparseArray<b> sparseArray, int i) {
        AppMethodBeat.i(94982);
        lVar.setPosition(8);
        int dU = a.dU(lVar.readInt());
        int readInt = lVar.readInt();
        if ((i & 16) != 0) {
            readInt = 0;
        }
        b bVar = (b) sparseArray.get(readInt);
        if (bVar == null) {
            AppMethodBeat.o(94982);
            return null;
        }
        if ((dU & 1) != 0) {
            long tK = lVar.tK();
            bVar.aYx.aZy = tK;
            bVar.aYx.aZz = tK;
        }
        c cVar = bVar.aYz;
        bVar.aYx.aZw = new c((dU & 2) != 0 ? lVar.tI() - 1 : cVar.aXT, (dU & 8) != 0 ? lVar.tI() : cVar.duration, (dU & 16) != 0 ? lVar.tI() : cVar.size, (dU & 32) != 0 ? lVar.tI() : cVar.flags);
        AppMethodBeat.o(94982);
        return bVar;
    }

    private static long n(l lVar) {
        AppMethodBeat.i(94983);
        lVar.setPosition(8);
        long tK;
        if (a.dT(lVar.readInt()) == 1) {
            tK = lVar.tK();
            AppMethodBeat.o(94983);
            return tK;
        }
        tK = lVar.cM();
        AppMethodBeat.o(94983);
        return tK;
    }

    private static int a(b bVar, int i, long j, int i2, l lVar, int i3) {
        Object obj;
        long b;
        AppMethodBeat.i(94984);
        lVar.setPosition(8);
        int dU = a.dU(lVar.readInt());
        j jVar = bVar.aYy;
        l lVar2 = bVar.aYx;
        c cVar = lVar2.aZw;
        lVar2.aZC[i] = lVar.tI();
        lVar2.aZB[i] = lVar2.aZy;
        if ((dU & 1) != 0) {
            long[] jArr = lVar2.aZB;
            jArr[i] = jArr[i] + ((long) lVar.readInt());
        }
        Object obj2 = (dU & 4) != 0 ? 1 : null;
        int i4 = cVar.flags;
        if (obj2 != null) {
            i4 = lVar.tI();
        }
        Object obj3 = (dU & 256) != 0 ? 1 : null;
        Object obj4 = (dU & com.tencent.mm.plugin.appbrand.jsapi.container.b.CTRL_INDEX) != 0 ? 1 : null;
        Object obj5 = (dU & 1024) != 0 ? 1 : null;
        if ((dU & 2048) != 0) {
            obj = 1;
        } else {
            obj = null;
        }
        if (jVar.aZp != null && jVar.aZp.length == 1 && jVar.aZp[0] == 0) {
            b = v.b(jVar.aZq[0], 1000, jVar.aZm);
        } else {
            b = 0;
        }
        int[] iArr = lVar2.aZD;
        int[] iArr2 = lVar2.aZE;
        long[] jArr2 = lVar2.aZF;
        boolean[] zArr = lVar2.aZG;
        Object obj6 = (jVar.type != 2 || (i2 & 1) == 0) ? null : 1;
        int i5 = i3 + lVar2.aZC[i];
        long j2 = jVar.aZm;
        if (i > 0) {
            j = lVar2.aZN;
        }
        long j3 = j;
        while (i3 < i5) {
            int tI = obj3 != null ? lVar.tI() : cVar.duration;
            int tI2 = obj4 != null ? lVar.tI() : cVar.size;
            int readInt = (i3 != 0 || obj2 == null) ? obj5 != null ? lVar.readInt() : cVar.flags : i4;
            if (obj != null) {
                iArr2[i3] = (int) ((((long) lVar.readInt()) * 1000) / j2);
            } else {
                iArr2[i3] = 0;
            }
            jArr2[i3] = v.b(j3, 1000, j2) - b;
            iArr[i3] = tI2;
            boolean z = ((readInt >> 16) & 1) == 0 && (obj6 == null || i3 == 0);
            zArr[i3] = z;
            j3 += (long) tI;
            i3++;
        }
        lVar2.aZN = j3;
        AppMethodBeat.o(94984);
        return i5;
    }

    private static void a(l lVar, l lVar2, byte[] bArr) {
        AppMethodBeat.i(94985);
        lVar.setPosition(8);
        lVar.readBytes(bArr, 0, 16);
        if (Arrays.equals(bArr, aXY)) {
            a(lVar, 16, lVar2);
            AppMethodBeat.o(94985);
            return;
        }
        AppMethodBeat.o(94985);
    }

    private static void a(l lVar, int i, l lVar2) {
        AppMethodBeat.i(94986);
        lVar.setPosition(i + 8);
        int dU = a.dU(lVar.readInt());
        o oVar;
        if ((dU & 1) != 0) {
            oVar = new o("Overriding TrackEncryptionBox parameters is unsupported.");
            AppMethodBeat.o(94986);
            throw oVar;
        }
        boolean z;
        if ((dU & 2) != 0) {
            z = true;
        } else {
            z = false;
        }
        int tI = lVar.tI();
        if (tI != lVar2.sampleCount) {
            oVar = new o("Length mismatch: " + tI + ", " + lVar2.sampleCount);
            AppMethodBeat.o(94986);
            throw oVar;
        }
        Arrays.fill(lVar2.aZI, 0, tI, z);
        lVar2.ea(lVar.tB());
        lVar2.q(lVar);
        AppMethodBeat.o(94986);
    }

    private static void a(l lVar, l lVar2, String str, l lVar3) {
        AppMethodBeat.i(94987);
        lVar.setPosition(8);
        int readInt = lVar.readInt();
        if (lVar.readInt() != aXX) {
            AppMethodBeat.o(94987);
            return;
        }
        if (a.dT(readInt) == 1) {
            lVar.eM(4);
        }
        o oVar;
        if (lVar.readInt() != 1) {
            oVar = new o("Entry count in sbgp != 1 (unsupported).");
            AppMethodBeat.o(94987);
            throw oVar;
        }
        lVar2.setPosition(8);
        readInt = lVar2.readInt();
        if (lVar2.readInt() != aXX) {
            AppMethodBeat.o(94987);
            return;
        }
        readInt = a.dT(readInt);
        if (readInt == 1) {
            if (lVar2.cM() == 0) {
                oVar = new o("Variable length description in sgpd found (unsupported)");
                AppMethodBeat.o(94987);
                throw oVar;
            }
        } else if (readInt >= 2) {
            lVar2.eM(4);
        }
        if (lVar2.cM() != 1) {
            oVar = new o("Entry count in sgpd != 1 (unsupported).");
            AppMethodBeat.o(94987);
            throw oVar;
        }
        lVar2.eM(1);
        readInt = lVar2.readUnsignedByte();
        int i = (readInt & 240) >> 4;
        int i2 = readInt & 15;
        if (lVar2.readUnsignedByte() == 1) {
            readInt = 1;
        } else {
            readInt = 0;
        }
        if (readInt == 0) {
            AppMethodBeat.o(94987);
            return;
        }
        int readUnsignedByte = lVar2.readUnsignedByte();
        byte[] bArr = new byte[16];
        lVar2.readBytes(bArr, 0, 16);
        byte[] bArr2 = null;
        if (readUnsignedByte == 0) {
            readInt = lVar2.readUnsignedByte();
            bArr2 = new byte[readInt];
            lVar2.readBytes(bArr2, 0, readInt);
        }
        lVar3.aZH = true;
        lVar3.aZJ = new k(true, str, readUnsignedByte, bArr, i, i2, bArr2);
        AppMethodBeat.o(94987);
    }

    private static DrmInitData u(List<b> list) {
        AppMethodBeat.i(94988);
        int size = list.size();
        List list2 = null;
        for (int i = 0; i < size; i++) {
            b bVar = (b) list.get(i);
            if (bVar.type == a.aWB) {
                if (list2 == null) {
                    list2 = new ArrayList();
                }
                byte[] bArr = bVar.aXz.data;
                UUID n = h.n(bArr);
                if (n != null) {
                    list2.add(new SchemeData(n, "video/mp4", bArr));
                }
            }
        }
        if (list2 == null) {
            AppMethodBeat.o(94988);
            return null;
        }
        DrmInitData drmInitData = new DrmInitData(list2);
        AppMethodBeat.o(94988);
        return drmInitData;
    }
}
