static byte[] buffer_blueLine_Y = null;
static byte[] buffer_blueLine_U = null;
static byte[] buffer_blueLine_V = null;
static byte[] buffer_result = null;
static int blueHeight = 0;
static int speed = 1;
public static byte[] doBlueLining(byte[] bytes, int width, int height) {
if (blueHeight >= height) return buffer_result;
if (buffer_blueLine_Y == null) {
buffer_blueLine_Y = new byte[width * height];
}
if (buffer_blueLine_U == null) {
buffer_blueLine_U = new byte[width * height / 4];
}
if (buffer_blueLine_V == null) {
buffer_blueLine_V = new byte[width * height / 4];
}
if (buffer_result == null) {
buffer_result = new byte[width * height * 3 / 2];
}
//把新的蓝线这一条的数据添加到蓝线数据中
//把Y的最新一行数据提出来
for (int i = blueHeight * width; i < (blueHeight + 2 * speed) * width; i++) {
buffer_blueLine_Y[i] = bytes[i];
}
//把U的最新一行数据提出来
for (int i = (blueHeight / 2 * width / 2); i < ((blueHeight / 2 + speed) * width / 2); i++) {
buffer_blueLine_U[i] = bytes[width * height + i];
}
//把V的最新一行数据提出来
for (int i = (blueHeight / 2 * width / 2); i < ((blueHeight / 2 + speed) * width / 2); i++) {
buffer_blueLine_V[i] = bytes[width * height * 5 / 4 + i];
}
//把Y提出来的数据放到result中
for (int i = 0; i < (blueHeight + 2 * speed) * width; i++) {
buffer_result[i] = buffer_blueLine_Y[i];
}
//把Y剩下的数据放到result中
for (int i = (blueHeight + 2 * speed) * width - 1; i < width * height; i++) {
buffer_result[i] = bytes[i];
}
//把U提出来的数据放到result中
for (int i = 0; i < (blueHeight / 2 + speed) * width / 2; i++) {
buffer_result[width * height + i] = buffer_blueLine_U[i];
}
//把U剩下的数据放到result中
for (int i = width * height + (blueHeight / 2 + speed) * width / 2 - 1; i < width * height * 5 / 4; i++) {
buffer_result[i] = bytes[i];
}
//把V提出来的数据放到result中
for (int i = 0; i < (blueHeight / 2 + speed) * width / 2; i++) {
buffer_result[width * height * 5 / 4 + i] = buffer_blueLine_V[i];
}
//把V剩下的数据放到result中
for (int i = width * height * 5 / 4 + (blueHeight / 2 + speed) * width / 2 - 1; i < width * height * 3 / 2; i++) {
buffer_result[i] = bytes[i];
}
blueHeight += 2 * speed;
return buffer_result;
}