Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static byte[] preAllocatedBufferColor;

    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)
        }
        return preAllocatedBufferColor;
    }
}