package com.applovin.impl; import java.nio.ByteBuffer; /* loaded from: classes.dex */ final class s2 { private long a; private long b; private boolean c; public void a() { this.a = 0L; this.b = 0L; this.c = false; } private long a(long j) { return this.a + Math.max(0L, ((this.b - 529) * 1000000) / j); } public long a(f9 f9Var) { return a(f9Var.A); } public long a(f9 f9Var, p5 p5Var) { if (this.b == 0) { this.a = p5Var.f; } if (this.c) { return p5Var.f; } ByteBuffer byteBuffer = (ByteBuffer) b1.a(p5Var.c); int i = 0; for (int i2 = 0; i2 < 4; i2++) { i = (i << 8) | (byteBuffer.get(i2) & 255); } int d = tf.d(i); if (d == -1) { this.c = true; this.b = 0L; this.a = p5Var.f; pc.d("C2Mp3TimestampTracker", "MPEG audio header is invalid."); return p5Var.f; } long a = a(f9Var.A); this.b += d; return a; } }