From 7f789bc5038e0a920f38663e3363e21ac3c5e04b Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Tue, 28 Sep 2021 17:22:11 -0700 Subject: [PATCH] Add CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION to allow for better preview stabilization. Add CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION. This CaptureRequest key may be advertised by devices which can support applying the same quality of stabilization to preview and all non RAW streams. This helps clients achieve a what you see is what you get effect. Bug: 170230992 Test: builds Change-Id: Ida56d335716a10861d2b9e60e7c4b237965dec9c Signed-off-by: Jayant Chowdhary --- core/api/current.txt | 1 + .../hardware/camera2/CameraMetadata.java | 12 ++++++++++++ .../hardware/camera2/CaptureRequest.java | 17 +++++++++++++++++ .../android/hardware/camera2/CaptureResult.java | 17 +++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/core/api/current.txt b/core/api/current.txt index 912842c6e9b4e..948571d924ff2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18325,6 +18325,7 @@ package android.hardware.camera2 { field public static final int CONTROL_SCENE_MODE_THEATRE = 7; // 0x7 field public static final int CONTROL_VIDEO_STABILIZATION_MODE_OFF = 0; // 0x0 field public static final int CONTROL_VIDEO_STABILIZATION_MODE_ON = 1; // 0x1 + field public static final int CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION = 2; // 0x2 field public static final int DISTORTION_CORRECTION_MODE_FAST = 1; // 0x1 field public static final int DISTORTION_CORRECTION_MODE_HIGH_QUALITY = 2; // 0x2 field public static final int DISTORTION_CORRECTION_MODE_OFF = 0; // 0x0 diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java index 4b35294826dbb..639abe9d1abf4 100644 --- a/core/java/android/hardware/camera2/CameraMetadata.java +++ b/core/java/android/hardware/camera2/CameraMetadata.java @@ -2657,6 +2657,18 @@ public abstract class CameraMetadata { */ public static final int CONTROL_VIDEO_STABILIZATION_MODE_ON = 1; + /** + *

Preview stabilization, where the preview in addition to all other non-RAW streams are + * stabilized with the same quality of stabilization, is enabled. This mode aims to give + * clients a 'what you see is what you get' effect. In this mode, the FoV reduction will + * be a maximum of 20 % both horizontally and vertically + * (10% from left, right, top, bottom) for the given zoom ratio / crop region. + * The resultant FoV will also be the same across all processed streams + * (that have the same aspect ratio).

+ * @see CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE + */ + public static final int CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION = 2; + // // Enumeration values for CaptureRequest#CONTROL_EXTENDED_SCENE_MODE // diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 08276ac230326..86ae3a311c9b6 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -2081,10 +2081,20 @@ public final class CaptureRequest extends CameraMetadata> * ({@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode}), turning both modes on may * produce undesirable interaction, so it is recommended not to enable * both at the same time.

+ *

If video stabilization is set to "PREVIEW_STABILIZATION", + * {@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode} is overridden. The camera sub-system may choose + * to turn on hardware based image stabilization in addition to software based stabilization + * if it deems that appropriate. + * This key may be a part of the available session keys, which camera clients may + * query via + * {@link android.hardware.camera2.CameraCharacteristics#getAvailableSessionKeys }. + * If this is the case, changing this key over the life-time of a capture session may + * cause delays / glitches.

*

Possible values:

*
    *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_OFF OFF}
  • *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_ON ON}
  • + *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION PREVIEW_STABILIZATION}
  • *
* *

This key is available on all devices.

@@ -2094,6 +2104,7 @@ public final class CaptureRequest extends CameraMetadata> * @see CaptureRequest#SCALER_CROP_REGION * @see #CONTROL_VIDEO_STABILIZATION_MODE_OFF * @see #CONTROL_VIDEO_STABILIZATION_MODE_ON + * @see #CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION */ @PublicKey @NonNull @@ -2785,6 +2796,11 @@ public final class CaptureRequest extends CameraMetadata> *

If a camera device supports both OIS and digital image stabilization * ({@link CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE android.control.videoStabilizationMode}), turning both modes on may produce undesirable * interaction, so it is recommended not to enable both at the same time.

+ *

If {@link CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE android.control.videoStabilizationMode} is set to "PREVIEW_STABILIZATION", + * {@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode} is overridden. The camera sub-system may choose + * to turn on hardware based image stabilization in addition to software based stabilization + * if it deems that appropriate. This key's value in the capture result will reflect which + * OIS mode was chosen.

*

Not all devices will support OIS; see * {@link CameraCharacteristics#LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION android.lens.info.availableOpticalStabilization} for * available controls.

@@ -2804,6 +2820,7 @@ public final class CaptureRequest extends CameraMetadata> * @see CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL * @see CameraCharacteristics#LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION + * @see CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE * @see #LENS_OPTICAL_STABILIZATION_MODE_OFF * @see #LENS_OPTICAL_STABILIZATION_MODE_ON */ diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 296bfbe2ba985..a0fb179add1c8 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -2335,10 +2335,20 @@ public class CaptureResult extends CameraMetadata> { * ({@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode}), turning both modes on may * produce undesirable interaction, so it is recommended not to enable * both at the same time.

+ *

If video stabilization is set to "PREVIEW_STABILIZATION", + * {@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode} is overridden. The camera sub-system may choose + * to turn on hardware based image stabilization in addition to software based stabilization + * if it deems that appropriate. + * This key may be a part of the available session keys, which camera clients may + * query via + * {@link android.hardware.camera2.CameraCharacteristics#getAvailableSessionKeys }. + * If this is the case, changing this key over the life-time of a capture session may + * cause delays / glitches.

*

Possible values:

*
    *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_OFF OFF}
  • *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_ON ON}
  • + *
  • {@link #CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION PREVIEW_STABILIZATION}
  • *
* *

This key is available on all devices.

@@ -2348,6 +2358,7 @@ public class CaptureResult extends CameraMetadata> { * @see CaptureRequest#SCALER_CROP_REGION * @see #CONTROL_VIDEO_STABILIZATION_MODE_OFF * @see #CONTROL_VIDEO_STABILIZATION_MODE_ON + * @see #CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION */ @PublicKey @NonNull @@ -3072,6 +3083,11 @@ public class CaptureResult extends CameraMetadata> { *

If a camera device supports both OIS and digital image stabilization * ({@link CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE android.control.videoStabilizationMode}), turning both modes on may produce undesirable * interaction, so it is recommended not to enable both at the same time.

+ *

If {@link CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE android.control.videoStabilizationMode} is set to "PREVIEW_STABILIZATION", + * {@link CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE android.lens.opticalStabilizationMode} is overridden. The camera sub-system may choose + * to turn on hardware based image stabilization in addition to software based stabilization + * if it deems that appropriate. This key's value in the capture result will reflect which + * OIS mode was chosen.

*

Not all devices will support OIS; see * {@link CameraCharacteristics#LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION android.lens.info.availableOpticalStabilization} for * available controls.

@@ -3091,6 +3107,7 @@ public class CaptureResult extends CameraMetadata> { * @see CaptureRequest#CONTROL_VIDEO_STABILIZATION_MODE * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL * @see CameraCharacteristics#LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION + * @see CaptureRequest#LENS_OPTICAL_STABILIZATION_MODE * @see #LENS_OPTICAL_STABILIZATION_MODE_OFF * @see #LENS_OPTICAL_STABILIZATION_MODE_ON */