package c.i.a.c.c2.l; import c.i.a.c.c2.d; import c.i.a.c.c2.g; import c.i.a.c.i2.e0; import c.i.a.c.i2.v; import c.i.a.c.i2.w; import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.scte35.PrivateCommand; import com.google.android.exoplayer2.metadata.scte35.SpliceInsertCommand; import com.google.android.exoplayer2.metadata.scte35.SpliceNullCommand; import com.google.android.exoplayer2.metadata.scte35.SpliceScheduleCommand; import com.google.android.exoplayer2.metadata.scte35.TimeSignalCommand; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; import java.util.List; /* compiled from: SpliceInfoDecoder */ public final class a extends g { public final w a = new w(); public final v b = new v(); /* renamed from: c reason: collision with root package name */ public e0 f780c; @Override // c.i.a.c.c2.g public Metadata b(d dVar, ByteBuffer byteBuffer) { int i; int i2; int i3; long j; boolean z2; long j2; ArrayList arrayList; boolean z3; boolean z4; int i4; long j3; long j4; boolean z5; int i5; int i6; int i7; long j5; boolean z6; List list; boolean z7; boolean z8; boolean z9; long j6; long j7; boolean z10; e0 e0Var = this.f780c; if (e0Var == null || dVar.q != e0Var.d()) { long j8 = dVar.m; e0 e0Var2 = new e0(j8); this.f780c = e0Var2; e0Var2.a(j8 - dVar.q); } byte[] array = byteBuffer.array(); int limit = byteBuffer.limit(); this.a.B(array, limit); this.b.j(array, limit); this.b.m(39); long g = (((long) this.b.g(1)) << 32) | ((long) this.b.g(32)); this.b.m(20); int g2 = this.b.g(12); int g3 = this.b.g(8); this.a.E(14); Metadata.Entry entry = null; if (g3 == 0) { entry = new SpliceNullCommand(); } else if (g3 != 255) { long j9 = 128; if (g3 == 4) { w wVar = this.a; int s2 = wVar.s(); ArrayList arrayList2 = new ArrayList(s2); int i8 = 0; while (i8 < s2) { long t = wVar.t(); boolean z11 = (wVar.s() & 128) != 0; ArrayList arrayList3 = new ArrayList(); if (!z11) { int s3 = wVar.s(); boolean z12 = (s3 & 128) != 0; boolean z13 = (s3 & 64) != 0; boolean z14 = (s3 & 32) != 0; long t2 = z13 ? wVar.t() : -9223372036854775807L; if (!z13) { int s4 = wVar.s(); ArrayList arrayList4 = new ArrayList(s4); int i9 = 0; while (i9 < s4) { arrayList4.add(new SpliceScheduleCommand.b(wVar.s(), wVar.t(), null)); i9++; s4 = s4; s2 = s2; } i4 = s2; arrayList3 = arrayList4; } else { i4 = s2; } if (z14) { long s5 = (long) wVar.s(); j3 = 128; z5 = (s5 & 128) != 0; j4 = ((((s5 & 1) << 32) | wVar.t()) * 1000) / 90; } else { j3 = 128; z5 = false; j4 = -9223372036854775807L; } z2 = z5; j = j4; arrayList = arrayList3; i3 = wVar.x(); z4 = z12; z3 = z13; j2 = t2; i2 = wVar.s(); i = wVar.s(); } else { i4 = s2; j3 = j9; arrayList = arrayList3; z4 = false; z3 = false; j2 = -9223372036854775807L; z2 = false; j = -9223372036854775807L; i3 = 0; i2 = 0; i = 0; } arrayList2.add(new SpliceScheduleCommand.c(t, z11, z4, z3, arrayList, j2, z2, j, i3, i2, i)); i8++; j9 = j3; s2 = i4; } entry = new SpliceScheduleCommand(arrayList2); } else if (g3 == 5) { w wVar2 = this.a; e0 e0Var3 = this.f780c; long t3 = wVar2.t(); boolean z15 = (wVar2.s() & 128) != 0; List emptyList = Collections.emptyList(); if (!z15) { int s6 = wVar2.s(); boolean z16 = (s6 & 128) != 0; boolean z17 = (s6 & 64) != 0; boolean z18 = (s6 & 32) != 0; boolean z19 = (s6 & 16) != 0; long a = (!z17 || z19) ? -9223372036854775807L : TimeSignalCommand.a(wVar2, g); if (!z17) { int s7 = wVar2.s(); ArrayList arrayList5 = new ArrayList(s7); for (int i10 = 0; i10 < s7; i10++) { int s8 = wVar2.s(); long a2 = !z19 ? TimeSignalCommand.a(wVar2, g) : -9223372036854775807L; arrayList5.add(new SpliceInsertCommand.b(s8, a2, e0Var3.b(a2), null)); } emptyList = arrayList5; } if (z18) { long s9 = (long) wVar2.s(); z10 = (s9 & 128) != 0; j7 = ((((s9 & 1) << 32) | wVar2.t()) * 1000) / 90; } else { z10 = false; j7 = -9223372036854775807L; } int x2 = wVar2.x(); int s10 = wVar2.s(); i7 = x2; z6 = z10; i5 = wVar2.s(); list = emptyList; j5 = j7; i6 = s10; z9 = z16; j6 = a; z7 = z19; z8 = z17; } else { list = emptyList; j6 = -9223372036854775807L; z9 = false; z8 = false; z7 = false; z6 = false; j5 = -9223372036854775807L; i7 = 0; i6 = 0; i5 = 0; } entry = new SpliceInsertCommand(t3, z15, z9, z8, z7, j6, e0Var3.b(j6), list, z6, j5, i7, i6, i5); } else if (g3 == 6) { w wVar3 = this.a; e0 e0Var4 = this.f780c; long a3 = TimeSignalCommand.a(wVar3, g); entry = new TimeSignalCommand(a3, e0Var4.b(a3)); } } else { w wVar4 = this.a; long t4 = wVar4.t(); int i11 = g2 - 4; byte[] bArr = new byte[i11]; System.arraycopy(wVar4.a, wVar4.b, bArr, 0, i11); wVar4.b += i11; entry = new PrivateCommand(t4, bArr, g); } return entry == null ? new Metadata(new Metadata.Entry[0]) : new Metadata(entry); } }