Last active
August 29, 2015 14:03
-
-
Save a-chernykh/394fb8520feddfea979f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static byte[] NV21toYUV420Planar(byte[] input, byte[] output, int width, int height) { | |
final int frameSize = width * height; | |
final int qFrameSize = frameSize/4; | |
System.arraycopy(input, 0, output, 0, frameSize); // Y | |
byte v, u; | |
for (int i = 0; i < qFrameSize; i++) { | |
v = input[frameSize + i*2]; | |
u = input[frameSize + i*2 + 1]; | |
output[frameSize + i + qFrameSize] = v; | |
output[frameSize + i] = u; | |
} | |
return output; | |
} | |
public static byte[] NV21toYUV420SemiPlanar(byte[] input, byte[] output, int width, int height) { | |
final int frameSize = width * height; | |
final int qFrameSize = frameSize/4; | |
System.arraycopy(input, 0, output, 0, frameSize); // Y | |
byte v, u; | |
for (int i = 0; i < qFrameSize; i++) { | |
v = input[frameSize + i*2]; | |
u = input[frameSize + i*2 + 1]; | |
output[frameSize + i*2] = u; | |
output[frameSize + i*2 + 1] = v; | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment