List of usage examples for java.lang System arraycopy
@HotSpotIntrinsicCandidate public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length);
From source file:Main.java
public static byte[] NV21toNV12(byte[] input, int width, int height) { final int frameSize = width * height; final int qFrameSize = frameSize / 4; System.arraycopy(input, 0, preAllocatedBufferColor, 0, frameSize); // Y for (int i = 0; i < qFrameSize; i++) { preAllocatedBufferColor[frameSize + i * 2] = input[frameSize + i * 2 + 1]; // Cb (U) preAllocatedBufferColor[frameSize + i * 2 + 1] = input[frameSize + i * 2]; // Cr (V) }//w w w .j av a 2 s . c om return preAllocatedBufferColor; }
From source file:Main.java
public static byte[] NV21toYV12(byte[] input, int width, int height) { final int frameSize = width * height; final int qFrameSize = frameSize / 4; System.arraycopy(input, 0, preAllocatedBufferColor, 0, frameSize); // Y for (int i = 0; i < qFrameSize; i++) { preAllocatedBufferColor[frameSize + i + qFrameSize] = input[frameSize + i * 2 + 1]; // Cb (U) preAllocatedBufferColor[frameSize + i] = input[frameSize + i * 2]; // Cr (V) }/* w ww. j ava 2 s . c o m*/ return preAllocatedBufferColor; }
From source file:Main.java
public static void transposeMatrix(float[][] origMat, boolean scaleOrNo) { //float [][] outMat = new float[origMat.length][origMat.length]; for (int i = 0; i < origMat.length; i++) { System.arraycopy(origMat[i], 0, tempMat[i], 0, origMat.length); }//ww w . j av a2 s . co m for (int row = 0; row < origMat.length; row++) { for (int col = 0; col < origMat.length; col++) { if (scaleOrNo) { origMat[col][row] = tempMat[row][col] / (float) origMat.length; } else { origMat[col][row] = tempMat[row][col]; } } } return; }
From source file:Main.java
public static byte[] uniteBytes(byte[]... data) { int length = 0; for (byte[] msg : data) { length += msg.length;/*from w w w . ja v a2s . c om*/ } byte[] newData = new byte[length]; int i = 0; for (byte[] msg : data) { System.arraycopy(msg, 0, newData, i, msg.length); i += msg.length; } return newData; }
From source file:Main.java
public static String getStr(byte[] b, int index) { int i;//w ww . j a v a 2 s . c o m for (i = index; i < b.length; i++) { if (b[i] == 0) break; } if (i == index) return ""; byte[] str = new byte[i - index]; System.arraycopy(b, index, str, 0, i - index); return new String(str); }
From source file:Main.java
static void convertToFixedLength(byte[] src, byte[] dest, int destOff, int destLen) { if (src.length < destLen) { int padding = destLen - src.length; for (int i = destOff; i < destOff + padding; i++) dest[i] = 0;/*www . j a va 2s.c om*/ System.arraycopy(src, 0, dest, destOff + padding, src.length); } else { int srcOff = src.length - destLen; System.arraycopy(src, srcOff, dest, destOff, destLen); } }
From source file:Main.java
public static byte[] intArrayToByteArray(int[] buffer) { byte[] buf = new byte[buffer.length * 4]; byte[] bf;/*from w ww . j a v a 2 s . c o m*/ for (int i = 0; i < buffer.length; i++) { bf = intToByteArray(buffer[i]); System.arraycopy(bf, 0, buf, i * 4, 4); } return buf; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static <T> T[] concatenate(T[] first, T[] second) { T[] result = Arrays.copyOf(first, first.length + second.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }
From source file:ArrayUtil.java
/** * Doubles the size of an array// w ww . j a v a 2 s. c o m * * @param in * @return The new array */ public static String[] grow(String[] in) { String[] na = new String[in.length * 2]; System.arraycopy(in, 0, na, 0, in.length); return na; }
From source file:Main.java
public static byte[] copyOfRange(byte[] original, int from, int to) { int newLength = to - from; if (newLength < 0) { throw new IllegalArgumentException(from + " > " + to); } else {/*from w ww . j a v a 2 s. co m*/ byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; } }