diff --git a/core/api/current.txt b/core/api/current.txt
index e702dadbf2280..9c72c9df520fe 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -18452,12 +18452,14 @@ package android.hardware.camera2 {
field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key
Submitting a request that targets Surfaces with an unsupported dynamic range combination + * will result in an {@link IllegalArgumentException}.
+ * * @param request the settings for this capture * @param listener The callback object to notify once this request has been * processed. If null, no metadata will be produced for this capture, @@ -347,13 +350,15 @@ public abstract class CameraCaptureSession implements AutoCloseable { * a different session; or the capture targets a Surface in * the middle of being {@link #prepare prepared}; or the * handler is null, the listener is not null, and the calling - * thread has no looper. + * thread has no looper; or the request targets Surfaces with + * an unsupported dynamic range combination * * @see #captureBurst * @see #setRepeatingRequest * @see #setRepeatingBurst * @see #abortCaptures * @see CameraDevice#createReprocessableCaptureSession + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public abstract int capture(@NonNull CaptureRequest request, @Nullable CaptureCallback listener, @Nullable Handler handler) @@ -389,13 +394,16 @@ public abstract class CameraCaptureSession implements AutoCloseable { * request was created with a {@link TotalCaptureResult} from * a different session; or the capture targets a Surface in * the middle of being {@link #prepare prepared}; or the - * executor is null, or the listener is not null. + * executor is null, or the listener is not null; + * or the request targets Surfaces with an unsupported dynamic + * range combination; * * @see #captureBurst * @see #setRepeatingRequest * @see #setRepeatingBurst * @see #abortCaptures * @see CameraDevice#createReprocessableCaptureSession + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public int captureSingleRequest(@NonNull CaptureRequest request, @NonNull @CallbackExecutor Executor executor, @NonNull CaptureCallback listener) @@ -427,6 +435,9 @@ public abstract class CameraCaptureSession implements AutoCloseable { * can submit reprocess capture requests. Submitting a reprocess request to a regular * capture session will result in an {@link IllegalArgumentException}. * + *Submitting a request that targets Surfaces with an unsupported dynamic range combination + * will result in an {@link IllegalArgumentException}.
+ * * @param requests the list of settings for this burst capture * @param listener The callback object to notify each time one of the * requests in the burst has been processed. If null, no metadata will be @@ -454,12 +465,15 @@ public abstract class CameraCaptureSession implements AutoCloseable { * {@link TotalCaptureResult} from a different session; or one * of the captures targets a Surface in the middle of being * {@link #prepare prepared}; or if the handler is null, the - * listener is not null, and the calling thread has no looper. + * listener is not null, and the calling thread has no looper; + * or the request targets Surfaces with an unsupported dynamic + * range combination. * * @see #capture * @see #setRepeatingRequest * @see #setRepeatingBurst * @see #abortCaptures + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public abstract int captureBurst(@NonNull ListSubmitting a request that targets Surfaces with an unsupported dynamic range combination + * will result in an {@link IllegalArgumentException}.
+ * * @param request the request to repeat indefinitely * @param listener The callback object to notify every time the * request finishes processing. If null, no metadata will be @@ -567,13 +587,16 @@ public abstract class CameraCaptureSession implements AutoCloseable { * is a reprocess capture request; or the capture targets a * Surface in the middle of being {@link #prepare prepared}; or * the handler is null, the listener is not null, and the - * calling thread has no looper; or no requests were passed in. + * calling thread has no looper; or no requests were passed in; + * or the request targets Surfaces with an unsupported dynamic + * range combination. * * @see #capture * @see #captureBurst * @see #setRepeatingBurst * @see #stopRepeating * @see #abortCaptures + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public abstract int setRepeatingRequest(@NonNull CaptureRequest request, @Nullable CaptureCallback listener, @Nullable Handler handler) @@ -604,13 +627,16 @@ public abstract class CameraCaptureSession implements AutoCloseable { * that are not currently configured as outputs; or the request * is a reprocess capture request; or the capture targets a * Surface in the middle of being {@link #prepare prepared}; or - * the executor is null; or the listener is null. + * the executor is null; or the listener is null; + * or the request targets Surfaces with an unsupported dynamic + * range combination. * * @see #capture * @see #captureBurst * @see #setRepeatingBurst * @see #stopRepeating * @see #abortCaptures + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public int setSingleRepeatingRequest(@NonNull CaptureRequest request, @NonNull @CallbackExecutor Executor executor, @NonNull CaptureCallback listener) @@ -655,6 +681,9 @@ public abstract class CameraCaptureSession implements AutoCloseable { * single reprocess input image. The request must be capturing images from the camera. If a * reprocess capture request is submitted, this method will throw IllegalArgumentException. * + *Submitting a request that targets Surfaces with an unsupported dynamic range combination + * will result in an {@link IllegalArgumentException}.
+ * * @param requests the list of requests to cycle through indefinitely * @param listener The callback object to notify each time one of the * requests in the repeating bursts has finished processing. If null, no @@ -678,13 +707,16 @@ public abstract class CameraCaptureSession implements AutoCloseable { * targets a Surface in the middle of being * {@link #prepare prepared}; or the handler is null, the * listener is not null, and the calling thread has no looper; - * or no requests were passed in. + * or no requests were passed in; + * or the request targets Surfaces with an unsupported dynamic + * range combination. * * @see #capture * @see #captureBurst * @see #setRepeatingRequest * @see #stopRepeating * @see #abortCaptures + * @see android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints */ public abstract int setRepeatingBurst(@NonNull ListThis key is available on all devices.
@@ -2236,6 +2237,7 @@ public final class CameraCharacteristics extends CameraMetadataDevices supporting the 10-bit output capability + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * must list their supported dynamic range profiles along with capture request + * constraints for specific profile combinations.
+ *Camera clients can retrieve the list of supported 10-bit dynamic range profiles by calling + * {@link android.hardware.camera2.params.DynamicRangeProfiles#getSupportedProfiles }. + * Any of them can be configured by setting OutputConfiguration dynamic range profile in + * {@link android.hardware.camera2.params.OutputConfiguration#setDynamicRangeProfile }. + * Clients can also check if there are any constraints that limit the combination + * of supported profiles that can be referenced within a single capture request by calling + * {@link android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints }.
+ *Optional - The value for this key may be {@code null} on some devices.
+ */ + @PublicKey + @NonNull + @SyntheticKey + public static final KeyA map of all available 10-bit dynamic range profiles along with their + * capture request constraints.
+ *Devices supporting the 10-bit output capability + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * must list their supported dynamic range profiles. In case the camera is not able to + * support every possible profile combination within a single capture request, then the + * constraints must be listed here as well.
+ *Possible values:
+ *Optional - The value for this key may be {@code null} on some devices.
+ * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10 + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10 + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10_PLUS + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF_PO + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM_PO + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF_PO + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM_PO + * @see #REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_MAX + * @hide + */ + public static final KeyRecommended 10-bit dynamic range profile.
+ *Devices supporting the 10-bit output capability + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * must list a 10-bit supported dynamic range profile that is expected to perform + * optimally in terms of image quality, power and performance. + * The value advertised can be used as a hint by camera clients when configuring the dynamic + * range profile when calling + * {@link android.hardware.camera2.params.OutputConfiguration#setDynamicRangeProfile }.
+ *Optional - The value for this key may be {@code null} on some devices.
+ */ + @PublicKey + @NonNull + public static final KeyThe list of image formats that are supported by this * camera device for output streams.
@@ -3339,6 +3421,32 @@ public final class CameraCharacteristics extends CameraMetadataAn array of mandatory stream combinations which are applicable when device support the + * 10-bit output capability + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * This is an app-readable conversion of the maximum resolution mandatory stream combination + * {@link android.hardware.camera2.CameraDevice#createCaptureSession tables}.
+ *The array of + * {@link android.hardware.camera2.params.MandatoryStreamCombination combinations} is + * generated according to the documented + * {@link android.hardware.camera2.CameraDevice#createCaptureSession guideline} for each + * device which has the + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * capability. + * Clients can use the array as a quick reference to find an appropriate camera stream + * combination. + * The mandatory stream combination array will be {@code null} in case the device is not an + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT } + * device.
+ *Optional - The value for this key may be {@code null} on some devices.
+ */ + @PublicKey + @NonNull + @SyntheticKey + public static final KeyWhether the camera device supports multi-resolution input or output streams
*A logical multi-camera or an ultra high resolution camera may support multi-resolution diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index 3c1ec3e629a9c..47eb79d07469b 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -402,7 +402,9 @@ public abstract class CameraDevice implements AutoCloseable { * registered surfaces do not meet the device-specific * extension requirements such as dimensions and/or * (output format)/(surface type), or if the extension is not - * supported. + * supported, or if any of the output configurations select + * a dynamic range different from + * {@link android.hardware.camera2.params.DynamicRangeProfiles#STANDARD} * @see CameraExtensionCharacteristics#getSupportedExtensions * @see CameraExtensionCharacteristics#getExtensionSupportedSizes */ @@ -822,7 +824,36 @@ public abstract class CameraDevice implements AutoCloseable { * be chosen from. {@code DEFAULT} refers to the default sensor pixel mode {@link * StreamConfigurationMap} and {@code MAX_RES} refers to the maximum resolution {@link * StreamConfigurationMap}. The same capture request must not mix targets from - * {@link StreamConfigurationMap}s corresponding to different sensor pixel modes. + * {@link StreamConfigurationMap}s corresponding to different sensor pixel modes.
+ * + *10-bit output capable + * {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT} + * devices support at least the following stream combinations:
+ *| 10-bit output additional guaranteed configurations | ||||||
|---|---|---|---|---|---|---|
| Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
| Type | Max size | Type | Max size | Type | Max size | |
| {@code PRIV} | {@code MAXIMUM} | }Simple preview, GPU video processing, or no-preview video recording. | ||||
| {@code YUV} | {@code MAXIMUM} | }In-application video/image processing. | ||||
| {@code PRIV} | {@code PREVIEW} | {@code JPEG} | {@code MAXIMUM } | Standard still imaging. | ||
| {@code PRIV} | {@code PREVIEW} | {@code YUV } | {@code MAXIMUM } | Maximum-resolution in-app processing with preview. | ||
| {@code YUV} | {@code PREVIEW} | {@code YUV} | {@code MAXIMUM } | Maximum-resolution two-input in-app processing. | ||
| {@code PRIV} | {@code PREVIEW} | {@code PRIV} | {@code RECORD } | High-resolution video recording with preview. | ||
| {@code PRIV} | {@code PREVIEW} | {@code PRIV} | {@code RECORD } | {@code YUV} | {@code RECORD } | High-resolution recording with in-app snapshot. |
| {@code PRIV} | {@code PREVIEW} | {@code PRIV } | {@code RECORD } | {@code JPEG} | {@code RECORD } | High-resolution recording with video snapshot. |
Here PRIV can be either 8 or 10-bit {@link android.graphics.ImageFormat#PRIVATE} pixel + * format. YUV can be either {@link android.graphics.ImageFormat#YUV_420_888} or + * {@link android.graphics.ImageFormat#YCBCR_P010}. + * For the maximum size column, PREVIEW refers to the best size match to the device's screen + * resolution, or to 1080p (1920x1080), whichever is smaller. RECORD refers to the camera + * device's maximum supported recording resolution, as determined by + * {@link android.media.CamcorderProfile}. MAXIMUM refers to the camera device's maximum output + * resolution for that format or target from {@link StreamConfigurationMap#getOutputSizes(int)}. + * Do note that invalid combinations such as having a camera surface configured to use pixel + * format {@link android.graphics.ImageFormat#YUV_420_888} with a 10-bit profile + * will cause a capture session initialization failure. + *
* *Since the capabilities of camera devices vary greatly, a given camera device may support * target combinations with sizes outside of these guarantees, but this can only be tested for @@ -907,6 +938,13 @@ public abstract class CameraDevice implements AutoCloseable { * guaranteed output targets that can be submitted in a regular or reprocess * {@link CaptureRequest} simultaneously.
* + *Reprocessing with 10-bit output targets on 10-bit capable + * {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT} devices is + * not supported. Trying to initialize a repreocessable capture session with one ore more + * output configurations set {@link OutputConfiguration#setDynamicRangeProfile(int)} to use + * a 10-bit dynamic range profile {@link android.hardware.camera2.params.DynamicRangeProfiles} + * will trigger {@link IllegalArgumentException}.
+ * * @@ -1083,13 +1121,17 @@ public abstract class CameraDevice implements AutoCloseable { * * @throws IllegalArgumentException In case the session configuration is invalid; or the output * configurations are empty; or the session configuration - * executor is invalid. + * executor is invalid; + * or the output dynamic range combination is + * invalid/unsupported. * @throws CameraAccessException In case the camera device is no longer connected or has * encountered a fatal error. * @see #createCaptureSession(List, CameraCaptureSession.StateCallback, Handler) * @see #createCaptureSessionByOutputConfigurations * @see #createReprocessableCaptureSession * @see #createConstrainedHighSpeedCaptureSession + * @see OutputConfiguration#setDynamicRangeProfile(int) + * @see android.hardware.camera2.params.DynamicRangeProfiles */ public void createCaptureSession( SessionConfiguration config) throws CameraAccessException { diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java index 639abe9d1abf4..803684da6ddb0 100644 --- a/core/java/android/hardware/camera2/CameraMetadata.java +++ b/core/java/android/hardware/camera2/CameraMetadata.java @@ -1190,6 +1190,135 @@ public abstract class CameraMetadataThe device supports one or more 10-bit camera outputs according to the dynamic range + * profiles specified in + * {@link android.hardware.camera2.params.DynamicRangeProfiles#getSupportedProfiles }. + * They can be configured as part of the capture session initialization via + * {@link android.hardware.camera2.params.OutputConfiguration#setDynamicRangeProfile }. + * Cameras that enable this capability must also support the following: + * * Profile {@link android.hardware.camera2.params.DynamicRangeProfiles#HLG10 } + * * All mandatory stream combinations for this specific capability as per + * documentation {@link android.hardware.camera2.CameraDevice#createCaptureSession } + * * In case the device is not able to capture some combination of supported + * standard 8-bit and/or 10-bit dynamic range profiles within the same capture request, + * then those constraints must be listed in + * {@link android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints } + * * Recommended dynamic range profile listed in + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_RECOMMENDED_TEN_BIT_DYNAMIC_RANGE_PROFILE }.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES + */ + public static final int REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT = 18; + + // + // Enumeration values for CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + // + + /** + *8-bit SDR profile which is the default for all non 10-bit output capable devices.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD = 0x1; + + /** + *10-bit pixel samples encoded using the Hybrid log-gamma transfer function.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10 = 0x2; + + /** + *10-bit pixel samples encoded using the SMPTE ST 2084 transfer function. + * This profile utilizes internal static metadata to increase the quality + * of the capture.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10 = 0x4; + + /** + *10-bit pixel samples encoded using the SMPTE ST 2084 transfer function. + * In contrast to HDR10, this profile uses internal per-frame metadata + * to further enhance the quality of the capture.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10_PLUS = 0x8; + + /** + *This is a camera mode for Dolby Vision capture optimized for a more scene + * accurate capture. This would typically differ from what a specific device + * might want to tune for a consumer optimized Dolby Vision general capture.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF = 0x10; + + /** + *This is the power optimized mode for 10-bit Dolby Vision HDR Reference Mode.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF_PO = 0x20; + + /** + *This is the camera mode for the default Dolby Vision capture mode for the + * specific device. This would be tuned by each specific device for consumer + * pleasing results that resonate with their particular audience. We expect + * that each specific device would have a different look for their default + * Dolby Vision capture.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM = 0x40; + + /** + *This is the power optimized mode for 10-bit Dolby Vision HDR device specific + * capture Mode.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM_PO = 0x80; + + /** + *This is the 8-bit version of the Dolby Vision reference capture mode optimized + * for scene accuracy.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF = 0x100; + + /** + *This is the power optimized mode for 8-bit Dolby Vision HDR Reference Mode.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF_PO = 0x200; + + /** + *This is the 8-bit version of device specific tuned and optimized Dolby Vision + * capture mode.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM = 0x400; + + /** + *This is the power optimized mode for 8-bit Dolby Vision HDR device specific + * capture Mode.
+ * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM_PO = 0x800; + + /** + * + * @see CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP + * @hide + */ + public static final int REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_MAX = 0x1000; + // // Enumeration values for CameraCharacteristics#SCALER_CROPPING_TYPE // diff --git a/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java index b8443fb6d14b9..9d2c901ed049f 100644 --- a/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java +++ b/core/java/android/hardware/camera2/impl/CameraAdvancedExtensionSessionImpl.java @@ -35,7 +35,6 @@ import android.hardware.camera2.CaptureResult; import android.hardware.camera2.TotalCaptureResult; import android.hardware.camera2.extension.CameraOutputConfig; import android.hardware.camera2.extension.CameraSessionConfig; -import android.hardware.camera2.extension.CaptureStageImpl; import android.hardware.camera2.extension.IAdvancedExtenderImpl; import android.hardware.camera2.extension.ICaptureCallback; import android.hardware.camera2.extension.IImageProcessorImpl; @@ -49,6 +48,7 @@ import android.hardware.camera2.extension.ParcelCaptureResult; import android.hardware.camera2.extension.ParcelImage; import android.hardware.camera2.extension.ParcelTotalCaptureResult; import android.hardware.camera2.extension.Request; +import android.hardware.camera2.params.DynamicRangeProfiles; import android.hardware.camera2.params.ExtensionSessionConfiguration; import android.hardware.camera2.params.OutputConfiguration; import android.hardware.camera2.params.SessionConfiguration; @@ -130,6 +130,13 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes config.getOutputConfigurations().size() + " expected <= 2"); } + for (OutputConfiguration c : config.getOutputConfigurations()) { + if (c.getDynamicRangeProfile() != DynamicRangeProfiles.STANDARD) { + throw new IllegalArgumentException("Unsupported dynamic range profile: " + + c.getDynamicRangeProfile()); + } + } + int suitableSurfaceCount = 0; ListAn instance of this class can be queried by retrieving the value of + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES}. + *
+ * + *All camera devices supporting the + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT} + * capability must advertise the supported 10-bit dynamic range profiles in + * {@link #getSupportedProfiles}
+ * + *Some devices may not be able to support 8-bit and/or 10-bit output with different dynamic + * range profiles within the same capture request. Such device specific constraints can be queried + * by calling {@link #getProfileCaptureRequestConstraints(int)}. Do note that unsupported + * combinations will result in {@link IllegalArgumentException} when trying to submit a capture + * request. Capture requests that only reference outputs configured using the same dynamic range + * profile value will never fail due to such constraints.
+ * + * @see OutputConfiguration#setDynamicRangeProfile(int) + */ +public final class DynamicRangeProfiles { + /** + * This the default 8-bit standard profile that will be used in case where camera clients do not + * explicitly configure a supported dynamic range profile by calling + * {@link OutputConfiguration#setDynamicRangeProfile(int)}. + */ + public static final int STANDARD = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_STANDARD; + + /** + * 10-bit pixel samples encoded using the Hybrid log-gamma transfer function + * + *All 10-bit output capable devices are required to support this profile.
+ */ + public static final int HLG10 = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HLG10; + + /** + * 10-bit pixel samples encoded using the SMPTE ST 2084 transfer function. + * + *This profile utilizes internal static metadata to increase the quality + * of the capture.
+ */ + public static final int HDR10 = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10; + + /** + * 10-bit pixel samples encoded using the SMPTE ST 2084 transfer function. + * + *In contrast to HDR10, this profile uses internal per-frame metadata + * to further enhance the quality of the capture.
+ */ + public static final int HDR10_PLUS = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_HDR10_PLUS; + + /** + *This is a camera mode for Dolby Vision capture optimized for a more scene + * accurate capture. This would typically differ from what a specific device + * might want to tune for a consumer optimized Dolby Vision general capture.
+ */ + public static final int DOLBY_VISION_10B_HDR_REF = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF; + + /** + *This is the power optimized mode for 10-bit Dolby Vision HDR Reference Mode.
+ */ + public static final int DOLBY_VISION_10B_HDR_REF_PO = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_REF_PO; + + /** + *This is the camera mode for the default Dolby Vision capture mode for the + * specific device. This would be tuned by each specific device for consumer + * pleasing results that resonate with their particular audience. We expect + * that each specific device would have a different look for their default + * Dolby Vision capture.
+ */ + public static final int DOLBY_VISION_10B_HDR_OEM = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM; + + /** + *This is the power optimized mode for 10-bit Dolby Vision HDR device specific capture + * Mode.
+ */ + public static final int DOLBY_VISION_10B_HDR_OEM_PO = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_10B_HDR_OEM_PO; + + /** + *This is the 8-bit version of the Dolby Vision reference capture mode optimized + * for scene accuracy.
+ */ + public static final int DOLBY_VISION_8B_HDR_REF = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF; + + /** + *This is the power optimized mode for 8-bit Dolby Vision HDR Reference Mode.
+ */ + public static final int DOLBY_VISION_8B_HDR_REF_PO = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_REF_PO; + + /** + *This is the 8-bit version of device specific tuned and optimized Dolby Vision + * capture mode.
+ */ + public static final int DOLBY_VISION_8B_HDR_OEM = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM; + + /** + *This is the power optimized mode for 8-bit Dolby Vision HDR device specific + * capture Mode.
+ */ + public static final int DOLBY_VISION_8B_HDR_OEM_PO = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_DOLBY_VISION_8B_HDR_OEM_PO; + + /* + * @hide + */ + public static final int PUBLIC_MAX = + CameraMetadata.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP_MAX; + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"PROFILE_"}, value = + {STANDARD, + HLG10, + HDR10, + HDR10_PLUS, + DOLBY_VISION_10B_HDR_REF, + DOLBY_VISION_10B_HDR_REF_PO, + DOLBY_VISION_10B_HDR_OEM, + DOLBY_VISION_10B_HDR_OEM_PO, + DOLBY_VISION_8B_HDR_REF, + DOLBY_VISION_8B_HDR_REF_PO, + DOLBY_VISION_8B_HDR_OEM, + DOLBY_VISION_8B_HDR_OEM_PO}) + public @interface Profile { + } + + private final HashMapThis constructor takes over the array; do not write to the array afterwards.
+ * + *Do note that the constructor is available for testing purposes only! + * Camera clients must always retrieve the value of + * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES}. + * for a given camera id in order to retrieve the device capabilities.
+ * + * @param elements + * An array of elements describing the map. It contains two elements per entry which + * describe the supported dynamic range profile value in the first element and in the + * second element a bitmap of concurrently supported dynamic range profiles within the + * same capture request. Bitmap values of 0 indicate that there are no constraints. + * + * @throws IllegalArgumentException + * if the {@code elements} array length is invalid, not divisible by 2 or contains + * invalid element values + * @throws NullPointerException + * if {@code elements} is {@code null} + * + */ + public DynamicRangeProfiles(@NonNull final int[] elements) { + if ((elements.length % 2) != 0) { + throw new IllegalArgumentException("Dynamic range profile map length " + + elements.length + " is not even!"); + } + + for (int i = 0; i < elements.length; i += 2) { + checkProfileValue(elements[i]); + // STANDARD is not expected to be included + if (elements[i] == STANDARD) { + throw new IllegalArgumentException("Dynamic range profile map must not include a" + + " STANDARD profile entry!"); + } + HashSetFor example if assume that a particular 10-bit output capable device + * returns ({@link #STANDARD}, {@link #HLG10}, {@link #HDR10}) as result from calling + * {@link #getSupportedProfiles()} and {@link #getProfileCaptureRequestConstraints(int)} + * returns ({@link #STANDARD}, {@link #HLG10}) when given an argument of {@link #STANDARD}. + * This means that the corresponding camera device will only accept and process capture requests + * that reference outputs configured using {@link #HDR10} dynamic profile or alternatively + * some combination of {@link #STANDARD} and {@link #HLG10}. However trying to + * queue capture requests to outputs that reference both {@link #HDR10} and + * {@link #STANDARD}/{@link #HLG10} will result in {@link IllegalArgumentException}.
+ * + *The list will be empty in case there are no constraints for the given + * profile.
+ * + * @return non-modifiable set of dynamic range profiles + * @throws IllegalArgumentException - If the profile argument is not + * within the list returned by + * getSupportedProfiles() + * + * @see OutputConfiguration#setDynamicRangeProfile(int) + */ + public @NonNull Set10-bit capable streams can be configured to output 10-bit sample data via calls to + * {@link android.hardware.camera2.params.OutputConfiguration#setDynamicRangeProfile} and + * selecting the appropriate output Surface pixel format which can be queried via + * {@link #get10BitFormat()} and will be either + * {@link ImageFormat#PRIVATE} (the default for Surfaces initialized by + * {@link android.view.SurfaceView}, {@link android.view.TextureView}, + * {@link android.media.MediaRecorder}, {@link android.media.MediaCodec} etc.) or + * {@link ImageFormat#YCBCR_P010}.
+ * + * @return true if stream is able to output 10-bit pixels + * + * @see android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_DYNAMIC_RANGE_TEN_BIT + * @see OutputConfiguration#setDynamicRangeProfile(int) + */ + public boolean is10BitCapable() { + return mIs10BitCapable; + } + /** * Return the list of available sizes for this mandatory stream. * @@ -201,6 +245,29 @@ public final class MandatoryStreamCombination { * @return integer format. */ public @Format int getFormat() { + // P010 YUV streams must be supported along with SDR 8-bit YUV streams + if ((mIs10BitCapable) && (mFormat == ImageFormat.YCBCR_P010)) { + return ImageFormat.YUV_420_888; + } + return mFormat; + } + + /** + * Retrieve the mandatory stream 10-bit {@code format} for 10-bit capable streams. + * + *In case {@link #is10BitCapable()} returns {@code true}, then this method + * will return the corresponding 10-bit output Surface pixel format. Depending on + * the stream type it will be either {@link ImageFormat#PRIVATE} or + * {@link ImageFormat#YCBCR_P010}.
+ * + * @return integer format. + * @throws UnsupportedOperationException in case the stream is not capable of 10-bit output + * @see #is10BitCapable() + */ + public @Format int get10BitFormat() { + if (!mIs10BitCapable) { + throw new UnsupportedOperationException("10-bit output is not supported!"); + } return mFormat; } @@ -932,6 +999,41 @@ public final class MandatoryStreamCombination { /*reprocessType*/ ReprocessType.PRIVATE), }; + private static StreamCombinationTemplate s10BitOutputStreamCombinations[] = { + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.MAXIMUM)}, + "Simple preview, GPU video processing, or no-preview video recording"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.YCBCR_P010, SizeThreshold.MAXIMUM)}, + "In-application video/image processing"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.JPEG, SizeThreshold.MAXIMUM), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)}, + "Standard still imaging"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.YCBCR_P010, SizeThreshold.MAXIMUM), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)}, + "Maximum-resolution in-app processing with preview"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.YCBCR_P010, SizeThreshold.MAXIMUM), + new StreamTemplate(ImageFormat.YCBCR_P010, SizeThreshold.PREVIEW)}, + "Maximum-resolution two-input in-app processing"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.RECORD), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)}, + "High-resolution video recording with preview"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.YCBCR_P010, SizeThreshold.RECORD), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.RECORD), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)}, + "High-resolution recording with in-app snapshot"), + new StreamCombinationTemplate(new StreamTemplate [] { + new StreamTemplate(ImageFormat.JPEG, SizeThreshold.RECORD), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.RECORD), + new StreamTemplate(ImageFormat.PRIVATE, SizeThreshold.PREVIEW)}, + "High-resolution recording with video snapshot"), + }; + /** * Helper builder class to generate a list of available mandatory stream combinations. * @hide @@ -970,6 +1072,86 @@ public final class MandatoryStreamCombination { CameraManager.isHiddenPhysicalCamera(Integer.toString(mCameraId)); } + /** + * Retrieve a list of all available mandatory 10-bit output capable stream combinations. + * + * @return a non-modifiable list of supported mandatory 10-bit capable stream combinations, + * null in case device is not 10-bit output capable. + */ + public @NonNull ListClients can choose from any profile advertised as supported in + * CameraCharacteristics.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES + * queried using {@link DynamicRangeProfiles#getSupportedProfiles()}. + * If this is not explicitly set, then the default profile will be + * {@link DynamicRangeProfiles#STANDARD}.
+ * + *Do note that invalid combinations between the registered output + * surface pixel format and the configured dynamic range profile will + * cause capture session initialization failure. Invalid combinations + * include any 10-bit dynamic range profile advertised in + * {@link DynamicRangeProfiles#getSupportedProfiles()} combined with + * an output Surface pixel format different from {@link ImageFormat#PRIVATE} + * (the default for Surfaces initialized by {@link android.view.SurfaceView}, + * {@link android.view.TextureView}, {@link android.media.MediaRecorder}, + * {@link android.media.MediaCodec} etc.) + * or {@link ImageFormat#YCBCR_P010}.
+ */ + public void setDynamicRangeProfile(@Profile int profile) { + mDynamicRangeProfile = profile; + } + + /** + * Return current dynamic range profile. + * + * @return the currently set dynamic range profile + */ + public @Profile int getDynamicRangeProfile() { + return mDynamicRangeProfile; + } + /** * Create a new {@link OutputConfiguration} instance. * @@ -319,6 +354,7 @@ public final class OutputConfiguration implements Parcelable { mPhysicalCameraId = null; mIsMultiResolution = false; mSensorPixelModesUsed = new ArrayList