From 1cfbbecbcf518e51fc9277cafc8a1e0dddf1d89f Mon Sep 17 00:00:00 2001 From: Shuzhen Wang Date: Mon, 8 Oct 2018 13:55:28 -0700 Subject: [PATCH] Camera: Add Y8 format in Camera NDK Test: Camera CTS Bug: 70216652 Change-Id: Ib8436bcb8347ec82353afc8a89e9702d90ce6e53 --- .../include/camera/NdkCameraMetadataTags.h | 17 +++++++---- media/ndk/NdkImageReader.cpp | 2 ++ media/ndk/include/media/NdkImage.h | 29 ++++++++++++++++++- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h index 8af3c7cc57..bb1f7c5951 100644 --- a/camera/ndk/include/camera/NdkCameraMetadataTags.h +++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h @@ -2783,7 +2783,7 @@ typedef enum acamera_metadata_tag { * {@link AIMAGE_FORMAT_RAW12 RAW12}. *
  • Processed (but not-stalling): any non-RAW format without a stall duration. Typically * {@link AIMAGE_FORMAT_YUV_420_888 YUV_420_888}, - * NV21, or YV12.
  • + * NV21, YV12, or {@link AIMAGE_FORMAT_Y8 Y8} . * * * @see ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS @@ -3251,6 +3251,7 @@ typedef enum acamera_metadata_tag { *
  • {@link AIMAGE_FORMAT_YUV_420_888 }
  • *
  • {@link AIMAGE_FORMAT_RAW10 }
  • *
  • {@link AIMAGE_FORMAT_RAW12 }
  • + *
  • {@link AIMAGE_FORMAT_Y8 }
  • * *

    All other formats may or may not have an allowed stall duration on * a per-capability basis; refer to ACAMERA_REQUEST_AVAILABLE_CAPABILITIES @@ -5457,8 +5458,8 @@ typedef enum acamera_metadata_tag { * 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, @@ -7143,7 +7144,7 @@ typedef enum acamera_metadata_enum_acamera_request_available_capabilities { * camera device can capture this size for at least 10 frames per second. Also the * ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES entry lists at least one FPS range where * the minimum FPS is >= 1 / minimumFrameDuration for the largest YUV_420_888 size.

    - *

    If the device supports the {@link AIMAGE_FORMAT_RAW10 }, {@link AIMAGE_FORMAT_RAW12 }, then those can also be + *

    If the device supports the {@link AIMAGE_FORMAT_RAW10 }, {@link AIMAGE_FORMAT_RAW12 }, {@link AIMAGE_FORMAT_Y8 }, then those can also be * captured at the same rate as the maximum-size YUV_420_888 resolution is.

    *

    In addition, the ACAMERA_SYNC_MAX_LATENCY field is guaranted to have a value between 0 * and 4, inclusive. ACAMERA_CONTROL_AE_LOCK_AVAILABLE and ACAMERA_CONTROL_AWB_LOCK_AVAILABLE @@ -7177,8 +7178,8 @@ typedef enum acamera_metadata_enum_acamera_request_available_capabilities { *

  • The ACAMERA_DEPTH_DEPTH_IS_EXCLUSIVE entry is listed by this device.
  • *
  • As of Android P, the ACAMERA_LENS_POSE_REFERENCE 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 @@ -7272,6 +7273,10 @@ typedef enum acamera_metadata_enum_acamera_request_available_capabilities { /** *

    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 AIMAGE_FORMAT_YUV_420_888 YUV_420_888} apply + * to {@link AIMAGE_FORMAT_Y8 Y8} as well.

    */ ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME = 12, diff --git a/media/ndk/NdkImageReader.cpp b/media/ndk/NdkImageReader.cpp index 47b0780f9f..1adecb969b 100644 --- a/media/ndk/NdkImageReader.cpp +++ b/media/ndk/NdkImageReader.cpp @@ -68,6 +68,7 @@ AImageReader::isSupportedFormatAndUsage(int32_t format, uint64_t usage) { case AIMAGE_FORMAT_RAW12: case AIMAGE_FORMAT_DEPTH16: case AIMAGE_FORMAT_DEPTH_POINT_CLOUD: + case AIMAGE_FORMAT_Y8: return true; case AIMAGE_FORMAT_PRIVATE: // For private format, cpu usage is prohibited. @@ -94,6 +95,7 @@ AImageReader::getNumPlanesForFormat(int32_t format) { case AIMAGE_FORMAT_RAW12: case AIMAGE_FORMAT_DEPTH16: case AIMAGE_FORMAT_DEPTH_POINT_CLOUD: + case AIMAGE_FORMAT_Y8: return 1; case AIMAGE_FORMAT_PRIVATE: return 0; diff --git a/media/ndk/include/media/NdkImage.h b/media/ndk/include/media/NdkImage.h index f936118776..15b340c2b7 100644 --- a/media/ndk/include/media/NdkImage.h +++ b/media/ndk/include/media/NdkImage.h @@ -499,7 +499,34 @@ enum AIMAGE_FORMATS { *

    When an {@link AImage} of this format is obtained from an {@link AImageReader} or * {@link AImage_getNumberOfPlanes()} method will return zero.

    */ - AIMAGE_FORMAT_PRIVATE = 0x22 + AIMAGE_FORMAT_PRIVATE = 0x22, + + /** + * Android Y8 format. + * + *

    Y8 is a planar format comprised of a WxH Y plane only, with each pixel + * being represented by 8 bits.

    + * + *

    This format assumes + *

    + *

    + * + *
     size = stride * height 
    + * + *

    For example, the {@link AImage} object can provide data + * in this format from a {@link ACameraDevice} (if supported) through a + * {@link AImageReader} object. The number of planes returned by + * {@link AImage_getNumberOfPlanes} will always be 1. The pixel stride returned by + * {@link AImage_getPlanePixelStride} will always be 1, and the + * {@link AImage_getPlaneRowStride} described the vertical neighboring pixel distance + * (in bytes) between adjacent rows.

    + * + */ + AIMAGE_FORMAT_Y8 = 0x20203859 }; /**