package c.i.a.c.v1; import c.i.a.c.i2.f0; import com.google.android.exoplayer2.audio.AudioProcessor; import java.nio.ByteBuffer; /* compiled from: ResamplingAudioProcessor */ public final class a0 extends u { /* JADX WARNING: Removed duplicated region for block: B:13:0x0039 */ /* JADX WARNING: Removed duplicated region for block: B:27:0x00b0 A[LOOP:4: B:27:0x00b0->B:28:0x00b2, LOOP_START, PHI: r0 PHI: (r0v2 int) = (r0v0 int), (r0v3 int) binds: [B:12:0x0037, B:28:0x00b2] A[DONT_GENERATE, DONT_INLINE]] */ @Override // com.google.android.exoplayer2.audio.AudioProcessor public void c(ByteBuffer byteBuffer) { int i; int position = byteBuffer.position(); int limit = byteBuffer.limit(); int i2 = limit - position; int i3 = this.b.d; if (i3 != 3) { if (i3 != 4) { if (i3 != 268435456) { if (i3 == 536870912) { i2 /= 3; } else if (i3 != 805306368) { throw new IllegalStateException(); } } ByteBuffer j = j(i2); i = this.b.d; if (i == 3) { while (position < limit) { j.put((byte) 0); j.put((byte) ((byteBuffer.get(position) & 255) - 128)); position++; } } else if (i == 4) { while (position < limit) { short g = (short) ((int) (f0.g(byteBuffer.getFloat(position), -1.0f, 1.0f) * 32767.0f)); j.put((byte) (g & 255)); j.put((byte) ((g >> 8) & 255)); position += 4; } } else if (i == 268435456) { while (position < limit) { j.put(byteBuffer.get(position + 1)); j.put(byteBuffer.get(position)); position += 2; } } else if (i == 536870912) { while (position < limit) { j.put(byteBuffer.get(position + 1)); j.put(byteBuffer.get(position + 2)); position += 3; } } else if (i == 805306368) { while (position < limit) { j.put(byteBuffer.get(position + 2)); j.put(byteBuffer.get(position + 3)); position += 4; } } else { throw new IllegalStateException(); } byteBuffer.position(byteBuffer.limit()); j.flip(); } i2 /= 2; ByteBuffer j = j(i2); i = this.b.d; if (i == 3) { } byteBuffer.position(byteBuffer.limit()); j.flip(); } i2 *= 2; ByteBuffer j = j(i2); i = this.b.d; if (i == 3) { } byteBuffer.position(byteBuffer.limit()); j.flip(); } @Override // c.i.a.c.v1.u public AudioProcessor.a f(AudioProcessor.a aVar) throws AudioProcessor.UnhandledAudioFormatException { int i = aVar.d; if (i == 3 || i == 2 || i == 268435456 || i == 536870912 || i == 805306368 || i == 4) { return i != 2 ? new AudioProcessor.a(aVar.b, aVar.f2202c, 2) : AudioProcessor.a.a; } throw new AudioProcessor.UnhandledAudioFormatException(aVar); } }