Java tutorial
//package com.java2s; //License from project: Apache License public class Main { private static byte[] preAllocatedBufferColor; public static byte[] YV12toI420(byte[] input, int width, int height) { final int frameSize = width * height; final int qFrameSize = frameSize / 4; System.arraycopy(input, 0, preAllocatedBufferColor, 0, frameSize); // Y System.arraycopy(input, frameSize + qFrameSize, preAllocatedBufferColor, frameSize, qFrameSize); // Cb (U) System.arraycopy(input, frameSize, preAllocatedBufferColor, frameSize + qFrameSize, qFrameSize); // Cr (V) return preAllocatedBufferColor; } }