mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add createShortBuffer() to TestUtil
PiperOrigin-RevId: 730875642 (cherry picked from commit 1399e772490b3ee602b298d58f5683ae0a00f688)
This commit is contained in:
parent
24b3bf21b8
commit
f2739302af
@ -78,6 +78,7 @@ import java.lang.reflect.Modifier;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -175,6 +176,14 @@ public class TestUtil {
|
||||
return content;
|
||||
}
|
||||
|
||||
/** Gets the underlying data of the {@link ByteBuffer} as a {@code short[]}. */
|
||||
public static short[] createShortArray(ByteBuffer byteBuffer) {
|
||||
ShortBuffer buffer = byteBuffer.asShortBuffer();
|
||||
short[] content = new short[buffer.remaining()];
|
||||
buffer.get(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
/** Creates a {@link ByteBuffer} containing the {@code data}. */
|
||||
public static ByteBuffer createByteBuffer(float[] data) {
|
||||
ByteBuffer buffer =
|
||||
|
Loading…
x
Reference in New Issue
Block a user