package org.webrtc; import androidx.annotation.Nullable; import java.nio.ByteBuffer; import org.webrtc.VideoFrame; /* loaded from: classes3.dex */ public class NV21Buffer implements VideoFrame.Buffer { private final byte[] data; private final int height; private final RefCountDelegate refCountDelegate; private final int width; public NV21Buffer(byte[] bArr, int i, int i2, @Nullable Runnable runnable) { this.data = bArr; this.width = i; this.height = i2; this.refCountDelegate = new RefCountDelegate(runnable); } private static native void nativeCropAndScale(int i, int i2, int i3, int i4, int i5, int i6, byte[] bArr, int i7, int i8, ByteBuffer byteBuffer, int i9, ByteBuffer byteBuffer2, int i10, ByteBuffer byteBuffer3, int i11); @Override // org.webrtc.VideoFrame.Buffer public VideoFrame.Buffer cropAndScale(int i, int i2, int i3, int i4, int i5, int i6) { JavaI420Buffer allocate = JavaI420Buffer.allocate(i5, i6); nativeCropAndScale(i, i2, i3, i4, i5, i6, this.data, this.width, this.height, allocate.getDataY(), allocate.getStrideY(), allocate.getDataU(), allocate.getStrideU(), allocate.getDataV(), allocate.getStrideV()); return allocate; } @Override // org.webrtc.VideoFrame.Buffer public int getHeight() { return this.height; } @Override // org.webrtc.VideoFrame.Buffer public int getWidth() { return this.width; } @Override // org.webrtc.VideoFrame.Buffer, org.webrtc.RefCounted public void release() { this.refCountDelegate.release(); } @Override // org.webrtc.VideoFrame.Buffer, org.webrtc.RefCounted public void retain() { this.refCountDelegate.retain(); } @Override // org.webrtc.VideoFrame.Buffer public VideoFrame.I420Buffer toI420() { int i = this.width; int i2 = this.height; return (VideoFrame.I420Buffer) cropAndScale(0, 0, i, i2, i, i2); } }