|
|
@ -126,27 +126,29 @@ public class YUVUtil { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void swap(byte[] a, int i, int j) { |
|
|
|
public static void flipYUV(byte[] dst, byte[] src, int width, int height) { |
|
|
|
byte temp = a[i]; |
|
|
|
|
|
|
|
a[i] = a[j]; |
|
|
|
|
|
|
|
a[j] = temp; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void flipYUV(byte[] dst, int width, int height, boolean flipX, boolean flipY) { |
|
|
|
|
|
|
|
if (dst == null || width <= 0 || height <= 0) |
|
|
|
if (dst == null || width <= 0 || height <= 0) |
|
|
|
return; |
|
|
|
return; |
|
|
|
if (flipY) { |
|
|
|
|
|
|
|
for (int i=0; i<height; i++) { |
|
|
|
int idx = 0; |
|
|
|
for (int j=0; j<width/2; j++) { |
|
|
|
// Y
|
|
|
|
swap(dst, j, width - j - 1); |
|
|
|
for (int i = 0; i < width; i++) { |
|
|
|
} |
|
|
|
for (int j = 0; j < height; j++) { |
|
|
|
|
|
|
|
dst[idx++] = src[width - i + (height - j) * width]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (flipX) { |
|
|
|
// U
|
|
|
|
for (int i=0; i<width; i++) { |
|
|
|
int offset = width * height; |
|
|
|
for (int j=0; j<height/2; j++) { |
|
|
|
for (int i = 0; i < width / 2; i++) { |
|
|
|
swap(dst, j, height - j - 1); |
|
|
|
for (int j = 0; j < height / 2; j++) { |
|
|
|
} |
|
|
|
dst[idx++] = src[offset + width - i + (height / 2 - j) * width / 2]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// V
|
|
|
|
|
|
|
|
offset += width * height / 4; |
|
|
|
|
|
|
|
for (int i = 0; i < width / 2; i++) { |
|
|
|
|
|
|
|
for (int j = 0; j < height / 2; j++) { |
|
|
|
|
|
|
|
dst[idx++] = src[offset + width - i + (height / 2 - j) * width / 2]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|