From 05f7a310f626f092faa4a2d8db9280cef3b798d3 Mon Sep 17 00:00:00 2001 From: Daniel Jacob Chittoor Date: Fri, 29 Mar 2024 10:49:05 +0530 Subject: [PATCH 1/4] CameraController: Append FP's custom scaler configuration --- .../cameracontroller/CameraController2.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java index b71a01f89..58694b947 100644 --- a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +++ b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java @@ -2860,6 +2860,28 @@ public class CameraController2 extends CameraController { camera_features.picture_sizes.add(new CameraController.Size(camera_size.getWidth(), camera_size.getHeight())); } } + + CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = null; + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + fairphoneAvailableStreamConfigurations = new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); + } + + int[] FP_StreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); + + for (int i = 0; i < FP_StreamConfigs.length / 4; i++) { + int format = FP_StreamConfigs[i * 4]; + int width = FP_StreamConfigs[i * 4 + 1]; + int height = FP_StreamConfigs[i * 4 + 2]; + int output = FP_StreamConfigs[i * 4 + 3]; + + if (output != 0) { + if( MyDebug.LOG ) + Log.d(TAG, "custom scaler size: " + height + " x " + width); + camera_features.picture_sizes.add(new Size(width, height)); + } + } + // sizes are usually already sorted from high to low, but sort just in case // note some devices do have sizes in a not fully sorted order (e.g., Nokia 8) Collections.sort(camera_features.picture_sizes, new CameraController.SizeSorter()); -- GitLab From 2ed7590a9b9b11374a0f7be5d0c848d99333452d Mon Sep 17 00:00:00 2001 From: Daniel Jacob Chittoor Date: Fri, 29 Mar 2024 10:55:02 +0530 Subject: [PATCH 2/4] CameraController: Conditionalize FP scaler for FP4 --- .../cameracontroller/CameraController2.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java index 58694b947..c9167ff4b 100644 --- a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +++ b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java @@ -80,6 +80,7 @@ public class CameraController2 extends CameraController { private CameraDevice camera; private final String cameraIdS; + private final boolean is_fairphone_4; private final boolean is_samsung; private final boolean is_samsung_s7; // Galaxy S7 or Galaxy S7 Edge private final boolean is_samsung_galaxy_s; @@ -2009,10 +2010,12 @@ public class CameraController2 extends CameraController { this.camera_error_cb = camera_error_cb; //this.is_oneplus = Build.MANUFACTURER.toLowerCase(Locale.US).contains("oneplus"); + this.is_fairphone_4 = Build.MODEL.toLowerCase(Locale.US).contains("fp4"); this.is_samsung = Build.MANUFACTURER.toLowerCase(Locale.US).contains("samsung"); this.is_samsung_s7 = Build.MODEL.toLowerCase(Locale.US).contains("sm-g93"); this.is_samsung_galaxy_s = is_samsung && Build.MODEL.toLowerCase(Locale.US).contains("sm-g"); if( MyDebug.LOG ) { + Log.d(TAG, "is_fairphone_4: " + is_fairphone_4); Log.d(TAG, "is_samsung: " + is_samsung); Log.d(TAG, "is_samsung_s7: " + is_samsung_s7); Log.d(TAG, "is_samsung_galaxy_s: " + is_samsung_galaxy_s); @@ -2861,24 +2864,26 @@ public class CameraController2 extends CameraController { } } - CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = null; + if (is_fairphone_4) { + CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - fairphoneAvailableStreamConfigurations = new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + fairphoneAvailableStreamConfigurations = new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); + } - int[] FP_StreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); + int[] FP_StreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); - for (int i = 0; i < FP_StreamConfigs.length / 4; i++) { - int format = FP_StreamConfigs[i * 4]; - int width = FP_StreamConfigs[i * 4 + 1]; - int height = FP_StreamConfigs[i * 4 + 2]; - int output = FP_StreamConfigs[i * 4 + 3]; + for (int i = 0; i < FP_StreamConfigs.length / 4; i++) { + int format = FP_StreamConfigs[i * 4]; + int width = FP_StreamConfigs[i * 4 + 1]; + int height = FP_StreamConfigs[i * 4 + 2]; + int output = FP_StreamConfigs[i * 4 + 3]; - if (output != 0) { - if( MyDebug.LOG ) - Log.d(TAG, "custom scaler size: " + height + " x " + width); - camera_features.picture_sizes.add(new Size(width, height)); + if (output != 0) { + if (MyDebug.LOG) + Log.d(TAG, "custom scaler size: " + height + " x " + width); + camera_features.picture_sizes.add(new Size(width, height)); + } } } -- GitLab From 32e49b928d652e69f1f6766482d7e6d58ca76c18 Mon Sep 17 00:00:00 2001 From: Daniel Jacob Chittoor Date: Wed, 1 May 2024 10:23:09 +0530 Subject: [PATCH 3/4] CameraController: Only add unique entries from FP's custom scaler --- .../cameracontroller/CameraController2.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java index c9167ff4b..214129b4a 100644 --- a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +++ b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java @@ -2864,25 +2864,23 @@ public class CameraController2 extends CameraController { } } - if (is_fairphone_4) { - CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = null; - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - fairphoneAvailableStreamConfigurations = new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); - } - + if (is_fairphone_4 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = + new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); int[] FP_StreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); for (int i = 0; i < FP_StreamConfigs.length / 4; i++) { - int format = FP_StreamConfigs[i * 4]; int width = FP_StreamConfigs[i * 4 + 1]; int height = FP_StreamConfigs[i * 4 + 2]; int output = FP_StreamConfigs[i * 4 + 3]; if (output != 0) { - if (MyDebug.LOG) - Log.d(TAG, "custom scaler size: " + height + " x " + width); - camera_features.picture_sizes.add(new Size(width, height)); + Size size = new Size(width, height); + if (!camera_features.picture_sizes.contains(size)) { + if (MyDebug.LOG) + Log.d(TAG, "custom scaler size: " + height + " x " + width); + camera_features.picture_sizes.add(size); + } } } } -- GitLab From 65451d569928aa7c7623cb8d84fef7fe2518a986 Mon Sep 17 00:00:00 2001 From: Daniel Jacob Chittoor Date: Fri, 3 May 2024 14:56:14 +0530 Subject: [PATCH 4/4] CameraController: Adhere to conventional Java naming practices --- .../opencamera/cameracontroller/CameraController2.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java index 214129b4a..1d37d40f3 100644 --- a/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java +++ b/app/src/main/java/net/sourceforge/opencamera/cameracontroller/CameraController2.java @@ -2867,12 +2867,12 @@ public class CameraController2 extends CameraController { if (is_fairphone_4 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { CameraCharacteristics.Key fairphoneAvailableStreamConfigurations = new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class); - int[] FP_StreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); + int[] fpStreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations); - for (int i = 0; i < FP_StreamConfigs.length / 4; i++) { - int width = FP_StreamConfigs[i * 4 + 1]; - int height = FP_StreamConfigs[i * 4 + 2]; - int output = FP_StreamConfigs[i * 4 + 3]; + for (int i = 0; i < fpStreamConfigs.length / 4; i++) { + int width = fpStreamConfigs[i * 4 + 1]; + int height = fpStreamConfigs[i * 4 + 2]; + int output = fpStreamConfigs[i * 4 + 3]; if (output != 0) { Size size = new Size(width, height); -- GitLab