Java tutorial
//package com.java2s; public class Main { public static byte[] YV12toYUV420PackedSemiPlanar(final byte[] input, final byte[] output, final int width, final int height) { /* * COLOR_TI_FormatYUV420PackedSemiPlanar is NV21 * We convert by putting the corresponding U and V bytes together (interleaved). */ final int frameSize = width * height; final int qFrameSize = frameSize / 4; System.arraycopy(input, 0, output, 0, frameSize); // Y for (int i = 0; i < qFrameSize; i++) { output[frameSize + i * 2 + 1] = input[frameSize + i + qFrameSize]; // Cb (U) output[frameSize + i * 2] = input[frameSize + i]; // Cr (V) } return output; } }