From 4c9d1aa0fa1b45a2d9501e8c830699d7a9f624cd Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Mon, 22 Aug 2022 20:13:46 +0800 Subject: [PATCH] Feature: flip yuv data of front Camera --- .../com/frank/live/camera/Camera2Helper.java | 2 +- .../java/com/frank/live/util/YUVUtil.java | 36 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Live/src/main/java/com/frank/live/camera/Camera2Helper.java b/Live/src/main/java/com/frank/live/camera/Camera2Helper.java index 20fdfbe..8221224 100644 --- a/Live/src/main/java/com/frank/live/camera/Camera2Helper.java +++ b/Live/src/main/java/com/frank/live/camera/Camera2Helper.java @@ -595,7 +595,7 @@ public class Camera2Helper { } // front camera need to flip if (CAMERA_ID_FRONT.equals(mCameraId)) { - YUVUtil.flipYUV(dstData, width, height, rotation == 90, rotation == 180); + YUVUtil.flipYUV(dstData, yuvData, width, height); } if (camera2Listener != null) { camera2Listener.onPreviewFrame(dstData); diff --git a/Live/src/main/java/com/frank/live/util/YUVUtil.java b/Live/src/main/java/com/frank/live/util/YUVUtil.java index 0f9591f..3b6063a 100644 --- a/Live/src/main/java/com/frank/live/util/YUVUtil.java +++ b/Live/src/main/java/com/frank/live/util/YUVUtil.java @@ -126,27 +126,29 @@ public class YUVUtil { } } - private static void swap(byte[] a, int i, int j) { - 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) { + public static void flipYUV(byte[] dst, byte[] src, int width, int height) { if (dst == null || width <= 0 || height <= 0) return; - if (flipY) { - for (int i=0; i