Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7b88b70 authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add HAL interface change for HEIC"

parents 7fea1b4a 55386823
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.hardware.camera.device@3.5;

import @3.2::StreamBuffer;
import @3.4::StreamConfiguration;
import @3.2::CameraBlobId;

/**
 * StreamConfiguration:
@@ -129,3 +130,35 @@ struct BufferRequest {
    uint32_t numBuffersRequested;
};

/**
 * CameraBlob:
 *
 * Identical to @3.2::CameraBlob, except that it also supports transport of JPEG
 * APP segments blob, which contains JPEG APP1 to APPn (Application Marker)
 * segments as specified in JEITA CP-3451.
 *
 * To capture a JPEG APP segments blob, a stream is created using the pixel format
 * HAL_PIXEL_FORMAT_BLOB and dataspace HAL_DATASPACE_JPEG_APP_SEGMENTS. The buffer
 * size for the stream is calculated by the framework, based on the static
 * metadata field android.heic.maxAppSegmentsCount.
 *
 * Similar to JPEG image, the JPEG APP segment images can be of variable size,
 * so the HAL needs to include the final size of all APP segments using this
 * structure inside the output stream buffer. The camera blob ID field must be
 * set to CameraBlobId::JPEG_APP_SEGMENTS.
 *
 * The transport header must be at the end of the JPEG APP segments output stream
 * buffer. That means the blobId must start at byte[buffer_size -
 * sizeof(CameraBlob)], where the buffer_size is the size of gralloc
 * buffer. The JPEG APP segments data itself starts at the beginning of the
 * buffer and must be blobSize bytes long.
 */
enum CameraBlobId : @3.2::CameraBlobId {
    JPEG_APP_SEGMENTS = 0x100,
};

struct CameraBlob {
    CameraBlobId blobId;
    uint32_t blobSize;
};
+85 −1
Original line number Diff line number Diff line
@@ -26,7 +26,34 @@ package android.hardware.camera.metadata@3.4;
import android.hardware.camera.metadata@3.2;
import android.hardware.camera.metadata@3.3;

// No new metadata sections added in this revision
/**
 * Top level hierarchy definitions for camera metadata. *_INFO sections are for
 * the static metadata that can be retrived without opening the camera device.
 */
enum CameraMetadataSection : @3.3::CameraMetadataSection {
    ANDROID_HEIC =
        android.hardware.camera.metadata@3.3::CameraMetadataSection:ANDROID_SECTION_COUNT,

    ANDROID_HEIC_INFO,

    ANDROID_SECTION_COUNT_3_4,

    VENDOR_SECTION_3_4 = 0x8000,

};

/**
 * Hierarchy positions in enum space. All vendor extension sections must be
 * defined with tag >= VENDOR_SECTION_START
 */
enum CameraMetadataSectionStart : android.hardware.camera.metadata@3.3::CameraMetadataSectionStart {
    ANDROID_HEIC_START = CameraMetadataSection:ANDROID_HEIC << 16,

    ANDROID_HEIC_INFO_START = CameraMetadataSection:ANDROID_HEIC_INFO << 16,

    VENDOR_SECTION_START_3_4 = CameraMetadataSection:VENDOR_SECTION_3_4 << 16,

};

/**
 * Main enumeration for defining camera metadata tags added in this revision
@@ -105,6 +132,47 @@ enum CameraMetadataTag : @3.3::CameraMetadataTag {

    ANDROID_LOGICAL_MULTI_CAMERA_END_3_4,

    /** android.heic.availableHeicStreamConfigurations [static, enum[], ndk_public]
     *
     * <p>The available HEIC (ISO/IEC 23008-12) stream
     * configurations that this camera device supports
     * (i.e. format, width, height, output/input stream).</p>
     */
    ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS = CameraMetadataSectionStart:ANDROID_HEIC_START,

    /** android.heic.availableHeicMinFrameDurations [static, int64[], ndk_public]
     *
     * <p>This lists the minimum frame duration for each
     * format/size combination for HEIC output formats.</p>
     */
    ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS,

    /** android.heic.availableHeicStallDurations [static, int64[], ndk_public]
     *
     * <p>This lists the maximum stall duration for each
     * output format/size combination for HEIC streams.</p>
     */
    ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS,

    ANDROID_HEIC_END_3_4,

    /** android.heic.info.supported [static, enum, system]
     *
     * <p>Whether this camera device can support identical set of stream combinations
     * involving HEIC image format, compared to the
     * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession">table of combinations</a>
     * involving JPEG image format required for the device's hardware level and capabilities.</p>
     */
    ANDROID_HEIC_INFO_SUPPORTED = CameraMetadataSectionStart:ANDROID_HEIC_INFO_START,

    /** android.heic.info.maxJpegAppSegmentsCount [static, byte, system]
     *
     * <p>The maximum number of Jpeg APP segments supported by the camera HAL device.</p>
     */
    ANDROID_HEIC_INFO_MAX_JPEG_APP_SEGMENTS_COUNT,

    ANDROID_HEIC_INFO_END_3_4,

};

/*
@@ -174,3 +242,19 @@ enum CameraMetadataEnumAndroidDepthAvailableDynamicDepthStreamConfigurations : u
    ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_OUTPUT,
    ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_INPUT,
};

/** android.heic.availableHeicStreamConfigurations enumeration values
 * @see ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS
 */
enum CameraMetadataEnumAndroidHeicAvailableHeicStreamConfigurations : uint32_t {
    ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS_OUTPUT,
    ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS_INPUT,
};

/** android.heic.info.supported enumeration values
 * @see ANDROID_HEIC_INFO_SUPPORTED
 */
enum CameraMetadataEnumAndroidHeicInfoSupported : uint32_t {
    ANDROID_HEIC_INFO_SUPPORTED_FALSE,
    ANDROID_HEIC_INFO_SUPPORTED_TRUE,
};
+35 −0
Original line number Diff line number Diff line
@@ -5539,6 +5539,41 @@ void CameraHidlTest::verifyCameraCharacteristics(Status status, const CameraMeta
        ADD_FAILURE() << "ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS"
            << " per API contract should never be set by Hal!";
    }

    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, &entry);
    if (0 == retcode || entry.count > 0) {
        ADD_FAILURE() << "ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS "
            << " per API contract should never be set by Hal!";
    }

    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS, &entry);
    if (0 == retcode || entry.count > 0) {
        ADD_FAILURE() << "ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS "
            << " per API contract should never be set by Hal!";
    }

    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS, &entry);
    if (0 == retcode || entry.count > 0) {
        ADD_FAILURE() << "ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS "
            << " per API contract should never be set by Hal!";
    }

    retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_HEIC_INFO_SUPPORTED, &entry);
    if (0 == retcode && entry.count > 0) {
        retcode = find_camera_metadata_ro_entry(metadata,
            ANDROID_HEIC_INFO_MAX_JPEG_APP_SEGMENTS_COUNT, &entry);
        if (0 == retcode && entry.count > 0) {
            uint8_t maxJpegAppSegmentsCount = entry.data.u8[0];
            ASSERT_TRUE(maxJpegAppSegmentsCount >= 1 &&
                    maxJpegAppSegmentsCount <= 16);
        } else {
            ADD_FAILURE() << "Get Heic maxJpegAppSegmentsCount failed!";
        }
    }
}

void CameraHidlTest::verifyMonochromeCharacteristics(const CameraMetadata& chars,
+38 −0
Original line number Diff line number Diff line
@@ -49,6 +49,32 @@ enum Dataspace : @1.1::Dataspace {
     * Embedded depth metadata following the dynamic depth specification.
     */
    DYNAMIC_DEPTH = 0x1002,

    /**
     * JPEG APP segments format as specified by JEIDA spec
     *
     * The buffer must only contain APP1 (Application Marker) segment followed
     * by zero or more APPn segments, as is specified by JEITA CP-3451C section 4.5.4.
     * The APP1 segment optionally contains a thumbnail. The buffer will not
     * contain main compressed image.
     *
     * This value is valid with formats:
     *    HAL_PIXEL_FORMAT_BLOB: JPEG APP segments optionally containing thumbnail image
     * in APP1. BLOB buffer with this dataspace is output by HAL, and used by
     * camera framework to encode into a HEIC image.
     */
    JPEG_APP_SEGMENTS = 0x1003,

    /**
     * ISO/IEC 23008-12
     *
     * High Efficiency Image File Format (HEIF)
     *
     * This value is valid with formats:
     *    HAL_PIXEL_FORMAT_BLOB: A HEIC image encoded by HEIC or HEVC encoder
     * according to ISO/IEC 23008-12.
     */
    HEIF = 0x1004,
};

enum ColorMode : @1.1::ColorMode {
@@ -69,6 +95,18 @@ enum ColorMode : @1.1::ColorMode {
    DISPLAY_BT2020 = 13,
};

/**
 * Buffer usage definitions.
 */
enum BufferUsage : @1.1::BufferUsage {
    /**
     * Buffer is used as input for HEIC encoder.
     */
    HW_IMAGE_ENCODER = 1ULL << 27,

    /* bits 28 and 32-47 must be zero and are reserved for future versions */
};

/**
 * HIDL counterpart of `AHardwareBuffer_Desc`.
 *