diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index b60586655dc8b..aa2097e872b23 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -1212,7 +1212,7 @@ public final class CameraCharacteristics extends CameraMetadata
If the camera device supports zoom-out from 1x zoom, minZoom will be less than 1.0, and - * setting android.control.zoomRation to values less than 1.0 increases the camera's field + * setting {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} to values less than 1.0 increases the camera's field * of view.
*Units: A pair of zoom ratio in floating points: (minZoom, maxZoom)
*Range of valid values:
For a logical multi-camera, bokeh may be implemented by stereo vision from sub-cameras * with different field of view. As a result, when bokeh mode is enabled, the camera device - * may override android.scaler.CropRegion, and the field of view will be smaller than when + * may override {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}, and the field of view will be smaller than when * bokeh mode is off.
*Possible values: *
Optional - The value for this key may be {@code null} on some devices.
+ * + * @see CaptureRequest#SCALER_CROP_REGION * @see #CONTROL_BOKEH_MODE_OFF * @see #CONTROL_BOKEH_MODE_STILL_CAPTURE * @see #CONTROL_BOKEH_MODE_CONTINUOUS @@ -2740,32 +2742,70 @@ public final class CaptureRequest extends CameraMetadataFor devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate
* system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0, 0) being
* the top-left pixel of the active array.
For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate
- * system depends on the mode being set.
- * When the distortion correction mode is OFF, the coordinate system follows
- * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with
- * (0, 0) being the top-left pixel of the pre-correction active array.
- * When the distortion correction mode is not OFF, the coordinate system follows
- * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with
- * (0, 0) being the top-left pixel of the active array.
Output streams use this rectangle to produce their output, - * cropping to a smaller region if necessary to maintain the - * stream's aspect ratio, then scaling the sensor input to + *
For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate system
+ * depends on the mode being set. When the distortion correction mode is OFF, the
+ * coordinate system follows {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with (0,
+ * 0) being the top-left pixel of the pre-correction active array. When the distortion
+ * correction mode is not OFF, the coordinate system follows
+ * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0, 0) being the top-left pixel of the
+ * active array.
Output streams use this rectangle to produce their output, cropping to a smaller region + * if necessary to maintain the stream's aspect ratio, then scaling the sensor input to * match the output's configured resolution.
- *The crop region is applied after the RAW to other color - * space (e.g. YUV) conversion. Since raw streams - * (e.g. RAW16) don't have the conversion stage, they are not + *
The crop region is applied after the RAW to other color space (e.g. YUV) + * conversion. Since raw streams (e.g. RAW16) don't have the conversion stage, they are not * croppable. The crop region will be ignored by raw streams.
- *For non-raw streams, any additional per-stream cropping will - * be done to maximize the final pixel area of the stream.
- *For example, if the crop region is set to a 4:3 aspect - * ratio, then 4:3 streams will use the exact crop - * region. 16:9 streams will further crop vertically - * (letterbox).
- *Conversely, if the crop region is set to a 16:9, then 4:3 - * outputs will crop horizontally (pillarbox), and 16:9 - * streams will match exactly. These additional crops will - * be centered within the crop region.
+ *For non-raw streams, any additional per-stream cropping will be done to maximize the + * final pixel area of the stream.
+ *For example, if the crop region is set to a 4:3 aspect ratio, then 4:3 streams will use + * the exact crop region. 16:9 streams will further crop vertically (letterbox).
+ *Conversely, if the crop region is set to a 16:9, then 4:3 outputs will crop horizontally + * (pillarbox), and 16:9 streams will match exactly. These additional crops will be + * centered within the crop region.
+ *To illustrate, here are several scenarios of different crop regions and output streams,
+ * for a hypothetical camera device with an active array of size (2000,1500). Note that
+ * several of these examples use non-centered crop regions for ease of illustration; such
+ * regions are only supported on devices with FREEFORM capability
+ * ({@link CameraCharacteristics#SCALER_CROPPING_TYPE android.scaler.croppingType} == FREEFORM), but this does not affect the way the crop
+ * rules work otherwise.
2000x1500 (3 MP, 4:3 aspect ratio)640x480 (VGA, 4:3 aspect ratio)1280x720 (720p, 16:9 aspect ratio)Rect(500, 375, 1500, 1125) // (left, top, right, bottom)
640x480 stream source area: (500, 375, 1500, 1125) (equal to crop region)1280x720 stream source area: (500, 469, 1500, 1031) (letterboxed)Rect(500, 375, 1833, 1125)
640x480 stream source area: (666, 375, 1666, 1125) (pillarboxed)1280x720 stream source area: (500, 375, 1833, 1125) (equal to crop region)Rect(500, 375, 1250, 1125)
640x480 stream source area: (500, 469, 1250, 1031) (letterboxed)1280x720 stream source area: (500, 543, 1250, 957) (letterboxed)640x480 stream with 1024x1024 stream, with 4:3 crop region:Rect(500, 375, 1500, 1125)
1024x1024 stream source area: (625, 375, 1375, 1125) (pillarboxed)1280x720 stream source area: (500, 469, 1500, 1031) (letterboxed)If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, the width and height
* of the crop region cannot be set to be smaller than
* floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} ) and
@@ -2776,18 +2816,16 @@ public final class CaptureRequest extends CameraMetadatafloor( preCorrectionActiveArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} ),
* respectively.
The camera device may adjust the crop region to account - * for rounding and other hardware requirements; the final - * crop region used will be included in the output capture - * result.
+ *The camera device may adjust the crop region to account for rounding and other hardware + * requirements; the final crop region used will be included in the output capture result.
*Starting from API level 30, it's strongly recommended to use {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} * to take advantage of better support for zoom with logical multi-camera. The benefits * include better precision with optical-digital zoom combination, and ability to do * zoom-out from 1.0x. When using {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for zoom, the crop region in * the capture request must be either letterboxing or pillarboxing (but not both). The * coordinate system is post-zoom, meaning that the activeArraySize or - * preCorrectionActiveArraySize covers the camera device's field of view "after" zoom. - * See {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for details.
+ * preCorrectionActiveArraySize covers the camera device's field of view "after" zoom. See + * {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for details. *Units: Pixel coordinates relative to
* {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on distortion correction
@@ -2797,6 +2835,7 @@ public final class CaptureRequest extends CameraMetadata
For a logical multi-camera, bokeh may be implemented by stereo vision from sub-cameras * with different field of view. As a result, when bokeh mode is enabled, the camera device - * may override android.scaler.CropRegion, and the field of view will be smaller than when + * may override {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}, and the field of view will be smaller than when * bokeh mode is off.
*Possible values: *
Optional - The value for this key may be {@code null} on some devices.
+ * + * @see CaptureRequest#SCALER_CROP_REGION * @see #CONTROL_BOKEH_MODE_OFF * @see #CONTROL_BOKEH_MODE_STILL_CAPTURE * @see #CONTROL_BOKEH_MODE_CONTINUOUS @@ -3379,32 +3381,70 @@ public class CaptureResult extends CameraMetadataFor devices not supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate
* system always follows that of {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0, 0) being
* the top-left pixel of the active array.
For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate
- * system depends on the mode being set.
- * When the distortion correction mode is OFF, the coordinate system follows
- * {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with
- * (0, 0) being the top-left pixel of the pre-correction active array.
- * When the distortion correction mode is not OFF, the coordinate system follows
- * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with
- * (0, 0) being the top-left pixel of the active array.
Output streams use this rectangle to produce their output, - * cropping to a smaller region if necessary to maintain the - * stream's aspect ratio, then scaling the sensor input to + *
For devices supporting {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} control, the coordinate system
+ * depends on the mode being set. When the distortion correction mode is OFF, the
+ * coordinate system follows {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize}, with (0,
+ * 0) being the top-left pixel of the pre-correction active array. When the distortion
+ * correction mode is not OFF, the coordinate system follows
+ * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, with (0, 0) being the top-left pixel of the
+ * active array.
Output streams use this rectangle to produce their output, cropping to a smaller region + * if necessary to maintain the stream's aspect ratio, then scaling the sensor input to * match the output's configured resolution.
- *The crop region is applied after the RAW to other color - * space (e.g. YUV) conversion. Since raw streams - * (e.g. RAW16) don't have the conversion stage, they are not + *
The crop region is applied after the RAW to other color space (e.g. YUV) + * conversion. Since raw streams (e.g. RAW16) don't have the conversion stage, they are not * croppable. The crop region will be ignored by raw streams.
- *For non-raw streams, any additional per-stream cropping will - * be done to maximize the final pixel area of the stream.
- *For example, if the crop region is set to a 4:3 aspect - * ratio, then 4:3 streams will use the exact crop - * region. 16:9 streams will further crop vertically - * (letterbox).
- *Conversely, if the crop region is set to a 16:9, then 4:3 - * outputs will crop horizontally (pillarbox), and 16:9 - * streams will match exactly. These additional crops will - * be centered within the crop region.
+ *For non-raw streams, any additional per-stream cropping will be done to maximize the + * final pixel area of the stream.
+ *For example, if the crop region is set to a 4:3 aspect ratio, then 4:3 streams will use + * the exact crop region. 16:9 streams will further crop vertically (letterbox).
+ *Conversely, if the crop region is set to a 16:9, then 4:3 outputs will crop horizontally + * (pillarbox), and 16:9 streams will match exactly. These additional crops will be + * centered within the crop region.
+ *To illustrate, here are several scenarios of different crop regions and output streams,
+ * for a hypothetical camera device with an active array of size (2000,1500). Note that
+ * several of these examples use non-centered crop regions for ease of illustration; such
+ * regions are only supported on devices with FREEFORM capability
+ * ({@link CameraCharacteristics#SCALER_CROPPING_TYPE android.scaler.croppingType} == FREEFORM), but this does not affect the way the crop
+ * rules work otherwise.
2000x1500 (3 MP, 4:3 aspect ratio)640x480 (VGA, 4:3 aspect ratio)1280x720 (720p, 16:9 aspect ratio)Rect(500, 375, 1500, 1125) // (left, top, right, bottom)
640x480 stream source area: (500, 375, 1500, 1125) (equal to crop region)1280x720 stream source area: (500, 469, 1500, 1031) (letterboxed)Rect(500, 375, 1833, 1125)
640x480 stream source area: (666, 375, 1666, 1125) (pillarboxed)1280x720 stream source area: (500, 375, 1833, 1125) (equal to crop region)Rect(500, 375, 1250, 1125)
640x480 stream source area: (500, 469, 1250, 1031) (letterboxed)1280x720 stream source area: (500, 543, 1250, 957) (letterboxed)640x480 stream with 1024x1024 stream, with 4:3 crop region:Rect(500, 375, 1500, 1125)
1024x1024 stream source area: (625, 375, 1375, 1125) (pillarboxed)1280x720 stream source area: (500, 469, 1500, 1031) (letterboxed)If the coordinate system is {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}, the width and height
* of the crop region cannot be set to be smaller than
* floor( activeArraySize.width / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} ) and
@@ -3415,18 +3455,16 @@ public class CaptureResult extends CameraMetadatafloor( preCorrectionActiveArraySize.height / {@link CameraCharacteristics#SCALER_AVAILABLE_MAX_DIGITAL_ZOOM android.scaler.availableMaxDigitalZoom} ),
* respectively.
The camera device may adjust the crop region to account - * for rounding and other hardware requirements; the final - * crop region used will be included in the output capture - * result.
+ *The camera device may adjust the crop region to account for rounding and other hardware + * requirements; the final crop region used will be included in the output capture result.
*Starting from API level 30, it's strongly recommended to use {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} * to take advantage of better support for zoom with logical multi-camera. The benefits * include better precision with optical-digital zoom combination, and ability to do * zoom-out from 1.0x. When using {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for zoom, the crop region in * the capture request must be either letterboxing or pillarboxing (but not both). The * coordinate system is post-zoom, meaning that the activeArraySize or - * preCorrectionActiveArraySize covers the camera device's field of view "after" zoom. - * See {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for details.
+ * preCorrectionActiveArraySize covers the camera device's field of view "after" zoom. See + * {@link CaptureRequest#CONTROL_ZOOM_RATIO android.control.zoomRatio} for details. *Units: Pixel coordinates relative to
* {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize} or
* {@link CameraCharacteristics#SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE android.sensor.info.preCorrectionActiveArraySize} depending on distortion correction
@@ -3436,6 +3474,7 @@ public class CaptureResult extends CameraMetadata