From ec5e8d25f0f3526ebe0f8e51a4fe3dfb57b2acba Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Fri, 28 Sep 2018 09:28:48 -0700 Subject: Camera: Unhide and update Y8 format spec - Unhide Y8 format as part of MONOCHROME camera support. - Specify required stream combination for Y8 format. Test: Camera CTS test Bug: 70216652 Change-Id: Iab28b7ee3f2d5ec534a517079f14e0ed648ae556 --- api/current.txt | 1 + .../hardware/camera2/CameraCharacteristics.java | 33 +++++++++++++++++++++- .../android/hardware/camera2/CameraDevice.java | 5 ++++ .../android/hardware/camera2/CameraMetadata.java | 14 +++++++-- .../android/hardware/camera2/CaptureRequest.java | 4 +-- .../android/hardware/camera2/CaptureResult.java | 4 +-- graphics/java/android/graphics/ImageFormat.java | 18 ++++++------ 7 files changed, 62 insertions(+), 17 deletions(-) diff --git a/api/current.txt b/api/current.txt index 0af3546ad918..e444600e80a7 100755 --- a/api/current.txt +++ b/api/current.txt @@ -13854,6 +13854,7 @@ package android.graphics { field public static final int RAW_SENSOR = 32; // 0x20 field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 + field public static final int Y8 = 538982489; // 0x20203859 field public static final int YUV_420_888 = 35; // 0x23 field public static final int YUV_422_888 = 39; // 0x27 field public static final int YUV_444_888 = 40; // 0x28 diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 46e66e0dbef5..33cc7a84b335 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -1583,7 +1583,7 @@ public final class CameraCharacteristics extends CameraMetadata *
  • Processed (but not-stalling): any non-RAW format without a stall duration. Typically * {@link android.graphics.ImageFormat#YUV_420_888 YUV_420_888}, - * {@link android.graphics.ImageFormat#NV21 NV21}, or {@link android.graphics.ImageFormat#YV12 YV12}.
  • + * {@link android.graphics.ImageFormat#NV21 NV21}, {@link android.graphics.ImageFormat#YV12 YV12}, or {@link android.graphics.ImageFormat#Y8 Y8} . * *

    Range of valid values:

    *

    For processed (and stalling) format streams, >= 1.

    @@ -1646,6 +1646,7 @@ public final class CameraCharacteristics extends CameraMetadata{@link android.graphics.ImageFormat#NV21 NV21} *
  • {@link android.graphics.ImageFormat#YV12 YV12}
  • *
  • Implementation-defined formats, i.e. {@link android.hardware.camera2.params.StreamConfigurationMap#isOutputSupportedFor(Class) }
  • + *
  • {@link android.graphics.ImageFormat#Y8 Y8}
  • * *

    For full guarantees, query {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputStallDuration } with a * processed format -- it will return 0 for a non-stalling stream.

    @@ -2122,6 +2123,35 @@ public final class CameraCharacteristics extends CameraMetadata *

    Attempting to configure an input stream with output streams not * listed as available in this map is not valid.

    + *

    Additionally, if the camera device is MONOCHROME with Y8 support, it will also support + * the following map of formats if its dependent capability + * ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities}) is supported:

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Input FormatOutput FormatCapability
    {@link android.graphics.ImageFormat#PRIVATE }{@link android.graphics.ImageFormat#Y8 }PRIVATE_REPROCESSING
    {@link android.graphics.ImageFormat#Y8 }{@link android.graphics.ImageFormat#JPEG }YUV_REPROCESSING
    {@link android.graphics.ImageFormat#Y8 }{@link android.graphics.ImageFormat#Y8 }YUV_REPROCESSING
    *

    Optional - This value may be {@code null} on some devices.

    * * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES @@ -2297,6 +2327,7 @@ public final class CameraCharacteristics extends CameraMetadata{@link android.graphics.ImageFormat#YUV_420_888 } *
  • {@link android.graphics.ImageFormat#RAW10 }
  • *
  • {@link android.graphics.ImageFormat#RAW12 }
  • + *
  • {@link android.graphics.ImageFormat#Y8 }
  • * *

    All other formats may or may not have an allowed stall duration on * a per-capability basis; refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES android.request.availableCapabilities} diff --git a/core/java/android/hardware/camera2/CameraDevice.java b/core/java/android/hardware/camera2/CameraDevice.java index ce88697fa8db..c0f226d6b921 100644 --- a/core/java/android/hardware/camera2/CameraDevice.java +++ b/core/java/android/hardware/camera2/CameraDevice.java @@ -356,6 +356,11 @@ public abstract class CameraDevice implements AutoCloseable { *
    *

    * + *

    MONOCHROME-capability ({@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} + * includes {@link CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME MONOCHROME}) + * supporting {@link ImageFormat#Y8 Y8} support substituting {@code YUV} streams with {@code Y8} + * in all guaranteed stream combinations for the device's hardware level and capabilities.

    + * *

    FULL-level ({@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL} * {@code == }{@link CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_FULL FULL}) devices * support at least the following stream combinations in addition to those for diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java index d4dc181e5eec..ffc22641f025 100644 --- a/core/java/android/hardware/camera2/CameraMetadata.java +++ b/core/java/android/hardware/camera2/CameraMetadata.java @@ -539,6 +539,8 @@ public abstract class CameraMetadata { *

  • {@link android.graphics.ImageFormat#PRIVATE } will be reprocessable into both * {@link android.graphics.ImageFormat#YUV_420_888 } and * {@link android.graphics.ImageFormat#JPEG } formats.
  • + *
  • For a MONOCHROME camera supporting Y8 format, {@link android.graphics.ImageFormat#PRIVATE } will be reprocessable into + * {@link android.graphics.ImageFormat#Y8 }.
  • *
  • The maximum available resolution for PRIVATE streams * (both input/output) will match the maximum available * resolution of JPEG streams.
  • @@ -612,7 +614,7 @@ public abstract class CameraMetadata { * then the list of resolutions for YUV_420_888 from {@link android.hardware.camera2.params.StreamConfigurationMap#getOutputSizes } contains at * least one resolution >= 8 megapixels, with a minimum frame duration of <= 1/20 * s.

    - *

    If the device supports the {@link android.graphics.ImageFormat#RAW10 }, {@link android.graphics.ImageFormat#RAW12 }, then those can also be + *

    If the device supports the {@link android.graphics.ImageFormat#RAW10 }, {@link android.graphics.ImageFormat#RAW12 }, {@link android.graphics.ImageFormat#Y8 }, then those can also be * captured at the same rate as the maximum-size YUV_420_888 resolution is.

    *

    If the device supports the PRIVATE_REPROCESSING capability, then the same guarantees * as for the YUV_420_888 format also apply to the {@link android.graphics.ImageFormat#PRIVATE } format.

    @@ -646,6 +648,8 @@ public abstract class CameraMetadata { * {@link android.graphics.ImageFormat#YUV_420_888 } and {@link android.graphics.ImageFormat#JPEG } formats. *
  • The maximum available resolution for {@link android.graphics.ImageFormat#YUV_420_888 } streams (both input/output) will match the * maximum available resolution of {@link android.graphics.ImageFormat#JPEG } streams.
  • + *
  • For a MONOCHROME camera with Y8 format support, all the requirements mentioned + * above for YUV_420_888 apply for Y8 format as well.
  • *
  • Static metadata {@link CameraCharacteristics#REPROCESS_MAX_CAPTURE_STALL android.reprocess.maxCaptureStall}.
  • *
  • Only the below controls are effective for reprocessing requests and will be present * in capture results. The reprocess requests are from the original capture results @@ -692,8 +696,8 @@ public abstract class CameraMetadata { *
  • The {@link CameraCharacteristics#DEPTH_DEPTH_IS_EXCLUSIVE android.depth.depthIsExclusive} entry is listed by this device.
  • *
  • As of Android P, the {@link CameraCharacteristics#LENS_POSE_REFERENCE android.lens.poseReference} entry is listed by this device.
  • *
  • A LIMITED camera with only the DEPTH_OUTPUT capability does not have to support - * normal YUV_420_888, JPEG, and PRIV-format outputs. It only has to support the DEPTH16 - * format.
  • + * normal YUV_420_888, Y8, JPEG, and PRIV-format outputs. It only has to support the + * DEPTH16 format. * *

    Generally, depth output operates at a slower frame rate than standard color capture, * so the DEPTH16 and DEPTH_POINT_CLOUD formats will commonly have a stall duration that @@ -877,6 +881,10 @@ public abstract class CameraMetadata { /** *

    The camera device is a monochrome camera that doesn't contain a color filter array, * and the pixel values on U and V planes are all 128.

    + *

    A MONOCHROME camera must support the guaranteed stream combinations required for + * its device level and capabilities. Additionally, if the monochrome camera device + * supports Y8 format, all mandatory stream combination requirements related to {@link android.graphics.ImageFormat#YUV_420_888 YUV_420_888} apply + * to {@link android.graphics.ImageFormat#Y8 Y8} as well.

    * @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES */ public static final int REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME = 12; diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 4a20468276d3..2744e9111509 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -3277,8 +3277,8 @@ public final class CaptureRequest extends CameraMetadata> * will not slow down capture rate when applying correction. FAST may be the same as OFF if * any correction at all would slow down capture rate. Every output stream will have a * similar amount of enhancement applied.

    - *

    The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not - * applied to any RAW output.

    + *

    The correction only applies to processed outputs such as YUV, Y8, JPEG, or DEPTH16; it is + * not applied to any RAW output.

    *

    This control will be on by default on devices that support this control. Applications * disabling distortion correction need to pay extra attention with the coordinate system of * metering regions, crop region, and face rectangles. When distortion correction is OFF, diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index a7e185c9853b..2b67f3e6adcb 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -4620,8 +4620,8 @@ public class CaptureResult extends CameraMetadata> { * will not slow down capture rate when applying correction. FAST may be the same as OFF if * any correction at all would slow down capture rate. Every output stream will have a * similar amount of enhancement applied.

    - *

    The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not - * applied to any RAW output.

    + *

    The correction only applies to processed outputs such as YUV, Y8, JPEG, or DEPTH16; it is + * not applied to any RAW output.

    *

    This control will be on by default on devices that support this control. Applications * disabling distortion correction need to pay extra attention with the coordinate system of * metering regions, crop region, and face rectangles. When distortion correction is OFF, diff --git a/graphics/java/android/graphics/ImageFormat.java b/graphics/java/android/graphics/ImageFormat.java index 9546a4aec330..c580c46cc888 100644 --- a/graphics/java/android/graphics/ImageFormat.java +++ b/graphics/java/android/graphics/ImageFormat.java @@ -16,8 +16,6 @@ package android.graphics; -import android.annotation.UnsupportedAppUsage; - public class ImageFormat { /* * these constants are chosen to be binary compatible with their previous @@ -92,20 +90,21 @@ public class ImageFormat { * *

    * - *
     y_size = stride * height 
    + *
     size = stride * height 
    * *

    For example, the {@link android.media.Image} object can provide data - * in this format from a {@link android.hardware.camera2.CameraDevice} - * through a {@link android.media.ImageReader} object if this format is - * supported by {@link android.hardware.camera2.CameraDevice}.

    + * in this format from a {@link android.hardware.camera2.CameraDevice} (if + * supported) through a {@link android.media.ImageReader} object. The + * {@link android.media.Image#getPlanes() Image#getPlanes()} will return a + * single plane containing the pixel data. The pixel stride is always 1 in + * {@link android.media.Image.Plane#getPixelStride()}, and the + * {@link android.media.Image.Plane#getRowStride()} describes the vertical + * neighboring pixel distance (in bytes) between adjacent rows.

    * * @see android.media.Image * @see android.media.ImageReader * @see android.hardware.camera2.CameraDevice - * - * @hide */ - @UnsupportedAppUsage public static final int Y8 = 0x20203859; /** @@ -787,6 +786,7 @@ public class ImageFormat { case DEPTH_POINT_CLOUD: case PRIVATE: case RAW_DEPTH: + case Y8: return true; } -- cgit v1.2.3-59-g8ed1b